Minor fixes, some cleanups, and standardising on echo("x") instead of echo "x"

git-svn-id: http://www.observium.org/svn/observer/trunk@1728 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Tom Laermans
2010-11-20 14:04:07 +00:00
parent 0cd548f0f2
commit 30bdd952ee
63 changed files with 199 additions and 283 deletions
+2 -2
View File
@@ -8,7 +8,7 @@ $mysql_cmd .= " nsExtendOutputFull.5.109.121.115.113.108";
$mysql = shell_exec($mysql_cmd);
echo " mysql...";
echo(" mysql...");
$data = explode("\n", $mysql);
@@ -110,5 +110,5 @@ if (!is_file($mysql_rrd)) {
}
rrdtool_update($mysql_rrd, "N:$nstring");
echo "done ";
echo("done ");
?>
+1 -1
View File
@@ -8,7 +8,7 @@ $nginx_cmd .= " nsExtendOutputFull.5.110.103.105.110.120";
$nginx = shell_exec($nginx_cmd);
echo " nginx statistics\n";
echo(" nginx statistics\n");
list($active, $reading, $writing, $waiting, $req) = explode("\n", $nginx);
if (!is_file($nginx_rrd)) {
+7 -7
View File
@@ -15,7 +15,7 @@ while($peer = mysql_fetch_array($peers)) {
if (!strstr($peer['bgpPeerIdentifier'],':'))
{
# v4 BGP4 MIB
## FIX ME - needs moved to function
## FIXME - needs moved to function
$peer_cmd = $config['snmpget'] . " -M ".$config['mibdir'] . " -m BGP4-MIB -OUvq -" . $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 .= "bgpPeerOutTotalMessages." . $peer['bgpPeerIdentifier'] . " bgpPeerFsmEstablishedTime." . $peer['bgpPeerIdentifier'] . " bgpPeerInUpdateElapsedTime." . $peer['bgpPeerIdentifier'] . " ";
@@ -31,8 +31,8 @@ if ($device['os'] == "junos")
if (!isset($junos_v6))
{
echo "\nCaching Oids...";
## FIX ME - needs moved to function
echo("\nCaching Oids...");
## FIXME - needs moved to function
$peer_cmd = $config['snmpwalk'] . " -M ".$config['mibdir'] . "/junos -m BGP4-V2-MIB-JUNIPER -OUnq -" . $device['snmpver'] . " -c" . $device['community'] . " " . $device['hostname'].":".$device['port'];
$peer_cmd .= " jnxBgpM2PeerStatus.0.ipv6";
foreach (explode("\n",trim(`$peer_cmd`)) as $oid)
@@ -42,7 +42,7 @@ if ($device['os'] == "junos")
$junos_v6[implode('.',array_slice($peer_id,35))] = implode('.',array_slice($peer_id,18));
}
}
## FIX ME - move to function (and clean up, wtf?)
## FIXME - move to function (and clean up, wtf?)
$peer_cmd = $config['snmpget'] . " -M ".$config['mibdir'] . "/junos -m BGP4-V2-MIB-JUNIPER -OUvq -" . $device['snmpver'] . " -c" . $device['community'] . " " . $device['hostname'].":".$device['port'];
$peer_cmd .= " jnxBgpM2PeerState.0.ipv6." . $junos_v6[$peer_ip];
$peer_cmd .= " jnxBgpM2PeerStatus.0.ipv6." . $junos_v6[$peer_ip]; # Should be jnxBgpM2CfgPeerAdminStatus but doesn't seem to be implemented?
@@ -54,11 +54,11 @@ if ($device['os'] == "junos")
$peer_cmd .= " jnxBgpM2PeerInUpdatesElapsedTime.0.ipv6." . $junos_v6[$peer_ip];
$peer_cmd .= " jnxBgpM2PeerLocalAddr.0.ipv6." . $junos_v6[$peer_ip];
$peer_cmd .= ' -M"' . $config['install_dir'] . '/mibs/junos"|grep -v "No Such Instance"';
if ($debug) echo "\n$peer_cmd\n";
if ($debug) echo("\n$peer_cmd\n");
$peer_data = trim(`$peer_cmd`);
list($bgpPeerState, $bgpPeerAdminStatus, $bgpPeerInUpdates, $bgpPeerOutUpdates, $bgpPeerInTotalMessages, $bgpPeerOutTotalMessages, $bgpPeerFsmEstablishedTime, $bgpPeerInUpdateElapsedTime, $bgpLocalAddr) = explode("\n", $peer_data);
if ($debug) { echo "State = $bgpPeerState - AdminStatus: $bgpPeerAdminStatus\n"; }
if ($debug) { echo("State = $bgpPeerState - AdminStatus: $bgpPeerAdminStatus\n"); }
$bgpLocalAddr = str_replace('"','',str_replace(' ','',$bgpLocalAddr));
if ($bgpLocalAddr == "00000000000000000000000000000000")
@@ -131,7 +131,7 @@ if ($device['os'] == "junos")
$afi = $peer_afi['afi'];
$safi = $peer_afi['safi'];
if($debug) { echo("$afi $safi". $config['afi'][$afi][$safi]. "\n"); }
## FIX ME - move to function
## FIXME - move to function
$cbgp_cmd = $config['snmpget'] . " -M ".$config['mibdir'] . " -m CISCO-BGP4-MIB -Ovq -" . $device['snmpver'] . " -c" . $device['community'] . " " . $device['hostname'].":".$device['port'];
$cbgp_cmd .= " cbgpPeerAcceptedPrefixes." . $peer['bgpPeerIdentifier'] . ".$afi.$safi";
$cbgp_cmd .= " cbgpPeerDeniedPrefixes." . $peer['bgpPeerIdentifier'] . ".$afi.$safi";
+1 -2
View File
@@ -28,12 +28,11 @@ while($fanspeed = mysql_fetch_array($fan_data)) {
rrdtool_update($fanrrd,"N:$fan");
if($fanspeed['sensor_current'] > $fanspeed['sensor_limit'] && $fan <= $fanspeed['sensor_limit']) {
if($device['sysContact']) { $email = $device['sysContact']; } else { $email = $config['email_default']; }
$msg = "Fan Alarm: " . $device['hostname'] . " " . $fanspeed['sensor_descr'] . " is " . $fan . "rpm (Limit " . $fanspeed['sensor_limit'];
$msg .= "rpm) at " . date($config['timestamp_format']);
notify($device, "Fan Alarm: " . $device['hostname'] . " " . $fanspeed['sensor_descr'], $msg);
echo("Alerting for " . $device['hostname'] . " " . $fanspeed['sensor_descr'] . "\n");
log_event('Fan speed ' . $fanspeed['sensor_descr'] . " under threshold: " . $fanspeed['sensor_current'] . " rpm (&gt; " . $fanspeed['sensor_limit'] . " rpm)", $device['device_id'], 'fanspeed', $fanspeed['sensor_id']);
log_event('Fan speed ' . $fanspeed['sensor_descr'] . " under threshold: " . $fanspeed['sensor_current'] . " rpm (> " . $fanspeed['sensor_limit'] . " rpm)", $device['device_id'], 'fanspeed', $fanspeed['sensor_id']);
}
mysql_query("UPDATE sensors SET sensor_current = '$fan' WHERE sensor_class='fanspeed' AND sensor_id = '" . $fanspeed['sensor_id'] . "'");
-2
View File
@@ -29,7 +29,6 @@ while($sensor = mysql_fetch_array($sensor_data)) {
if($sensor['sensor_current'] > $sensor['sensor_limit_low'] && $freq <= $sensor['sensor_limit_low'])
{
if($device['sysContact']) { $email = $device['sysContact']; } else { $email = $config['email_default']; }
$msg = "Frequency Alarm: " . $device['hostname'] . " " . $sensor['sensor_descr'] . " is " . $freq . "Hz (Limit " . $sensor['sensor_limit'];
$msg .= "Hz) at " . date($config['timestamp_format']);
notify($device, "Frequency Alarm: " . $device['hostname'] . " " . $sensor['sensor_descr'], $msg);
@@ -38,7 +37,6 @@ while($sensor = mysql_fetch_array($sensor_data)) {
}
else if($sensor['sensor_current'] < $sensor['sensor_limit'] && $freq >= $sensor['sensor_limit'])
{
if($device['sysContact']) { $email = $device['sysContact']; } else { $email = $config['email_default']; }
$msg = "Frequency Alarm: " . $device['hostname'] . " " . $sensor['sensor_descr'] . " is " . $freq . "Hz (Limit " . $sensor['sensor_limit'];
$msg .= "Hz) at " . date($config['timestamp_format']);
notify($device, "Frequency Alarm: " . $device['hostname'] . " " . $sensor['sensor_descr'], $msg);
-2
View File
@@ -32,7 +32,6 @@ while($humidity = mysql_fetch_array($hum_data)) {
if($humidity['sensor_current'] > $humidity['sensor_limit_low'] && $hum <= $humidity['sensor_limit_low'])
{
if($device['sysContact']) { $email = $device['sysContact']; } else { $email = $config['email_default']; }
$msg = "Humidity Alarm: " . $device['hostname'] . " " . $humidity['sensor_descr'] . " is " . $hum . "% (Limit " . $humidity['sensor_limit'];
$msg .= "%) at " . date($config['timestamp_format']);
notify($device, "Humidity Alarm: " . $device['hostname'] . " " . $humidity['sensor_descr'], $msg);
@@ -41,7 +40,6 @@ while($humidity = mysql_fetch_array($hum_data)) {
}
else if($humidity['sensor_current'] < $humidity['sensor_limit'] && $hum >= $humidity['sensor_limit'])
{
if($device['sysContact']) { $email = $device['sysContact']; } else { $email = $config['email_default']; }
$msg = "Humidity Alarm: " . $device['hostname'] . " " . $humidity['sensor_descr'] . " is " . $hum . "% (Limit " . $humidity['sensor_limit'];
$msg .= "%) at " . date($config['timestamp_format']);
notify($device, "Humidity Alarm: " . $device['hostname'] . " " . $humidity['sensor_descr'], $msg);
+1 -1
View File
@@ -40,7 +40,7 @@ if (is_numeric($cpu_usage))
RRA:MIN:0.5:24:2000 \
RRA:MIN:0.5:288:2000");
}
echo "CPU: $cpu_usage%\n";
echo("CPU: $cpu_usage%\n");
rrdtool_update($cpurrd, " N:$cpu_usage");
}
+4 -4
View File
@@ -8,7 +8,7 @@ while($temperature = mysql_fetch_array($temp_data)) {
for ($i = 0;$i < 5;$i++) # Try 5 times to get a valid temp reading
{
if ($debug) echo "Attempt $i ";
if ($debug) echo("Attempt $i ");
$temp_cmd = $config['snmpget'] . " -M ".$config['mibdir'] . " -m SNMPv2-MIB -O Uqnv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " " . $temperature['sensor_oid'] . "|grep -v \"No Such Instance\"";
$temp = trim(str_replace("\"", "", shell_exec($temp_cmd)));
@@ -46,13 +46,13 @@ while($temperature = mysql_fetch_array($temp_data)) {
rrdtool_update($rrd_file,"N:$temp");
if($temperature['sensor_current'] < $temperature['sensor_limit'] && $temp >= $temperature['sensor_limit']) {
if($device['sysContact']) { $email = $device['sysContact']; } else { $email = $config['email_default']; }
if($temperature['sensor_current'] < $temperature['sensor_limit'] && $temp >= $temperature['sensor_limit'])
{
$msg = "Temp Alarm: " . $device['hostname'] . " " . $temperature['sensor_descr'] . " is " . $temp . " (Limit " . $temperature['sensor_limit'];
$msg .= ") at " . date($config['timestamp_format']);
notify($device, "Temp Alarm: " . $device['hostname'] . " " . $temperature['sensor_descr'], $msg);
echo("Alerting for " . $device['hostname'] . " " . $temperature['sensor_descr'] . "\n");
log_event('Temperature ' . $temperature['sensor_descr'] . " over threshold: " . $temp . " °C (> " . $temperature['sensor_limit'] . " °C)", $device['device_id'], 'temperature', $temperature['sensor_id']);
log_event('Temperature ' . $temperature['sensor_descr'] . " over threshold: " . $temp . " " . html_entity_decode('&deg;') . "C (> " . $temperature['sensor_limit'] . " " . html_entity_decode('&deg;') . 'C)', $device['device_id'], 'temperature', $temperature['sensor_id']);
}
mysql_query("UPDATE sensors SET sensor_current = '$temp' WHERE sensor_class='temperature' AND sensor_id = '" . $temperature['sensor_id'] . "'");
-2
View File
@@ -32,7 +32,6 @@ while($sensor = mysql_fetch_array($volt_data)) {
if($sensor['sensor_current'] > $sensor['sensor_limit_low'] && $volt <= $sensor['sensor_limit_low'])
{
if($device['sysContact']) { $email = $device['sysContact']; } else { $email = $config['email_default']; }
$msg = "Voltage Alarm: " . $device['hostname'] . " " . $sensor['sensor_descr'] . " is " . $volt . "V (Limit " . $sensor['sensor_limit'];
$msg .= "V) at " . date($config['timestamp_format']);
notify($device, "Voltage Alarm: " . $device['hostname'] . " " . $sensor['sensor_descr'], $msg);
@@ -41,7 +40,6 @@ while($sensor = mysql_fetch_array($volt_data)) {
}
else if($sensor['sensor_current'] < $sensor['sensor_limit'] && $volt >= $sensor['sensor_limit'])
{
if($device['sysContact']) { $email = $device['sysContact']; } else { $email = $config['email_default']; }
$msg = "Voltage Alarm: " . $device['hostname'] . " " . $sensor['sensor_descr'] . " is " . $volt . "V (Limit " . $sensor['sensor_limit'];
$msg .= "V) at " . date($config['timestamp_format']);
notify($device, "Voltage Alarm: " . $device['hostname'] . " " . $sensor['sensor_descr'], $msg);
+5 -5
View File
@@ -1,6 +1,6 @@
<?php
echo "Wireless: ";
echo("Wireless: ");
if ($device['type'] == 'network')
{
@@ -9,7 +9,7 @@ if ($device['type'] == 'network')
if ($device['os'] == 'airport')
{
echo "Checking Airport Wireless clients... ";
echo("Checking Airport Wireless clients... ");
$wificlients1 = snmp_get($device, "wirelessNumber.0", "-OUqnv", "AIRPORT-BASESTATION-3-MIB") +0;
@@ -21,12 +21,12 @@ if ($device['type'] == 'network')
if ($device['os'] == 'ios' and substr($device['hardware'],0,4) == 'AIR-')
{
echo "Checking Aironet Wireless clients... ";
echo("Checking Aironet Wireless clients... ");
$wificlients1 = snmp_get($device, "cDot11ActiveWirelessClients.1", "-OUqnv", "CISCO-DOT11-ASSOCIATION-MIB");
$wificlients2 = snmp_get($device, "cDot11ActiveWirelessClients.2", "-OUqnv", "CISCO-DOT11-ASSOCIATION-MIB");
echo ($wificlients1 +0) . " clients on dot11Radio0, " . ($wificlients2 +0) . " clients on dot11Radio1\n";
echo(($wificlients1 +0) . " clients on dot11Radio0, " . ($wificlients2 +0) . " clients on dot11Radio1\n");
}
@@ -76,6 +76,6 @@ if ($device['type'] == 'network')
}
echo "\n";
echo("\n");
?>