The hrProcessorLoad oid at .1.3.6.1.2.1.25.3.3.1.2 has no index, yet you can walk this oid and get the load values of processors installed in a host. Without an index how could I get the appropriate oid for machines with more than one, two cpus etc?
The solution was to walk the oid itself and REGEXP the OID taking the last number and using that number as the snmp_index when inserting into the host_snmp_cache table.
for example the xml file portion for windows cpu:
Code: Select all
<index>
<name>Index</name>
<method>walk</method>
<source>VALREP/REGEXP:.*\.([0-9]+)$</source>
<direction>input</direction>
<oid>.1.3.6.1.2.1.25.3.3.1.2</oid>
</index>
Code: Select all
}elseif (ereg("^VALREP/REGEXP:", $field_array["source"])) {
for ($i=0;($i<sizeof($snmp_data));$i++) {
$value = ereg_replace(ereg_replace("^VALREP/REGEXP:", "", $field_array["source"]), "\\1", $$
$snmp_index = $value;
$oid = $field_array["oid"] . "." . $value;
db_execute("replace into host_snmp_cache
(host_id,snmp_query_id,field_name,field_value,snmp_index,oid)
values ($host_id,$snmp_query_id,'$field_name','$value',$snmp_index,'$oid')");
}
-Jeff