per-port SNMP polling. thanks to jonathan@studenteninternet.be

git-svn-id: http://www.observium.org/svn/observer/trunk@340 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Adam Amstrong
2009-02-02 16:00:11 +00:00
parent da6dd950b1
commit 96bb007d4b
35 changed files with 129 additions and 112 deletions
+10 -3
View File
@@ -8,18 +8,25 @@ if($argv[1] && $argv[2] && $argv[3]) {
$host = strtolower($argv[1]); $host = strtolower($argv[1]);
$community = $argv[2]; $community = $argv[2];
$snmpver = strtolower($argv[3]); $snmpver = strtolower($argv[3]);
if (is_numeric($argv[4]))
$port = $argv[4];
else
$port = 161;
list($hostshort) = explode(".", $host); list($hostshort) = explode(".", $host);
if ( isDomainResolves($argv[1])){ if ( isDomainResolves($argv[1])){
if ( isPingable($argv[1])) { if ( isPingable($argv[1])) {
if ( mysql_result(mysql_query("SELECT COUNT(*) FROM `devices` WHERE `hostname` = '".mres($host)."'"), 0) == '0' ) { if ( mysql_result(mysql_query("SELECT COUNT(*) FROM `devices` WHERE `hostname` = '".mres($host)."'"), 0) == '0' ) {
$snmphost = trim(`snmpget -Oqv -$snmpver -c $community $host sysName.0 | sed s/\"//g`); $snmphost = trim(`snmpget -Oqv -$snmpver -c $community $host:$port sysName.0 | sed s/\"//g`);
var_dump($snmphost);
if ($snmphost == $host || $hostshort = $host) { if ($snmphost == $host || $hostshort = $host) {
$return = createHost ($host, $community, $snmpver); $return = createHost ($host, $community, $snmpver, $port);
var_dump($return);
if($return) { echo($return . "\n"); } else { echo("Adding $host failed\n"); } if($return) { echo($return . "\n"); } else { echo("Adding $host failed\n"); }
} else { echo("Given hostname does not match SNMP-read hostname!\n"); } } else { echo("Given hostname does not match SNMP-read hostname!\n"); }
} else { echo("Already got host $host\n"); } } else { echo("Already got host $host\n"); }
} else { echo("Could not ping $host\n"); } } else { echo("Could not ping $host\n"); }
} else { echo("Could not resolve $host\n"); } } else { echo("Could not resolve $host\n"); }
} else { echo("Add Host Tool\nUsage: ./addhost.php <hostname> <community> <snmpversion>\n"); } } else { echo("Add Host Tool\nUsage: ./addhost.php <hostname> <community> <snmpversion> <port>\n"); }
?> ?>
+6 -5
View File
@@ -13,8 +13,8 @@ $data = mysql_query($query);
while($row = mysql_fetch_array($data)) { while($row = mysql_fetch_array($data)) {
$mask = trim(shell_exec($config['ipcalc'] . " ".$row['addr']."/".$row['cidr']." | grep Netmask: | cut -d \" \" -f 4")); $mask = trim(shell_exec($config['ipcalc'] . " ".$row['addr']."/".$row['cidr']." | grep Netmask: | cut -d \" \" -f 4"));
$response = trim(`snmpget -v2c -Osq -c $row[community] $row[hostname] ipAdEntIfIndex.$row[addr] | cut -d " " -f 2`); $response = trim(`snmpget -v2c -Osq -c $row[community] $row[hostname]:$row[port] ipAdEntIfIndex.$row[addr] | cut -d " " -f 2`);
$maskcheck = trim(`snmpget -v2c -Osq -c $row[community] $row[hostname] ipAdEntNetMask.$row[addr] | cut -d " " -f 2`); $maskcheck = trim(`snmpget -v2c -Osq -c $row[community] $row[hostname]:$row[port] ipAdEntNetMask.$row[addr] | cut -d " " -f 2`);
if($response == $row['ifIndex'] && $mask == $maskcheck) { if($response == $row['ifIndex'] && $mask == $maskcheck) {
} else { } else {
mysql_query("delete from ipaddr where id = '$row[id]'"); mysql_query("delete from ipaddr where id = '$row[id]'");
@@ -26,7 +26,7 @@ $sql = "SELECT * FROM devices WHERE status = '1'";
$query = mysql_query($sql); $query = mysql_query($sql);
while($device = mysql_fetch_array($query)) { while($device = mysql_fetch_array($query)) {
echo($device['hostname'] . " \n\n"); echo($device['hostname'] . " \n\n");
$oids = shell_exec("snmpwalk -v2c -c ".$device['community']." ".$device['hostname']." ipAddressIfIndex.ipv6 -Osq"); $oids = shell_exec("snmpwalk -v2c -c ".$device['community']." ".$device['hostname'].":".$device['port']." ipAddressIfIndex.ipv6 -Osq");
$oids = str_replace("ipAddressIfIndex.ipv6.", "", $oids); $oids = str_replace("\"", "", $oids); $oids = trim($oids); $oids = str_replace("ipAddressIfIndex.ipv6.", "", $oids); $oids = str_replace("\"", "", $oids); $oids = trim($oids);
unset($valid_ips); unset($valid_ips);
foreach(explode("\n", $oids) as $data) { foreach(explode("\n", $oids) as $data) {
@@ -52,8 +52,9 @@ $data = mysql_query($query);
while($row = mysql_fetch_array($data)) { while($row = mysql_fetch_array($data)) {
$index = $row[ifIndex]; $index = $row[ifIndex];
$hostname = $row['hostname']; $hostname = $row['hostname'];
$community = $row['community']; $community = $row['community'];
$response = trim(`snmpget -v2c -Osq -c $community $hostname ifIndex.$index | cut -d " " -f 2`); $port = $row['port'];
$response = trim(`snmpget -v2c -Osq -c $community $hostname:$port ifIndex.$index | cut -d " " -f 2`);
if($response != $index) { if($response != $index) {
mysql_query("DELETE from interfaces where interface_id = '" . $row['interface_id'] . "'"); mysql_query("DELETE from interfaces where interface_id = '" . $row['interface_id'] . "'");
mysql_query("DELETE from `adjacencies` WHERE `interface_id` = '" . $row['interface_id'] . "'"); mysql_query("DELETE from `adjacencies` WHERE `interface_id` = '" . $row['interface_id'] . "'");
+4 -4
View File
@@ -66,15 +66,15 @@ function getDates($dayofmonth) {
} }
function getValue($host, $community, $id, $inout) { function getValue($host, $community, $port, $id, $inout) {
$oid = "IF-MIB::ifHC" . $inout . "Octets." . $id; $oid = "IF-MIB::ifHC" . $inout . "Octets." . $id;
$value = `snmpget -c $community -v2c -O qv $host $oid`; $value = `snmpget -c $community -v2c -O qv $host:$port $oid`;
return $value; return $value;
} }
function getIfName($host, $id) { function getIfName($host, $port, $id) {
$oid = "IF-MIB::ifDescr." . $id; $oid = "IF-MIB::ifDescr." . $id;
$value = `snmpget -c xyyz -v2c -O qv $host $oid`; $value = `snmpget -c xyyz -v2c -O qv $host:$port $oid`;
return $value; return $value;
} }
+2 -2
View File
@@ -4,7 +4,7 @@
echo("BGP Sessions : "); echo("BGP Sessions : ");
$as_cmd = $config['snmpwalk'] . " -CI -Oqvn -" . $device['snmpver'] . " -c" . $device['community'] . " " . $device['hostname'] . " "; $as_cmd = $config['snmpwalk'] . " -CI -Oqvn -" . $device['snmpver'] . " -c" . $device['community'] . " " . $device['hostname'].":".$device['port'] . " ";
$as_cmd .= ".1.3.6.1.2.1.15.2"; $as_cmd .= ".1.3.6.1.2.1.15.2";
$bgpLocalAs = trim(shell_exec($as_cmd)); $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"); } 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'] . " "; $peers_cmd = $config['snmpwalk'] . " -CI -Oq -" . $device['snmpver'] . " -c" . $device['community'] . " " . $device['hostname'].":".$device['port'] . " ";
$peers_cmd .= "BGP4-MIB::bgpPeerRemoteAs"; $peers_cmd .= "BGP4-MIB::bgpPeerRemoteAs";
$peers = trim(str_replace("BGP4-MIB::bgpPeerRemoteAs.", "", `$peers_cmd`)); $peers = trim(str_replace("BGP4-MIB::bgpPeerRemoteAs.", "", `$peers_cmd`));
foreach (explode("\n", $peers) as $peer) { foreach (explode("\n", $peers) as $peer) {
+2 -2
View File
@@ -4,7 +4,7 @@
if($config['enable_inventory']) { if($config['enable_inventory']) {
$ents_cmd = "snmpwalk -O qn -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'] . " "; $ents_cmd = "snmpwalk -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_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`); $ents = trim(`$ents_cmd | grep -v o`);
@@ -12,7 +12,7 @@
foreach(explode("\n", $ents) as $entPhysicalIndex) { foreach(explode("\n", $ents) as $entPhysicalIndex) {
$ent_data = "snmpget -Ovqs -"; $ent_data = "snmpget -Ovqs -";
$ent_data .= $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname']; $ent_data .= $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'] .":".$device['port'];
$ent_data .= " entPhysicalDescr." . $entPhysicalIndex; $ent_data .= " entPhysicalDescr." . $entPhysicalIndex;
$ent_data .= " entPhysicalContainedIn." . $entPhysicalIndex; $ent_data .= " entPhysicalContainedIn." . $entPhysicalIndex;
$ent_data .= " entPhysicalClass." . $entPhysicalIndex; $ent_data .= " entPhysicalClass." . $entPhysicalIndex;
+3 -3
View File
@@ -5,7 +5,7 @@
echo("PW : "); echo("PW : ");
$oids = shell_exec($config['snmpwalk'] . " -CI -Ln -Osqn -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'] . " cpwVcID"); $oids = shell_exec($config['snmpwalk'] . " -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); $oids = str_replace(".1.3.6.1.4.1.9.10.106.1.2.1.10.", "", $oids);
@@ -14,8 +14,8 @@
if($oid) { if($oid) {
list($cpwOid, $cpwVcID) = explode(" ", $oid); list($cpwOid, $cpwVcID) = explode(" ", $oid);
if($cpwOid) { if($cpwOid) {
list($cpw_remote_id) = split(":", shell_exec($config['snmpget'] . " -Ln -Osqnv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'] . " cpwVcMplsPeerLdpID." . $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'] . " cpwVcName." . $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); $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);
$if_id = @mysql_result(mysql_query("SELECT `interface_id` FROM `interfaces` WHERE `ifDescr` = '$interface_descr' AND `device_id` = '".$device['device_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) { if($cpw_remote_device && $if_id) {
+4 -4
View File
@@ -2,24 +2,24 @@
echo("Cisco VLANs : "); echo("Cisco VLANs : ");
$vtpversion_cmd = $config['snmpget'] . " -Oqv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'] . " .1.3.6.1.4.1.9.9.46.1.1.1.0"; $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 = trim(`$vtpversion_cmd 2>/dev/null`); $vtpversion = trim(`$vtpversion_cmd 2>/dev/null`);
if($vtpversion == '1' || $vtpversion == '2') { if($vtpversion == '1' || $vtpversion == '2') {
$vtp_domain_cmd = "snmpget -Oqv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'] . " .1.3.6.1.4.1.9.9.46.1.2.1.1.2.1"; $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 = trim(str_replace("\"", "", `$vtp_domain_cmd 2>/dev/null`)); $vtp_domain = trim(str_replace("\"", "", `$vtp_domain_cmd 2>/dev/null`));
echo("VTP v$vtpversion $vtp_domain "); echo("VTP v$vtpversion $vtp_domain ");
$vlans_cmd = "snmpwalk -O qn -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'] . " "; $vlans_cmd = "snmpwalk -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_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`); $vlans = trim(`$vlans_cmd | grep -v o`);
foreach(explode("\n", $vlans) as $vlan) { foreach(explode("\n", $vlans) as $vlan) {
$vlan_descr_cmd = "snmpget -O nvq -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'] . " "; $vlan_descr_cmd = "snmpget -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_cmd .= ".1.3.6.1.4.1.9.9.46.1.3.1.1.4.1." . $vlan;
$vlan_descr = `$vlan_descr_cmd`; $vlan_descr = `$vlan_descr_cmd`;
+4 -4
View File
@@ -4,7 +4,7 @@
echo("VRF : "); echo("VRF : ");
$oids = shell_exec($config['snmpwalk'] . " -CI -Ln -Osqn -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'] . " mplsVpnVrfRouteDistinguisher"); $oids = shell_exec($config['snmpwalk'] . " -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(".1.3.6.1.3.118.1.2.2.1.3.", "", $oids);
$oids = str_replace(" \"", "||", $oids); $oids = str_replace(" \"", "||", $oids);
@@ -14,9 +14,9 @@
foreach ( explode("\n", $oids) as $oid ) { foreach ( explode("\n", $oids) as $oid ) {
if($oid) { if($oid) {
list($vrf['oid'], $vrf['mplsVpnVrfRouteDistinguisher']) = explode("||", $oid); list($vrf['oid'], $vrf['mplsVpnVrfRouteDistinguisher']) = explode("||", $oid);
$vrf['name'] = shell_exec($config['snmpget'] . " -Ln -Osq -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'] . " mplsVpnVrfRouteDistinguisher.".$vrf['oid']); $vrf['name'] = shell_exec($config['snmpget'] . " -Ln -Osq -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " mplsVpnVrfRouteDistinguisher.".$vrf['oid']);
list(,$vrf['name'],, $vrf['mplsVpnVrfRouteDistinguisher']) = explode("\"", $vrf['name']); list(,$vrf['name'],, $vrf['mplsVpnVrfRouteDistinguisher']) = explode("\"", $vrf['name']);
$vrf['mplsVpnVrfDescription'] = trim(shell_exec($config['snmpget'] . " -Ln -Osqvn -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'] . " mplsVpnVrfDescription.".$vrf['oid'])); $vrf['mplsVpnVrfDescription'] = trim(shell_exec($config['snmpget'] . " -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']."' if(@mysql_result(mysql_query("SELECT count(*) FROM vrfs WHERE `device_id` = '".$device['device_id']."'
AND `vrf_oid`='".$vrf['oid']."'"),0)) { 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); $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']." "); 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_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'] . " $interfaces_oid"); $interfaces = shell_exec($config['snmpwalk'] . " -CI -Ln -Osqn -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " $interfaces_oid");
$interfaces = trim(str_replace($interfaces_oid . ".", "", $interfaces)); $interfaces = trim(str_replace($interfaces_oid . ".", "", $interfaces));
# list($interfaces) = explode(" ", $interfaces); # list($interfaces) = explode(" ", $interfaces);
echo(" ( "); echo(" ( ");
+2 -2
View File
@@ -4,7 +4,7 @@
echo("Interfaces : "); echo("Interfaces : ");
$cmd = $config['snmpwalk'] . " -O nsq -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'] . " .1.3.6.1.2.1.2.2.1.2"; $cmd = $config['snmpwalk'] . " -O nsq -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " .1.3.6.1.2.1.2.2.1.2";
$interfaces = trim(shell_exec($cmd)); $interfaces = trim(shell_exec($cmd));
$interfaces = str_replace("\"", "", $interfaces); $interfaces = str_replace("\"", "", $interfaces);
$interfaces = str_replace("ifDescr.", "", $interfaces); $interfaces = str_replace("ifDescr.", "", $interfaces);
@@ -19,7 +19,7 @@
list($ifIndex, $ifName) = explode("||", $entry); list($ifIndex, $ifName) = explode("||", $entry);
if($config['ifdescr'][$device['os']]) { if($config['ifdescr'][$device['os']]) {
$ifDescr = shell_exec($config['snmpget'] . " -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'] . " ifDescr.$ifIndex"); $ifDescr = shell_exec($config['snmpget'] . " -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 Object available on this agent at this OID", "", $ifDescr);
$ifDescr = str_replace("No Such Instance currently exists at this OID", "", $ifDescr); $ifDescr = str_replace("No Such Instance currently exists at this OID", "", $ifDescr);
$ifDescr = trim(str_replace("\"", "", $ifDescr)); $ifDescr = trim(str_replace("\"", "", $ifDescr));
+2 -2
View File
@@ -2,13 +2,13 @@
echo("IP Addresses : "); echo("IP Addresses : ");
$oids = shell_exec($config['snmpwalk'] . " -".$device['snmpver']." -Osq -c ".$device['community']." ".$device['hostname']." ipAdEntIfIndex"); $oids = shell_exec($config['snmpwalk'] . " -".$device['snmpver']." -Osq -c ".$device['community']." ".$device['hostname'].":".$device['port']." ipAdEntIfIndex");
$oids = trim($oids); $oids = trim($oids);
$oids = str_replace("ipAdEntIfIndex.", "", $oids); $oids = str_replace("ipAdEntIfIndex.", "", $oids);
foreach(explode("\n", $oids) as $data) { foreach(explode("\n", $oids) as $data) {
$data = trim($data); $data = trim($data);
list($oid,$ifIndex) = explode(" ", $data); list($oid,$ifIndex) = explode(" ", $data);
$mask = shell_exec($config['snmpget']." -O qv -".$device['snmpver']." -c ".$device['community']." ".$device['hostname']." ipAdEntNetMask.$oid"); $mask = shell_exec($config['snmpget']." -O qv -".$device['snmpver']." -c ".$device['community']." ".$device['hostname'].":".$device['port']." ipAdEntNetMask.$oid");
$mask = trim($mask); $mask = trim($mask);
$network = trim(shell_exec ($config['ipcalc'] . " $oid/$mask | grep Network | cut -d\" \" -f 4")); $network = trim(shell_exec ($config['ipcalc'] . " $oid/$mask | grep Network | cut -d\" \" -f 4"));
list($net,$cidr) = explode("/", $network); list($net,$cidr) = explode("/", $network);
+4 -4
View File
@@ -2,11 +2,11 @@
echo("IPv6 Addresses : "); echo("IPv6 Addresses : ");
$ipv6interfaces = shell_exec($config['snmpget']." -Ovnq -".$device['snmpver']." -c ".$device['community']." ".$device['hostname']." ipv6Interfaces.0"); $ipv6interfaces = shell_exec($config['snmpget']." -Ovnq -".$device['snmpver']." -c ".$device['community']." ".$device['hostname'].":".$device['port']." ipv6Interfaces.0");
if($ipv6interfaces){ if($ipv6interfaces){
$oids = trim(trim(shell_exec($config['snmpwalk']." -".$device['snmpver']." -Ln -c ".$device['community']." ".$device['hostname']." ipAddressIfIndex.ipv6 -Osq | grep -v No"))); $oids = trim(trim(shell_exec($config['snmpwalk']." -".$device['snmpver']." -Ln -c ".$device['community']." ".$device['hostname'].":".$device['port']." ipAddressIfIndex.ipv6 -Osq | grep -v No")));
$oids = str_replace("ipAddressIfIndex.ipv6.", "", $oids); $oids = str_replace("\"", "", $oids); $oids = trim($oids); $oids = str_replace("ipAddressIfIndex.ipv6.", "", $oids); $oids = str_replace("\"", "", $oids); $oids = trim($oids);
foreach(explode("\n", $oids) as $data) { foreach(explode("\n", $oids) as $data) {
if($data) { if($data) {
@@ -25,8 +25,8 @@ if($ipv6interfaces){
if($do == 2) { $adsep = ":"; $do = '0'; } else { $adsep = "";} if($do == 2) { $adsep = ":"; $do = '0'; } else { $adsep = "";}
} }
$cidr = trim(shell_exec($config['snmpget']." -".$device['snmpver']." -c ".$device['community']." ".$device['hostname']." .1.3.6.1.2.1.4.34.1.5.2.16.$oid | sed 's/.*\.//'")); $cidr = 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/.*\.//'"));
$origin = trim(shell_exec($config['snmpget']." -Ovq -".$device['snmpver']." -c ".$device['community']." ".$device['hostname']." .1.3.6.1.2.1.4.34.1.6.2.16.$oid")); $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"));
$network = trim(shell_exec($config['sipcalc']." $address/$cidr | grep Subnet | cut -f 2 -d '-'")); $network = trim(shell_exec($config['sipcalc']." $address/$cidr | grep Subnet | cut -f 2 -d '-'"));
$comp = trim(shell_exec($config['sipcalc']." $address/$cidr | grep Compressed | cut -f 2 -d '-'")); $comp = trim(shell_exec($config['sipcalc']." $address/$cidr | grep Compressed | cut -f 2 -d '-'"));
+2 -2
View File
@@ -4,13 +4,13 @@
echo("Storage : "); echo("Storage : ");
$oids = shell_exec($config['snmpwalk'] . " -Osq -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'] . " hrStorageIndex"); $oids = shell_exec($config['snmpwalk'] . " -Osq -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " hrStorageIndex");
$oids = trim(str_replace("hrStorageIndex.","",$oids)); $oids = trim(str_replace("hrStorageIndex.","",$oids));
foreach(explode("\n", $oids) as $data) { foreach(explode("\n", $oids) as $data) {
$data = trim($data); $data = trim($data);
list($oid,$hrStorageIndex) = explode(" ", $data); list($oid,$hrStorageIndex) = explode(" ", $data);
$temp = shell_exec($config['snmpget'] . " -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'] . " hrStorageDescr.$oid hrStorageAllocationUnits.$oid hrStorageSize.$oid hrStorageType.$oid"); $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 = trim($temp); $temp = trim($temp);
list($descr, $units, $size, $type) = explode("\n", $temp); list($descr, $units, $size, $type) = explode("\n", $temp);
list($units) = explode(" ", $units); list($units) = explode(" ", $units);
+13 -12
View File
@@ -3,13 +3,14 @@
$hostname = $device['hostname']; $hostname = $device['hostname'];
$community = $device['community']; $community = $device['community'];
$snmpver = $device['snmpver']; $snmpver = $device['snmpver'];
$port = $device['port'];
echo("Temperatures : "); echo("Temperatures : ");
## JunOS Temperatures ## JunOS Temperatures
if($device['os'] == "JunOS") { if($device['os'] == "JunOS") {
echo("JunOS "); echo("JunOS ");
$oids = shell_exec($config['snmpwalk'] . " -v2c -CI -Osqn -c $community $hostname 1.3.6.1.4.1.2636.3.1.13.1.7"); $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 = trim($oids); $oids = trim($oids);
foreach(explode("\n", $oids) as $data) { foreach(explode("\n", $oids) as $data) {
$data = trim($data); $data = trim($data);
@@ -18,10 +19,10 @@
list($oid) = explode(" ", $data); list($oid) = explode(" ", $data);
$temp_oid = "1.3.6.1.4.1.2636.3.1.13.1.7.$oid"; $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_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 $descr_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 $temp_oid")); $temp = trim(shell_exec("snmpget -O qv -v2c -c $community $hostname:$port $temp_oid"));
if(!strstr($descr, "No") && !strstr($temp, "No") && $descr != "" && $temp != "0") { if(!strstr($descr, "No") && !strstr($temp, "No") && $descr != "" && $temp != "0") {
$descr = `snmpget -O qv -v2c -c $community $hostname $descr_oid`; $descr = `snmpget -O qv -v2c -c $community $hostname:$port $descr_oid`;
$descr = str_replace("\"", "", $descr); $descr = str_replace("\"", "", $descr);
$descr = str_replace("temperature", "", $descr); $descr = str_replace("temperature", "", $descr);
$descr = str_replace("temp", "", $descr); $descr = str_replace("temp", "", $descr);
@@ -40,12 +41,12 @@
## Begin Observer-Style ## Begin Observer-Style
if($device['os'] == "Linux") { if($device['os'] == "Linux") {
echo("Observer-Style "); echo("Observer-Style ");
$oids = `snmpwalk -$snmpver -Osqn -CI -c $community $hostname .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 = `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 = trim($oids); $oids = trim($oids);
foreach(explode("\n",$oids) as $oid) { foreach(explode("\n",$oids) as $oid) {
$oid = trim($oid); $oid = trim($oid);
if($oid != "") { if($oid != "") {
$descr = trim(str_replace("\"", "", `snmpget -v2c -Osqn -c $community $hostname .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("\"", "", `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\ //`));
$fulloid = ".1.3.6.1.4.1.2021.7891.$oid.101.1"; $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)) { if(!mysql_result(mysql_query("SELECT count(temp_id) FROM temperature WHERE `temp_host` = '$id' AND `temp_oid` = '$fulloid'"), 0)) {
echo("+"); echo("+");
@@ -64,13 +65,13 @@
## Dell Temperatures ## Dell Temperatures
if(strstr($device['hardware'], "Dell")) { if(strstr($device['hardware'], "Dell")) {
echo("Dell OMSA "); echo("Dell OMSA ");
$oids = `snmpwalk -$snmpver -CI -Osqn -c $community $hostname .1.3.6.1.4.1.674.10892.1.700.20.1.8`; $oids = `snmpwalk -$snmpver -CI -Osqn -c $community $hostname:$port .1.3.6.1.4.1.674.10892.1.700.20.1.8`;
$oids = trim($oids); $oids = trim($oids);
foreach(explode("\n",$oids) as $oid) { foreach(explode("\n",$oids) as $oid) {
$oid = substr(trim($oid), 36); $oid = substr(trim($oid), 36);
list($oid) = explode(" ", $oid); list($oid) = explode(" ", $oid);
if($oid != "") { if($oid != "") {
$descr = trim(str_replace("\"", "", `snmpget -v2c -Onvq -c $community $hostname .1.3.6.1.4.1.674.10892.1.700.20.1.8.$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`));
$fulloid = ".1.3.6.1.4.1.674.10892.1.700.20.1.6.$oid"; $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)) { 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');"); mysql_query("INSERT INTO `temperature` (`temp_host`,`temp_oid`,`temp_descr`, `temp_tenths`) VALUES ('$id', '$fulloid', '$descr', '1');");
@@ -90,7 +91,7 @@
## Cisco Temperatures ## Cisco Temperatures
if($device['os'] == "IOS") { if($device['os'] == "IOS") {
echo("Cisco "); echo("Cisco ");
$oids = shell_exec($config['snmpwalk'] . " -v2c -CI -Osqn -c $community $hostname .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'] . " -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 = trim($oids); $oids = trim($oids);
foreach(explode("\n", $oids) as $data) { foreach(explode("\n", $oids) as $data) {
$data = trim($data); $data = trim($data);
@@ -98,10 +99,10 @@
list($oid) = explode(" ", $data); list($oid) = explode(" ", $data);
$temp_oid = ".1.3.6.1.4.1.9.9.13.1.3.1.3.$oid"; $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_oid = ".1.3.6.1.4.1.9.9.13.1.3.1.2.$oid";
$descr = `snmpget -O qv -v2c -c $community $hostname $descr_oid`; $descr = `snmpget -O qv -v2c -c $community $hostname:$port $descr_oid`;
$temp = `snmpget -O qv -v2c -c $community $hostname $temp_oid`; $temp = `snmpget -O qv -v2c -c $community $hostname:$port $temp_oid`;
if(!strstr($descr, "No") && !strstr($temp, "No") && $descr != "" ) { if(!strstr($descr, "No") && !strstr($temp, "No") && $descr != "" ) {
$descr = `snmpget -O qv -v2c -c $community $hostname $descr_oid`; $descr = `snmpget -O qv -v2c -c $community $hostname:$port $descr_oid`;
$descr = str_replace("\"", "", $descr); $descr = str_replace("\"", "", $descr);
$descr = str_replace("temperature", "", $descr); $descr = str_replace("temperature", "", $descr);
$descr = str_replace("temp", "", $descr); $descr = str_replace("temp", "", $descr);
+11 -11
View File
@@ -60,11 +60,11 @@ function rrdtool_update($rrdfile, $rrdupdate) {
return shell_exec($config['rrdtool'] . " update $rrdfile $rrdupdate"); return shell_exec($config['rrdtool'] . " update $rrdfile $rrdupdate");
} }
function getHostOS($hostname, $community, $snmpver) { function getHostOS($hostname, $community, $snmpver, $port) {
global $config; global $config;
$sysDescr_cmd = $config['snmpget']." -O qv -" . $snmpver . " -c " . $community . " " . $hostname . " sysDescr.0"; $sysDescr_cmd = $config['snmpget']." -O qv -" . $snmpver . " -c " . $community . " " . $hostname.":".$port . " sysDescr.0";
$sysDescr = str_replace("\"", "", trim(shell_exec($sysDescr_cmd))); $sysDescr = str_replace("\"", "", trim(shell_exec($sysDescr_cmd)));
$dir_handle = @opendir($config['install_dir'] . "/includes/osdiscovery") or die("Unable to open $path"); $dir_handle = @opendir($config['install_dir'] . "/includes/osdiscovery") or die("Unable to open $path");
while ($file = readdir($dir_handle)) { while ($file = readdir($dir_handle)) {
@@ -362,16 +362,16 @@ function delHost($id)
} }
function addHost($host, $community, $snmpver) function addHost($host, $community, $snmpver, $port = 161)
{ {
global $config; global $config;
list($hostshort) = explode(".", $host); list($hostshort) = explode(".", $host);
if ( isDomainResolves($host)){ if ( isDomainResolves($host)){
if ( isPingable($host)) { if ( isPingable($host)) {
if ( mysql_result(mysql_query("SELECT COUNT(*) FROM `devices` WHERE `hostname` = '$host'"), 0) == '0' ) { if ( mysql_result(mysql_query("SELECT COUNT(*) FROM `devices` WHERE `hostname` = '$host'"), 0) == '0' ) {
$snmphost = shell_exec($config['snmpget'] ." -Oqv -$snmpver -c $community $host sysName.0"); $snmphost = shell_exec($config['snmpget'] ." -Oqv -$snmpver -c $community $host:$port sysName.0");
if ($snmphost == $host || $hostshort = $host) { if ($snmphost == $host || $hostshort = $host) {
createHost ($host, $community, $snmpver); createHost ($host, $community, $snmpver, $port);
} else { echo("Given hostname does not match SNMP-read hostname!\n"); } } else { echo("Given hostname does not match SNMP-read hostname!\n"); }
} else { echo("Already got host $host\n"); } } else { echo("Already got host $host\n"); }
} else { echo("Could not ping $host\n"); } } else { echo("Could not ping $host\n"); }
@@ -481,13 +481,13 @@ function formatUptime($diff, $format="long")
return "$uptime"; return "$uptime";
} }
function isSNMPable($hostname, $community, $snmpver) function isSNMPable($hostname, $community, $snmpver, $port)
{ {
global $config; global $config;
$pos = shell_exec($config['snmpget'] ." -$snmpver -c $community -t 1 $hostname sysDescr.0"); $pos = shell_exec($config['snmpget'] ." -$snmpver -c $community -t 1 $hostname:$port sysDescr.0");
if($pos == '') { if($pos == '') {
$status='0'; $status='0';
$posb = shell_exec($config['snmpget'] ." -$snmpver -c $community -t 1 $hostname 1.3.6.1.2.1.7526.2.4"); $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'; } if($posb == '') { } else { $status='1'; }
} else { } else {
$status='1'; $status='1';
@@ -599,11 +599,11 @@ function fixIOSHardware($hardware){
} }
function createHost ($host, $community, $snmpver){ function createHost ($host, $community, $snmpver, $port = 161){
$host = trim(strtolower($host)); $host = trim(strtolower($host));
$host_os = getHostOS($host, $community, $snmpver); $host_os = getHostOS($host, $community, $snmpver, $port);
if($host_os) { if($host_os) {
$sql = mysql_query("INSERT INTO `devices` (`hostname`, `community`, `os`, `status`) VALUES ('$host', '$community', '$host_os', '1')"); $sql = mysql_query("INSERT INTO `devices` (`hostname`, `community`, `port`, `os`, `status`) VALUES ('$host', '$community', '$port', '$host_os', '1')");
if(mysql_affected_rows()) { if(mysql_affected_rows()) {
return("Created host : $host ($host_os)"); return("Created host : $host ($host_os)");
} else { return FALSE; } } else { return FALSE; }
+3 -3
View File
@@ -20,19 +20,19 @@ function pollDevice() {
$memrrd = "rrd/" . $device['hostname'] . "-mem.rrd"; $memrrd = "rrd/" . $device['hostname'] . "-mem.rrd";
$memgraph = "public_html/graphs/" . $device['hostname'] . "-mem.png"; $memgraph = "public_html/graphs/" . $device['hostname'] . "-mem.png";
$cmd = $config['snmpget'] . " -O qv -v2c -c ".$community." ".$device['hostname']." 1.3.6.1.4.1.9.2.1.58.0 1.3.6.1.4.1.9.2.1.56.0"; $cmd = $config['snmpget'] . " -O qv -v2c -c ".$community." ".$device['hostname'].":".$device['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($cmd)); list ($cpu5m, $cpu5s) = explode("\n", shell_exec($cmd));
$cpu5m = $cpu5m + 0; $cpu5m = $cpu5m + 0;
$cpu5s = $cpu5s + 0; $cpu5s = $cpu5s + 0;
$cmd = $config['snmpget'] . " -O qv -v2c -c ".$community." ".$device['hostname']." .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"; $cmd = $config['snmpget'] . " -O qv -v2c -c ".$community." ".$device['hostname'].":".$device['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";
list ($tempin1, $tempout1) = explode("\n", shell_exec($cmd)); list ($tempin1, $tempout1) = explode("\n", shell_exec($cmd));
$tempin1 = $tempin1 +0; $tempin1 = $tempin1 +0;
$tempout1 = $tempout1 + 0; $tempout1 = $tempout1 + 0;
$cmd = $config['snmpget'] . " -O qv -v2c -c ".$community." ".$device['hostname']; $cmd = $config['snmpget'] . " -O qv -v2c -c ".$community." ".$device['hostname'].":".$device['port'];
$cmd .= " .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.5.2 .1.3.6.1.4.1.9.9.48.1.1.1.5.1"; $cmd .= " .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.5.2 .1.3.6.1.4.1.9.9.48.1.1.1.5.1";
list ($memfreeio, $memfreeproc, $memusedio, $memusedproc) = explode("\n", shell_exec($cmd)); list ($memfreeio, $memfreeproc, $memusedio, $memusedproc) = explode("\n", shell_exec($cmd));
+2 -2
View File
@@ -2,9 +2,9 @@
if(!$os) { if(!$os) {
$sysObjectId = shell_exec($config['snmpget'] . " -Ovq -v2c -c ". $community ." ". $hostname ." .1.3.6.1.2.1.1.2.0"); $sysObjectId = shell_exec($config['snmpget'] . " -Ovq -v2c -c ". $community ." ". $hostname.":".$port ." .1.3.6.1.2.1.1.2.0");
if(strstr($sysObjectId, "fortinet")) { if(strstr($sysObjectId, "fortinet")) {
$fnSysVersion = shell_exec($config['snmpget'] . " -Ovq -v2c -c ". $community ." ". $hostname ." fnSysVersion.0"); $fnSysVersion = shell_exec($config['snmpget'] . " -Ovq -v2c -c ". $community ." ". $hostname.":".$port ." fnSysVersion.0");
if(strstr($fnSysVersion, "Fortigate")) { if(strstr($fnSysVersion, "Fortigate")) {
$os = "Fortigate"; $os = "Fortigate";
} }
+1 -1
View File
@@ -2,7 +2,7 @@
if(!$os) { if(!$os) {
$sysObjectId = shell_exec($config['snmpget'] . " -Ovqn -v2c -c ". $community ." ". $hostname ." sysObjectID.0"); $sysObjectId = shell_exec($config['snmpget'] . " -Ovqn -v2c -c ". $community ." ". $hostname.":".$port ." sysObjectID.0");
if(strstr($sysObjectId, ".1.3.6.1.4.1.2636")) { $os = "JunOS"; } if(strstr($sysObjectId, ".1.3.6.1.4.1.2636")) { $os = "JunOS"; }
} }
+2 -1
View File
@@ -2,7 +2,8 @@
if(!$os) { if(!$os) {
$sysObjectId = shell_exec($config['snmpget'] . " -Ovq -v2c -c ". $community ." ". $hostname ." .1.3.6.1.2.1.1.2.0"); var_dump($port);
$sysObjectId = shell_exec($config['snmpget'] . " -Ovq -v2c -c ". $community ." ". $hostname.":".$port ." .1.3.6.1.2.1.1.2.0");
if(strstr($sysObjectId, "netscreen")) { $os = "ScreenOS"; } elseif (strstr($sysObjectId, "enterprises.3224.1")) { $os = "ScreenOS"; } if(strstr($sysObjectId, "netscreen")) { $os = "ScreenOS"; } elseif (strstr($sysObjectId, "enterprises.3224.1")) { $os = "ScreenOS"; }
+1 -1
View File
@@ -12,7 +12,7 @@ while($peer = mysql_fetch_array($peers)) {
echo("Checking ".$peer['bgpPeerIdentifier']."\n"); echo("Checking ".$peer['bgpPeerIdentifier']."\n");
$peer_cmd = $config['snmpget'] . " -Ovq -" . $device['snmpver'] . " -c" . $device['community'] . " " . $device['hostname'] . " "; $peer_cmd = $config['snmpget'] . " -Ovq -" . $device['snmpver'] . " -c" . $device['community'] . " " . $device['hostname'].":".$device['port'] . " ";
$peer_cmd .= "bgpPeerState." . $peer['bgpPeerIdentifier'] . " bgpPeerAdminStatus." . $peer['bgpPeerIdentifier'] . " bgpPeerInUpdates." . $peer['bgpPeerIdentifier'] . " bgpPeerOutUpdates." . $peer['bgpPeerIdentifier'] . " bgpPeerInTotalMessages." . $peer['bgpPeerIdentifier'] . " "; $peer_cmd .= "bgpPeerState." . $peer['bgpPeerIdentifier'] . " bgpPeerAdminStatus." . $peer['bgpPeerIdentifier'] . " bgpPeerInUpdates." . $peer['bgpPeerIdentifier'] . " bgpPeerOutUpdates." . $peer['bgpPeerIdentifier'] . " bgpPeerInTotalMessages." . $peer['bgpPeerIdentifier'] . " ";
$peer_cmd .= "bgpPeerOutTotalMessages." . $peer['bgpPeerIdentifier'] . " bgpPeerFsmEstablishedTime." . $peer['bgpPeerIdentifier'] . " bgpPeerInUpdateElapsedTime." . $peer['bgpPeerIdentifier'] . " "; $peer_cmd .= "bgpPeerOutTotalMessages." . $peer['bgpPeerIdentifier'] . " bgpPeerFsmEstablishedTime." . $peer['bgpPeerIdentifier'] . " bgpPeerInUpdateElapsedTime." . $peer['bgpPeerIdentifier'] . " ";
$peer_cmd .= "bgpPeerLocalAddr." . $peer['bgpPeerIdentifier'] . ""; $peer_cmd .= "bgpPeerLocalAddr." . $peer['bgpPeerIdentifier'] . "";
+2 -2
View File
@@ -2,8 +2,8 @@
echo("Fortinet Fortigate Poller\n"); echo("Fortinet Fortigate Poller\n");
$fnSysVersion = shell_exec($config['snmpget']." -".$device['snmpver']." -Ovq -c ".$device['community']." ".$device['hostname']." fnSysVersion.0"); $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']." fnSysSerial.0"); $serial = shell_exec($config['snmpget']." -".$device['snmpver']." -Ovq -c ".$device['community']." ".$device['hostname'].":".$device['port']." fnSysSerial.0");
$version = preg_replace("/(.+)\ (.+),(.+),(.+)/", "Fortinet \\1||\\2||\\3||\\4", $fnSysVersion); $version = preg_replace("/(.+)\ (.+),(.+),(.+)/", "Fortinet \\1||\\2||\\3||\\4", $fnSysVersion);
list($hardware,$version,$features) = explode("||", $version); list($hardware,$version,$features) = explode("||", $version);
+4 -3
View File
@@ -3,6 +3,7 @@
$community = $device['community']; $community = $device['community'];
$id = $device['device_id']; $id = $device['device_id'];
$hostname = $device['hostname']; $hostname = $device['hostname'];
$port = $device['port'];
$Otemprrd = "rrd/" . $hostname . "-temp.rrd"; $Otemprrd = "rrd/" . $hostname . "-temp.rrd";
$Ocpurrd = "rrd/" . $hostname . "-cpu.rrd"; $Ocpurrd = "rrd/" . $hostname . "-cpu.rrd";
@@ -48,15 +49,15 @@
} }
list ($cpu5m, $cpu5s) = explode("\n", `snmpget -O qv -v2c -c $community $hostname 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", `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`);
$cpu5m = $cpu5m + 0; $cpu5m = $cpu5m + 0;
$cpu5s = $cpu5s + 0; $cpu5s = $cpu5s + 0;
list ($tempin1, $tempout1) = explode("\n", `snmpget -O qv -v2c -c $community $hostname .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`); 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; $tempin1 = $tempin1 +0;
$tempout1 = $tempout1 + 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.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_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 $mem_get`; $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); $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); list ($memfreeio, $memfreeproc, $memfreeprocb, $memusedio, $memusedproc, $memusedprocb) = explode("\n", $mem_raw);
echo("$hostname\n"); echo("$hostname\n");
+1 -1
View File
@@ -27,7 +27,7 @@ if($device[os] != "Snom") {
} }
if(!file_exists($rrdfile)) { `$rrd_create`; } if(!file_exists($rrdfile)) { `$rrd_create`; }
$snmpdata_cmd = "snmpget -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'] . " $snmpstring"; $snmpdata_cmd = "snmpget -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " $snmpstring";
$snmpdata = trim(`$snmpdata_cmd`); $snmpdata = trim(`$snmpdata_cmd`);
$rrdupdate = "N"; $rrdupdate = "N";
foreach(explode("\n", $snmpdata) as $data) { foreach(explode("\n", $snmpdata) as $data) {
+2 -2
View File
@@ -10,11 +10,11 @@
if(is_file($Omemrrd) && !is_file($memrrd)) { rename($Omemrrd, $memrrd); echo("Moving $Omemrrd to $memrrd"); } if(is_file($Omemrrd) && !is_file($memrrd)) { rename($Omemrrd, $memrrd); echo("Moving $Omemrrd to $memrrd"); }
$cpu_cmd = "snmpget -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'] . " 1.3.6.1.4.1.11.2.14.11.5.1.9.6.1.0"; $cpu_cmd = "snmpget -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " 1.3.6.1.4.1.11.2.14.11.5.1.9.6.1.0";
$cpu = `$cpu_cmd`; $cpu = `$cpu_cmd`;
$mem_cmd = "snmpget -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname']; $mem_cmd = "snmpget -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'];
$mem_cmd .= " 1.3.6.1.4.1.11.2.14.11.5.1.1.2.2.1.1.5.1 1.3.6.1.4.1.11.2.14.11.5.1.1.2.2.1.1.6.1 1.3.6.1.4.1.11.2.14.11.5.1.1.2.2.1.1.7.1"; $mem_cmd .= " 1.3.6.1.4.1.11.2.14.11.5.1.1.2.2.1.1.5.1 1.3.6.1.4.1.11.2.14.11.5.1.1.2.2.1.1.6.1 1.3.6.1.4.1.11.2.14.11.5.1.1.2.2.1.1.7.1";
$mem = `$mem_cmd`; $mem = `$mem_cmd`;
+3 -3
View File
@@ -4,7 +4,7 @@
// Get SNOM specific version string from silly SNOM location. Silly SNOM! // Get SNOM specific version string from silly SNOM location. Silly SNOM!
$cmd = "snmpget -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'] . " 1.3.6.1.2.1.7526.2.4"; $cmd = "snmpget -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " 1.3.6.1.2.1.7526.2.4";
$sysDescr = `$cmd`; $sysDescr = `$cmd`;
$sysDescr = str_replace("-", " ", $sysDescr); $sysDescr = str_replace("-", " ", $sysDescr);
$sysDescr = str_replace("\"", "", $sysDescr); $sysDescr = str_replace("\"", "", $sysDescr);
@@ -12,8 +12,8 @@
// Get data for calls and network from SNOM specific SNMP OIDs. // Get data for calls and network from SNOM specific SNMP OIDs.
$cmda = "snmpget -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'] . " 1.3.6.1.2.1.7526.2.1.1 1.3.6.1.2.1.7526.2.1.2 1.3.6.1.2.1.7526.2.2.1 1.3.6.1.2.1.7526.2.2.2"; $cmda = "snmpget -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " 1.3.6.1.2.1.7526.2.1.1 1.3.6.1.2.1.7526.2.1.2 1.3.6.1.2.1.7526.2.2.1 1.3.6.1.2.1.7526.2.2.2";
$cmdb = "snmpget -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'] . " 1.3.6.1.2.1.7526.2.5 1.3.6.1.2.1.7526.2.6"; $cmdb = "snmpget -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " 1.3.6.1.2.1.7526.2.5 1.3.6.1.2.1.7526.2.6";
echo($cmda); echo($cmda);
$snmpdata = `$cmda`; $snmpdata = `$cmda`;
$snmpdatab = `$cmdb`; $snmpdatab = `$cmdb`;
+6 -6
View File
@@ -42,12 +42,12 @@ if(is_file($Osysrrd) && !is_file($sysrrd)) { rename($Osysrrd, $sysrrd); echo("Mo
list(,,$version) = explode (" ", $sysDescr); list(,,$version) = explode (" ", $sysDescr);
if(strstr($sysDescr, "386")|| strstr($sysDescr, "486")||strstr($sysDescr, "586")||strstr($sysDescr, "686")) { $hardware = "Generic x86"; } 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"; } if(strstr($sysDescr, "x86_64")) { $hardware = "Generic x86 64-bit"; }
$cmd = "snmpget -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'] . " .1.3.6.1.4.1.2021.7890.1.101.1"; $cmd = "snmpget -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port']. " .1.3.6.1.4.1.2021.7890.1.101.1";
$features = trim(`$cmd`); $features = trim(`$cmd`);
$features = str_replace("No Such Object available on this agent at this OID", "", $features); $features = str_replace("No Such Object available on this agent at this OID", "", $features);
$features = str_replace("\"", "", $features); $features = str_replace("\"", "", $features);
// Detect Dell hardware via OpenManage SNMP // Detect Dell hardware via OpenManage SNMP
$cmd = "snmpget -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'] . " .1.3.6.1.4.1.674.10892.1.300.10.1.9.1"; $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";
$hw = trim(str_replace("\"", "", `$cmd`)); $hw = trim(str_replace("\"", "", `$cmd`));
if(strstr($hw, "No")) { unset($hw); } else { $hardware = "Dell " . $hw; } if(strstr($hw, "No")) { unset($hw); } else { $hardware = "Dell " . $hw; }
} }
@@ -60,7 +60,7 @@ while ($dr = mysql_fetch_array($dq)) {
$hrStorageAllocationUnits = $dr['hrStorageAllocationUnits']; $hrStorageAllocationUnits = $dr['hrStorageAllocationUnits'];
$hrStorageSize = $dr['hrStorageAllocationUnits'] * $dr['hrStorageSize']; $hrStorageSize = $dr['hrStorageAllocationUnits'] * $dr['hrStorageSize'];
$hrStorageDescr = $dr['hrStorageDescr']; $hrStorageDescr = $dr['hrStorageDescr'];
$cmd = "snmpget -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'] . " hrStorageUsed.$hrStorageIndex"; $cmd = "snmpget -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " hrStorageUsed.$hrStorageIndex";
$used_units = trim(`$cmd`); $used_units = trim(`$cmd`);
$used = $used_units * $hrStorageAllocationUnits; $used = $used_units * $hrStorageAllocationUnits;
$perc = round($used / $hrStorageSize * 100, 2); $perc = round($used / $hrStorageSize * 100, 2);
@@ -120,7 +120,7 @@ $oid_ssCpuUser = ".1.3.6.1.4.1.2021.11.9.0";
$oid_ssCpuSystem = ".1.3.6.1.4.1.2021.11.10.0"; $oid_ssCpuSystem = ".1.3.6.1.4.1.2021.11.10.0";
$cpu_cmd = "snmpget -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname']; $cpu_cmd = "snmpget -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'];
$cpu_cmd .= " $oid_ssCpuRawUser $oid_ssCpuRawSystem $oid_ssCpuRawNice $oid_ssCpuRawIdle $oid_hrSystemProcesses"; $cpu_cmd .= " $oid_ssCpuRawUser $oid_ssCpuRawSystem $oid_ssCpuRawNice $oid_ssCpuRawIdle $oid_hrSystemProcesses";
$cpu_cmd .= " $oid_hrSystemNumUsers $oid_ssCpuUser $oid_ssCpuSystem .1.3.6.1.4.1.2021.1.101.1"; $cpu_cmd .= " $oid_hrSystemNumUsers $oid_ssCpuUser $oid_ssCpuSystem .1.3.6.1.4.1.2021.1.101.1";
$cpu = `$cpu_cmd`; $cpu = `$cpu_cmd`;
@@ -209,12 +209,12 @@ if($device[os] != "m0n0wall" && $device[os] != "Voswall" && $device[os] != "pfSe
} // end create load rrd } // end create load rrd
$mem_get = "memTotalSwap.0 memAvailSwap.0 memTotalReal.0 memAvailReal.0 memTotalFree.0 memShared.0 memBuffer.0 memCached.0"; $mem_get = "memTotalSwap.0 memAvailSwap.0 memTotalReal.0 memAvailReal.0 memTotalFree.0 memShared.0 memBuffer.0 memCached.0";
$mem_cmd = "snmpget -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'] . " " . $mem_get; $mem_cmd = "snmpget -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " " . $mem_get;
$mem_raw = `$mem_cmd`; $mem_raw = `$mem_cmd`;
list($memTotalSwap, $memAvailSwap, $memTotalReal, $memAvailReal, $memTotalFree, $memShared, $memBuffer, $memCached) = explode("\n", $mem_raw); list($memTotalSwap, $memAvailSwap, $memTotalReal, $memAvailReal, $memTotalFree, $memShared, $memBuffer, $memCached) = explode("\n", $mem_raw);
$load_get = "laLoadInt.1 laLoadInt.2 laLoadInt.3"; $load_get = "laLoadInt.1 laLoadInt.2 laLoadInt.3";
$load_cmd = "snmpget -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'] . " " . $load_get; $load_cmd = "snmpget -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " " . $load_get;
$load_raw = `$load_cmd`; $load_raw = `$load_cmd`;
list ($load1, $load5, $load10) = explode ("\n", $load_raw); list ($load1, $load5, $load10) = explode ("\n", $load_raw);
+3 -3
View File
@@ -22,7 +22,7 @@
$oid_hrSystemProcesses = ".1.3.6.1.2.1.25.1.6.0"; $oid_hrSystemProcesses = ".1.3.6.1.2.1.25.1.6.0";
$oid_hrSystemNumUsers = ".1.3.6.1.2.1.25.1.5.0"; $oid_hrSystemNumUsers = ".1.3.6.1.2.1.25.1.5.0";
$s_cmd = "snmpget -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname']; $s_cmd = "snmpget -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'];
$s_cmd .= " $oid_ssCpuRawUser $oid_ssCpuRawSystem $oid_ssCpuRawNice $oid_ssCpuRawIdle $oid_hrSystemProcesses $oid_hrSystemNumUsers"; $s_cmd .= " $oid_ssCpuRawUser $oid_ssCpuRawSystem $oid_ssCpuRawNice $oid_ssCpuRawIdle $oid_hrSystemProcesses $oid_hrSystemNumUsers";
$s = `$s_cmd`; $s = `$s_cmd`;
list ($cpuUser, $cpuSystem, $cpuNice, $cpuIdle, $procs, $users) = explode("\n", $s); list ($cpuUser, $cpuSystem, $cpuNice, $cpuIdle, $procs, $users) = explode("\n", $s);
@@ -97,12 +97,12 @@
} }
$mem_get = "memTotalSwap.0 memAvailSwap.0 memTotalReal.0 memAvailReal.0 memTotalFree.0 memShared.0 memBuffer.0 memCached.0"; $mem_get = "memTotalSwap.0 memAvailSwap.0 memTotalReal.0 memAvailReal.0 memTotalFree.0 memShared.0 memBuffer.0 memCached.0";
$mem_cmd = "snmpget -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'] . " " . $mem_get; $mem_cmd = "snmpget -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " " . $mem_get;
$mem_raw = `$mem_cmd`; $mem_raw = `$mem_cmd`;
list($memTotalSwap, $memAvailSwap, $memTotalReal, $memAvailReal, $memTotalFree, $memShared, $memBuffer, $memCached) = explode("\n", $mem_raw); list($memTotalSwap, $memAvailSwap, $memTotalReal, $memAvailReal, $memTotalFree, $memShared, $memBuffer, $memCached) = explode("\n", $mem_raw);
$load_get = "laLoadInt.1 laLoadInt.2 laLoadInt.3"; $load_get = "laLoadInt.1 laLoadInt.2 laLoadInt.3";
$load_cmd = "snmpget -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'] . " " . $load_get; $load_cmd = "snmpget -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " " . $load_get;
$load_raw = `$load_cmd`; $load_raw = `$load_cmd`;
list ($load1, $load5, $load10) = explode ("\n", $load_raw); list ($load1, $load5, $load10) = explode ("\n", $load_raw);
+4 -4
View File
@@ -18,7 +18,7 @@ while ($interface = mysql_fetch_array($interface_query)) {
echo("Looking at " . $interface['ifDescr'] . " on " . $device['hostname'] . "\n"); echo("Looking at " . $interface['ifDescr'] . " on " . $device['hostname'] . "\n");
$snmp_cmd = $config['snmpget'] . " -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname']; $snmp_cmd = $config['snmpget'] . " -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'];
$snmp_cmd .= " ifAdminStatus." . $interface['ifIndex'] . " ifOperStatus." . $interface['ifIndex'] . " ifAlias." . $interface['ifIndex']; $snmp_cmd .= " ifAdminStatus." . $interface['ifIndex'] . " ifOperStatus." . $interface['ifIndex'] . " ifAlias." . $interface['ifIndex'];
$snmp_output = trim(`$snmp_cmd`); $snmp_output = trim(`$snmp_cmd`);
@@ -93,8 +93,8 @@ while ($interface = mysql_fetch_array($interface_query)) {
if($ifOperStatus == "up") { if($ifOperStatus == "up") {
$snmp_data_cmd = "snmpget -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname']; $snmp_data_cmd = "snmpget -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'];
$snmp_data_cmd = "snmpget -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname']; $snmp_data_cmd = "snmpget -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 .= " ifHCInOctets." . $interface['ifIndex'] . " ifHCOutOctets." . $interface['ifIndex'] . " ifInErrors." . $interface['ifIndex'];
$snmp_data_cmd .= " ifOutErrors." . $interface['ifIndex'] . " ifInUcastPkts." . $interface['ifIndex'] . " ifOutUcastPkts." . $interface['ifIndex']; $snmp_data_cmd .= " ifOutErrors." . $interface['ifIndex'] . " ifInUcastPkts." . $interface['ifIndex'] . " ifOutUcastPkts." . $interface['ifIndex'];
$snmp_data_cmd .= " ifInNUcastPkts." . $interface['ifIndex'] . " ifOutNUcastPkts." . $interface['ifIndex']; $snmp_data_cmd .= " ifInNUcastPkts." . $interface['ifIndex'] . " ifOutNUcastPkts." . $interface['ifIndex'];
@@ -106,7 +106,7 @@ while ($interface = mysql_fetch_array($interface_query)) {
list($ifHCInOctets, $ifHCOutOctets, $ifInErrors, $ifOutErrors, $ifInUcastPkts, $ifOutUcastPkts, $ifInNUcastPkts, $ifOutNUcastPkts) = explode("\n", $snmp_data); list($ifHCInOctets, $ifHCOutOctets, $ifInErrors, $ifOutErrors, $ifInUcastPkts, $ifOutUcastPkts, $ifInNUcastPkts, $ifOutNUcastPkts) = explode("\n", $snmp_data);
if($ifHCInOctets == "" || strpos($ifHCInOctets, "No") !== FALSE ) { if($ifHCInOctets == "" || strpos($ifHCInOctets, "No") !== FALSE ) {
$octets_cmd = "snmpget -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname']; $octets_cmd = "snmpget -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'];
$octets_cmd .= " ifInOctets." . $interface['ifIndex'] . " ifOutOctets." . $interface['ifIndex']; $octets_cmd .= " ifInOctets." . $interface['ifIndex'] . " ifOutOctets." . $interface['ifIndex'];
$octets = `$octets_cmd`; $octets = `$octets_cmd`;
list ($ifHCInOctets, $ifHCOutOctets) = explode("\n", $octets); list ($ifHCInOctets, $ifHCOutOctets) = explode("\n", $octets);
+1 -1
View File
@@ -4,7 +4,7 @@ $query = "SELECT * FROM temperature WHERE temp_host = '" . $device['device_id']
$temp_data = mysql_query($query); $temp_data = mysql_query($query);
while($temperature = mysql_fetch_array($temp_data)) { while($temperature = mysql_fetch_array($temp_data)) {
$temp_cmd = "snmpget -O Uqnv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'] . " " . $temperature['temp_oid']; $temp_cmd = "snmpget -O Uqnv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " " . $temperature['temp_oid'];
$temp = `$temp_cmd`; $temp = `$temp_cmd`;
echo("Checking temp " . $temperature['temp_descr'] . "... "); echo("Checking temp " . $temperature['temp_descr'] . "... ");
+3 -2
View File
@@ -35,11 +35,12 @@ function CollectData($bill_id) {
$port_id = $port_data['port_id']; $port_id = $port_data['port_id'];
$host = $port_data['hostname']; $host = $port_data['hostname'];
$port = $port_data['port'];
echo("\nPolling ".$port_data['ifDescr']." on ".$port_data['hostname']."\n"); echo("\nPolling ".$port_data['ifDescr']." on ".$port_data['hostname']."\n");
$port_in_measurement = trim(getValue($host, $port_data['community'], $port_data['ifIndex'], "In")); $port_in_measurement = trim(getValue($host, $port_data['community'], $port, $port_data['ifIndex'], "In"));
$port_out_measurement = trim(getValue($host, $port_data['community'], $port_data['ifIndex'], "Out")); $port_out_measurement = trim(getValue($host, $port_data['community'], $port, $port_data['ifIndex'], "Out"));
echo("$port_in_measurement and $port_out_measurement \n"); echo("$port_in_measurement and $port_out_measurement \n");
+4 -4
View File
@@ -42,7 +42,7 @@ while ($device = mysql_fetch_array($device_query)) {
$snmpable = FALSE; $snmpable = FALSE;
if($pingable) { if($pingable) {
$snmpable = isSNMPable($device['hostname'], $device['community'], $device['snmpver']); $snmpable = isSNMPable($device['hostname'], $device['community'], $device['snmpver'], $device['port']);
if($snmpable) { echo("SNMP : yes :)\n"); } else { echo("SNMP : no :(\n"); } if($snmpable) { echo("SNMP : yes :)\n"); } else { echo("SNMP : no :(\n"); }
} }
@@ -56,11 +56,11 @@ while ($device = mysql_fetch_array($device_query)) {
} else { } else {
$uptimeoid = "1.3.6.1.2.1.1.3.0"; $uptimeoid = "1.3.6.1.2.1.1.3.0";
} }
$snmp_cmd = $config['snmpget'] . " -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname']; $snmp_cmd = $config['snmpget'] . " -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'];
$snmp_cmd .= " $uptimeoid sysLocation.0 sysContact.0"; $snmp_cmd .= " $uptimeoid sysLocation.0 sysContact.0";
#$snmp_cmd .= " | grep -v 'Cisco Internetwork Operating System Software'"; #$snmp_cmd .= " | grep -v 'Cisco Internetwork Operating System Software'";
if($device['os'] == "IOS" || $device['os'] == "IOS XE") { if($device['os'] == "IOS" || $device['os'] == "IOS XE") {
$snmp_cmdb = $config['snmpget'] . " -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname']; $snmp_cmdb = $config['snmpget'] . " -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'];
$snmp_cmdb .= " .1.3.6.1.2.1.47.1.1.1.1.13.1"; $snmp_cmdb .= " .1.3.6.1.2.1.47.1.1.1.1.13.1";
$snmp_cmdb .= " | grep -v 'Cisco Internetwork Operating System Software'"; $snmp_cmdb .= " | grep -v 'Cisco Internetwork Operating System Software'";
$ciscomodel = str_replace("\"", "", trim(`$snmp_cmdb`)); $ciscomodel = str_replace("\"", "", trim(`$snmp_cmdb`));
@@ -71,7 +71,7 @@ while ($device = mysql_fetch_array($device_query)) {
$snmpdata = trim($snmpdata); $snmpdata = trim($snmpdata);
$snmpdata = str_replace("\"", "", $snmpdata); $snmpdata = str_replace("\"", "", $snmpdata);
list($sysUptime, $sysLocation, $sysContact) = explode("\n", $snmpdata); list($sysUptime, $sysLocation, $sysContact) = explode("\n", $snmpdata);
$sysDescr = trim(shell_exec($config['snmpget'] . " -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'] . " sysDescr.0")); $sysDescr = trim(shell_exec($config['snmpget'] . " -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " sysDescr.0"));
$sysUptime = str_replace("(", "", $sysUptime); $sysUptime = str_replace("(", "", $sysUptime);
$sysUptime = str_replace(")", "", $sysUptime); $sysUptime = str_replace(")", "", $sysUptime);
list($days, $hours, $mins, $secs) = explode(":", $sysUptime); list($days, $hours, $mins, $secs) = explode(":", $sysUptime);
+7 -5
View File
@@ -1,13 +1,15 @@
#!/usr/local/bin/php #!/usr/bin/php
<?php <?php
// //
// Interface Status Poller // Interface Status Poller
// //
include("config.php"); include("config.php");
include("functions.php"); include("includes/functions.php");
$interface_query = mysql_query("SELECT *, I.id AS sqlid FROM `interfaces` AS I, `devices` AS D where I.host = D.id AND D.status = '1' AND I.id LIKE '%" . $argv[1] . "' ORDER BY I.id DESC"); $interface_query = mysql_query("SELECT *, I.interface_id AS sqlid FROM `interfaces` AS I, `devices` AS D where I.device_id = D.device_id AND D.status = '1' AND I.device_id LIKE '%" . $argv[1] . "' ORDER BY I.device_id DESC");
var_dump($interface_query);
while ($interface = mysql_fetch_array($interface_query)) { while ($interface = mysql_fetch_array($interface_query)) {
$hostname = $interface['hostname']; $hostname = $interface['hostname'];
$host = $interface['host']; $host = $interface['host'];
@@ -22,7 +24,7 @@
$old_mac = $interface['mac']; $old_mac = $interface['mac'];
$old_up_admin = $interface['up_admin']; $old_up_admin = $interface['up_admin'];
$snmpver = $interface['snmpver']; $snmpver = $interface['snmpver'];
$snmp_cmd = "snmpget -O qv -".$interface['snmpver']." -c ".$interface['community']." ".$interface['hostname']." ifDescr.$ifIndex ifAdminStatus.$ifIndex ifOperStatus.$ifIndex "; $snmp_cmd = "snmpget -O qv -".$interface['snmpver']." -c ".$interface['community']." ".$interface['hostname'].":".$interface['port']." ifDescr.$ifIndex ifAdminStatus.$ifIndex ifOperStatus.$ifIndex ";
$snmp_cmd .= "ifAlias.$ifIndex 1.3.6.1.2.1.10.7.2.1.$ifIndex ifName.$ifIndex"; $snmp_cmd .= "ifAlias.$ifIndex 1.3.6.1.2.1.10.7.2.1.$ifIndex ifName.$ifIndex";
$snmp_output = trim(shell_exec($snmp_cmd)); $snmp_output = trim(shell_exec($snmp_cmd));
list($ifDescr, $ifAdminStatus, $ifOperStatus, $ifAlias, $ifDuplex, $ifName) = explode("\n", $snmp_output); list($ifDescr, $ifAdminStatus, $ifOperStatus, $ifAlias, $ifDuplex, $ifName) = explode("\n", $snmp_output);
+2 -2
View File
@@ -1,6 +1,6 @@
#!/usr/local/bin/bash #!/bin/bash
cd /usr/local/network cd /opt/observer/
./poll-ifstatus.php 1 & ./poll-ifstatus.php 1 &
./poll-ifstatus.php 2 & ./poll-ifstatus.php 2 &
./poll-ifstatus.php 3 & ./poll-ifstatus.php 3 &
+3 -2
View File
@@ -4,10 +4,11 @@
include("config.php"); include("config.php");
include("includes/functions.php"); include("includes/functions.php");
$device_query = mysql_query("SELECT device_id,hostname,os,community,snmpver FROM `devices` WHERE `device_id` LIKE '%" . $argv[1] . "' AND status = '1' ORDER BY device_id DESC"); $device_query = mysql_query("SELECT device_id,hostname,os,community,snmpver,port FROM `devices` WHERE `device_id` LIKE '%" . $argv[1] . "' AND status = '1' ORDER BY device_id DESC");
while ($device = mysql_fetch_array($device_query)) { while ($device = mysql_fetch_array($device_query)) {
$os = getHostOS($device['hostname'], $device['community'], $device[snmpver]);
$os = getHostOS($device['hostname'], $device['community'], $device['snmpver'], $device['port']);
if($os != $device['os']) { if($os != $device['os']) {
$sql = mysql_query("UPDATE `devices` SET `os` = '$os' WHERE `device_id` = '".$device['device_id']."'"); $sql = mysql_query("UPDATE `devices` SET `os` = '$os' WHERE `device_id` = '".$device['device_id']."'");
+4 -2
View File
@@ -15,6 +15,7 @@ while ($device = mysql_fetch_array($device_query)) {
$old_status = $device['status']; $old_status = $device['status'];
$community = $device['community']; $community = $device['community'];
$snmpver = $device['snmpver']; $snmpver = $device['snmpver'];
$port = $device['port'];
echo("$hostname\n"); echo("$hostname\n");
@@ -22,10 +23,10 @@ while ($device = mysql_fetch_array($device_query)) {
$status = trim($status); $status = trim($status);
if(strstr($status, "alive")) { if(strstr($status, "alive")) {
$pos = shell_exec($config['snmpget'] . " -$snmpver -c $community -t 1 $hostname sysDescr.0"); $pos = shell_exec($config['snmpget'] . " -$snmpver -c $community -t 1 $hostname:$port sysDescr.0");
if($pos == '') { if($pos == '') {
$status='0'; $status='0';
$posb = shell_exec($config['snmpget'] . " -$snmpver -c $community -t 1 $hostname 1.3.6.1.2.1.7526.2.4"); $posb = shell_exec($config['snmpget'] . " -$snmpver -c $community -t 1 $hostname:$port 1.3.6.1.2.1.7526.2.4");
if($posb == '') { } else { if($posb == '') { } else {
$status='1'; $status='1';
} }
@@ -36,6 +37,7 @@ while ($device = mysql_fetch_array($device_query)) {
$status='0'; $status='0';
} }
if($status != $device['status']) { if($status != $device['status']) {
if($device['sysContact']) { $email = $device['sysContact']; } else { $email = $config['email_default']; } if($device['sysContact']) { $email = $device['sysContact']; } else { $email = $config['email_default']; }
+2 -2
View File
@@ -20,7 +20,7 @@ while ($interface = mysql_fetch_array($interface_query)) {
echo("Looking at " . $interface['ifDescr'] . " on " . $device['hostname'] . "\n"); echo("Looking at " . $interface['ifDescr'] . " on " . $device['hostname'] . "\n");
$snmp_cmd = "snmpget -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'] . " ifName." . $interface['ifIndex']; $snmp_cmd = "snmpget -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " ifName." . $interface['ifIndex'];
$snmp_cmd .= " ifDescr." . $interface['ifIndex'] . " ifAdminStatus." . $interface['ifIndex'] . " ifOperStatus." . $interface['ifIndex'] . " "; $snmp_cmd .= " ifDescr." . $interface['ifIndex'] . " ifAdminStatus." . $interface['ifIndex'] . " ifOperStatus." . $interface['ifIndex'] . " ";
$snmp_cmd .= "ifAlias." . $interface['ifIndex'] . " ifSpeed." . $interface['ifIndex'] . " 1.3.6.1.2.1.10.7.2.1." . $interface['ifIndex']; $snmp_cmd .= "ifAlias." . $interface['ifIndex'] . " ifSpeed." . $interface['ifIndex'] . " 1.3.6.1.2.1.10.7.2.1." . $interface['ifIndex'];
$snmp_cmd .= " ifType." . $interface['ifIndex'] . " ifMtu." . $interface['ifIndex'] . " ifPhysAddress." . $interface['ifIndex']; $snmp_cmd .= " ifType." . $interface['ifIndex'] . " ifMtu." . $interface['ifIndex'] . " ifPhysAddress." . $interface['ifIndex'];
@@ -32,7 +32,7 @@ while ($interface = mysql_fetch_array($interface_query)) {
if($device['os'] == "IOS") { if($device['os'] == "IOS") {
$snmp_cmdb = "snmpget -M /usr/share/snmp/mibs/ -m CISCO-VLAN-MEMBERSHIP-MIB -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname']; $snmp_cmdb = "snmpget -M /usr/share/snmp/mibs/ -m CISCO-VLAN-MEMBERSHIP-MIB -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'];
$snmp_cmdb .= " .1.3.6.1.4.1.9.2.2.1.1.1." . $interface['ifIndex']; $snmp_cmdb .= " .1.3.6.1.4.1.9.2.2.1.1.1." . $interface['ifIndex'];
$snmp_cmdb .= " .1.3.6.1.4.1.9.9.68.1.2.2.1.2." . $interface['ifIndex']; $snmp_cmdb .= " .1.3.6.1.4.1.9.9.68.1.2.2.1.2." . $interface['ifIndex'];
$snmp_cmdb .= " .1.3.6.1.4.1.9.9.46.1.6.1.1.16." . $interface['ifIndex']; $snmp_cmdb .= " .1.3.6.1.4.1.9.9.46.1.6.1.1.16." . $interface['ifIndex'];