mirror of
https://github.com/stylersnico/librenms.git
synced 2026-07-28 08:02:41 +02:00
git-svn-id: http://www.observium.org/svn/observer/trunk@118 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
@@ -1,19 +1,12 @@
|
||||
<?php
|
||||
|
||||
$id = $device['device_id'];
|
||||
$hostname = $device['hostname'];
|
||||
|
||||
$loadrrd = "rrd/" . $hostname . "-load.rrd";
|
||||
$loadgraph = "public_html/graphs/" . $hostname . "-load.png";
|
||||
$cpurrd = "rrd/" . $hostname . "-cpu.rrd";
|
||||
$cpugraph = "public_html/graphs/" . $hostname . "-cpu.png";
|
||||
$memrrd = "rrd/" . $hostname . "-mem.rrd";
|
||||
$memgraph = "public_html/graphs/" . $hostname . "-mem.png";
|
||||
$sysrrd = "rrd/" . $hostname . "-sys.rrd";
|
||||
$sysgraph = "public_html/graphs/" . $hostname . "-sys.png";
|
||||
$loadrrd = "rrd/" . $device['hostname'] . "-load.rrd";
|
||||
$cpurrd = "rrd/" . $device['hostname'] . "-cpu.rrd";
|
||||
$memrrd = "rrd/" . $device['hostname'] . "-mem.rrd";
|
||||
$sysrrd = "rrd/" . $device['hostname'] . "-sys.rrd";
|
||||
|
||||
## Check Disks
|
||||
$dq = mysql_query("SELECT * FROM storage WHERE host_id = '$id'");
|
||||
$dq = mysql_query("SELECT * FROM storage WHERE host_id = '" . $device['device_id'] . "'");
|
||||
while ($dr = mysql_fetch_array($dq)) {
|
||||
$hrStorageIndex = $dr['hrStorageIndex'];
|
||||
$hrStorageAllocationUnits = $dr['hrStorageAllocationUnits'];
|
||||
@@ -25,7 +18,7 @@ while ($dr = mysql_fetch_array($dq)) {
|
||||
$perc = round($used / $hrStorageSize * 100, 2);
|
||||
|
||||
$filedesc = str_replace("\"", "", str_replace("/", "_", $hrStorageDescr));
|
||||
$storerrd = "rrd/" . $hostname . "-storage-" . $filedesc . ".rrd";
|
||||
$storerrd = "rrd/" . $device['hostname'] . "-storage-" . $filedesc . ".rrd";
|
||||
if (!is_file($storerrd)) {
|
||||
`rrdtool create $storerrd \
|
||||
--step 300 \
|
||||
@@ -44,6 +37,20 @@ while ($dr = mysql_fetch_array($dq)) {
|
||||
rrd_update($storerrd, "N:$hrStorageSize:$used:$perc");
|
||||
mysql_query("UPDATE `storage` SET `hrStorageUsed` = '$used_units', `storage_perc` = '$perc' WHERE storage_id = '" . $dr['storage_id'] . "'");
|
||||
|
||||
if($dr['storage_perc'] < '40' && $perc >= '40') {
|
||||
|
||||
if($device['sysContact']) { $email = $device['sysContact']; } else { $email = $config['email_default']; }
|
||||
|
||||
$msg = "Disk Alarm: " . $device['hostname'] . " " . $dr['hrStorageDescr'] . " is " . $perc;
|
||||
$msg .= " at " . date('l dS F Y h:i:s A');
|
||||
|
||||
mail($email, "Disk Alarm: " . $device['hostname'] . " " . $dr['hrStorageDescr'], $msg, $config['email_headers']);
|
||||
|
||||
echo("Alerting for " . $device['hostname'] . " " . $dr['hrStorageDescr'] . "/n");
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
## Set OIDs
|
||||
@@ -148,26 +155,16 @@ if($device[os] != "m0n0wall" && $device[os] != "Voswall" && $device[os] != "pfSe
|
||||
rrd_update($loadrrd, "N:$load1:$load5:$load10");
|
||||
rrd_update($memrrd, "N:$memTotalSwap:$memAvailSwap:$memTotalReal:$memAvailReal:$memTotalFree:$memShared:$memBuffer:$memCached");
|
||||
|
||||
if($device['courier']) {
|
||||
include("includes/polling/courierstats.inc.php");
|
||||
}
|
||||
|
||||
if($device['postfix']) {
|
||||
include("includes/polling/mailstats.inc.php");
|
||||
}
|
||||
|
||||
if($device['apache']) {
|
||||
$apacherrd = "rrd/" . $hostname . "-apache.rrd";
|
||||
if(!is_file($apacherrd)) {
|
||||
$woo= `rrdtool create $apacherrd \
|
||||
DS:bits:COUNTER:600:U:10000000 \
|
||||
DS:hits:COUNTER:600:U:10000000 \
|
||||
RRA:AVERAGE:0.5:1:800 \
|
||||
RRA:AVERAGE:0.5:6:700 \
|
||||
RRA:AVERAGE:0.5:24:775 \
|
||||
RRA:AVERAGE:0.5:288:797 \
|
||||
RRA:MAX:0.5:1:800 \
|
||||
RRA:MAX:0.5:6:700 \
|
||||
RRA:MAX:0.5:24:775 \
|
||||
RRA:MAX:0.5:288:797`;
|
||||
}
|
||||
|
||||
list($ahits,$abits) = explode("\n", `./get-apache.sh $hostname`);
|
||||
$abits = $abits * 8;
|
||||
|
||||
rrd_update($apacherrd,"N:$abits:$ahits");
|
||||
} // end apache
|
||||
include("includes/polling/apachestats.inc.php");
|
||||
}
|
||||
|
||||
} // end Non-m0n0wall
|
||||
|
||||
@@ -4,10 +4,11 @@ $query = "SELECT * FROM temperature WHERE temp_host = '" . $device['device_id']
|
||||
$temp_data = mysql_query($query);
|
||||
while($temperature = mysql_fetch_array($temp_data)) {
|
||||
|
||||
$temp_cmd = "snmpget -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'] . " " . $temperature['temp_oid'];
|
||||
echo($temp_cmd);
|
||||
$temp_cmd = "snmpget -O Uqnv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'] . " " . $temperature['temp_oid'];
|
||||
$temp = `$temp_cmd`;
|
||||
|
||||
echo("Checking temp " . $temperature['temp_descr'] . "... ");
|
||||
|
||||
$temprrd = addslashes("rrd/" . $device['hostname'] . "-temp-" . str_replace("/", "_", str_replace(" ", "_",$temperature['temp_descr'])) . ".rrd");
|
||||
$temprrd = str_replace(")", "_", $temprrd);
|
||||
$temprrd = str_replace("(", "_", $temprrd);
|
||||
@@ -23,18 +24,28 @@ while($temperature = mysql_fetch_array($temp_data)) {
|
||||
RRA:AVERAGE:0.5:12:2400`;
|
||||
}
|
||||
|
||||
$temp = str_replace("\"", "", $temp);
|
||||
$temp = trim(str_replace("\"", "", $temp));
|
||||
if($temperature['temp_tenths']) { $temp = $temp / 10; }
|
||||
echo("$temprrd N:$temp");
|
||||
|
||||
echo($temp . "C\n");
|
||||
|
||||
$updatecmd = "rrdtool update $temprrd N:$temp";
|
||||
|
||||
echo($updatecmd . "\n");
|
||||
|
||||
`$updatecmd`;
|
||||
|
||||
if($temperature['temp_current'] < $temperature['temp_limit'] && $temp >= $temperature['temp_limit']) {
|
||||
$updated = ", `service_changed` = '" . time() . "' ";
|
||||
if($device['sysContact']) { $email = $device['sysContact']; } else { $email = $config['email_default']; }
|
||||
$msg = "Temp Alarm: " . $device['hostname'] . " " . $temperature['temp_descr'] . " is " . $temp . " (Limit " . $temperature['temp_limit'];
|
||||
$msg .= ") at " . date('l dS F Y h:i:s A');
|
||||
mail($email, "Temp Alarm: " . $device['hostname'] . " " . $temperature['temp_descr'], $msg, $config['email_headers']);
|
||||
echo("Alerting for " . $device['hostname'] . " " . $temperature['temp_descr'] . "/n");
|
||||
}
|
||||
|
||||
mysql_query("UPDATE temperature SET temp_current = '$temp' WHERE temp_id = '$temperature[temp_id]'");
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user