fix junos (change to snmp_get function) and fix poller detection and setting of up/down

git-svn-id: http://www.observium.org/svn/observer/trunk@876 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Adam Amstrong
2010-02-16 23:14:02 +00:00
parent af7dcfcff0
commit ba9246f60d
2 changed files with 21 additions and 25 deletions

View File

@@ -7,8 +7,8 @@ if(strpos($sysDescr, "olive")) {
$hardware = "Olive";
$serial = "";
} else {
$hardware = snmp_get($device, ".1.3.6.1.4.1.2636.3.1.2.0", "OQv", "+JUNIPER-MIB", "+".$config['install_dir']."/mibs/junos");
$serial = snmp_get($device, ".1.3.6.1.4.1.2636.3.1.3.0", "OQv", "+JUNIPER-MIB", "+".$config['install_dir']."/mibs/junos");
$hardware = snmp_get($device, ".1.3.6.1.4.1.2636.3.1.2.0", "-OQv", "+JUNIPER-MIB", "+".$config['install_dir']."/mibs/junos");
$serial = snmp_get($device, ".1.3.6.1.4.1.2636.3.1.3.0", "-OQv", "+JUNIPER-MIB", "+".$config['install_dir']."/mibs/junos");
list(,$hardware,) = explode(" ", $hardware);
$hardware = "Juniper " . $hardware;
}

View File

@@ -59,18 +59,27 @@ while ($device = mysql_fetch_array($device_query)) {
if ($pingable) { echo("Pings : yes :)\n"); } else { echo("Pings : no :(\n"); }
$snmpable = FALSE;
if ($pingable) {
$snmpable = isSNMPable($device['hostname'], $device['community'], $device['snmpver'], $device['port']);
if ($snmpable) { echo("SNMP : yes :)\n"); } else { echo("SNMP : no :(\n"); }
if (isSNMPable($device['hostname'], $device['community'], $device['snmpver'], $device['port'])) {
echo("SNMP : yes :)\n");
$status = "1";
} else {
echo("SNMP : no :(\n");
$status = "0";
}
} else {
$status = "0";
}
unset($snmpdata);
if ( $device['status'] != $status ) {
$update .= $seperator . "`status` = '$status'";
$seperator = ", ";
mysql_query("UPDATE `devices` SET `status` = '".$status."' WHERE `device_id` = '".$device['device_id']."'");
mysql_query("INSERT INTO alerts (importance, device_id, message) VALUES ('0', '" . $device['device_id'] . "', 'Device is " . ($status == '1' ? 'up' : 'down') . "')");
eventlog('Device status changed to ' . ($status == '1' ? 'Up' : 'Down'), $device['device_id']);
}
if ($snmpable) {
$status = '1';
if ($status) {
$snmp_cmd = $config['snmpget'] . " -m SNMPv2-MIB -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'];
$snmp_cmd .= " sysUpTime.0 sysLocation.0 sysContact.0 sysName.0";
$snmpdata = shell_exec($snmp_cmd);
@@ -99,7 +108,6 @@ while ($device = mysql_fetch_array($device_query)) {
echo("Generic :(");
}
$sysLocation = str_replace("\"","", $sysLocation);
include("includes/polling/temperatures.inc.php");
@@ -180,22 +188,10 @@ while ($device = mysql_fetch_array($device_query)) {
$seperator = ", ";
}
$update .= $seperator . "`last_polled` = NOW()";
$seperator = ", ";
$polled_devices++;
echo("\n");
} else {
$update_query = "UPDATE `devices` SET ";
$update_query .= " `status` = '0'";
$update_query .= " WHERE `device_id` = '" . $device['device_id'] . "'";
echo("Updating " . $device['hostname'] . "\n");
$update_result = mysql_query($update_query);
}
if ( $device['status'] != $status ) {
$update .= $seperator . "`status` = '$status'";
$seperator = ", ";
mysql_query("INSERT INTO alerts (importance, device_id, message) VALUES ('0', '" . $device['device_id'] . "', 'Device is " . ($status == '1' ? 'up' : 'down') . "')");
eventlog('Device status changed to ' . ($status == '1' ? 'Up' : 'Down'), $device['device_id']);
}
}
if ($update) {
$update_query = "UPDATE `devices` SET ";