walkF5Stats is at
https://devcentral.f5.com/wiki/iControl.walkF5Stats.ashx
The CPU Stats (For 9.3 and later) uses the sysHostInfo OID's. The code looks like
----------------------------------------------------------------------------
0871 getHostSNMPCPUStats
0872----------------------------------------------------------------------------
0873sub getHostSNMPCPUStats {
0874 my ($dbh, $dev)=(@_);
0875 my $t0=[gettimeofday];
0876
0877 my $devID=$dev->{ID};
0878 my $devFQDN=$dev->{FQDN};
0879 my $icServer=$dev->{MgmtAddr};
0880 my $icPort=$dev->{MgmtPort};
0881
0882 my $oid_enterprises=".1.3.6.1.4.1";
0883 my $oid_f5="$oid_enterprises.3375";
0884 my $oid_bigipTrafficMgmt="$oid_f5.2";
0885 my $oid_bigipSystem="$oid_bigipTrafficMgmt.1";
0886 my $oid_sysHostInfoStat="$oid_bigipSystem.7";
0887
0888 my $oid_sysHostMemory="oid_sysHostInfoStat.1";
0889 my $oid_sysHostMemoryTotal="$oid_sysHostMemory.1";
0890 my $oid_sysHostMemoryUsed="$oid_sysHostMemory.2";
0891
0892 my $oid_sysHostCpu="$oid_sysHostInfoStat.2";
0893 my $oid_sysHostCpuNumber="$oid_sysHostCpu.1.0";
0894 my $oid_sysHostCpuTable="$oid_sysHostCpu.2";
0895
0896
0897 my $hostVersion=lookupHostVersion($dbh, $dev);
0898 dbprint "getHostSNMPCPUStats: Host version is $hostVersion\n";
0899 my($majVer, $minVer, $pttVer)=split('\.', $hostVersion);
0900
0901 if(!(($majVer>=9)and($minVer>=3))) {
0902 print "getHostSNMPCPUStats: Appliance is version $verDecimal [$hostVersion == $majVer $minVer $pttVer]\n";
0903 print "getHostSNMPCPUStats: Need at least v9.3.0 for SNMP CPU Stats\n";
0904 return;
0905 }
0906 my ($snmp_session, $snmp_err) = Net::SNMP->session(-hostname => $icServer, -community => $SNMPcommunity, -version => 2);
0907
0908 my($now) = time();
0909
0910 dbprint "getHostSNMPCPUStats: Grabbing oid_sysHostCpuNumber with $oid_sysHostCpuNumber\n";
0911 my $result=$snmp_session->get_request(-varbindlist => [$oid_sysHostCpuNumber,
0912 $oid_sysHostMemoryTotal, $oid_sysHostMemoryUsed]);
0913
0914 Save out the host memory stats first...
0915 saveValue64($dbh, $dev->{rrdpath}, "STATISTIC_HOST_MEMORY_TOTAL", "$devFQDN.SYSTEM.STATISTIC_HOST_MEMORY_TOTAL", $result->{$oid_sysHostMemoryTotal}, $now);
0916 saveValue64($dbh, $dev->{rrdpath}, "STATISTIC_HOST_MEMORY_USED", "$devFQDN.SYSTEM.STATISTIC_HOST_MEMORY_USED", $result->{$oid_sysHostMemoryUsed}, $now);
0917
0918 Now do the CPU stats...
0919 my $hostCpuCount=$result->{$oid_sysHostCpuNumber};
0920 dbprint "getHostSNMPCPUStats: System $devFQDN has $hostCpuCount Host CPU's\n";
0921
0922 dbprint "getHostSNMPCPUStats: Getting table \@ $oid_sysHostCpuTable with community $SNMPcommunity\n";
0923 my $result=$snmp_session->get_table(-baseoid => $oid_sysHostCpuTable);
0924 if(defined($result)) {
0925 my $snmpCPUNum;
0926 my $oid_sysHostCpuEntry="$oid_sysHostCpuTable.1";
0927
0928 for ($snmpCPUNum=1; $snmpCPUNum<=$hostCpuCount; $snmpCPUNum++) {
0929
0930 my $oid_sysHostCpuId="$oid_sysHostCpuEntry.2.$snmpCPUNum";
0931 my $oid_sysHostCpuUser="$oid_sysHostCpuEntry.3.$snmpCPUNum";
0932 my $oid_sysHostCpuNice="$oid_sysHostCpuEntry.4.$snmpCPUNum";
0933 my $oid_sysHostCpuSystem="$oid_sysHostCpuEntry.5.$snmpCPUNum";
0934 my $oid_sysHostCpuIdle="$oid_sysHostCpuEntry.6.$snmpCPUNum";
0935 my $oid_sysHostCpuIrq="$oid_sysHostCpuEntry.7.$snmpCPUNum";
0936 my $oid_sysHostCpuSoftirq="$oid_sysHostCpuEntry.8.$snmpCPUNum";
0937 my $oid_sysHostCpuIowait="$oid_sysHostCpuEntry.9.$snmpCPUNum";
0938
0939 dbprint "getHostSNMPCPUStats: $devFQDN oid_sysHostCpuUser [$oid_sysHostCpuUser] => $result->{$oid_sysHostCpuUser}\n";
0940 dbprint "getHostSNMPCPUStats: $devFQDN oid_sysHostCpuNice [$oid_sysHostCpuNice] => $result->{$oid_sysHostCpuNice}\n";
0941 dbprint "getHostSNMPCPUStats: $devFQDN oid_sysHostCpuSystem [$oid_sysHostCpuSystem] => $result->{$oid_sysHostCpuSystem}\n";
0942 dbprint "getHostSNMPCPUStats: $devFQDN oid_sysHostCpuIdle [$oid_sysHostCpuIdle] => $result->{$oid_sysHostCpuIdle}\n";
0943 dbprint "getHostSNMPCPUStats: $devFQDN oid_sysHostCpuIowait [$oid_sysHostCpuIowait] => $result->{$oid_sysHostCpuIowait}\n";
0944
0945 SNMP numbers the CPU's from 1... So we need to subtract 1 to get the raw (Or real) CPU number, counting from 0...
0946 (Because everything else numbers from 0... e.g. top etc)
0947 my $rawCPUNum=$snmpCPUNum-1;
0948
0949 saveValue64($dbh, $dev->{rrdpath}, "STATISTIC_CPU_INFO_USER", "$devFQDN.SYSTEM.STATISTIC_HOSTCPU_USER.$rawCPUNum", $result->{$oid_sysHostCpuUser}, $now);
0950 saveValue64($dbh, $dev->{rrdpath}, "STATISTIC_CPU_INFO_NICED", "$devFQDN.SYSTEM.STATISTIC_HOSTCPU_NICED.$rawCPUNum", $result->{$oid_sysHostCpuNice}, $now);
0951 saveValue64($dbh, $dev->{rrdpath}, "STATISTIC_CPU_INFO_SYSTEM", "$devFQDN.SYSTEM.STATISTIC_HOSTCPU_SYSTEM.$rawCPUNum", $result->{$oid_sysHostCpuSystem}, $now);
0952 saveValue64($dbh, $dev->{rrdpath}, "STATISTIC_CPU_INFO_IDLE", "$devFQDN.SYSTEM.STATISTIC_HOSTCPU_IDLE.$rawCPUNum", $result->{$oid_sysHostCpuIdle}, $now);
0953 saveValue64($dbh, $dev->{rrdpath}, "STATISTIC_CPU_INFO_IRQ", "$devFQDN.SYSTEM.STATISTIC_HOSTCPU_IRQ.$rawCPUNum", $result->{$oid_sysHostCpuIrq}, $now);
0954 saveValue64($dbh, $dev->{rrdpath}, "STATISTIC_CPU_INFO_SOFTIRQ", "$devFQDN.SYSTEM.STATISTIC_HOSTCPU_SOFTIRQ.$rawCPUNum", $result->{$oid_sysHostCpuSoftirq}, $now);
0955 saveValue64($dbh, $dev->{rrdpath}, "STATISTIC_CPU_INFO_IOWAIT", "$devFQDN.SYSTEM.STATISTIC_HOSTCPU_IOWAIT.$rawCPUNum", $result->{$oid_sysHostCpuIowait}, $now);
0956
0957 {
0958 my $cpuUser=$result->{$oid_sysHostCpuUser};
0959 my $cpuSystem=$result->{$oid_sysHostCpuSystem};
0960 my $cpuIdle=$result->{$oid_sysHostCpuIdle};
0961 my $cpuIowait=$result->{$oid_sysHostCpuIowait};
0962
0963 dbprint "getHostSNMPCPUStats: $icServer Processor $rawCPUNum idle $cpuIdle user $cpuUser system $cpuSystem iowait $cpuIowait\n";
0964 }
0965 }
0966
0967 }
0968 $snmp_session->close();
0969}
H