erm, forgot to add quite a bunch of files to the repo for the last few commits :/

git-svn-id: http://www.observium.org/svn/observer/trunk@1097 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Tom Laermans 2010-06-04 09:05:42 +00:00
parent 389ea564d5
commit bdf1cdf7f6
8 changed files with 8093 additions and 0 deletions

View File

@ -0,0 +1,56 @@
<?php
include("common.inc.php");
$device = device_by_id_cache($id);
$rrd_options .= " -l 0 -E ";
$iter = "1";
$sql = mysql_query("SELECT * FROM frequency where device_id = '$id'");
$rrd_options .= " COMMENT:' Cur Min Max\\n'";
while($frequency = mysql_fetch_array($sql))
{
switch ($iter)
{
case "1":
$colour= "CC0000";
break;
case "2":
$colour= "008C00";
break;
case "3":
$colour= "4096EE";
break;
case "4":
$colour= "73880A";
break;
case "5":
$colour= "D01F3C";
break;
case "6":
$colour= "36393D";
break;
case "7":
default:
$colour= "FF0084";
unset($iter);
break;
}
$hostname = gethostbyid($frequency['device_id']);
$descr = substr(str_pad($frequency['freq_descr'], 15),0,15);
$rrd_filename = $config['rrd_dir'] . "/".$device['hostname']."/" . safename("freq-" . $frequency['freq_descr'] . ".rrd");
$freq_id = $frequency['freq_id'];
$rrd_options .= " DEF:freq$freq_id=$rrd_filename:freq:AVERAGE";
$rrd_options .= " LINE1:freq$freq_id#".$colour.":'" . $descr . "'";
$rrd_options .= " GPRINT:freq$freq_id:AVERAGE:%5.2lfHz";
$rrd_options .= " GPRINT:freq$freq_id:MIN:%5.2lfHz";
$rrd_options .= " GPRINT:freq$freq_id:MAX:%5.2lfHz\\\\l";
$iter++;
}
?>

View File

@ -0,0 +1,23 @@
<?php
$scale_min = "0";
include("common.inc.php");
$rrd_options .= " COMMENT:' Last Max\\n'";
$frequency = mysql_fetch_array(mysql_query("SELECT * FROM frequency where freq_id = '".mres($_GET['id'])."'"));
$hostname = mysql_result(mysql_query("SELECT hostname FROM devices WHERE device_id = '" . $frequency['device_id'] . "'"),0);
$frequency['freq_descr_fixed'] = substr(str_pad($frequency['freq_descr'], 28),0,28);
$rrd_filename = $config['rrd_dir'] . "/".$hostname."/" . safename("freq-" . $frequency['freq_descr'] . ".rrd");
$rrd_options .= " DEF:freq=$rrd_filename:freq:AVERAGE";
$rrd_options .= " AREA:freq#FFFF99";
$rrd_options .= " LINE1.5:freq#cc0000:'" . $frequency['freq_descr_fixed']."'";
$rrd_options .= " GPRINT:freq:LAST:%3.0lfHz";
$rrd_options .= " GPRINT:freq:MAX:%3.0lfHz\\\\l";
?>

View File

