From dde365e30ce588d33a431c652f92fe6fc6b9b6b6 Mon Sep 17 00:00:00 2001 From: Adam Amstrong Date: Fri, 24 Apr 2009 15:04:45 +0000 Subject: [PATCH] many polling and discovery performance improvements git-svn-id: http://www.observium.org/svn/observer/trunk@408 61d68cd4-352d-0410-923a-c4978735b2b8 --- addhost.php | 2 +- includes/billing.php | 9 +--- includes/discovery/bgp-peers.php | 4 +- includes/discovery/cisco-physical.php | 4 +- includes/discovery/cisco-processors.php | 6 +-- includes/discovery/cisco-pw.php | 12 +++--- includes/discovery/cisco-vlans.php | 12 +++--- includes/discovery/cisco-vrf.php | 8 ++-- includes/discovery/interfaces.php | 5 ++- includes/discovery/ipv4-addresses.php | 4 +- includes/discovery/ipv6-addresses.php | 10 +++-- includes/discovery/storage.php | 4 +- includes/discovery/temperatures.php | 27 ++++++------ includes/functions.php | 8 ++-- includes/polling/device-fortigate.inc.php | 6 +-- includes/polling/device-ios.inc.php | 51 ++--------------------- includes/polling/device-junos.inc.php | 8 ++-- includes/polling/device-unix.inc.php | 4 +- includes/polling/interfaces.inc.php | 3 +- includes/polling/temperatures.inc.php | 6 +-- test-discovery.php | 6 --- 21 files changed, 75 insertions(+), 124 deletions(-) diff --git a/addhost.php b/addhost.php index 90ab27855d..42371881c8 100755 --- a/addhost.php +++ b/addhost.php @@ -17,7 +17,7 @@ if($argv[1] && $argv[2] && $argv[3]) { if ( isDomainResolves($argv[1])){ if ( isPingable($argv[1])) { if ( mysql_result(mysql_query("SELECT COUNT(*) FROM `devices` WHERE `hostname` = '".mres($host)."'"), 0) == '0' ) { - $snmphost = trim(`snmpget -Oqv -$snmpver -c $community $host:$port sysName.0 | sed s/\"//g`); + $snmphost = trim(shell_exec($config['snmpget'] ." -m SNMPv2-MIB -Oqv -$snmpver -c $community $host:$port sysName.0 | sed s/\"//g`); # var_dump($snmphost); if ($snmphost == $host || $hostshort = $host) { $return = createHost ($host, $community, $snmpver, $port); diff --git a/includes/billing.php b/includes/billing.php index 695730fb31..6861b2a86a 100644 --- a/includes/billing.php +++ b/includes/billing.php @@ -67,17 +67,12 @@ function getDates($dayofmonth) { function getValue($host, $community, $port, $id, $inout) { + global $config; $oid = "IF-MIB::ifHC" . $inout . "Octets." . $id; - $value = `snmpget -c $community -v2c -O qv $host:$port $oid`; + $value = shell_exec($config['snmpget'] ." -m IF-MIB -c $community -v2c -O qv $host:$port $oid"); return $value; } -function getIfName($host, $port, $id) { - $oid = "IF-MIB::ifDescr." . $id; - $value = `snmpget -c xyyz -v2c -O qv $host:$port $oid`; - return $value; -} - function getLastPortCounter($port_id,$inout) { $query = mysql_query("SELECT count(counter) from port_" . $inout . "_measurements WHERE port_id=" . $port_id); $rows = mysql_result($query, 0); diff --git a/includes/discovery/bgp-peers.php b/includes/discovery/bgp-peers.php index f1d722c022..bf6bc2ab45 100755 --- a/includes/discovery/bgp-peers.php +++ b/includes/discovery/bgp-peers.php @@ -4,7 +4,7 @@ echo("BGP Sessions : "); - $as_cmd = $config['snmpwalk'] . " -CI -Oqvn -" . $device['snmpver'] . " -c" . $device['community'] . " " . $device['hostname'].":".$device['port'] . " "; + $as_cmd = $config['snmpwalk'] . " -m BGP4-MIB -CI -Oqvn -" . $device['snmpver'] . " -c" . $device['community'] . " " . $device['hostname'].":".$device['port'] . " "; $as_cmd .= ".1.3.6.1.2.1.15.2"; $bgpLocalAs = trim(shell_exec($as_cmd)); @@ -14,7 +14,7 @@ if($bgpLocalAs != $device['bgpLocalAs']) { mysql_query("UPDATE devices SET bgpLocalAs = '$bgpLocalAs' WHERE device_id = '".$device['device_id']."'"); echo("Updated AS\n"); } - $peers_cmd = $config['snmpwalk'] . " -CI -Oq -" . $device['snmpver'] . " -c" . $device['community'] . " " . $device['hostname'].":".$device['port'] . " "; + $peers_cmd = $config['snmpwalk'] . " -m BGP4-MIB -CI -Oq -" . $device['snmpver'] . " -c" . $device['community'] . " " . $device['hostname'].":".$device['port'] . " "; $peers_cmd .= "BGP4-MIB::bgpPeerRemoteAs"; $peers = trim(str_replace("BGP4-MIB::bgpPeerRemoteAs.", "", `$peers_cmd`)); foreach (explode("\n", $peers) as $peer) { diff --git a/includes/discovery/cisco-physical.php b/includes/discovery/cisco-physical.php index c82ae8a19a..9b47daafcc 100755 --- a/includes/discovery/cisco-physical.php +++ b/includes/discovery/cisco-physical.php @@ -4,14 +4,14 @@ if($config['enable_inventory']) { - $ents_cmd = "snmpwalk -O qn -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['$port'] . " "; + $ents_cmd = $config['snmpwalk'] . " -m ENTITY-MIB -O qn -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['$port'] . " "; $ents_cmd .= "1.3.6.1.2.1.47.1.1.1.1.2 | sed s/.1.3.6.1.2.1.47.1.1.1.1.2.//g | cut -f 1 -d\" \""; $ents = trim(`$ents_cmd | grep -v o`); foreach(explode("\n", $ents) as $entPhysicalIndex) { - $ent_data = "snmpget -Ovqs -"; + $ent_data = $config['snmpget'] . " -m ENTITY-MIB -Ovqs -"; $ent_data .= $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'] .":".$device['port']; $ent_data .= " entPhysicalDescr." . $entPhysicalIndex; $ent_data .= " entPhysicalContainedIn." . $entPhysicalIndex; diff --git a/includes/discovery/cisco-processors.php b/includes/discovery/cisco-processors.php index 512757b32c..f3265756bc 100755 --- a/includes/discovery/cisco-processors.php +++ b/includes/discovery/cisco-processors.php @@ -10,7 +10,7 @@ ## Cisco Processors if($device['os'] == "IOS" || $device['os'] == "IOS XE") { echo("Cisco "); - $oids = shell_exec($config['snmpwalk'] . " -v2c -CI -Osqn -c ".$community." ".$hostname.":".$port." .1.3.6.1.4.1.9.9.109.1.1.1.1.2 | sed s/.1.3.6.1.4.1.9.9.109.1.1.1.1.2.//g"); + $oids = shell_exec($config['snmpwalk'] . " -m CISCO-PROCESS-MIB -v2c -CI -Osqn -c ".$community." ".$hostname.":".$port." .1.3.6.1.4.1.9.9.109.1.1.1.1.2 | sed s/.1.3.6.1.4.1.9.9.109.1.1.1.1.2.//g"); $oids = trim($oids); foreach(explode("\n", $oids) as $data) { $data = trim($data); @@ -18,8 +18,8 @@ list($oid, $entPhysicalIndex) = explode(" ", $data); $usage_oid = "cpmCPUTotal5minRev.$oid"; $descr_oid = "entPhysicalName.$entPhysicalIndex"; - $descr = trim(shell_exec("snmpget -O qv -v2c -c $community $hostname:$port $descr_oid")); - $usage = trim(shell_exec("snmpget -O qv -v2c -c $community $hostname:$port $usage_oid")); + $descr = trim(shell_exec($config['snmpget'] . " -m ENTITY-MIB -O qv -v2c -c $community $hostname:$port $descr_oid")); + $usage = trim(shell_exec($config['snmpget'] . " -m CISCO-PROCESS-MIB -O qv -v2c -c $community $hostname:$port $usage_oid")); if($entPhysicalIndex == "0") { $descr = "Proc $oid"; } if(!strstr($descr, "No") && !strstr($usage, "No") && $descr != "" ) { $descr = str_replace("\"", "", $descr); diff --git a/includes/discovery/cisco-pw.php b/includes/discovery/cisco-pw.php index 70a293fa10..d63d93b74e 100755 --- a/includes/discovery/cisco-pw.php +++ b/includes/discovery/cisco-pw.php @@ -7,7 +7,7 @@ if($config['enable_pseudowires']) { echo("PW : "); - $oids = shell_exec($config['snmpwalk'] . " -CI -Ln -Osqn -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " cpwVcID"); + $oids = shell_exec($config['snmpwalk'] . " -m CISCO-IETF-PW-MIB -CI -Ln -Osqn -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " cpwVcID"); $oids = str_replace(".1.3.6.1.4.1.9.10.106.1.2.1.10.", "", $oids); @@ -16,13 +16,13 @@ if($config['enable_pseudowires']) { if($oid) { list($cpwOid, $cpwVcID) = explode(" ", $oid); if($cpwOid) { - list($cpw_remote_id) = split(":", shell_exec($config['snmpget'] . " -Ln -Osqnv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " cpwVcMplsPeerLdpID." . $cpwOid)); - $interface_descr = trim(shell_exec("snmpwalk -Oqvn -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " cpwVcName." . $cpwOid)); - $cpw_remote_device = @mysql_result(mysql_query("SELECT device_id FROM ipaddr AS A, interfaces AS I WHERE A.addr = '".$cpw_remote_id."' AND A.interface_id = I.interface_id"),0); + list($cpw_remote_id) = split(":", shell_exec($config['snmpget'] . " -m CISCO-IETF-PW-MPLS-MIB -Ln -Osqnv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " cpwVcMplsPeerLdpID." . $cpwOid)); + $interface_descr = trim(shell_exec($config['snmpwalk'] . " -m CISCO-IETF-PW-MIB -Oqvn -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " cpwVcName." . $cpwOid)); + $cpw_remote_device = @mysql_result(mysql_query("SELECT device_id FROM ipv4_addresses AS A, interfaces AS I WHERE A.ipv4_address = '".$cpw_remote_id."' AND A.interface_id = I.interface_id"),0); $if_id = @mysql_result(mysql_query("SELECT `interface_id` FROM `interfaces` WHERE `ifDescr` = '$interface_descr' AND `device_id` = '".$device['device_id']."'"),0); if($cpw_remote_device && $if_id) { $hostname = gethostbyid($cpw_remote_device); -# echo("Oid: " . $cpwOid . " cpwVcID: " . $cpwVcID . " Remote Id: " . $cpw_remote_id . "($hostname(".$cpw_remote_device.") -> $interface_descr($if_id)) \n"); + #echo("\nOid: " . $cpwOid . " cpwVcID: " . $cpwVcID . " Remote Id: " . $cpw_remote_id . "($hostname(".$cpw_remote_device.") -> $interface_descr($if_id))"); if(mysql_result(mysql_query("SELECT count(*) FROM pseudowires WHERE `interface_id` = '$if_id' AND `cpwVcID`='".$cpwVcID."'"),0)) { echo("."); @@ -31,7 +31,7 @@ if($config['enable_pseudowires']) { $insert_query .= "VALUES ('$if_id','$cpw_remote_device','$cpw_remote_id','$cpwVcID', '$cpwOid')"; mysql_query($insert_query); echo("+"); - # echo($device['device_id'] . " $cpwOid $cpw_remote_device $if_id $cpwVcID\n"); + #echo($device['device_id'] . " $cpwOid $cpw_remote_device $if_id $cpwVcID\n"); } $cpw_exists[] = $device['device_id'] . " $cpwOid $cpw_remote_device $if_id $cpwVcID"; } diff --git a/includes/discovery/cisco-vlans.php b/includes/discovery/cisco-vlans.php index 667e32ab02..dd2aee1e10 100755 --- a/includes/discovery/cisco-vlans.php +++ b/includes/discovery/cisco-vlans.php @@ -2,26 +2,28 @@ echo("Cisco VLANs : "); - $vtpversion_cmd = $config['snmpget'] . " -Oqv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " .1.3.6.1.4.1.9.9.46.1.1.1.0"; + $vtpversion_cmd = $config['snmpget'] . " -m CISCO-VTP-MIB -Oqv -" . $device['snmpver'] . " -c " . $device['community'] . " "; + $vtpversion_cmd .= $device['hostname'].":".$device['port'] . " .1.3.6.1.4.1.9.9.46.1.1.1.0"; $vtpversion = trim(`$vtpversion_cmd 2>/dev/null`); if($vtpversion == '1' || $vtpversion == '2' || $vtpversion == 'two' || $vtpversion == 'three') { - $vtp_domain_cmd = "snmpget -Oqv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " .1.3.6.1.4.1.9.9.46.1.2.1.1.2.1"; + $vtp_domain_cmd = $config['snmpget'] . " -m CISCO-VTP-MIB -Oqv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port']; + $vtp_domain_cmd .= " .1.3.6.1.4.1.9.9.46.1.2.1.1.2.1"; $vtp_domain = trim(str_replace("\"", "", `$vtp_domain_cmd 2>/dev/null`)); echo("VTP v$vtpversion $vtp_domain "); - $vlans_cmd = "snmpwalk -O qn -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " "; + $vlans_cmd = $config['snmpwalk'] . " -m CISCO-VTP-MIB -O qn -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " "; $vlans_cmd .= "1.3.6.1.4.1.9.9.46.1.3.1.1.2.1 | sed s/.1.3.6.1.4.1.9.9.46.1.3.1.1.2.1.//g | cut -f 1 -d\" \""; $vlans = trim(`$vlans_cmd | grep -v o`); foreach(explode("\n", $vlans) as $vlan) { - $vlan_descr_cmd = "snmpget -O nvq -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " "; + $vlan_descr_cmd = $config['snmpget'] . " -m CISCO-VTP-MIB -O nvq -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " "; $vlan_descr_cmd .= ".1.3.6.1.4.1.9.9.46.1.3.1.1.4.1." . $vlan; - $vlan_descr = `$vlan_descr_cmd`; + $vlan_descr = shell_exec($vlan_descr_cmd); $vlan_descr = trim(str_replace("\"", "", $vlan_descr)); diff --git a/includes/discovery/cisco-vrf.php b/includes/discovery/cisco-vrf.php index fd2d086a63..317d971d07 100755 --- a/includes/discovery/cisco-vrf.php +++ b/includes/discovery/cisco-vrf.php @@ -4,7 +4,7 @@ echo("VRF : "); - $oids = shell_exec($config['snmpwalk'] . " -CI -Ln -Osqn -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " mplsVpnVrfRouteDistinguisher"); + $oids = shell_exec($config['snmpwalk'] . " -m MPLS-VPN-MIB -CI -Ln -Osqn -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " mplsVpnVrfRouteDistinguisher"); $oids = str_replace(".1.3.6.1.3.118.1.2.2.1.3.", "", $oids); $oids = str_replace(" \"", "||", $oids); @@ -14,9 +14,9 @@ foreach ( explode("\n", $oids) as $oid ) { if($oid) { list($vrf['oid'], $vrf['mplsVpnVrfRouteDistinguisher']) = explode("||", $oid); - $vrf['name'] = shell_exec($config['snmpget'] . " -Ln -Osq -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " mplsVpnVrfRouteDistinguisher.".$vrf['oid']); + $vrf['name'] = shell_exec($config['snmpget'] . " -m MPLS-VPN-MIB -Ln -Osq -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " mplsVpnVrfRouteDistinguisher.".$vrf['oid']); list(,$vrf['name'],, $vrf['mplsVpnVrfRouteDistinguisher']) = explode("\"", $vrf['name']); - $vrf['mplsVpnVrfDescription'] = trim(shell_exec($config['snmpget'] . " -Ln -Osqvn -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " mplsVpnVrfDescription.".$vrf['oid'])); + $vrf['mplsVpnVrfDescription'] = trim(shell_exec($config['snmpget'] . " -m MPLS-VPN-MIB -Ln -Osqvn -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " mplsVpnVrfDescription.".$vrf['oid'])); if(@mysql_result(mysql_query("SELECT count(*) FROM vrfs WHERE `device_id` = '".$device['device_id']."' AND `vrf_oid`='".$vrf['oid']."'"),0)) { @@ -31,7 +31,7 @@ $vrf_id = mysql_result(mysql_query("SELECT vrf_id FROM vrfs WHERE `device_id` = '".$device['device_id']."' AND `vrf_oid`='".$vrf['oid']."'"),0); echo("\nRD:".$vrf['mplsVpnVrfRouteDistinguisher']." Id: ($vrf_id) Descr: ".$vrf['mplsVpnVrfDescription']." "); $interfaces_oid = ".1.3.6.1.3.118.1.2.1.1.2." . $vrf['oid']; - $interfaces = shell_exec($config['snmpwalk'] . " -CI -Ln -Osqn -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " $interfaces_oid"); + $interfaces = shell_exec($config['snmpwalk'] . " -m MPLS-VPN-MIB -CI -Ln -Osqn -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " $interfaces_oid"); $interfaces = trim(str_replace($interfaces_oid . ".", "", $interfaces)); # list($interfaces) = explode(" ", $interfaces); echo(" ( "); diff --git a/includes/discovery/interfaces.php b/includes/discovery/interfaces.php index b01d70c889..6ad37c1b96 100755 --- a/includes/discovery/interfaces.php +++ b/includes/discovery/interfaces.php @@ -4,7 +4,8 @@ echo("Interfaces : "); - $cmd = $config['snmpwalk'] . " -O nsq -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " .1.3.6.1.2.1.2.2.1.2"; + $cmd = $config['snmpwalk'] . " -m IF-MIB -O nsq -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port']; + $cmd .= " .1.3.6.1.2.1.2.2.1.2"; $interfaces = trim(shell_exec($cmd)); $interfaces = str_replace("\"", "", $interfaces); $interfaces = str_replace("ifDescr.", "", $interfaces); @@ -19,7 +20,7 @@ list($ifIndex, $ifName) = explode("||", $entry); if($config['ifdescr'][$device['os']]) { - $ifDescr = shell_exec($config['snmpget'] . " -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " ifDescr.$ifIndex"); + $ifDescr = shell_exec($config['snmpget'] . " -m IF-MIB -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " ifDescr.$ifIndex"); $ifDescr = str_replace("No Such Object available on this agent at this OID", "", $ifDescr); $ifDescr = str_replace("No Such Instance currently exists at this OID", "", $ifDescr); $ifDescr = trim(str_replace("\"", "", $ifDescr)); diff --git a/includes/discovery/ipv4-addresses.php b/includes/discovery/ipv4-addresses.php index c6bb9d59da..ec1afa28db 100755 --- a/includes/discovery/ipv4-addresses.php +++ b/includes/discovery/ipv4-addresses.php @@ -2,13 +2,13 @@ echo("IP Addresses : "); - $oids = shell_exec($config['snmpwalk'] . " -".$device['snmpver']." -Osq -c ".$device['community']." ".$device['hostname'].":".$device['port']." ipAdEntIfIndex"); + $oids = shell_exec($config['snmpwalk'] . " -m IP-MIB -".$device['snmpver']." -Osq -c ".$device['community']." ".$device['hostname'].":".$device['port']." ipAdEntIfIndex"); $oids = trim($oids); $oids = str_replace("ipAdEntIfIndex.", "", $oids); foreach(explode("\n", $oids) as $data) { $data = trim($data); list($oid,$ifIndex) = explode(" ", $data); - $mask = shell_exec($config['snmpget']." -O qv -".$device['snmpver']." -c ".$device['community']." ".$device['hostname'].":".$device['port']." ipAdEntNetMask.$oid"); + $mask = shell_exec($config['snmpget']." -m IP-MIB -O qv -".$device['snmpver']." -c ".$device['community']." ".$device['hostname'].":".$device['port']." ipAdEntNetMask.$oid"); $mask = trim($mask); $network = trim(shell_exec ($config['ipcalc'] . " $oid/$mask | grep Network | cut -d\" \" -f 4")); list($net,$cidr) = explode("/", $network); diff --git a/includes/discovery/ipv6-addresses.php b/includes/discovery/ipv6-addresses.php index 1818a59dcc..effb987d6a 100644 --- a/includes/discovery/ipv6-addresses.php +++ b/includes/discovery/ipv6-addresses.php @@ -2,11 +2,13 @@ echo("IPv6 Addresses : "); -$ipv6interfaces = shell_exec($config['snmpget']." -Ovnq -".$device['snmpver']." -c ".$device['community']." ".$device['hostname'].":".$device['port']." ipv6Interfaces.0"); +$ipv6interfaces = shell_exec($config['snmpget']." -m IPV6-MIB -Ovnq -".$device['snmpver']." -c ".$device['community']." ".$device['hostname'].":".$device['port']." ipv6Interfaces.0"); if($ipv6interfaces){ - $oids = trim(trim(shell_exec($config['snmpwalk']." -".$device['snmpver']." -Ln -c ".$device['community']." ".$device['hostname'].":".$device['port']." ipAddressIfIndex.ipv6 -Osq | grep -v No"))); + $cmd = $config['snmpwalk']." -m IP-MIB -".$device['snmpver']." -Ln -c ".$device['community']." ".$device['hostname'].":".$device['port']; + $cmd .= " ipAddressIfIndex.ipv6 -Osq | grep -v No"; + $oids = trim(trim(shell_exec($cmd))); $oids = str_replace("ipAddressIfIndex.ipv6.", "", $oids); $oids = str_replace("\"", "", $oids); $oids = trim($oids); foreach(explode("\n", $oids) as $data) { if($data) { @@ -24,8 +26,8 @@ if($ipv6interfaces){ $do++; if($do == 2) { $adsep = ":"; $do = '0'; } else { $adsep = "";} } - $ipv6_prefixlen = trim(shell_exec($config['snmpget']." -".$device['snmpver']." -c ".$device['community']." ".$device['hostname'].":".$device['port']." .1.3.6.1.2.1.4.34.1.5.2.16.$oid | sed 's/.*\.//'")); - $ipv6_origin = trim(shell_exec($config['snmpget']." -Ovq -".$device['snmpver']." -c ".$device['community']." ".$device['hostname'].":".$device['port']." .1.3.6.1.2.1.4.34.1.6.2.16.$oid")); + $ipv6_prefixlen = trim(shell_exec($config['snmpget']." -m IP-MIB -".$device['snmpver']." -c ".$device['community']." ".$device['hostname'].":".$device['port']." .1.3.6.1.2.1.4.34.1.5.2.16.$oid | sed 's/.*\.//'")); + $ipv6_origin = trim(shell_exec($config['snmpget']." -m IP-MIB -Ovq -".$device['snmpver']." -c ".$device['community']." ".$device['hostname'].":".$device['port']." .1.3.6.1.2.1.4.34.1.6.2.16.$oid")); $ipv6_network = trim(shell_exec($config['sipcalc']." $ipv6_address/$ipv6_prefixlen | grep Subnet | cut -f 2 -d '-'")); $ipv6_compressed = trim(shell_exec($config['sipcalc']." $ipv6_address/$ipv6_prefixlen | grep Compressed | cut -f 2 -d '-'")); diff --git a/includes/discovery/storage.php b/includes/discovery/storage.php index 3979351f1b..49eb5c3ef6 100755 --- a/includes/discovery/storage.php +++ b/includes/discovery/storage.php @@ -4,13 +4,13 @@ echo("Storage : "); - $oids = shell_exec($config['snmpwalk'] . " -Osq -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " hrStorageIndex"); + $oids = shell_exec($config['snmpwalk'] . " -m HOST-RESOURCES-MIB -Osq -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " hrStorageIndex"); $oids = trim(str_replace("hrStorageIndex.","",$oids)); foreach(explode("\n", $oids) as $data) { $data = trim($data); list($oid,$hrStorageIndex) = explode(" ", $data); - $temp = shell_exec($config['snmpget'] . " -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " hrStorageDescr.$oid hrStorageAllocationUnits.$oid hrStorageSize.$oid hrStorageType.$oid"); + $temp = shell_exec($config['snmpget'] . " -m HOST-RESOURCES-MIB -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " hrStorageDescr.$oid hrStorageAllocationUnits.$oid hrStorageSize.$oid hrStorageType.$oid"); $temp = trim($temp); list($descr, $units, $size, $type) = explode("\n", $temp); list($units) = explode(" ", $units); diff --git a/includes/discovery/temperatures.php b/includes/discovery/temperatures.php index eb19ca337b..0e7177be93 100755 --- a/includes/discovery/temperatures.php +++ b/includes/discovery/temperatures.php @@ -10,7 +10,7 @@ ## JunOS Temperatures if($device['os'] == "JunOS") { echo("JunOS "); - $oids = shell_exec($config['snmpwalk'] . " -v2c -CI -Osqn -c $community $hostname:$port 1.3.6.1.4.1.2636.3.1.13.1.7"); + $oids = shell_exec($config['snmpwalk'] . " -m JUNIPER-MIB -$snmpver -CI -Osqn -c $community $hostname:$port 1.3.6.1.4.1.2636.3.1.13.1.7"); $oids = trim($oids); foreach(explode("\n", $oids) as $data) { $data = trim($data); @@ -19,10 +19,10 @@ list($oid) = explode(" ", $data); $temp_oid = "1.3.6.1.4.1.2636.3.1.13.1.7.$oid"; $descr_oid = "1.3.6.1.4.1.2636.3.1.13.1.5.$oid"; - $descr = trim(shell_exec("snmpget -O qv -v2c -c $community $hostname:$port $descr_oid")); - $temp = trim(shell_exec("snmpget -O qv -v2c -c $community $hostname:$port $temp_oid")); + $descr = trim(shell_exec($config['snmpget'] . " -m JUNIPER-MIB -O qv -$snmpver -c $community $hostname:$port $descr_oid")); + $temp = trim(shell_exec($config['snmpget'] . " -m JUNIPER-MIB -O qv -$snmpver -c $community $hostname:$port $temp_oid")); if(!strstr($descr, "No") && !strstr($temp, "No") && $descr != "" && $temp != "0") { - $descr = `snmpget -O qv -v2c -c $community $hostname:$port $descr_oid`; + $descr = shell_exec($config['snmpget'] . " -m JUNIPER-MIB -O qv -$snmpver -c $community $hostname:$port $descr_oid"); $descr = str_replace("\"", "", $descr); $descr = str_replace("temperature", "", $descr); $descr = str_replace("temp", "", $descr); @@ -41,12 +41,13 @@ ## Begin Observer-Style if($device['os'] == "Linux") { echo("Observer-Style "); - $oids = `snmpwalk -$snmpver -Osqn -CI -c $community $hostname:$port .1.3.6.1.4.1.2021.7891 | sed s/.1.3.6.1.4.1.2021.7891.// | grep ".1.1 " | grep -v ".101." | cut -d"." -f 1`; + $oids = shell_exec($config['snmpwalk'] . " -$snmpver -m SNMPv2-SMI -Osqn -CI -c $community $hostname:$port .1.3.6.1.4.1.2021.7891 | sed s/.1.3.6.1.4.1.2021.7891.// | grep '.1.1 ' | grep -v '.101.' | cut -d'.' -f 1"); $oids = trim($oids); foreach(explode("\n",$oids) as $oid) { $oid = trim($oid); if($oid != "") { - $descr = trim(str_replace("\"", "", `snmpget -v2c -Osqn -c $community $hostname:$port .1.3.6.1.4.1.2021.7891.$oid.2.1 | sed s/.1.3.6.1.4.1.2021.7891.$oid.2.1\ //`)); + $descr_query = $config['snmpget'] . " -$snmpver -m SNMPv2-SMI -Osqn -c $community $hostname:$port .1.3.6.1.4.1.2021.7891.$oid.2.1 | sed s/.1.3.6.1.4.1.2021.7891.$oid.2.1\ //"; + $descr = trim(str_replace("\"", "", shell_exec($descr_query))); $fulloid = ".1.3.6.1.4.1.2021.7891.$oid.101.1"; if(!mysql_result(mysql_query("SELECT count(temp_id) FROM temperature WHERE `temp_host` = '$id' AND `temp_oid` = '$fulloid'"), 0)) { echo("+"); @@ -65,19 +66,21 @@ ## Dell Temperatures if(strstr($device['hardware'], "Dell")) { echo("Dell OMSA "); - $oids = shell_exec($config['snmpwalk'] . " -v2c -CI -Osqn -c $community $hostname:$port .1.3.6.1.4.1.674.10892.1.700.20.1.8"); + $oids = shell_exec($config['snmpwalk'] . " -m MIB-Dell-10892 -$snmpver -CI -Osqn -c $community $hostname:$port .1.3.6.1.4.1.674.10892.1.700.20.1.8"); $oids = trim($oids); foreach(explode("\n",$oids) as $oid) { $oid = substr(trim($oid), 36); list($oid) = explode(" ", $oid); if($oid != "") { - $descr = trim(str_replace("\"", "", `snmpget -v2c -Onvq -c $community $hostname:$port .1.3.6.1.4.1.674.10892.1.700.20.1.8.$oid`)); + $descr_query = $config['snmpget'] . " -m MIB-Dell-10892 -$snmpver -Onvq -c $community $hostname:$port .1.3.6.1.4.1.674.10892.1.700.20.1.8.$oid"; + $descr = trim(str_replace("\"", "", shell_exec($descr_query))); $fulloid = ".1.3.6.1.4.1.674.10892.1.700.20.1.6.$oid"; if(!mysql_result(mysql_query("SELECT count(temp_id) FROM temperature WHERE `temp_host` = '$id' AND `temp_oid` = '$fulloid'"), 0)) { mysql_query("INSERT INTO `temperature` (`temp_host`,`temp_oid`,`temp_descr`, `temp_tenths`) VALUES ('$id', '$fulloid', '$descr', '1');"); echo("+"); } elseif (mysql_result(mysql_query("SELECT `temp_descr` FROM temperature WHERE `temp_host` = '$id' AND `temp_oid` = '$fulloid'"), 0) != $descr) { mysql_query("UPDATE temperature SET `temp_descr` = '$descr' WHERE `temp_host` = '$id' AND `temp_oid` = '$fulloid'"); + echo("UPDATE temperature SET `temp_descr` = '$descr' WHERE `temp_host` = '$id' AND `temp_oid` = '$fulloid'"); echo("U"); } else { echo("."); @@ -91,7 +94,7 @@ ## Cisco Temperatures if($device['os'] == "IOS" || $device['os'] == "IOS XE") { echo("Cisco "); - $oids = shell_exec($config['snmpwalk'] . " -v2c -CI -Osqn -c $community $hostname:$port .1.3.6.1.4.1.9.9.13.1.3.1.2 | sed s/.1.3.6.1.4.1.9.9.13.1.3.1.2.//g"); + $oids = shell_exec($config['snmpwalk'] . " -m CISCO-ENVMON-MIB -$snmpver -CI -Osqn -c $community $hostname:$port .1.3.6.1.4.1.9.9.13.1.3.1.2 | sed s/.1.3.6.1.4.1.9.9.13.1.3.1.2.//g"); $oids = trim($oids); foreach(explode("\n", $oids) as $data) { $data = trim($data); @@ -99,10 +102,10 @@ list($oid) = explode(" ", $data); $temp_oid = ".1.3.6.1.4.1.9.9.13.1.3.1.3.$oid"; $descr_oid = ".1.3.6.1.4.1.9.9.13.1.3.1.2.$oid"; - $descr = `snmpget -O qv -v2c -c $community $hostname:$port $descr_oid`; - $temp = `snmpget -O qv -v2c -c $community $hostname:$port $temp_oid`; + $descr = shell_exec($config['snmpget'] . " -m CISCO-ENVMON-MIB -O qv -$snmpver -c $community $hostname:$port $descr_oid"); + $temp = shell_exec($config['snmpget'] . " -m CISCO-ENVMON-MIB -O qv -$snmpver -c $community $hostname:$port $temp_oid"); if(!strstr($descr, "No") && !strstr($temp, "No") && $descr != "" ) { - $descr = `snmpget -O qv -v2c -c $community $hostname:$port $descr_oid`; + $descr = shell_exec($config['snmpget'] . " -m CISCO-ENVMON-MIB -O qv -$snmpver -c $community $hostname:$port $descr_oid"); $descr = str_replace("\"", "", $descr); $descr = str_replace("temperature", "", $descr); $descr = str_replace("temp", "", $descr); diff --git a/includes/functions.php b/includes/functions.php index 02b9bfbdcf..6a4b4636c3 100755 --- a/includes/functions.php +++ b/includes/functions.php @@ -69,7 +69,7 @@ function getHostOS($hostname, $community, $snmpver, $port) { global $config; - $sysDescr_cmd = $config['snmpget']." -O qv -" . $snmpver . " -c " . $community . " " . $hostname.":".$port . " sysDescr.0"; + $sysDescr_cmd = $config['snmpget']." -m SNMPv2-MIB -O qv -" . $snmpver . " -c " . $community . " " . $hostname.":".$port . " sysDescr.0"; $sysDescr = str_replace("\"", "", trim(shell_exec($sysDescr_cmd))); $dir_handle = @opendir($config['install_dir'] . "/includes/osdiscovery") or die("Unable to open $path"); while ($file = readdir($dir_handle)) { @@ -374,7 +374,7 @@ function addHost($host, $community, $snmpver, $port = 161) if ( isDomainResolves($host)){ if ( isPingable($host)) { if ( mysql_result(mysql_query("SELECT COUNT(*) FROM `devices` WHERE `hostname` = '$host'"), 0) == '0' ) { - $snmphost = shell_exec($config['snmpget'] ." -Oqv -$snmpver -c $community $host:$port sysName.0"); + $snmphost = shell_exec($config['snmpget'] ." -m SNMPv2-MIB -Oqv -$snmpver -c $community $host:$port sysName.0"); if ($snmphost == $host || $hostshort = $host) { createHost ($host, $community, $snmpver, $port); } else { echo("Given hostname does not match SNMP-read hostname!\n"); } @@ -465,11 +465,9 @@ function formatUptime($diff, $format="long") function isSNMPable($hostname, $community, $snmpver, $port) { global $config; - $pos = shell_exec($config['snmpget'] ." -$snmpver -c $community -t 1 $hostname:$port sysDescr.0"); + $pos = shell_exec($config['snmpget'] ." -m SNMPv2-MIB -$snmpver -c $community -t 1 $hostname:$port sysDescr.0"); if($pos == '') { $status='0'; - $posb = shell_exec($config['snmpget'] ." -$snmpver -c $community -t 1 $hostname:$port 1.3.6.1.2.1.7526.2.4"); - if($posb == '') { } else { $status='1'; } } else { $status='1'; } diff --git a/includes/polling/device-fortigate.inc.php b/includes/polling/device-fortigate.inc.php index aa63c765fd..a74b442f07 100755 --- a/includes/polling/device-fortigate.inc.php +++ b/includes/polling/device-fortigate.inc.php @@ -2,8 +2,8 @@ echo("Fortinet Fortigate Poller\n"); -$fnSysVersion = shell_exec($config['snmpget']." -".$device['snmpver']." -Ovq -c ".$device['community']." ".$device['hostname'].":".$device['port']." fnSysVersion.0"); -$serial = shell_exec($config['snmpget']." -".$device['snmpver']." -Ovq -c ".$device['community']." ".$device['hostname'].":".$device['port']." fnSysSerial.0"); +$fnSysVersion = shell_exec($config['snmpget']." -m FORTINET-MIB-280 -".$device['snmpver']." -Ovq -c ".$device['community']." ".$device['hostname'].":".$device['port']." fnSysVersion.0"); +$serial = shell_exec($config['snmpget']." -m FORTINET-MIB-280 -".$device['snmpver']." -Ovq -c ".$device['community']." ".$device['hostname'].":".$device['port']." fnSysSerial.0"); $version = preg_replace("/(.+)\ (.+),(.+),(.+)/", "Fortinet \\1||\\2||\\3||\\4", $fnSysVersion); list($hardware,$version,$features) = explode("||", $version); @@ -12,7 +12,7 @@ $cpurrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/fortigate-cpu.rrd $memrrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/fortigate-memory.rrd"; $sessrrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/fortigate-sessions.rrd"; -$cmd = $config['snmpget'] . " -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname']; +$cmd = $config['snmpget'] . " -m FORTINET-MIB-280 -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname']; $cmd .= " fnSysCpuUsage.0 fnSysMemUsage.0 fnSysSesCount.0 fnSysMemCapacity.0"; $data = shell_exec($cmd); list ($cpu, $mem, $ses, $memsize) = explode("\n", $data); diff --git a/includes/polling/device-ios.inc.php b/includes/polling/device-ios.inc.php index a8c79f36a6..8048cfd076 100755 --- a/includes/polling/device-ios.inc.php +++ b/includes/polling/device-ios.inc.php @@ -4,6 +4,7 @@ $id = $device['device_id']; $hostname = $device['hostname']; $port = $device['port']; + $snmpver = $device['snmpver']; $temprrd = $config['rrd_dir'] . "/" . $hostname . "/temp.rrd"; $cpurrd = $config['rrd_dir'] . "/" . $hostname . "/cpu.rrd"; @@ -39,25 +40,12 @@ } - list ($cpu5m, $cpu5s) = explode("\n", `snmpget -O qv -v2c -c $community $hostname:$port 1.3.6.1.4.1.9.2.1.58.0 1.3.6.1.4.1.9.2.1.56.0`); + list ($cpu5m, $cpu5s) = explode("\n", shell_exec($config['snmpget'] . " -m OLD-CISCO-CPU-MIB -O qv -$snmpver -c $community $hostname:$port 1.3.6.1.4.1.9.2.1.58.0 1.3.6.1.4.1.9.2.1.56.0")); $cpu5m = $cpu5m + 0; $cpu5s = $cpu5s + 0; - list ($tempin1, $tempout1) = explode("\n", `snmpget -O qv -v2c -c $community $hostname:$port .1.3.6.1.4.1.9.9.13.1.3.1.3.1 .1.3.6.1.4.1.9.9.13.1.3.1.3.2`); - $tempin1 = $tempin1 +0; - $tempout1 = $tempout1 + 0; - $mem_get = ".1.3.6.1.4.1.9.9.48.1.1.1.6.2 .1.3.6.1.4.1.9.9.48.1.1.1.6.1 .1.3.6.1.4.1.9.9.48.1.1.1.6.3"; - $mem_get .= ".1.3.6.1.4.1.9.9.48.1.1.1.5.2 .1.3.6.1.4.1.9.9.48.1.1.1.5.1 .1.3.6.1.4.1.9.9.48.1.1.1.5.3"; - $mem_raw = `snmpget -O qv -v2c -c $community $hostname:$port $mem_get`; - $mem_raw = str_replace("No Such Instance currently exists at this OID", "0", $mem_raw); - list ($memfreeio, $memfreeproc, $memfreeprocb, $memusedio, $memusedproc, $memusedprocb) = explode("\n", $mem_raw); + echo("$hostname\n"); - $memfreeproc = $memfreeproc + $memfreeprocb; - $memusedproc = $memusedproc + $memusedprocb; - $memfreeio = $memfreeio + 0; - $memfreeproc = $memfreeproc + 0; - $memusedio = $memusedio + 0; - $memusedproc = $memusedproc + 0; - $memtotal = $memfreeio + $memfreeproc + $memusedio + $memusedproc; + if (!is_file($cpurrd)) { $rrdcreate = `rrdtool create $cpurrd --step 300 \ DS:LOAD5S:GAUGE:600:-1:100 \ @@ -71,39 +59,8 @@ RRA:MAX:0.5:24:2000 \ RRA:MAX:0.5:288:2000`; } - if (!is_file($temprrd)) { - $rrdcreate = `rrdtool create $temprrd --step 300 \ - DS:TEMPIN1:GAUGE:600:-25:100 \ - DS:TEMPOUT1:GAUGE:600:-25:100 \ - RRA:AVERAGE:0.5:1:2000 \ - RRA:AVERAGE:0.5:6:2000 \ - RRA:AVERAGE:0.5:24:2000 \ - RRA:AVERAGE:0.5:288:2000 \ - RRA:MAX:0.5:1:2000 \ - RRA:MAX:0.5:6:2000 \ - RRA:MAX:0.5:24:2000 \ - RRA:MAX:0.5:288:2000`; - } - if (!is_file($memrrd)) { - $rrdcreate = `rrdtool create $memrrd --step 300 \ - DS:IOFREE:GAUGE:600:0:U \ - DS:IOUSED:GAUGE:600:-1:U \ - DS:PROCFREE:GAUGE:600:0:U \ - DS:PROCUSED:GAUGE:600:-1:U \ - DS:MEMTOTAL:GAUGE:600:-1:U \ - RRA:AVERAGE:0.5:1:2000 \ - RRA:AVERAGE:0.5:6:2000 \ - RRA:AVERAGE:0.5:24:2000 \ - RRA:AVERAGE:0.5:288:2000 \ - RRA:MAX:0.5:1:2000 \ - RRA:MAX:0.5:6:2000 \ - RRA:MAX:0.5:24:2000 \ - RRA:MAX:0.5:288:2000`; - } - `rrdtool update $temprrd N:$tempin1:$tempout1`; `rrdtool update $cpurrd N:$cpu5s:$cpu5m`; - `rrdtool update $memrrd N:$memfreeio:$memusedio:$memfreeproc:$memusedproc:$memtotal`; include("includes/polling/bgpPeer.inc.php"); include("includes/polling/cisco-processors.inc.php"); diff --git a/includes/polling/device-junos.inc.php b/includes/polling/device-junos.inc.php index e0621103a5..725cda6673 100644 --- a/includes/polling/device-junos.inc.php +++ b/includes/polling/device-junos.inc.php @@ -2,9 +2,9 @@ echo("Doing Juniper JunOS"); -$jun_ver = trim(str_replace("\"", "", shell_exec($config['snmpget'] . " -".$device['snmpver']." -Oqv -c ".$device['community']." ".$device['hostname']." .1.3.6.1.2.1.25.6.3.1.2.2"))); -$hardware = trim(str_replace("\"", "", shell_exec($config['snmpget'] . " -".$device['snmpver']." -Oqv -c ".$device['community']." ".$device['hostname']." .1.3.6.1.4.1.2636.3.1.2.0"))); -$serial = trim(str_replace("\"", "", shell_exec($config['snmpget'] . " -".$device['snmpver']." -Oqv -c ".$device['community']." ".$device['hostname']." .1.3.6.1.4.1.2636.3.1.3.0"))); +$jun_ver = trim(str_replace("\"", "", shell_exec($config['snmpget'] . " -m HOST-RESOURCES-MIB -".$device['snmpver']." -Oqv -c ".$device['community']." ".$device['hostname']." .1.3.6.1.2.1.25.6.3.1.2.2"))); +$hardware = trim(str_replace("\"", "", shell_exec($config['snmpget'] . " -m JUNIPER-MIB -".$device['snmpver']." -Oqv -c ".$device['community']." ".$device['hostname']." .1.3.6.1.4.1.2636.3.1.2.0"))); +$serial = trim(str_replace("\"", "", shell_exec($config['snmpget'] . " -m JUNIPER-MIB -".$device['snmpver']." -Oqv -c ".$device['community']." ".$device['hostname']." .1.3.6.1.4.1.2636.3.1.3.0"))); $version = preg_replace("/.+\[(.+)\].+/", "\\1", $jun_ver); $features = preg_replace("/.+\ \((.+)\)$/", "\\1", $jun_ver); @@ -13,7 +13,7 @@ echo("$hardware - $version - $features - $serial\n"); $cpurrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/junos-cpu.rrd"; -$cpu_cmd = $config['snmpget'] . " -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname']; +$cpu_cmd = $config['snmpget'] . " -m JUNIPER-MIB -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname']; $cpu_cmd .= " .1.3.6.1.4.1.2636.3.1.13.1.8.9.1.0.0"; $cpu_usage = trim(shell_exec($cpu_cmd)); diff --git a/includes/polling/device-unix.inc.php b/includes/polling/device-unix.inc.php index 21f3319a79..b1121cd014 100755 --- a/includes/polling/device-unix.inc.php +++ b/includes/polling/device-unix.inc.php @@ -30,12 +30,12 @@ $sysrrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/sys.rrd"; list(,,$version) = explode (" ", $sysDescr); if(strstr($sysDescr, "386")|| strstr($sysDescr, "486")||strstr($sysDescr, "586")||strstr($sysDescr, "686")) { $hardware = "Generic x86"; } if(strstr($sysDescr, "x86_64")) { $hardware = "Generic x86 64-bit"; } - $cmd = "snmpget -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port']. " .1.3.6.1.4.1.2021.7890.1.3.1.1.6.100.105.115.116.114.111"; + $cmd = $config['snmpget'] . " -m UCD-SNMP-MIB -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port']. " .1.3.6.1.4.1.2021.7890.1.3.1.1.6.100.105.115.116.114.111"; $features = trim(`$cmd`); $features = str_replace("No Such Object available on this agent at this OID", "", $features); $features = str_replace("\"", "", $features); // Detect Dell hardware via OpenManage SNMP - $cmd = "snmpget -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " .1.3.6.1.4.1.674.10892.1.300.10.1.9.1"; + $cmd = $config['snmpget'] . " -m MIB-Dell-10892 -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " .1.3.6.1.4.1.674.10892.1.300.10.1.9.1"; $hw = trim(str_replace("\"", "", `$cmd`)); if(strstr($hw, "No")) { unset($hw); } else { $hardware = "Dell " . $hw; } } diff --git a/includes/polling/interfaces.inc.php b/includes/polling/interfaces.inc.php index 7b230ac61a..57010bc454 100644 --- a/includes/polling/interfaces.inc.php +++ b/includes/polling/interfaces.inc.php @@ -93,7 +93,6 @@ while ($interface = mysql_fetch_array($interface_query)) { if($ifOperStatus == "up") { -# $snmp_data_cmd = "snmpget -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port']; $snmp_data_cmd = "snmpget -m IF-MIB -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port']; $snmp_data_cmd .= " ifHCInOctets." . $interface['ifIndex'] . " ifHCOutOctets." . $interface['ifIndex'] . " ifInErrors." . $interface['ifIndex']; $snmp_data_cmd .= " ifOutErrors." . $interface['ifIndex'] . " ifInUcastPkts." . $interface['ifIndex'] . " ifOutUcastPkts." . $interface['ifIndex']; @@ -106,7 +105,7 @@ while ($interface = mysql_fetch_array($interface_query)) { list($ifHCInOctets, $ifHCOutOctets, $ifInErrors, $ifOutErrors, $ifInUcastPkts, $ifOutUcastPkts, $ifInNUcastPkts, $ifOutNUcastPkts) = explode("\n", $snmp_data); if($ifHCInOctets == "" || strpos($ifHCInOctets, "No") !== FALSE ) { - $octets_cmd = "snmpget -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port']; + $octets_cmd = "snmpget -m IF-MIB -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port']; $octets_cmd .= " ifInOctets." . $interface['ifIndex'] . " ifOutOctets." . $interface['ifIndex']; $octets = `$octets_cmd`; list ($ifHCInOctets, $ifHCOutOctets) = explode("\n", $octets); diff --git a/includes/polling/temperatures.inc.php b/includes/polling/temperatures.inc.php index 23a3dcb4dc..d04cd0c6f5 100755 --- a/includes/polling/temperatures.inc.php +++ b/includes/polling/temperatures.inc.php @@ -4,8 +4,8 @@ $query = "SELECT * FROM temperature WHERE temp_host = '" . $device['device_id'] $temp_data = mysql_query($query); while($temperature = mysql_fetch_array($temp_data)) { - $temp_cmd = "snmpget -O Uqnv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " " . $temperature['temp_oid']; - $temp = `$temp_cmd`; + $temp_cmd = $config['snmpget'] . " -m SNMPv2-MIB-O Uqnv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " " . $temperature['temp_oid']; + $temp = shell_exec($temp_cmd); echo("Checking temp " . $temperature['temp_descr'] . "... "); @@ -30,7 +30,7 @@ while($temperature = mysql_fetch_array($temp_data)) { $updatecmd = "rrdtool update $temprrd N:$temp"; - `$updatecmd`; + shell_exec($updatecmd); if($temperature['temp_current'] < $temperature['temp_limit'] && $temp >= $temperature['temp_limit']) { $updated = ", `service_changed` = '" . time() . "' "; diff --git a/test-discovery.php b/test-discovery.php index a29f7d8b77..c5a97de7e5 100755 --- a/test-discovery.php +++ b/test-discovery.php @@ -45,12 +45,6 @@ while ($device = mysql_fetch_array($device_query)) { echo("\n" . $device['hostname'] ."\n"); include("includes/discovery/".$type.".php"); -# include("includes/discovery/ipv6-addresses.php"); -# include("includes/discovery/cisco-pw.php"); - -# include("includes/discovery/host-physical.php"); - -# include("includes/discovery/bgp-peers.php"); echo("\n"); $devices_polled++; }