1551
1553
***************************************************************************
1554
* Read IPv6 network sockets statistics from /proc/net/sockstat6.
1557
* @st_net_sock6 Structure where stats will be saved.
1560
* @st_net_sock6 Structure with statistics.
1561
***************************************************************************
1563
void read_net_sock6(struct stats_net_sock6 *st_net_sock6)
1568
if ((fp = fopen(NET_SOCKSTAT6, "r")) == NULL)
1571
while (fgets(line, 96, fp) != NULL) {
1573
if (!strncmp(line, "TCP6:", 5)) {
1575
sscanf(line + 12, "%u", &st_net_sock6->tcp6_inuse);
1577
else if (!strncmp(line, "UDP6:", 5)) {
1579
sscanf(line + 12, "%u", &st_net_sock6->udp6_inuse);
1581
else if (!strncmp(line, "RAW6:", 5)) {
1582
/* IPv6 RAW sockets */
1583
sscanf(line + 12, "%u", &st_net_sock6->raw6_inuse);
1585
else if (!strncmp(line, "FRAG6:", 6)) {
1586
/* IPv6 FRAGments */
1587
sscanf(line + 13, "%u", &st_net_sock6->frag6_inuse);
1595
***************************************************************************
1596
* Read IPv6 network traffic statistics from /proc/net/snmp6.
1599
* @st_net_ip6 Structure where stats will be saved.
1602
* @st_net_ip6 Structure with statistics.
1603
***************************************************************************
1605
void read_net_ip6(struct stats_net_ip6 *st_net_ip6)
1610
if ((fp = fopen(NET_SNMP6, "r")) == NULL)
1613
while (fgets(line, 128, fp) != NULL) {
1615
if (!strncmp(line, "Ip6InReceives ", 14)) {
1616
sscanf(line + 14, "%lu", &st_net_ip6->InReceives6);
1618
else if (!strncmp(line, "Ip6OutForwDatagrams ", 20)) {
1619
sscanf(line + 20, "%lu", &st_net_ip6->OutForwDatagrams6);
1621
else if (!strncmp(line, "Ip6InDelivers ", 14)) {
1622
sscanf(line + 14, "%lu", &st_net_ip6->InDelivers6);
1624
else if (!strncmp(line, "Ip6OutRequests ", 15)) {
1625
sscanf(line + 15, "%lu", &st_net_ip6->OutRequests6);
1627
else if (!strncmp(line, "Ip6ReasmReqds ", 14)) {
1628
sscanf(line + 14, "%lu", &st_net_ip6->ReasmReqds6);
1630
else if (!strncmp(line, "Ip6ReasmOKs ", 12)) {
1631
sscanf(line + 12, "%lu", &st_net_ip6->ReasmOKs6);
1633
else if (!strncmp(line, "Ip6InMcastPkts ", 15)) {
1634
sscanf(line + 15, "%lu", &st_net_ip6->InMcastPkts6);
1636
else if (!strncmp(line, "Ip6OutMcastPkts ", 16)) {
1637
sscanf(line + 16, "%lu", &st_net_ip6->OutMcastPkts6);
1639
else if (!strncmp(line, "Ip6FragOKs ", 11)) {
1640
sscanf(line + 11, "%lu", &st_net_ip6->FragOKs6);
1642
else if (!strncmp(line, "Ip6FragCreates ", 15)) {
1643
sscanf(line + 15, "%lu", &st_net_ip6->FragCreates6);
1651
***************************************************************************
1652
* Read IPv6 network error statistics from /proc/net/snmp6.
1655
* @st_net_eip6 Structure where stats will be saved.
1658
* @st_net_eip6 Structure with statistics.
1659
***************************************************************************
1661
void read_net_eip6(struct stats_net_eip6 *st_net_eip6)
1666
if ((fp = fopen(NET_SNMP6, "r")) == NULL)
1669
while (fgets(line, 128, fp) != NULL) {
1671
if (!strncmp(line, "Ip6InHdrErrors ", 15)) {
1672
sscanf(line + 15, "%lu", &st_net_eip6->InHdrErrors6);
1674
else if (!strncmp(line, "Ip6InAddrErrors ", 16)) {
1675
sscanf(line + 16, "%lu", &st_net_eip6->InAddrErrors6);
1677
else if (!strncmp(line, "Ip6InUnknownProtos ", 19)) {
1678
sscanf(line + 19, "%lu", &st_net_eip6->InUnknownProtos6);
1680
else if (!strncmp(line, "Ip6InTooBigErrors ", 18)) {
1681
sscanf(line + 18, "%lu", &st_net_eip6->InTooBigErrors6);
1683
else if (!strncmp(line, "Ip6InDiscards ", 14)) {
1684
sscanf(line + 14, "%lu", &st_net_eip6->InDiscards6);
1686
else if (!strncmp(line, "Ip6OutDiscards ", 15)) {
1687
sscanf(line + 15, "%lu", &st_net_eip6->OutDiscards6);
1689
else if (!strncmp(line, "Ip6InNoRoutes ", 14)) {
1690
sscanf(line + 14, "%lu", &st_net_eip6->InNoRoutes6);
1692
else if (!strncmp(line, "Ip6OutNoRoutes ", 15)) {
1693
sscanf(line + 15, "%lu", &st_net_eip6->OutNoRoutes6);
1695
else if (!strncmp(line, "Ip6ReasmFails ", 14)) {
1696
sscanf(line + 14, "%lu", &st_net_eip6->ReasmFails6);
1698
else if (!strncmp(line, "Ip6FragFails ", 13)) {
1699
sscanf(line + 13, "%lu", &st_net_eip6->FragFails6);
1701
else if (!strncmp(line, "Ip6InTruncatedPkts ", 19)) {
1702
sscanf(line + 19, "%lu", &st_net_eip6->InTruncatedPkts6);
1710
***************************************************************************
1711
* Read ICMPv6 network traffic statistics from /proc/net/snmp6.
1714
* @st_net_icmp6 Structure where stats will be saved.
1717
* @st_net_icmp6 Structure with statistics.
1718
***************************************************************************
1720
void read_net_icmp6(struct stats_net_icmp6 *st_net_icmp6)
1725
if ((fp = fopen(NET_SNMP6, "r")) == NULL)
1728
while (fgets(line, 128, fp) != NULL) {
1730
if (!strncmp(line, "Icmp6InMsgs ", 12)) {
1731
sscanf(line + 12, "%lu", &st_net_icmp6->InMsgs6);
1733
else if (!strncmp(line, "Icmp6OutMsgs ", 13)) {
1734
sscanf(line + 13, "%lu", &st_net_icmp6->OutMsgs6);
1736
else if (!strncmp(line, "Icmp6InEchos ", 13)) {
1737
sscanf(line + 13, "%lu", &st_net_icmp6->InEchos6);
1739
else if (!strncmp(line, "Icmp6InEchoReplies ", 19)) {
1740
sscanf(line + 19, "%lu", &st_net_icmp6->InEchoReplies6);
1742
else if (!strncmp(line, "Icmp6OutEchoReplies ", 20)) {
1743
sscanf(line + 20, "%lu", &st_net_icmp6->OutEchoReplies6);
1745
else if (!strncmp(line, "Icmp6InGroupMembQueries ", 24)) {
1746
sscanf(line + 24, "%lu", &st_net_icmp6->InGroupMembQueries6);
1748
else if (!strncmp(line, "Icmp6InGroupMembResponses ", 26)) {
1749
sscanf(line + 26, "%lu", &st_net_icmp6->InGroupMembResponses6);
1751
else if (!strncmp(line, "Icmp6OutGroupMembResponses ", 27)) {
1752
sscanf(line + 27, "%lu", &st_net_icmp6->OutGroupMembResponses6);
1754
else if (!strncmp(line, "Icmp6InGroupMembReductions ", 27)) {
1755
sscanf(line + 27, "%lu", &st_net_icmp6->InGroupMembReductions6);
1757
else if (!strncmp(line, "Icmp6OutGroupMembReductions ", 28)) {
1758
sscanf(line + 28, "%lu", &st_net_icmp6->OutGroupMembReductions6);
1760
else if (!strncmp(line, "Icmp6InRouterSolicits ", 22)) {
1761
sscanf(line + 22, "%lu", &st_net_icmp6->InRouterSolicits6);
1763
else if (!strncmp(line, "Icmp6OutRouterSolicits ", 23)) {
1764
sscanf(line + 23, "%lu", &st_net_icmp6->OutRouterSolicits6);
1766
else if (!strncmp(line, "Icmp6InRouterAdvertisements ", 28)) {
1767
sscanf(line + 28, "%lu", &st_net_icmp6->InRouterAdvertisements6);
1769
else if (!strncmp(line, "Icmp6InNeighborSolicits ", 24)) {
1770
sscanf(line + 24, "%lu", &st_net_icmp6->InNeighborSolicits6);
1772
else if (!strncmp(line, "Icmp6OutNeighborSolicits ", 25)) {
1773
sscanf(line + 25, "%lu", &st_net_icmp6->OutNeighborSolicits6);
1775
else if (!strncmp(line, "Icmp6InNeighborAdvertisements ", 30)) {
1776
sscanf(line + 30, "%lu", &st_net_icmp6->InNeighborAdvertisements6);
1778
else if (!strncmp(line, "Icmp6OutNeighborAdvertisements ", 31)) {
1779
sscanf(line + 31, "%lu", &st_net_icmp6->OutNeighborAdvertisements6);
1787
***************************************************************************
1788
* Read ICMPv6 network error statistics from /proc/net/snmp6.
1791
* @st_net_eicmp6 Structure where stats will be saved.
1794
* @st_net_eicmp6 Structure with statistics.
1795
***************************************************************************
1797
void read_net_eicmp6(struct stats_net_eicmp6 *st_net_eicmp6)
1802
if ((fp = fopen(NET_SNMP6, "r")) == NULL)
1805
while (fgets(line, 128, fp) != NULL) {
1807
if (!strncmp(line, "Icmp6InErrors ", 14)) {
1808
sscanf(line + 14, "%lu", &st_net_eicmp6->InErrors6);
1810
else if (!strncmp(line, "Icmp6InDestUnreachs ", 20)) {
1811
sscanf(line + 20, "%lu", &st_net_eicmp6->InDestUnreachs6);
1813
else if (!strncmp(line, "Icmp6OutDestUnreachs ", 21)) {
1814
sscanf(line + 21, "%lu", &st_net_eicmp6->OutDestUnreachs6);
1816
else if (!strncmp(line, "Icmp6InTimeExcds ", 17)) {
1817
sscanf(line + 17, "%lu", &st_net_eicmp6->InTimeExcds6);
1819
else if (!strncmp(line, "Icmp6OutTimeExcds ", 18)) {
1820
sscanf(line + 18, "%lu", &st_net_eicmp6->OutTimeExcds6);
1822
else if (!strncmp(line, "Icmp6InParmProblems ", 20)) {
1823
sscanf(line + 20, "%lu", &st_net_eicmp6->InParmProblems6);
1825
else if (!strncmp(line, "Icmp6OutParmProblems ", 21)) {
1826
sscanf(line + 21, "%lu", &st_net_eicmp6->OutParmProblems6);
1828
else if (!strncmp(line, "Icmp6InRedirects ", 17)) {
1829
sscanf(line + 17, "%lu", &st_net_eicmp6->InRedirects6);
1831
else if (!strncmp(line, "Icmp6OutRedirects ", 18)) {
1832
sscanf(line + 18, "%lu", &st_net_eicmp6->OutRedirects6);
1834
else if (!strncmp(line, "Icmp6InPktTooBigs ", 18)) {
1835
sscanf(line + 18, "%lu", &st_net_eicmp6->InPktTooBigs6);
1837
else if (!strncmp(line, "Icmp6OutPktTooBigs ", 19)) {
1838
sscanf(line + 19, "%lu", &st_net_eicmp6->OutPktTooBigs6);
1846
***************************************************************************
1847
* Read UDPv6 network traffic statistics from /proc/net/snmp6.
1850
* @st_net_udp6 Structure where stats will be saved.
1853
* @st_net_udp6 Structure with statistics.
1854
***************************************************************************
1856
void read_net_udp6(struct stats_net_udp6 *st_net_udp6)
1861
if ((fp = fopen(NET_SNMP6, "r")) == NULL)
1864
while (fgets(line, 128, fp) != NULL) {
1866
if (!strncmp(line, "Udp6InDatagrams ", 16)) {
1867
sscanf(line + 16, "%lu", &st_net_udp6->InDatagrams6);
1869
else if (!strncmp(line, "Udp6OutDatagrams ", 17)) {
1870
sscanf(line + 17, "%lu", &st_net_udp6->OutDatagrams6);
1872
else if (!strncmp(line, "Udp6NoPorts ", 12)) {
1873
sscanf(line + 12, "%lu", &st_net_udp6->NoPorts6);
1875
else if (!strncmp(line, "Udp6InErrors ", 13)) {
1876
sscanf(line + 13, "%lu", &st_net_udp6->InErrors6);
1884
***************************************************************************
1552
1885
* Read machine uptime, independently of the number of processors.