return 0;
}
+// --------------------------------------------------------------------------------------------------------------------
+// net.inet.tcp.states
+
+int do_net_inet_tcp_states(int update_every, usec_t dt) {
+ static int mib[4] = {0, 0, 0, 0};
+ uint64_t tcps_states[TCP_NSTATES];
+
+ // see http://net-snmp.sourceforge.net/docs/mibs/tcp.html
+ if (unlikely(GETSYSCTL_SIMPLE("net.inet.tcp.states", mib, tcps_states))) {
+ error("DISABLED: ipv4.tcpsock chart");
+ error("DISABLED: net.inet.tcp.states module");
+ return 1;
+ } else {
+
+ // --------------------------------------------------------------------
+
+ static RRDSET *st = NULL;
+ static RRDDIM *rd = NULL;
+
+ if (unlikely(!st)) {
+ st = rrdset_create_localhost("ipv4",
+ "tcpsock",
+ NULL,
+ "tcp",
+ NULL,
+ "IPv4 TCP Connections",
+ "active connections",
+ 2500,
+ update_every,
+ RRDSET_TYPE_LINE
+ );
+
+ rd = rrddim_add(st, "CurrEstab", "connections", 1, 1, RRD_ALGORITHM_ABSOLUTE);
+ } else
+ rrdset_next(st);
+
+ rrddim_set_by_pointer(st, rd, tcps_states[TCPS_ESTABLISHED]);
+ rrdset_done(st);
+ }
+
+ return 0;
+}
+
// --------------------------------------------------------------------------------------------------------------------
// old sources
// NEEDED BY: do_tcp...
struct tcpstat tcpstat;
- uint64_t tcps_states[TCP_NSTATES];
// NEEDED BY: do_udp...
struct udpstat udpstat;
// --------------------------------------------------------------------
- // see http://net-snmp.sourceforge.net/docs/mibs/tcp.html
- if (likely(do_tcp_sockets)) {
- if (unlikely(GETSYSCTL_BY_NAME("net.inet.tcp.states", tcps_states))) {
- do_tcp_sockets = 0;
- error("DISABLED: ipv4.tcpsock");
- } else {
- if (likely(do_tcp_sockets)) {
- st = rrdset_find_localhost("ipv4.tcpsock");
- if (unlikely(!st)) {
- st = rrdset_create_localhost("ipv4", "tcpsock", NULL, "tcp", NULL, "IPv4 TCP Connections",
- "active connections", 2500, update_every, RRDSET_TYPE_LINE);
-
- rrddim_add(st, "CurrEstab", "connections", 1, 1, RRD_ALGORITHM_ABSOLUTE);
- } else
- rrdset_next(st);
-
- rrddim_set(st, "CurrEstab", tcps_states[TCPS_ESTABLISHED]);
- rrdset_done(st);
- }
- }
- }
-
- // --------------------------------------------------------------------
-
// see http://net-snmp.sourceforge.net/docs/mibs/tcp.html
if (likely(do_tcp_packets || do_tcp_errors || do_tcp_handshake || do_tcpext_connaborts || do_tcpext_ofo || do_tcpext_syscookies || do_ecn)) {
if (unlikely(GETSYSCTL_BY_NAME("net.inet.tcp.stats", tcpstat))){
{ .name = "kern.ipc.msq", .dim = "message_queues", .enabled = 1, .func = do_kern_ipc_msq },
{ .name = "uptime", .dim = "uptime", .enabled = 1, .func = do_uptime },
{ .name = "net.isr", .dim = "net_isr", .enabled = 1, .func = do_net_isr },
+ { .name = "net.inet.tcp.states", .dim = "tcp_states", .enabled = 1, .func = do_net_inet_tcp_states },
// CPU metrics
{ .name = "kern.cp_times", .dim = "cp_times", .enabled = 1, .func = do_kern_cp_times },