mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
rework netstats polling to work around missing oids and implement snmp_get_multi (maybe needs more work)
git-svn-id: http://www.observium.org/svn/observer/trunk@1379 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
@@ -51,13 +51,25 @@ if($device[os] != "Snom") {
|
||||
$snmpstring .= " $oid.0";
|
||||
}
|
||||
if(!file_exists($rrdfile)) { shell_exec($rrd_create); }
|
||||
$snmpdata_cmd = $config['snmpget'] . " -M ".$config['mibdir'] . " -m IP-MIB:SNMPv2-MIB:UDP-MIB:TCP-MIB:IP-MIB -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " $snmpstring";
|
||||
$snmpdata = trim(shell_exec($snmpdata_cmd));
|
||||
#$snmpdata_cmd = $config['snmpget'] . " -M ".$config['mibdir'] . " -m IP-MIB:SNMPv2-MIB:UDP-MIB:TCP-MIB:IP-MIB -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " $snmpstring";
|
||||
#$snmpdata = trim(shell_exec($snmpdata_cmd));
|
||||
$data = snmp_get_multi($device ,$snmpstring);
|
||||
|
||||
# print_r($data);
|
||||
|
||||
$rrdupdate = "N";
|
||||
foreach(explode("\n", $snmpdata) as $data) {
|
||||
if(strstr($data, "No") || strstr($data, "d") || strstr($data, "s")) { $data = "0"; }
|
||||
$rrdupdate .= ":$data";
|
||||
|
||||
foreach($oids[$proto] as $oid){
|
||||
if(is_numeric($data[0][$oid])) { $value = $data[0][$oid]; } else { $value = "0"; }
|
||||
$rrdupdate .= ":$value";
|
||||
}
|
||||
|
||||
# $rrdupdate = "N";
|
||||
# foreach(explode("\n", $snmpdata) as $data) {
|
||||
# if(strstr($data, "No") || strstr($data, "d") || strstr($data, "s")) { $data = "0"; }
|
||||
# $rrdupdate .= ":$data";
|
||||
# }
|
||||
|
||||
unset($snmpstring);
|
||||
rrdtool_update($rrdfile, $rrdupdate);
|
||||
}
|
||||
|
||||
@@ -1,13 +1,24 @@
|
||||
<?php
|
||||
|
||||
echo("Microsoft Windows");
|
||||
|
||||
if(strstr($sysDescr, "x86")) { $hardware = "Generic x86"; }
|
||||
if(strstr($sysDescr, "AMD64")) { $hardware = "Generic x64"; }
|
||||
if(strstr($sysDescr, "Windows 2000 Version 5.1")) { $version = "XP"; }
|
||||
if(strstr($sysDescr, "Windows Version 5.2")) { $version = "2003 Server"; }
|
||||
if(strstr($sysDescr, "Windows Version 6.1")) { $version = "Windows 7"; }
|
||||
|
||||
if(strstr($sysDescr, "Build Number: 1381")) { $version = "NT 4.0"; }
|
||||
if(strstr($sysDescr, "Build 2195")) { $version = "2000 (NT 5.0)"; }
|
||||
if(strstr($sysDescr, "Build 2600")) { $version = "XP (NT 5.1)"; }
|
||||
if(strstr($sysDescr, "Build 3790")) { $version = "XP / 2003 (NT 5.2)"; }
|
||||
if(strstr($sysDescr, "Build 6000")) { $version = "Vista (NT 6.0)"; }
|
||||
if(strstr($sysDescr, "Build 6001")) { $version = "Vista SP1 / 2008 (NT 6.0)"; }
|
||||
if(strstr($sysDescr, "Build 6001")) { $version = "Vista SP2 / 2008 SP2 (NT 6.0)"; }
|
||||
if(strstr($sysDescr, "Build 6001")) { $version = "7 / 2008 R2 (NT 6.1)"; }
|
||||
|
||||
if(strstr($sysDescr, "Uniprocessor Free")) { $features = "Uniprocessor"; }
|
||||
if(strstr($sysDescr, "Multiprocessor Free")) { $features = "Multiprocessor"; }
|
||||
|
||||
### Detect processor type? : I.E. x86 Family 15 Model 2 Stepping 7
|
||||
|
||||
include("ucd-mib.inc.php");
|
||||
include("hr-mib.inc.php");
|
||||
|
||||
|
||||
@@ -5,6 +5,32 @@
|
||||
|
||||
#$config['snmp']['timeout'] = 300; # timeout in ms
|
||||
#$config['snmp']['retries'] = 6; # how many times to retry the query
|
||||
|
||||
function snmp_get_multi ($device, $oids, $options = "-OQUs", $mib = NULL, $mibdir = NULL)
|
||||
{
|
||||
global $debug; global $config; global $runtime_stats;
|
||||
$cmd = $config['snmpget'] . " -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'];
|
||||
if($options) { $cmd .= " " . $options; }
|
||||
if($mib) { $cmd .= " -m " . $mib; }
|
||||
if($mibdir) { $cmd .= " -M " . $mibdir; } else { $cmd .= " -M ".$config['mibdir']; }
|
||||
#$cmd .= " -t " . $config['snmp']['timeout'] . " -r " . $config['snmp']['retries'];
|
||||
$cmd .= " ".$oids;
|
||||
if($debug) { echo("$cmd\n"); }
|
||||
$data = trim(shell_exec($cmd));
|
||||
$runtime_stats['snmpget']++;
|
||||
if($debug) { echo("$data\n"); }
|
||||
foreach(explode("\n", $data) as $entry) {
|
||||
list($oid,$value) = explode("=", $entry);
|
||||
$oid = trim($oid); $value = trim($value);
|
||||
list($oid, $index) = explode(".", $oid);
|
||||
if (!strstr($value, "at this OID") && isset($oid) && isset($index)) {
|
||||
$array[$index][$oid] = $value;
|
||||
}
|
||||
}
|
||||
return $array;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function snmp_get ($device, $oid, $options = NULL, $mib = NULL, $mibdir = NULL)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user