~ubuntu-branches/ubuntu/maverick/sysstat/maverick

« back to all changes in this revision

Viewing changes to rd_stats.c

  • Committer: Bazaar Package Importer
  • Author(s): Robert Luberda
  • Date: 2009-03-08 19:01:43 UTC
  • mfrom: (1.1.14 upstream)
  • Revision ID: james.westby@ubuntu.com-20090308190143-88odmo9euvg7f71d
Tags: 9.0.1-1
* New upstream release:
  + sar man page now mentions dependencies on sadc options (closes: #518438).
* Makefile.in: don't update sysstat.pot in clean. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
 * rd_stats.c: Read system statistics
3
 
 * (C) 1999-2008 by Sebastien GODARD (sysstat <at> orange.fr)
 
3
 * (C) 1999-2009 by Sebastien GODARD (sysstat <at> orange.fr)
4
4
 *
5
5
 ***************************************************************************
6
6
 * This program is free software; you can redistribute it and/or modify it *
523
523
{
524
524
        FILE *fp;
525
525
        char line[256];
 
526
        char dev_name[MAX_NAME_LEN];
526
527
        unsigned int major, minor;
527
528
        unsigned long rd_ios, wr_ios;
528
529
        unsigned long long rd_sec, wr_sec;
532
533
 
533
534
        while (fgets(line, 256, fp) != NULL) {
534
535
 
535
 
                if (sscanf(line, "%u %u %*s %lu %*u %llu %*u %lu %*u %llu",
536
 
                           &major, &minor,
537
 
                           &rd_ios, &rd_sec, &wr_ios, &wr_sec) == 6) {
 
536
                if (sscanf(line, "%u %u %s %lu %*u %llu %*u %lu %*u %llu",
 
537
                           &major, &minor, dev_name,
 
538
                           &rd_ios, &rd_sec, &wr_ios, &wr_sec) == 7) {
538
539
                        
539
 
                        if (ioc_iswhole(major, minor)) {
 
540
                        if (is_device(dev_name)) {
540
541
                                /*
541
542
                                 * OK: It's a device and not a partition.
542
543
                                 * Note: Structure should have been initialized first!
694
695
{
695
696
        FILE *fp;
696
697
        char line[256];
 
698
        char dev_name[MAX_NAME_LEN];
697
699
        int dsk = 0;
698
700
        struct stats_disk *st_disk_i;
699
701
        unsigned int major, minor;
706
708
 
707
709
        while ((fgets(line, 256, fp) != NULL) && (dsk < nbr)) {
708
710
 
709
 
                if (sscanf(line, "%u %u %*s %lu %*u %llu %lu %lu %*u %llu"
 
711
                if (sscanf(line, "%u %u %s %lu %*u %llu %lu %lu %*u %llu"
710
712
                           " %lu %*u %lu %lu",
711
 
                           &major, &minor,
 
713
                           &major, &minor, dev_name,
712
714
                           &rd_ios, &rd_sec, &rd_ticks, &wr_ios, &wr_sec, &wr_ticks,
713
 
                           &tot_ticks, &rq_ticks) == 10) {
 
715
                           &tot_ticks, &rq_ticks) == 11) {
714
716
                        
715
717
                        if (!rd_ios && !wr_ios)
716
718
                                /* Unused device: ignore it */
717
719
                                continue;
718
720
 
719
 
                        if (ioc_iswhole(major, minor)) {
 
721
                        if (is_device(dev_name)) {
720
722
                                /* It's a device and not a partition */
721
723
                                st_disk_i = st_disk + dsk++;
722
724
                                st_disk_i->major     = major;
1549
1551
 
1550
1552
/*
1551
1553
 ***************************************************************************
 
1554
 * Read IPv6 network sockets statistics from /proc/net/sockstat6.
 
1555
 *
 
1556
 * IN:
 
1557
 * @st_net_sock6        Structure where stats will be saved.
 
1558
 *
 
1559
 * OUT:
 
1560
 * @st_net_sock6        Structure with statistics.
 
1561
 ***************************************************************************
 
1562
 */
 
1563
void read_net_sock6(struct stats_net_sock6 *st_net_sock6)
 
1564
{
 
1565
        FILE *fp;
 
1566
        char line[96];
 
1567
 
 
1568
        if ((fp = fopen(NET_SOCKSTAT6, "r")) == NULL)
 
1569
                return;
 
1570
        
 
1571
        while (fgets(line, 96, fp) != NULL) {
 
1572
 
 
1573
                if (!strncmp(line, "TCP6:", 5)) {
 
1574
                        /* TCPv6 sockets */
 
1575
                        sscanf(line + 12, "%u", &st_net_sock6->tcp6_inuse);
 
1576
                }
 
1577
                else if (!strncmp(line, "UDP6:", 5)) {
 
1578
                        /* UDPv6 sockets */
 
1579
                        sscanf(line + 12, "%u", &st_net_sock6->udp6_inuse);
 
1580
                }
 
1581
                else if (!strncmp(line, "RAW6:", 5)) {
 
1582
                        /* IPv6 RAW sockets */
 
1583
                        sscanf(line + 12, "%u", &st_net_sock6->raw6_inuse);
 
1584
                }
 
1585
                else if (!strncmp(line, "FRAG6:", 6)) {
 
1586
                        /* IPv6 FRAGments */
 
1587
                        sscanf(line + 13, "%u", &st_net_sock6->frag6_inuse);
 
1588
                }
 
1589
        }
 
1590
 
 
1591
        fclose(fp);
 
1592
}
 
1593
 
 
1594
/*
 
1595
 ***************************************************************************
 
1596
 * Read IPv6 network traffic statistics from /proc/net/snmp6.
 
1597
 *
 
1598
 * IN:
 
1599
 * @st_net_ip6  Structure where stats will be saved.
 
1600
 *
 
1601
 * OUT:
 
1602
 * @st_net_ip6  Structure with statistics.
 
1603
 ***************************************************************************
 
1604
 */
 
1605
void read_net_ip6(struct stats_net_ip6 *st_net_ip6)
 
1606
{
 
1607
        FILE *fp;
 
1608
        char line[128];
 
1609
 
 
1610
        if ((fp = fopen(NET_SNMP6, "r")) == NULL)
 
1611
                return;
 
1612
 
 
1613
        while (fgets(line, 128, fp) != NULL) {
 
1614
 
 
1615
                if (!strncmp(line, "Ip6InReceives ", 14)) {
 
1616
                        sscanf(line + 14, "%lu", &st_net_ip6->InReceives6);
 
1617
                }
 
1618
                else if (!strncmp(line, "Ip6OutForwDatagrams ", 20)) {
 
1619
                        sscanf(line + 20, "%lu", &st_net_ip6->OutForwDatagrams6);
 
1620
                }
 
1621
                else if (!strncmp(line, "Ip6InDelivers ", 14)) {
 
1622
                        sscanf(line + 14, "%lu", &st_net_ip6->InDelivers6);
 
1623
                }
 
1624
                else if (!strncmp(line, "Ip6OutRequests ", 15)) {
 
1625
                        sscanf(line + 15, "%lu", &st_net_ip6->OutRequests6);
 
1626
                }
 
1627
                else if (!strncmp(line, "Ip6ReasmReqds ", 14)) {
 
1628
                        sscanf(line + 14, "%lu", &st_net_ip6->ReasmReqds6);
 
1629
                }
 
1630
                else if (!strncmp(line, "Ip6ReasmOKs ", 12)) {
 
1631
                        sscanf(line + 12, "%lu", &st_net_ip6->ReasmOKs6);
 
1632
                }
 
1633
                else if (!strncmp(line, "Ip6InMcastPkts ", 15)) {
 
1634
                        sscanf(line + 15, "%lu", &st_net_ip6->InMcastPkts6);
 
1635
                }
 
1636
                else if (!strncmp(line, "Ip6OutMcastPkts ", 16)) {
 
1637
                        sscanf(line + 16, "%lu", &st_net_ip6->OutMcastPkts6);
 
1638
                }
 
1639
                else if (!strncmp(line, "Ip6FragOKs ", 11)) {
 
1640
                        sscanf(line + 11, "%lu", &st_net_ip6->FragOKs6);
 
1641
                }
 
1642
                else if (!strncmp(line, "Ip6FragCreates ", 15)) {
 
1643
                        sscanf(line + 15, "%lu", &st_net_ip6->FragCreates6);
 
1644
                }
 
1645
        }
 
1646
        
 
1647
        fclose(fp);
 
1648
}
 
1649
 
 
1650
/*
 
1651
 ***************************************************************************
 
1652
 * Read IPv6 network error statistics from /proc/net/snmp6.
 
1653
 *
 
1654
 * IN:
 
1655
 * @st_net_eip6 Structure where stats will be saved.
 
1656
 *
 
1657
 * OUT:
 
1658
 * @st_net_eip6 Structure with statistics.
 
1659
 ***************************************************************************
 
1660
 */
 
1661
void read_net_eip6(struct stats_net_eip6 *st_net_eip6)
 
1662
{
 
1663
        FILE *fp;
 
1664
        char line[128];
 
1665
 
 
1666
        if ((fp = fopen(NET_SNMP6, "r")) == NULL)
 
1667
                return;
 
1668
 
 
1669
        while (fgets(line, 128, fp) != NULL) {
 
1670
 
 
1671
                if (!strncmp(line, "Ip6InHdrErrors ", 15)) {
 
1672
                        sscanf(line + 15, "%lu", &st_net_eip6->InHdrErrors6);
 
1673
                }
 
1674
                else if (!strncmp(line, "Ip6InAddrErrors ", 16)) {
 
1675
                        sscanf(line + 16, "%lu", &st_net_eip6->InAddrErrors6);
 
1676
                }
 
1677
                else if (!strncmp(line, "Ip6InUnknownProtos ", 19)) {
 
1678
                        sscanf(line + 19, "%lu", &st_net_eip6->InUnknownProtos6);
 
1679
                }
 
1680
                else if (!strncmp(line, "Ip6InTooBigErrors ", 18)) {
 
1681
                        sscanf(line + 18, "%lu", &st_net_eip6->InTooBigErrors6);
 
1682
                }
 
1683
                else if (!strncmp(line, "Ip6InDiscards ", 14)) {
 
1684
                        sscanf(line + 14, "%lu", &st_net_eip6->InDiscards6);
 
1685
                }
 
1686
                else if (!strncmp(line, "Ip6OutDiscards ", 15)) {
 
1687
                        sscanf(line + 15, "%lu", &st_net_eip6->OutDiscards6);
 
1688
                }
 
1689
                else if (!strncmp(line, "Ip6InNoRoutes ", 14)) {
 
1690
                        sscanf(line + 14, "%lu", &st_net_eip6->InNoRoutes6);
 
1691
                }
 
1692
                else if (!strncmp(line, "Ip6OutNoRoutes ", 15)) {
 
1693
                        sscanf(line + 15, "%lu", &st_net_eip6->OutNoRoutes6);
 
1694
                }
 
1695
                else if (!strncmp(line, "Ip6ReasmFails ", 14)) {
 
1696
                        sscanf(line + 14, "%lu", &st_net_eip6->ReasmFails6);
 
1697
                }
 
1698
                else if (!strncmp(line, "Ip6FragFails ", 13)) {
 
1699
                        sscanf(line + 13, "%lu", &st_net_eip6->FragFails6);
 
1700
                }
 
1701
                else if (!strncmp(line, "Ip6InTruncatedPkts ", 19)) {
 
1702
                        sscanf(line + 19, "%lu", &st_net_eip6->InTruncatedPkts6);
 
1703
                }
 
1704
        }
 
1705
        
 
1706
        fclose(fp);
 
1707
}
 
1708
 
 
1709
/*
 
1710
 ***************************************************************************
 
1711
 * Read ICMPv6 network traffic statistics from /proc/net/snmp6.
 
1712
 *
 
1713
 * IN:
 
1714
 * @st_net_icmp6        Structure where stats will be saved.
 
1715
 *
 
1716
 * OUT:
 
1717
 * @st_net_icmp6        Structure with statistics.
 
1718
 ***************************************************************************
 
1719
 */
 
1720
void read_net_icmp6(struct stats_net_icmp6 *st_net_icmp6)
 
1721
{
 
1722
        FILE *fp;
 
1723
        char line[128];
 
1724
 
 
1725
        if ((fp = fopen(NET_SNMP6, "r")) == NULL)
 
1726
                return;
 
1727
 
 
1728
        while (fgets(line, 128, fp) != NULL) {
 
1729
 
 
1730
                if (!strncmp(line, "Icmp6InMsgs ", 12)) {
 
1731
                        sscanf(line + 12, "%lu", &st_net_icmp6->InMsgs6);
 
1732
                }
 
1733
                else if (!strncmp(line, "Icmp6OutMsgs ", 13)) {
 
1734
                        sscanf(line + 13, "%lu", &st_net_icmp6->OutMsgs6);
 
1735
                }
 
1736
                else if (!strncmp(line, "Icmp6InEchos ", 13)) {
 
1737
                        sscanf(line + 13, "%lu", &st_net_icmp6->InEchos6);
 
1738
                }
 
1739
                else if (!strncmp(line, "Icmp6InEchoReplies ", 19)) {
 
1740
                        sscanf(line + 19, "%lu", &st_net_icmp6->InEchoReplies6);
 
1741
                }
 
1742
                else if (!strncmp(line, "Icmp6OutEchoReplies ", 20)) {
 
1743
                        sscanf(line + 20, "%lu", &st_net_icmp6->OutEchoReplies6);
 
1744
                }
 
1745
                else if (!strncmp(line, "Icmp6InGroupMembQueries ", 24)) {
 
1746
                        sscanf(line + 24, "%lu", &st_net_icmp6->InGroupMembQueries6);
 
1747
                }
 
1748
                else if (!strncmp(line, "Icmp6InGroupMembResponses ", 26)) {
 
1749
                        sscanf(line + 26, "%lu", &st_net_icmp6->InGroupMembResponses6);
 
1750
                }
 
1751
                else if (!strncmp(line, "Icmp6OutGroupMembResponses ", 27)) {
 
1752
                        sscanf(line + 27, "%lu", &st_net_icmp6->OutGroupMembResponses6);
 
1753
                }
 
1754
                else if (!strncmp(line, "Icmp6InGroupMembReductions ", 27)) {
 
1755
                        sscanf(line + 27, "%lu", &st_net_icmp6->InGroupMembReductions6);
 
1756
                }
 
1757
                else if (!strncmp(line, "Icmp6OutGroupMembReductions ", 28)) {
 
1758
                        sscanf(line + 28, "%lu", &st_net_icmp6->OutGroupMembReductions6);
 
1759
                }
 
1760
                else if (!strncmp(line, "Icmp6InRouterSolicits ", 22)) {
 
1761
                        sscanf(line + 22, "%lu", &st_net_icmp6->InRouterSolicits6);
 
1762
                }
 
1763
                else if (!strncmp(line, "Icmp6OutRouterSolicits ", 23)) {
 
1764
                        sscanf(line + 23, "%lu", &st_net_icmp6->OutRouterSolicits6);
 
1765
                }
 
1766
                else if (!strncmp(line, "Icmp6InRouterAdvertisements ", 28)) {
 
1767
                        sscanf(line + 28, "%lu", &st_net_icmp6->InRouterAdvertisements6);
 
1768
                }
 
1769
                else if (!strncmp(line, "Icmp6InNeighborSolicits ", 24)) {
 
1770
                        sscanf(line + 24, "%lu", &st_net_icmp6->InNeighborSolicits6);
 
1771
                }
 
1772
                else if (!strncmp(line, "Icmp6OutNeighborSolicits ", 25)) {
 
1773
                        sscanf(line + 25, "%lu", &st_net_icmp6->OutNeighborSolicits6);
 
1774
                }
 
1775
                else if (!strncmp(line, "Icmp6InNeighborAdvertisements ", 30)) {
 
1776
                        sscanf(line + 30, "%lu", &st_net_icmp6->InNeighborAdvertisements6);
 
1777
                }
 
1778
                else if (!strncmp(line, "Icmp6OutNeighborAdvertisements ", 31)) {
 
1779
                        sscanf(line + 31, "%lu", &st_net_icmp6->OutNeighborAdvertisements6);
 
1780
                }
 
1781
        }
 
1782
        
 
1783
        fclose(fp);
 
1784
}
 
1785
 
 
1786
/*
 
1787
 ***************************************************************************
 
1788
 * Read ICMPv6 network error statistics from /proc/net/snmp6.
 
1789
 *
 
1790
 * IN:
 
1791
 * @st_net_eicmp6       Structure where stats will be saved.
 
1792
 *
 
1793
 * OUT:
 
1794
 * @st_net_eicmp6       Structure with statistics.
 
1795
 ***************************************************************************
 
1796
 */
 
1797
void read_net_eicmp6(struct stats_net_eicmp6 *st_net_eicmp6)
 
1798
{
 
1799
        FILE *fp;
 
1800
        char line[128];
 
1801
 
 
1802
        if ((fp = fopen(NET_SNMP6, "r")) == NULL)
 
1803
                return;
 
1804
 
 
1805
        while (fgets(line, 128, fp) != NULL) {
 
1806
 
 
1807
                if (!strncmp(line, "Icmp6InErrors ", 14)) {
 
1808
                        sscanf(line + 14, "%lu", &st_net_eicmp6->InErrors6);
 
1809
                }
 
1810
                else if (!strncmp(line, "Icmp6InDestUnreachs ", 20)) {
 
1811
                        sscanf(line + 20, "%lu", &st_net_eicmp6->InDestUnreachs6);
 
1812
                }
 
1813
                else if (!strncmp(line, "Icmp6OutDestUnreachs ", 21)) {
 
1814
                        sscanf(line + 21, "%lu", &st_net_eicmp6->OutDestUnreachs6);
 
1815
                }
 
1816
                else if (!strncmp(line, "Icmp6InTimeExcds ", 17)) {
 
1817
                        sscanf(line + 17, "%lu", &st_net_eicmp6->InTimeExcds6);
 
1818
                }
 
1819
                else if (!strncmp(line, "Icmp6OutTimeExcds ", 18)) {
 
1820
                        sscanf(line + 18, "%lu", &st_net_eicmp6->OutTimeExcds6);
 
1821
                }
 
1822
                else if (!strncmp(line, "Icmp6InParmProblems ", 20)) {
 
1823
                        sscanf(line + 20, "%lu", &st_net_eicmp6->InParmProblems6);
 
1824
                }
 
1825
                else if (!strncmp(line, "Icmp6OutParmProblems ", 21)) {
 
1826
                        sscanf(line + 21, "%lu", &st_net_eicmp6->OutParmProblems6);
 
1827
                }
 
1828
                else if (!strncmp(line, "Icmp6InRedirects ", 17)) {
 
1829
                        sscanf(line + 17, "%lu", &st_net_eicmp6->InRedirects6);
 
1830
                }
 
1831
                else if (!strncmp(line, "Icmp6OutRedirects ", 18)) {
 
1832
                        sscanf(line + 18, "%lu", &st_net_eicmp6->OutRedirects6);
 
1833
                }
 
1834
                else if (!strncmp(line, "Icmp6InPktTooBigs ", 18)) {
 
1835
                        sscanf(line + 18, "%lu", &st_net_eicmp6->InPktTooBigs6);
 
1836
                }
 
1837
                else if (!strncmp(line, "Icmp6OutPktTooBigs ", 19)) {
 
1838
                        sscanf(line + 19, "%lu", &st_net_eicmp6->OutPktTooBigs6);
 
1839
                }
 
1840
        }
 
1841
        
 
1842
        fclose(fp);
 
1843
}
 
1844
 
 
1845
/*
 
1846
 ***************************************************************************
 
1847
 * Read UDPv6 network traffic statistics from /proc/net/snmp6.
 
1848
 *
 
1849
 * IN:
 
1850
 * @st_net_udp6 Structure where stats will be saved.
 
1851
 *
 
1852
 * OUT:
 
1853
 * @st_net_udp6 Structure with statistics.
 
1854
 ***************************************************************************
 
1855
 */
 
1856
void read_net_udp6(struct stats_net_udp6 *st_net_udp6)
 
1857
{
 
1858
        FILE *fp;
 
1859
        char line[128];
 
1860
 
 
1861
        if ((fp = fopen(NET_SNMP6, "r")) == NULL)
 
1862
                return;
 
1863
 
 
1864
        while (fgets(line, 128, fp) != NULL) {
 
1865
 
 
1866
                if (!strncmp(line, "Udp6InDatagrams ", 16)) {
 
1867
                        sscanf(line + 16, "%lu", &st_net_udp6->InDatagrams6);
 
1868
                }
 
1869
                else if (!strncmp(line, "Udp6OutDatagrams ", 17)) {
 
1870
                        sscanf(line + 17, "%lu", &st_net_udp6->OutDatagrams6);
 
1871
                }
 
1872
                else if (!strncmp(line, "Udp6NoPorts ", 12)) {
 
1873
                        sscanf(line + 12, "%lu", &st_net_udp6->NoPorts6);
 
1874
                }
 
1875
                else if (!strncmp(line, "Udp6InErrors ", 13)) {
 
1876
                        sscanf(line + 13, "%lu", &st_net_udp6->InErrors6);
 
1877
                }
 
1878
        }
 
1879
        
 
1880
        fclose(fp);
 
1881
}
 
1882
 
 
1883
/*
 
1884
 ***************************************************************************
1552
1885
 * Read machine uptime, independently of the number of processors.
1553
1886
 *
1554
1887
 * OUT:
1568
1901
                return;
1569
1902
 
1570
1903
        sscanf(line, "%lu.%lu", &up_sec, &up_cent);
1571
 
        *uptime = up_sec * HZ + up_cent * HZ / 100;
 
1904
        *uptime = (unsigned long long) up_sec * HZ + (unsigned long long) up_cent * HZ / 100;
1572
1905
 
1573
1906
        fclose(fp);
1574
1907
 
1699
2032
{
1700
2033
        FILE *fp;
1701
2034
        char line[256];
 
2035
        char dev_name[MAX_NAME_LEN];
1702
2036
        int dev = 0, i;
1703
2037
        unsigned long rd_ios, wr_ios;
1704
2038
 
1712
2046
         */
1713
2047
        while (fgets(line, 256, fp) != NULL) {
1714
2048
                if (!count_part) {
1715
 
                        i = sscanf(line, "%*d %*d %*s %lu %*u %*u %*u %lu",
1716
 
                                   &rd_ios, &wr_ios);
1717
 
                        if (i == 1)
 
2049
                        i = sscanf(line, "%*d %*d %s %lu %*u %*u %*u %lu",
 
2050
                                   dev_name, &rd_ios, &wr_ios);
 
2051
                        if ((i == 2) || !is_device(dev_name))
1718
2052
                                /* It was a partition and not a device */
1719
2053
                                continue;
1720
2054
                        if (only_used_dev && !rd_ios && !wr_ios)
1760
2094
                         * header, blank line,... or a line without stats!)
1761
2095
                         */
1762
2096
                        if (!count_part && !ioc_iswhole(major, minor))
1763
 
                                /* This was a partition, and we don't want to count them */
 
2097
                                /* This was a partition, and we don't want to count it */
1764
2098
                                continue;
1765
2099
                        dev++;
1766
2100
                }
1988
2322
        return irq;
1989
2323
}
1990
2324
 
 
2325
/*
 
2326
 ***************************************************************************
 
2327
 * Read CPU frequency statistics.
 
2328
 *
 
2329
 * IN:
 
2330
 * @st_pwr_cpufreq      Structure where stats will be saved.
 
2331
 * @nbr                 Total number of CPU (including cpu "all").
 
2332
 *
 
2333
 * OUT:
 
2334
 * @st_pwr_cpufreq      Structure with statistics.
 
2335
 ***************************************************************************
 
2336
 */
 
2337
void read_cpuinfo(struct stats_pwr_cpufreq *st_pwr_cpufreq, int nbr)
 
2338
{
 
2339
        FILE *fp;
 
2340
        struct stats_pwr_cpufreq *st_pwr_cpufreq_i;
 
2341
        char line[1024];
 
2342
        int proc_nb = 0, nr = 0;
 
2343
        unsigned int ifreq, dfreq;
 
2344
        
 
2345
        if ((fp = fopen(CPUINFO, "r")) == NULL)
 
2346
                return;
 
2347
        
 
2348
        st_pwr_cpufreq->cpufreq = 0;
 
2349
        
 
2350
        while (fgets(line, 1024, fp) != NULL) {
 
2351
                
 
2352
                if (!strncmp(line, "processor\t", 10)) {
 
2353
                        sscanf(strchr(line, ':') + 1, "%d", &proc_nb);
 
2354
                }
 
2355
                
 
2356
                else if (!strncmp(line, "cpu MHz\t", 8)) {
 
2357
                        sscanf(strchr(line, ':') + 1, "%u.%u", &ifreq, &dfreq);
 
2358
                        
 
2359
                        if (proc_nb < (nbr - 1)) {
 
2360
                                /* Save current CPU frequency */
 
2361
                                st_pwr_cpufreq_i = st_pwr_cpufreq + proc_nb + 1;
 
2362
                                st_pwr_cpufreq_i->cpufreq = ifreq * 100 + dfreq / 10;
 
2363
                                
 
2364
                                /* Also save it to compute an average CPU frequency */
 
2365
                                st_pwr_cpufreq->cpufreq += st_pwr_cpufreq_i->cpufreq;
 
2366
                                nr++;
 
2367
                        }
 
2368
                }
 
2369
        }
 
2370
        
 
2371
        fclose(fp);
 
2372
        
 
2373
        if (nr) {
 
2374
                /* Compute average CPU frequency for this machine */
 
2375
                st_pwr_cpufreq->cpufreq /= nr;
 
2376
        }
 
2377
}