@ -0,0 +1,61 @@
<?php
if($_SESSION['userlevel'] >= '5') {
$sql = "SELECT * FROM `frequency` AS V, `devices` AS D WHERE V.device_id = D.device_id ORDER BY D.hostname, V.freq_descr";
} else {
$sql = "SELECT * FROM `frequency` AS V, `devices` AS D, devices_perms as P WHERE V.device_id = D.device_id AND D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' ORDER BY D.hostname, V.freq_descr";
}
$query = mysql_query($sql);
echo('<table cellspacing="0" cellpadding="2" width="100%">');
echo('<tr class=tablehead>
<th width="280">Device</th>
<th width="180">Sensor</th>
<th></th>
<th></th>
<th width="100">Current</th>
<th width="250">Range limit</th>
<th>Notes</th>
</tr>');
$row = 1;
while($freq = mysql_fetch_array($query))
{
if(is_integer($row/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; }
$weekly_freq = "graph.php?id=" . $freq['freq_id'] . "&amp;type=frequency&amp;from=$week&amp;to=$now&amp;width=500&amp;height=150";
$freq_popup = "<a onmouseover=\"return overlib('<img src=\'$weekly_freq\'>', LEFT);\" onmouseout=\"return nd();\">
" . $freq['freq_descr'] . "</a>";
if($freq['freq_current'] >= $freq['freq_limit']) { $alert = '<img src="images/16/flag_red.png" alt="alert" />'; } else { $alert = ""; }
$freq_day = "graph.php?id=" . $freq['freq_id'] . "&amp;type=frequency&amp;from=$day&amp;to=$now&amp;width=300&amp;height=100";
$freq_week = "graph.php?id=" . $freq['freq_id'] . "&amp;type=frequency&amp;from=$week&amp;to=$now&amp;width=300&amp;height=100";
$freq_month = "graph.php?id=" . $freq['freq_id'] . "&amp;type=frequency&amp;from=$month&amp;to=$now&amp;width=300&amp;height=100";
$freq_year = "graph.php?id=" . $freq['freq_id'] . "&amp;type=frequency&amp;from=$year&amp;to=$now&amp;width=300&amp;height=100";
$freq_minigraph = "<img src='graph.php?id=" . $freq['freq_id'] . "&amp;type=frequency&amp;from=$day&amp;to=$now&amp;width=100&amp;height=20'";
$freq_minigraph .= " onmouseover=\"return overlib('<div class=list-large>".$freq['hostname']." - ".$freq['freq_descr'];
$freq_minigraph .= "</div><div style=\'width: 750px\'><img src=\'$freq_day\'><img src=\'$freq_week\'><img src=\'$freq_month\'><img src=\'$freq_year\'></div>', RIGHT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\" >";
echo("<tr bgcolor=$row_colour>
<td class=list-bold>" . generatedevicelink($freq) . "</td>
<td>$freq_popup</td>
<td>$freq_minigraph</td>
<td width=100>$alert</td>
<td style='text-align: center; font-weight: bold;'>" . $freq['freq_current'] . "Hz</td>
<td style='text-align: center'>" . $freq['freq_limit_low'] . "Hz - " . $freq['freq_limit'] . "Hz</td>
<td>" . (isset($freq['freq_notes']) ? $freq['freq_notes'] : '') . "</td>
</tr>\n");
$row++;
}
echo("</table>");
?>

View File

@ -0,0 +1,202 @@
<?php
$id = $device['device_id'];
$hostname = $device['hostname'];
$community = $device['community'];
$snmpver = $device['snmpver'];
$port = $device['port'];
echo("Frequencies : ");
## MGE UPS Frequencies
if ($device['os'] == "mgeups")
{
echo("MGE ");
$oids = trim(snmp_walk($device, "1.3.6.1.4.1.705.1.7.1", "-OsqnU"));
if ($debug) { echo($oids."\n"); }
list($unused,$numPhase) = explode(' ',$oids);
for($i = 1; $i <= $numPhase;$i++)
{
$freq_oid = ".1.3.6.1.4.1.705.1.7.2.1.3.$i.0";
$descr = "Output"; if ($numPhase > 1) $descr .= " Phase $i";
$current = snmp_get($device, $freq_oid, "-Oqv") / 10;
$type = "mge-ups";
$precision = 10;
$index = $i;
if ($current > 55 && $current < 65)
{
#FIXME Are these sensible values?
$lowlimit = 58;
$limit = 62;
}
else if ($current > 45 && $current < 55)
{
#FIXME Are these sensible values?
$lowlimit = 48;
$limit = 52;
}
else
{
$lowlimit = 0;
$limit = 0;
}
echo discover_freq($device, $freq_oid, $index, $type, $descr, $precision, $lowlimit, $limit, $current);
$freq_exists[$type][$index] = 1;
}
$oids = trim(snmp_walk($device, "1.3.6.1.4.1.705.1.6.1", "-OsqnU"));
if ($debug) { echo($oids."\n"); }
list($unused,$numPhase) = explode(' ',$oids);
for($i = 1; $i <= $numPhase;$i++)
{
$freq_oid = ".1.3.6.1.4.1.705.1.6.2.1.3.$i.0";
$descr = "Input"; if ($numPhase > 1) $descr .= " Phase $i";
$current = snmp_get($device, $freq_oid, "-Oqv") / 10;
$type = "mge-ups";
$precision = 10;
$index = 100+$i;
if ($current > 55 && $current < 65)
{
#FIXME Are these sensible values?
$lowlimit = 58;
$limit = 62;
}
else if ($current > 45 && $current < 55)
{
#FIXME Are these sensible values?
$lowlimit = 48;
$limit = 52;
}
else
{
$lowlimit = 0;
$limit = 0;
}
echo discover_freq($device, $freq_oid, $index, $type, $descr, $precision, $lowlimit, $limit, $current);
$freq_exists[$type][$index] = 1;
}
}
## Delete removed sensors
if($debug) { print_r($freq_exists); }
$sql = "SELECT * FROM frequency WHERE device_id = '".$device['device_id']."'";
if ($query = mysql_query($sql))
{
while ($test_freq = mysql_fetch_array($query))
{
$index = $test_freq['freq_index'];
$type = $test_freq['freq_type'];
if($debug) { echo("$type -> $index\n"); }
if(!$freq_exists[$type][$index]) {
echo("-");
mysql_query("DELETE FROM `frequency` WHERE freq_id = '" . $test_freq['freq_id'] . "'");
}
}
}
unset($fan_exists); echo("\n");
?>
<?php
$id = $device['device_id'];
$hostname = $device['hostname'];
$community = $device['community'];
$snmpver = $device['snmpver'];
$port = $device['port'];
echo("Frequencies : ");
## MGE UPS Frequencies
if ($device['os'] == "mgeups")
{
echo("MGE ");
$oids = trim(snmp_walk($device, "1.3.6.1.4.1.705.1.7.1", "-OsqnU"));
if ($debug) { echo($oids."\n"); }
list($unused,$numPhase) = explode(' ',$oids);
for($i = 1; $i <= $numPhase;$i++)
{
$freq_oid = ".1.3.6.1.4.1.705.1.7.2.1.3.$i.0";
$descr = "Output"; if ($numPhase > 1) $descr .= " Phase $i";
$current = snmp_get($device, $freq_oid, "-Oqv") / 10;
$type = "mge-ups";
$precision = 10;
$index = $i;
if ($current > 55 && $current < 65)
{
#FIXME Are these sensible values?
$lowlimit = 58;
$limit = 62;
}
else if ($current > 45 && $current < 55)
{
#FIXME Are these sensible values?
$lowlimit = 48;
$limit = 52;
}
else
{
$lowlimit = 0;
$limit = 0;
}
echo discover_freq($device, $freq_oid, $index, $type, $descr, $precision, $lowlimit, $limit, $current);
$freq_exists[$type][$index] = 1;
}
$oids = trim(snmp_walk($device, "1.3.6.1.4.1.705.1.6.1", "-OsqnU"));
if ($debug) { echo($oids."\n"); }
list($unused,$numPhase) = explode(' ',$oids);
for($i = 1; $i <= $numPhase;$i++)
{
$freq_oid = ".1.3.6.1.4.1.705.1.6.2.1.3.$i.0";
$descr = "Input"; if ($numPhase > 1) $descr .= " Phase $i";
$current = snmp_get($device, $freq_oid, "-Oqv") / 10;
$type = "mge-ups";
$precision = 10;
$index = 100+$i;
if ($current > 55 && $current < 65)
{
#FIXME Are these sensible values?
$lowlimit = 58;
$limit = 62;
}
else if ($current > 45 && $current < 55)
{
#FIXME Are these sensible values?
$lowlimit = 48;
$limit = 52;
}
else
{
$lowlimit = 0;
$limit = 0;
}
echo discover_freq($device, $freq_oid, $index, $type, $descr, $precision, $lowlimit, $limit, $current);
$freq_exists[$type][$index] = 1;
}
}
## Delete removed sensors
if($debug) { print_r($freq_exists); }
$sql = "SELECT * FROM frequency WHERE device_id = '".$device['device_id']."'";
if ($query = mysql_query($sql))
{
while ($test_freq = mysql_fetch_array($query))
{
$index = $test_freq['freq_index'];
$type = $test_freq['freq_type'];
if($debug) { echo("$type -> $index\n"); }
if(!$freq_exists[$type][$index]) {
echo("-");
mysql_query("DELETE FROM `frequency` WHERE freq_id = '" . $test_freq['freq_id'] . "'");
}
}
}
unset($fan_exists); echo("\n");
?>

View File

@ -0,0 +1,30 @@
<?php
$id = $device['device_id'];
$hostname = $device['hostname'];
$community = $device['community'];
$snmpver = $device['snmpver'];
$port = $device['port'];
echo("UPS : ");
?>
<?php
$id = $device['device_id'];
$hostname = $device['hostname'];
$community = $device['community'];
$snmpver = $device['snmpver'];
$port = $device['port'];
echo("UPS : ");
?>
<?php
$id = $device['device_id'];
$hostname = $device['hostname'];
$community = $device['community'];
$snmpver = $device['snmpver'];
$port = $device['port'];
echo("UPS : ");
?>

View File

@ -0,0 +1,27 @@
<?php
if(!$os) {
if(strstr($sysDescr, "Pulsar M")) { $os = "mgeups"; }
}
?>
<?php
if(!$os) {
if(strstr($sysDescr, "Pulsar M")) { $os = "mgeups"; }
}
?>
<?php
if(!$os) {
if(strstr($sysDescr, "Pulsar M")) { $os = "mgeups"; }
}
?>

View File

@ -0,0 +1,110 @@
<?php
$query = "SELECT * FROM frequency WHERE device_id = '" . $device['device_id'] . "'";
$freq_data = mysql_query($query);
while($frequency = mysql_fetch_array($freq_data)) {
echo("Checking frequency " . $frequency['freq_descr'] . "... ");
$freq_cmd = $config['snmpget'] . " -m SNMPv2-MIB -O Uqnv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " " . $frequency['freq_oid'] . "|grep -v \"No Such Instance\"";
$freq = trim(str_replace("\"", "", shell_exec($freq_cmd)));
if ($frequency['freq_precision'])
{
$freq = $freq / $frequency['freq_precision'];
}
$freqrrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("freq-" . $frequency['freq_descr'] . ".rrd");
if (!is_file($freqrrd)) {
`rrdtool create $freqrrd \
--step 300 \
DS:freq:GAUGE:600:-273:1000 \
RRA:AVERAGE:0.5:1:1200 \
RRA:MIN:0.5:12:2400 \
RRA:MAX:0.5:12:2400 \
RRA:AVERAGE:0.5:12:2400`;
}
echo($freq . " Hz\n");
rrdtool_update($freqrrd,"N:$freq");
if($frequency['freq_current'] > $frequency['freq_limit_low'] && $freq <= $frequency['freq_limit_low'])
{
if($device['sysContact']) { $email = $device['sysContact']; } else { $email = $config['email_default']; }
$msg = "Frequency Alarm: " . $device['hostname'] . " " . $frequency['freq_descr'] . " is " . $freq . "Hz (Limit " . $frequency['freq_limit'];
$msg .= "Hz) at " . date($config['timestamp_format']);
mail($email, "Frequency Alarm: " . $device['hostname'] . " " . $frequency['freq_descr'], $msg, $config['email_headers']);
echo("Alerting for " . $device['hostname'] . " " . $frequency['freq_descr'] . "\n");
eventlog('Frequency ' . $frequency['freq_descr'] . " under threshold: " . $frequency['freq_current'] . " Hz (> " . $frequency['freq_limit'] . " Hz)", $device['device_id']);
}
else if($frequency['freq_current'] < $frequency['freq_limit'] && $freq >= $frequency['freq_limit'])
{
if($device['sysContact']) { $email = $device['sysContact']; } else { $email = $config['email_default']; }
$msg = "Frequency Alarm: " . $device['hostname'] . " " . $frequency['freq_descr'] . " is " . $freq . "Hz (Limit " . $frequency['freq_limit'];
$msg .= "Hz) at " . date($config['timestamp_format']);
mail($email, "Frequency Alarm: " . $device['hostname'] . " " . $frequency['freq_descr'], $msg, $config['email_headers']);
echo("Alerting for " . $device['hostname'] . " " . $frequency['freq_descr'] . "\n");
eventlog('Frequency ' . $frequency['freq_descr'] . " above threshold: " . $frequency['freq_current'] . " Hz (< " . $frequency['freq_limit'] . " Hz)", $device['device_id']);
}
mysql_query("UPDATE frequency SET freq_current = '$freq' WHERE freq_id = '" . $frequency['freq_id'] . "'");
}
?>
<?php
$query = "SELECT * FROM frequency WHERE device_id = '" . $device['device_id'] . "'";
$freq_data = mysql_query($query);
while($frequency = mysql_fetch_array($freq_data)) {
echo("Checking frequency " . $frequency['freq_descr'] . "... ");
$freq_cmd = $config['snmpget'] . " -m SNMPv2-MIB -O Uqnv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " " . $frequency['freq_oid'] . "|grep -v \"No Such Instance\"";
$freq = trim(str_replace("\"", "", shell_exec($freq_cmd)));
if ($frequency['freq_precision'])
{
$freq = $freq / $frequency['freq_precision'];
}
$freqrrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("freq-" . $frequency['freq_descr'] . ".rrd");
if (!is_file($freqrrd)) {
`rrdtool create $freqrrd \
--step 300 \
DS:freq:GAUGE:600:-273:1000 \
RRA:AVERAGE:0.5:1:1200 \
RRA:MIN:0.5:12:2400 \
RRA:MAX:0.5:12:2400 \
RRA:AVERAGE:0.5:12:2400`;
}
echo($freq . " Hz\n");
rrdtool_update($freqrrd,"N:$freq");
if($frequency['freq_current'] > $frequency['freq_limit_low'] && $freq <= $frequency['freq_limit_low'])
{
if($device['sysContact']) { $email = $device['sysContact']; } else { $email = $config['email_default']; }
$msg = "Frequency Alarm: " . $device['hostname'] . " " . $frequency['freq_descr'] . " is " . $freq . "Hz (Limit " . $frequency['freq_limit'];
$msg .= "Hz) at " . date($config['timestamp_format']);
mail($email, "Frequency Alarm: " . $device['hostname'] . " " . $frequency['freq_descr'], $msg, $config['email_headers']);
echo("Alerting for " . $device['hostname'] . " " . $frequency['freq_descr'] . "\n");
eventlog('Frequency ' . $frequency['freq_descr'] . " under threshold: " . $frequency['freq_current'] . " Hz (> " . $frequency['freq_limit'] . " Hz)", $device['device_id']);
}
else if($frequency['freq_current'] < $frequency['freq_limit'] && $freq >= $frequency['freq_limit'])
{
if($device['sysContact']) { $email = $device['sysContact']; } else { $email = $config['email_default']; }
$msg = "Frequency Alarm: " . $device['hostname'] . " " . $frequency['freq_descr'] . " is " . $freq . "Hz (Limit " . $frequency['freq_limit'];
$msg .= "Hz) at " . date($config['timestamp_format']);
mail($email, "Frequency Alarm: " . $device['hostname'] . " " . $frequency['freq_descr'], $msg, $config['email_headers']);
echo("Alerting for " . $device['hostname'] . " " . $frequency['freq_descr'] . "\n");
eventlog('Frequency ' . $frequency['freq_descr'] . " above threshold: " . $frequency['freq_current'] . " Hz (< " . $frequency['freq_limit'] . " Hz)", $device['device_id']);
}
mysql_query("UPDATE frequency SET freq_current = '$freq' WHERE freq_id = '" . $frequency['freq_id'] . "'");
}
?>

7584
mibs/mgeups.mib Normal file

File diff suppressed because it is too large Load Diff