Separate net.inet.tcp.stats module
Vladimir Kobal committed
Mar 14, 2017 at 15:28 UTC
4821a68140d9fc010bd602cb47ac6ab145b6f3d4
3 files changed
+186
-149
src/freebsd_sysctl.c
+183
-148
@@ -1481,11 +1481,11 @@ int do_net_inet_tcp_stats(int update_every, usec_t dt) {
1481
// --------------------------------------------------------------------
1482
1483
if (likely(do_tcp_packets)) {
1484
- static RRDSET *st_packets = NULL;
1484
+ static RRDSET *st = NULL;
1485
static RRDDIM *rd_in_segs = NULL, *rd_out_segs = NULL;
1486
1487
- if (unlikely(!st_packets)) {
1488
- st_packets = rrdset_create_localhost("ipv4",
1487
+ if (unlikely(!st)) {
1488
+ st = rrdset_create_localhost("ipv4",
1489
"tcppackets",
1490
NULL,
1491
"tcp",
@@ -1497,24 +1497,24 @@ int do_net_inet_tcp_stats(int update_every, usec_t dt) {
1497
RRDSET_TYPE_LINE
1498
);
1499
1500
- rd_in_segs = rrddim_add(st_packets, "InSegs", "received", 1, 1, RRD_ALGORITHM_INCREMENTAL);
1501
- rd_out_segs = rrddim_add(st_packets, "OutSegs", "sent", -1, 1, RRD_ALGORITHM_INCREMENTAL);
1500
+ rd_in_segs = rrddim_add(st, "InSegs", "received", 1, 1, RRD_ALGORITHM_INCREMENTAL);
1501
+ rd_out_segs = rrddim_add(st, "OutSegs", "sent", -1, 1, RRD_ALGORITHM_INCREMENTAL);
1502
} else
1503
- rrdset_next(st_packets);
1503
+ rrdset_next(st);
1504
1505
- rrddim_set_by_pointer(st_packets, rd_in_segs, tcpstat.tcps_rcvtotal);
1506
- rrddim_set_by_pointer(st_packets, rd_out_segs, tcpstat.tcps_sndtotal);
1507
- rrdset_done(st_packets);
1505
+ rrddim_set_by_pointer(st, rd_in_segs, tcpstat.tcps_rcvtotal);
1506
+ rrddim_set_by_pointer(st, rd_out_segs, tcpstat.tcps_sndtotal);
1507
+ rrdset_done(st);
1508
}
1509
1510
// --------------------------------------------------------------------
1511
1512
if (likely(do_tcp_errors)) {
1513
- static RRDSET *st_errors = NULL;
1513
+ static RRDSET *st = NULL;
1514
static RRDDIM *rd_in_errs = NULL, *rd_in_csum_errs = NULL, *rd_retrans_segs = NULL;
1515
1516
- if (unlikely(!st_errors)) {
1517
- st_errors = rrdset_create_localhost("ipv4",
1516
+ if (unlikely(!st)) {
1517
+ st = rrdset_create_localhost("ipv4",
1518
"tcperrors",
1519
NULL,
1520
"tcp",
@@ -1526,34 +1526,34 @@ int do_net_inet_tcp_stats(int update_every, usec_t dt) {
1526
RRDSET_TYPE_LINE
1527
);
1528
1529
- rrdset_flag_set(st_errors, RRDSET_FLAG_DETAIL);
1529
+ rrdset_flag_set(st, RRDSET_FLAG_DETAIL);
1530
1531
- rd_in_errs = rrddim_add(st_errors, "InErrs", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
1532
- rd_in_csum_errs = rrddim_add(st_errors, "InCsumErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
1533
- rd_retrans_segs = rrddim_add(st_errors, "RetransSegs", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);
1531
+ rd_in_errs = rrddim_add(st, "InErrs", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
1532
+ rd_in_csum_errs = rrddim_add(st, "InCsumErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
1533
+ rd_retrans_segs = rrddim_add(st, "RetransSegs", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);
1534
} else
1535
- rrdset_next(st_errors);
1535
+ rrdset_next(st);
1536
1537
#if __FreeBSD__ >= 11
1538
- rrddim_set_by_pointer(st_errors, rd_in_errs, tcpstat.tcps_rcvbadoff + tcpstat.tcps_rcvreassfull +
1538
+ rrddim_set_by_pointer(st, rd_in_errs, tcpstat.tcps_rcvbadoff + tcpstat.tcps_rcvreassfull +
1539
tcpstat.tcps_rcvshort);
1540
#else
1541
- rrddim_set_by_pointer(st_errors, rd_in_errs, tcpstat.tcps_rcvbadoff + tcpstat.tcps_rcvshort);
1541
+ rrddim_set_by_pointer(st, rd_in_errs, tcpstat.tcps_rcvbadoff + tcpstat.tcps_rcvshort);
1542
#endif
1543
- rrddim_set_by_pointer(st_errors, rd_in_csum_errs, tcpstat.tcps_rcvbadsum);
1544
- rrddim_set_by_pointer(st_errors, rd_retrans_segs, tcpstat.tcps_sndrexmitpack);
1545
- rrdset_done(st_errors);
1543
+ rrddim_set_by_pointer(st, rd_in_csum_errs, tcpstat.tcps_rcvbadsum);
1544
+ rrddim_set_by_pointer(st, rd_retrans_segs, tcpstat.tcps_sndrexmitpack);
1545
+ rrdset_done(st);
1546
}
1547
1548
// --------------------------------------------------------------------
1549
1550
if (likely(do_tcp_handshake)) {
1551
- static RRDSET *st_handshake = NULL;
1551
+ static RRDSET *st = NULL;
1552
static RRDDIM *rd_estab_resets = NULL, *rd_active_opens = NULL, *rd_passive_opens = NULL,
1553
*rd_attempt_fails = NULL;
1554
1555
- if (unlikely(!st_handshake)) {
1556
- st_handshake = rrdset_create_localhost("ipv4",
1555
+ if (unlikely(!st)) {
1556
+ st = rrdset_create_localhost("ipv4",
1557
"tcphandshake",
1558
NULL,
1559
"tcp",
@@ -1565,20 +1565,20 @@ int do_net_inet_tcp_stats(int update_every, usec_t dt) {
1565
RRDSET_TYPE_LINE
1566
);
1567
1568
- rrdset_flag_set(st_handshake, RRDSET_FLAG_DETAIL);
1568
+ rrdset_flag_set(st, RRDSET_FLAG_DETAIL);
1569
1570
- rd_estab_resets = rrddim_add(st_handshake, "EstabResets", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
1571
- rd_active_opens = rrddim_add(st_handshake, "ActiveOpens", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
1572
- rd_passive_opens = rrddim_add(st_handshake, "PassiveOpens", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
1573
- rd_attempt_fails = rrddim_add(st_handshake, "AttemptFails", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
1570
+ rd_estab_resets = rrddim_add(st, "EstabResets", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
1571
+ rd_active_opens = rrddim_add(st, "ActiveOpens", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
1572
+ rd_passive_opens = rrddim_add(st, "PassiveOpens", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
1573
+ rd_attempt_fails = rrddim_add(st, "AttemptFails", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
1574
} else
1575
- rrdset_next(st_handshake);
1575
+ rrdset_next(st);
1576
1577
- rrddim_set_by_pointer(st_handshake, rd_estab_resets, tcpstat.tcps_drops);
1578
- rrddim_set_by_pointer(st_handshake, rd_active_opens, tcpstat.tcps_connattempt);
1579
- rrddim_set_by_pointer(st_handshake, rd_passive_opens, tcpstat.tcps_accepts);
1580
- rrddim_set_by_pointer(st_handshake, rd_attempt_fails, tcpstat.tcps_conndrops);
1581
- rrdset_done(st_handshake);
1577
+ rrddim_set_by_pointer(st, rd_estab_resets, tcpstat.tcps_drops);
1578
+ rrddim_set_by_pointer(st, rd_active_opens, tcpstat.tcps_connattempt);
1579
+ rrddim_set_by_pointer(st, rd_passive_opens, tcpstat.tcps_accepts);
1580
+ rrddim_set_by_pointer(st, rd_attempt_fails, tcpstat.tcps_conndrops);
1581
+ rrdset_done(st);
1582
}
1583
1584
// --------------------------------------------------------------------
@@ -1586,12 +1586,12 @@ int do_net_inet_tcp_stats(int update_every, usec_t dt) {
1586
if (do_tcpext_connaborts == CONFIG_BOOLEAN_YES || (do_tcpext_connaborts == CONFIG_BOOLEAN_AUTO && (tcpstat.tcps_rcvpackafterwin || tcpstat.tcps_rcvafterclose || tcpstat.tcps_rcvmemdrop || tcpstat.tcps_persistdrop || tcpstat.tcps_finwait2_drops))) {
1587
do_tcpext_connaborts = CONFIG_BOOLEAN_YES;
1588
1589
- static RRDSET *st_connaborts = NULL;
1589
+ static RRDSET *st = NULL;
1590
static RRDDIM *rd_on_data = NULL, *rd_on_close = NULL, *rd_on_memory = NULL,
1591
*rd_on_timeout = NULL, *rd_on_linger = NULL;
1592
1593
- if (unlikely(!st_connaborts)) {
1594
- st_connaborts = rrdset_create_localhost("ipv4",
1593
+ if (unlikely(!st)) {
1594
+ st = rrdset_create_localhost("ipv4",
1595
"tcpconnaborts",
1596
NULL,
1597
"tcp",
@@ -1603,25 +1603,20 @@ int do_net_inet_tcp_stats(int update_every, usec_t dt) {
1603
RRDSET_TYPE_LINE
1604
);
1605
1606
- rd_on_data = rrddim_add(st_connaborts, "TCPAbortOnData", "baddata", 1, 1,
1607
- RRD_ALGORITHM_INCREMENTAL);
1608
- rd_on_close = rrddim_add(st_connaborts, "TCPAbortOnClose", "userclosed", 1, 1,
1609
- RRD_ALGORITHM_INCREMENTAL);
1610
- rd_on_memory = rrddim_add(st_connaborts, "TCPAbortOnMemory", "nomemory", 1, 1,
1611
- RRD_ALGORITHM_INCREMENTAL);
1612
- rd_on_timeout = rrddim_add(st_connaborts, "TCPAbortOnTimeout", "timeout", 1, 1,
1613
- RRD_ALGORITHM_INCREMENTAL);
1614
- rd_on_linger = rrddim_add(st_connaborts, "TCPAbortOnLinger", "linger", 1, 1,
1615
- RRD_ALGORITHM_INCREMENTAL);
1606
+ rd_on_data = rrddim_add(st, "TCPAbortOnData", "baddata", 1, 1, RRD_ALGORITHM_INCREMENTAL);
1607
+ rd_on_close = rrddim_add(st, "TCPAbortOnClose", "userclosed", 1, 1, RRD_ALGORITHM_INCREMENTAL);
1608
+ rd_on_memory = rrddim_add(st, "TCPAbortOnMemory", "nomemory", 1, 1, RRD_ALGORITHM_INCREMENTAL);
1609
+ rd_on_timeout = rrddim_add(st, "TCPAbortOnTimeout", "timeout", 1, 1, RRD_ALGORITHM_INCREMENTAL);
1610
+ rd_on_linger = rrddim_add(st, "TCPAbortOnLinger", "linger", 1, 1, RRD_ALGORITHM_INCREMENTAL);
1611
}
1617
- else rrdset_next(st_connaborts);
1618
-
1619
- rrddim_set_by_pointer(st_connaborts, rd_on_data, tcpstat.tcps_rcvpackafterwin);
1620
- rrddim_set_by_pointer(st_connaborts, rd_on_close, tcpstat.tcps_rcvafterclose);
1621
- rrddim_set_by_pointer(st_connaborts, rd_on_memory, tcpstat.tcps_rcvmemdrop);
1622
- rrddim_set_by_pointer(st_connaborts, rd_on_timeout, tcpstat.tcps_persistdrop);
1623
- rrddim_set_by_pointer(st_connaborts, rd_on_linger, tcpstat.tcps_finwait2_drops);
1624
- rrdset_done(st_connaborts);
1612
+ else rrdset_next(st);
1613
+
1614
+ rrddim_set_by_pointer(st, rd_on_data, tcpstat.tcps_rcvpackafterwin);
1615
+ rrddim_set_by_pointer(st, rd_on_close, tcpstat.tcps_rcvafterclose);
1616
+ rrddim_set_by_pointer(st, rd_on_memory, tcpstat.tcps_rcvmemdrop);
1617
+ rrddim_set_by_pointer(st, rd_on_timeout, tcpstat.tcps_persistdrop);
1618
+ rrddim_set_by_pointer(st, rd_on_linger, tcpstat.tcps_finwait2_drops);
1619
+ rrdset_done(st);
1620
}
1621
1622
// --------------------------------------------------------------------
@@ -1629,11 +1624,11 @@ int do_net_inet_tcp_stats(int update_every, usec_t dt) {
1624
if (do_tcpext_ofo == CONFIG_BOOLEAN_YES || (do_tcpext_ofo == CONFIG_BOOLEAN_AUTO && tcpstat.tcps_rcvoopack)) {
1625
do_tcpext_ofo = CONFIG_BOOLEAN_YES;
1626
1632
- static RRDSET *st_ofo_queue = NULL;
1627
+ static RRDSET *st = NULL;
1628
static RRDDIM *rd_ofo_queue = NULL;
1629
1635
- if (unlikely(!st_ofo_queue)) {
1636
- st_ofo_queue = rrdset_create_localhost("ipv4",
1630
+ if (unlikely(!st)) {
1631
+ st = rrdset_create_localhost("ipv4",
1632
"tcpofo",
1633
NULL,
1634
"tcp",
@@ -1645,12 +1640,12 @@ int do_net_inet_tcp_stats(int update_every, usec_t dt) {
1640
RRDSET_TYPE_LINE
1641
);
1642
1648
- rd_ofo_queue = rrddim_add(st_ofo_queue, "TCPOFOQueue", "inqueue", 1, 1, RRD_ALGORITHM_INCREMENTAL);
1643
+ rd_ofo_queue = rrddim_add(st, "TCPOFOQueue", "inqueue", 1, 1, RRD_ALGORITHM_INCREMENTAL);
1644
}
1650
- else rrdset_next(st_ofo_queue);
1645
+ else rrdset_next(st);
1646
1652
- rrddim_set_by_pointer(st_ofo_queue, rd_ofo_queue, tcpstat.tcps_rcvoopack);
1653
- rrdset_done(st_ofo_queue);
1647
+ rrddim_set_by_pointer(st, rd_ofo_queue, tcpstat.tcps_rcvoopack);
1648
+ rrdset_done(st);
1649
}
1650
1651
// --------------------------------------------------------------------
@@ -1658,11 +1653,11 @@ int do_net_inet_tcp_stats(int update_every, usec_t dt) {
1653
if (do_tcpext_syncookies == CONFIG_BOOLEAN_YES || (do_tcpext_syncookies == CONFIG_BOOLEAN_AUTO && (tcpstat.tcps_sc_sendcookie || tcpstat.tcps_sc_recvcookie || tcpstat.tcps_sc_zonefail))) {
1654
do_tcpext_syncookies = CONFIG_BOOLEAN_YES;
1655
1661
- static RRDSET *st_syncookies = NULL;
1656
+ static RRDSET *st = NULL;
1657
static RRDDIM *rd_recv = NULL, *rd_send = NULL, *rd_failed = NULL;
1658
1664
- if (unlikely(!st_syncookies)) {
1665
- st_syncookies = rrdset_create_localhost("ipv4",
1659
+ if (unlikely(!st)) {
1660
+ st = rrdset_create_localhost("ipv4",
1661
"tcpsyncookies",
1662
NULL,
1663
"tcp",
@@ -1674,16 +1669,16 @@ int do_net_inet_tcp_stats(int update_every, usec_t dt) {
1669
RRDSET_TYPE_LINE
1670
);
1671
1677
- rd_recv = rrddim_add(st_syncookies, "SyncookiesRecv", "received", 1, 1, RRD_ALGORITHM_INCREMENTAL);
1678
- rd_send = rrddim_add(st_syncookies, "SyncookiesSent", "sent", -1, 1, RRD_ALGORITHM_INCREMENTAL);
1679
- rd_failed = rrddim_add(st_syncookies, "SyncookiesFailed", "failed", -1, 1, RRD_ALGORITHM_INCREMENTAL);
1672
+ rd_recv = rrddim_add(st, "SyncookiesRecv", "received", 1, 1, RRD_ALGORITHM_INCREMENTAL);
1673
+ rd_send = rrddim_add(st, "SyncookiesSent", "sent", -1, 1, RRD_ALGORITHM_INCREMENTAL);
1674
+ rd_failed = rrddim_add(st, "SyncookiesFailed", "failed", -1, 1, RRD_ALGORITHM_INCREMENTAL);
1675
}
1681
- else rrdset_next(st_syncookies);
1676
+ else rrdset_next(st);
1677
1683
- rrddim_set_by_pointer(st_syncookies, rd_recv, tcpstat.tcps_sc_recvcookie);
1684
- rrddim_set_by_pointer(st_syncookies, rd_send, tcpstat.tcps_sc_sendcookie);
1685
- rrddim_set_by_pointer(st_syncookies, rd_failed, tcpstat.tcps_sc_zonefail);
1686
- rrdset_done(st_syncookies);
1678
+ rrddim_set_by_pointer(st, rd_recv, tcpstat.tcps_sc_recvcookie);
1679
+ rrddim_set_by_pointer(st, rd_send, tcpstat.tcps_sc_sendcookie);
1680
+ rrddim_set_by_pointer(st, rd_failed, tcpstat.tcps_sc_zonefail);
1681
+ rrdset_done(st);
1682
}
1683
1684
// --------------------------------------------------------------------
@@ -1691,11 +1686,11 @@ int do_net_inet_tcp_stats(int update_every, usec_t dt) {
1686
if (do_ecn == CONFIG_BOOLEAN_YES || (do_ecn == CONFIG_BOOLEAN_AUTO && (tcpstat.tcps_ecn_ce || tcpstat.tcps_ecn_ect0 || tcpstat.tcps_ecn_ect1))) {
1687
do_ecn = CONFIG_BOOLEAN_YES;
1688
1694
- static RRDSET *st_ecn = NULL;
1689
+ static RRDSET *st = NULL;
1690
static RRDDIM *rd_ce = NULL, *rd_no_ect = NULL, *rd_ect0 = NULL, *rd_ect1 = NULL;
1691
1697
- if (unlikely(!st_ecn)) {
1698
- st_ecn = rrdset_create_localhost("ipv4",
1692
+ if (unlikely(!st)) {
1693
+ st = rrdset_create_localhost("ipv4",
1694
"ecnpkts",
1695
NULL,
1696
"ecn",
@@ -1707,21 +1702,21 @@ int do_net_inet_tcp_stats(int update_every, usec_t dt) {
1702
RRDSET_TYPE_LINE
1703
);
1704
1710
- rrdset_flag_set(st_ecn, RRDSET_FLAG_DETAIL);
1705
+ rrdset_flag_set(st, RRDSET_FLAG_DETAIL);
1706
1712
- rd_ce = rrddim_add(st_ecn, "InCEPkts", "CEP", 1, 1, RRD_ALGORITHM_INCREMENTAL);
1713
- rd_no_ect = rrddim_add(st_ecn, "InNoECTPkts", "NoECTP", -1, 1, RRD_ALGORITHM_INCREMENTAL);
1714
- rd_ect0 = rrddim_add(st_ecn, "InECT0Pkts", "ECTP0", 1, 1, RRD_ALGORITHM_INCREMENTAL);
1715
- rd_ect1 = rrddim_add(st_ecn, "InECT1Pkts", "ECTP1", 1, 1, RRD_ALGORITHM_INCREMENTAL);
1707
+ rd_ce = rrddim_add(st, "InCEPkts", "CEP", 1, 1, RRD_ALGORITHM_INCREMENTAL);
1708
+ rd_no_ect = rrddim_add(st, "InNoECTPkts", "NoECTP", -1, 1, RRD_ALGORITHM_INCREMENTAL);
1709
+ rd_ect0 = rrddim_add(st, "InECT0Pkts", "ECTP0", 1, 1, RRD_ALGORITHM_INCREMENTAL);
1710
+ rd_ect1 = rrddim_add(st, "InECT1Pkts", "ECTP1", 1, 1, RRD_ALGORITHM_INCREMENTAL);
1711
}
1717
- else rrdset_next(st_ecn);
1712
+ else rrdset_next(st);
1713
1719
- rrddim_set_by_pointer(st_ecn, rd_ce, tcpstat.tcps_ecn_ce);
1720
- rrddim_set_by_pointer(st_ecn, rd_no_ect, tcpstat.tcps_ecn_ce - (tcpstat.tcps_ecn_ect0 +
1714
+ rrddim_set_by_pointer(st, rd_ce, tcpstat.tcps_ecn_ce);
1715
+ rrddim_set_by_pointer(st, rd_no_ect, tcpstat.tcps_ecn_ce - (tcpstat.tcps_ecn_ect0 +
1716
tcpstat.tcps_ecn_ect1));
1722
- rrddim_set_by_pointer(st_ecn, rd_ect0, tcpstat.tcps_ecn_ect0);
1723
- rrddim_set_by_pointer(st_ecn, rd_ect1, tcpstat.tcps_ecn_ect1);
1724
- rrdset_done(st_ecn);
1717
+ rrddim_set_by_pointer(st, rd_ect0, tcpstat.tcps_ecn_ect0);
1718
+ rrddim_set_by_pointer(st, rd_ect1, tcpstat.tcps_ecn_ect1);
1719
+ rrdset_done(st);
1720
}
1721
1722
}
@@ -1733,7 +1728,105 @@ int do_net_inet_tcp_stats(int update_every, usec_t dt) {
1728
return 0;
1729
}
1730
1731
+// --------------------------------------------------------------------------------------------------------------------
1732
+// net.inet.udp.stats
1733
+
1734
+int do_net_inet_udp_stats(int update_every, usec_t dt) {
1735
+ static int do_udp_packets = -1, do_udp_errors = -1;
1736
+
1737
+ if (unlikely(do_udp_packets == -1)) {
1738
+ do_udp_packets = config_get_boolean("plugin:freebsd:sysctl", "ipv4 UDP packets", 1);
1739
+ do_udp_errors = config_get_boolean("plugin:freebsd:sysctl", "ipv4 UDP errors", 1);
1740
+ }
1741
+
1742
+ static int mib[4] = {0, 0, 0, 0};
1743
+ struct udpstat udpstat;
1744
+
1745
+ // see http://net-snmp.sourceforge.net/docs/mibs/udp.html
1746
+ if (likely(do_udp_packets || do_udp_errors)) {
1747
+ if (unlikely(GETSYSCTL_SIMPLE("net.inet.udp.stats", mib, udpstat))) {
1748
+ do_udp_packets = 0;
1749
+ error("DISABLED: ipv4.udppackets chart");
1750
+ do_udp_errors = 0;
1751
+ error("DISABLED: ipv4.udperrors chart");
1752
+ error("DISABLED: net.inet.udp.stats module");
1753
+ return 1;
1754
+ } else {
1755
+
1756
+ // --------------------------------------------------------------------
1757
+
1758
+ if (likely(do_udp_packets)) {
1759
+ static RRDSET *st = NULL;
1760
+ static RRDDIM *rd_in = NULL, *rd_out = NULL;
1761
+
1762
+ if (unlikely(!st)) {
1763
+ st = rrdset_create_localhost("ipv4",
1764
+ "udppackets",
1765
+ NULL,
1766
+ "udp",
1767
+ NULL,
1768
+ "IPv4 UDP Packets",
1769
+ "packets/s",
1770
+ 2601,
1771
+ update_every,
1772
+ RRDSET_TYPE_LINE
1773
+ );
1774
+
1775
+ rd_in = rrddim_add(st, "InDatagrams", "received", 1, 1, RRD_ALGORITHM_INCREMENTAL);
1776
+ rd_out = rrddim_add(st, "OutDatagrams", "sent", -1, 1, RRD_ALGORITHM_INCREMENTAL);
1777
+ } else
1778
+ rrdset_next(st);
1779
+
1780
+ rrddim_set_by_pointer(st, rd_in, udpstat.udps_ipackets);
1781
+ rrddim_set_by_pointer(st, rd_out, udpstat.udps_opackets);
1782
+ rrdset_done(st);
1783
+ }
1784
+
1785
+ // --------------------------------------------------------------------
1786
+
1787
+ if (likely(do_udp_errors)) {
1788
+ static RRDSET *st = NULL;
1789
+ static RRDDIM *rd_in_errors = NULL, *rd_no_ports = NULL, *rd_recv_buf_errors = NULL,
1790
+ *rd_in_csum_errors = NULL, *rd_ignored_multi = NULL;
1791
+
1792
+ if (unlikely(!st)) {
1793
+ st = rrdset_create_localhost("ipv4",
1794
+ "udperrors",
1795
+ NULL,
1796
+ "udp",
1797
+ NULL,
1798
+ "IPv4 UDP Errors",
1799
+ "events/s",
1800
+ 2701,
1801
+ update_every,
1802
+ RRDSET_TYPE_LINE
1803
+ );
1804
1805
+ rrdset_flag_set(st, RRDSET_FLAG_DETAIL);
1806
+
1807
+ rd_in_errors = rrddim_add(st, "InErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
1808
+ rd_no_ports = rrddim_add(st, "NoPorts", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
1809
+ rd_recv_buf_errors = rrddim_add(st, "RcvbufErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
1810
+ rd_in_csum_errors = rrddim_add(st, "InCsumErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
1811
+ rd_ignored_multi = rrddim_add(st, "IgnoredMulti", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
1812
+ } else
1813
+ rrdset_next(st);
1814
+
1815
+ rrddim_set_by_pointer(st, rd_in_errors, udpstat.udps_hdrops + udpstat.udps_badlen);
1816
+ rrddim_set_by_pointer(st, rd_no_ports, udpstat.udps_noport);
1817
+ rrddim_set_by_pointer(st, rd_recv_buf_errors, udpstat.udps_fullsock);
1818
+ rrddim_set_by_pointer(st, rd_in_csum_errors, udpstat.udps_badsum + udpstat.udps_nosum);
1819
+ rrddim_set_by_pointer(st, rd_ignored_multi, udpstat.udps_filtermcast);
1820
+ rrdset_done(st);
1821
+ }
1822
+ }
1823
+ } else {
1824
+ error("DISABLED: net.inet.udp.stats module");
1825
+ return 1;
1826
+ }
1827
+
1828
+ return 0;
1829
+}
1830
1831
// --------------------------------------------------------------------------------------------------------------------
1832
// old sources
@@ -1741,7 +1834,7 @@ int do_net_inet_tcp_stats(int update_every, usec_t dt) {
1834
int do_freebsd_sysctl_old(int update_every, usec_t dt) {
1835
static int do_disk_io = -1,
1836
do_bandwidth = -1,
1744
- do_udp_packets = -1, do_udp_errors = -1, do_icmp_packets = -1, do_icmpmsg = -1,
1837
+ do_icmp_packets = -1, do_icmpmsg = -1,
1838
do_ip_packets = -1, do_ip_fragsout = -1, do_ip_fragsin = -1, do_ip_errors = -1,
1839
do_ip6_packets = -1, do_ip6_fragsout = -1, do_ip6_fragsin = -1, do_ip6_errors = -1,
1840
do_icmp6 = -1, do_icmp6_redir = -1, do_icmp6_errors = -1, do_icmp6_echos = -1, do_icmp6_router = -1,
@@ -1750,8 +1843,6 @@ int do_freebsd_sysctl_old(int update_every, usec_t dt) {
1843
if (unlikely(do_disk_io == -1)) {
1844
do_disk_io = config_get_boolean("plugin:freebsd:sysctl", "stats for all disks", 1);
1845
do_bandwidth = config_get_boolean("plugin:freebsd:sysctl", "bandwidth", 1);
1753
- do_udp_packets = config_get_boolean("plugin:freebsd:sysctl", "ipv4 UDP packets", 1);
1754
- do_udp_errors = config_get_boolean("plugin:freebsd:sysctl", "ipv4 UDP errors", 1);
1846
do_icmp_packets = config_get_boolean("plugin:freebsd:sysctl", "ipv4 ICMP packets", 1);
1847
do_icmpmsg = config_get_boolean("plugin:freebsd:sysctl", "ipv4 ICMP messages", 1);
1848
do_ip_packets = config_get_boolean("plugin:freebsd:sysctl", "ipv4 packets", 1);
@@ -1808,9 +1899,6 @@ int do_freebsd_sysctl_old(int update_every, usec_t dt) {
1899
u_long ift_obytes;
1900
} iftot = {0, 0};
1901
1811
- // NEEDED BY: do_udp...
1812
- struct udpstat udpstat;
1813
-
1902
// NEEDED BY: do_icmp...
1903
struct icmpstat icmpstat;
1904
struct icmp_total {
@@ -2164,59 +2252,6 @@ int do_freebsd_sysctl_old(int update_every, usec_t dt) {
2252
2253
// --------------------------------------------------------------------
2254
2167
- // see http://net-snmp.sourceforge.net/docs/mibs/udp.html
2168
- if (likely(do_udp_packets || do_udp_errors)) {
2169
- if (unlikely(GETSYSCTL_BY_NAME("net.inet.udp.stats", udpstat))) {
2170
- do_udp_packets = 0;
2171
- error("DISABLED: ipv4.udppackets");
2172
- do_udp_errors = 0;
2173
- error("DISABLED: ipv4.udperrors");
2174
- } else {
2175
- if (likely(do_udp_packets)) {
2176
- st = rrdset_find_localhost("ipv4.udppackets");
2177
- if (unlikely(!st)) {
2178
- st = rrdset_create_localhost("ipv4", "udppackets", NULL, "udp", NULL, "IPv4 UDP Packets",
2179
- "packets/s", 2601, update_every, RRDSET_TYPE_LINE);
2180
-
2181
- rrddim_add(st, "InDatagrams", "received", 1, 1, RRD_ALGORITHM_INCREMENTAL);
2182
- rrddim_add(st, "OutDatagrams", "sent", -1, 1, RRD_ALGORITHM_INCREMENTAL);
2183
- } else
2184
- rrdset_next(st);
2185
-
2186
- rrddim_set(st, "InDatagrams", udpstat.udps_ipackets);
2187
- rrddim_set(st, "OutDatagrams", udpstat.udps_opackets);
2188
- rrdset_done(st);
2189
- }
2190
-
2191
- // --------------------------------------------------------------------
2192
-
2193
- if (likely(do_udp_errors)) {
2194
- st = rrdset_find_localhost("ipv4.udperrors");
2195
- if (unlikely(!st)) {
2196
- st = rrdset_create_localhost("ipv4", "udperrors", NULL, "udp", NULL, "IPv4 UDP Errors", "events/s",
2197
- 2701, update_every, RRDSET_TYPE_LINE);
2198
- rrdset_flag_set(st, RRDSET_FLAG_DETAIL);
2199
-
2200
- rrddim_add(st, "RcvbufErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
2201
- rrddim_add(st, "InErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
2202
- rrddim_add(st, "NoPorts", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
2203
- rrddim_add(st, "InCsumErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
2204
- rrddim_add(st, "IgnoredMulti", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
2205
- } else
2206
- rrdset_next(st);
2207
-
2208
- rrddim_set(st, "InErrors", udpstat.udps_hdrops + udpstat.udps_badlen);
2209
- rrddim_set(st, "NoPorts", udpstat.udps_noport);
2210
- rrddim_set(st, "RcvbufErrors", udpstat.udps_fullsock);
2211
- rrddim_set(st, "InCsumErrors", udpstat.udps_badsum + udpstat.udps_nosum);
2212
- rrddim_set(st, "IgnoredMulti", udpstat.udps_filtermcast);
2213
- rrdset_done(st);
2214
- }
2215
- }
2216
- }
2217
-
2218
- // --------------------------------------------------------------------
2219
-
2255
if (likely(do_icmp_packets || do_icmpmsg)) {
2256
if (unlikely(GETSYSCTL_BY_NAME("net.inet.icmp.stats", icmpstat))) {
2257
do_icmp_packets = 0;
src/plugin_freebsd.c
+2
-1
@@ -35,7 +35,8 @@ static struct freebsd_module {
35
36
// network metrics
37
{ .name = "net.inet.tcp.states", .dim = "tcp_states", .enabled = 1, .func = do_net_inet_tcp_states },
38
- { .name = "net.inet.tcp.stats", .dim = "tcp_stats", .enabled = 1, .func = do_net_inet_tcp_stats },
38
+ { .name = "net.inet.tcp.stats", .dim = "tcp_stats", .enabled = 1, .func = do_net_inet_tcp_stats },
39
+ { .name = "net.inet.udp.stats", .dim = "udp_stats", .enabled = 1, .func = do_net_inet_udp_stats },
40
41
// CPU metrics
42
{ .name = "kern.cp_times", .dim = "cp_times", .enabled = 1, .func = do_kern_cp_times },
src/plugin_freebsd.h
+1
@@ -27,6 +27,7 @@ extern int do_uptime(int update_every, usec_t dt);
27
extern int do_net_isr(int update_every, usec_t dt);
28
extern int do_net_inet_tcp_states(int update_every, usec_t dt);
29
extern int do_net_inet_tcp_stats(int update_every, usec_t dt);
30
+extern int do_net_inet_udp_stats(int update_every, usec_t dt);
31
32
extern int do_freebsd_sysctl_old(int update_every, usec_t dt);
33