update rrd locations

git-svn-id: http://www.observium.org/svn/observer/trunk@139 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Adam Amstrong
2008-03-12 13:55:50 +00:00
parent 729adc0da0
commit 544180decc
9 changed files with 119 additions and 78 deletions

View File

@@ -4,12 +4,19 @@
$id = $device['device_id'];
$hostname = $device['hostname'];
$temprrd = "rrd/" . $hostname . "-temp.rrd";
$tempgraph = "public_html/graphs/" . $hostname . "-temp.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";
$Otemprrd = "rrd/" . $hostname . "-temp.rrd";
$Ocpurrd = "rrd/" . $hostname . "-cpu.rrd";
$Omemrrd = "rrd/" . $hostname . "-mem.rrd";
$temprrd = $rrd_dir . "/" . $hostname . "/temp.rrd";
$cpurrd = $rrd_dir . "/" . $hostname . "/cpu.rrd";
$memrrd = $rrd_dir . "/" . $hostname . "/mem.rrd";
if(is_file($Otemprrd) && !is_file($temprrd)) { rename($Otemprrd, $temprrd); echo("Moving $Otemprrd to $temprrd"); }
if(is_file($Ocpurrd) && !is_file($cpurrd)) { rename($Ocpurrd, $cpurrd); echo("Moving $Ocpurrd to $cpurrd"); }
if(is_file($Omemrrd) && !is_file($memrrd)) { rename($Omemrrd, $memrrd); echo("Moving $Omemrrd to $memrrd"); }
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`);
$cpu5m = $cpu5m + 0;
$cpu5s = $cpu5s + 0;

View File

@@ -12,7 +12,11 @@ if($device[os] != "Snom") {
'tcpEstabResets','tcpInSegs','tcpOutSegs','tcpRetransSegs','udpInDatagrams','udpOutDatagrams','udpInErrors',
'udpNoPorts');
$rrdfile = "rrd/" . $device['hostname'] . "-netinfo.rrd";
$rrdfile = $rrd_file . "/" . $device['hostname'] . "/netinfo.rrd";
$Orrdfile = "rrd/" . $device['hostname'] . "-netinfo.rrd";
if(is_file($Orrdfile) && !is_file($rrdfile)) { rename($Orrdfile, $rrdfile); echo("Moving $Orrdfile to $rrdfile"); }
$rrd_create = "rrdtool create $rrdfile ";
$rrd_create .= "RRA:AVERAGE:0.5:1:600 RRA:AVERAGE:0.5:6:700 RRA:AVERAGE:0.5:24:775 RRA:AVERAGE:0.5:288:797 RRA:MAX:0.5:1:600 \
RRA:MAX:0.5:6:700 RRA:MAX:0.5:24:775 RRA:MAX:0.5:288:797";

View File

@@ -1,7 +1,14 @@
<?
$cpurrd = "rrd/" . $device['hostname'] . "-cpu.rrd";
$memrrd = "rrd/" . $device['hostname'] . "-mem.rrd";
$Ocpurrd = "rrd/" . $hostname . "-cpu.rrd";
$Omemrrd = "rrd/" . $hostname . "-mem.rrd";
$cpurrd = $rrd_dir . "/" . $hostname . "/cpu.rrd";
$memrrd = $rrd_dir . "/" . $hostname . "/mem.rrd";
if(is_file($Ocpurrd) && !is_file($cpurrd)) { rename($Ocpurrd, $cpurrd); echo("Moving $Ocpurrd to $cpurrd"); }
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 = `$cpu_cmd`;

View File

@@ -24,7 +24,7 @@
$rxbytes = 0 - $rxbytes * 8;
echo("$rxbytes, $rxpkts, $txbytes, $txpkts, $calls, $registrations");
$rrdfile = "rrd/" . $device['hostname'] . "-data.rrd";
$rrdfile = $rrd_dir . "/" . $device['hostname'] . "/data.rrd";
if(!is_file($rrdfile)) {
$woo = `rrdtool create $rrdfile \
DS:INOCTETS:COUNTER:600:U:100000000000 \

View File

@@ -1,9 +1,21 @@
<?php
$loadrrd = "rrd/" . $device['hostname'] . "-load.rrd";
$cpurrd = "rrd/" . $device['hostname'] . "-cpu.rrd";
$memrrd = "rrd/" . $device['hostname'] . "-mem.rrd";
$sysrrd = "rrd/" . $device['hostname'] . "-sys.rrd";
$Oloadrrd = "rrd/" . $device['hostname'] . "-load.rrd";
$Ocpurrd = "rrd/" . $device['hostname'] . "-cpu.rrd";
$Omemrrd = "rrd/" . $device['hostname'] . "-mem.rrd";
$Osysrrd = "rrd/" . $device['hostname'] . "-sys.rrd";
$loadrrd = $rrd_dir . "/" . $device['hostname'] . "/load.rrd";
$cpurrd = $rrd_dir . "/" . $device['hostname'] . "/cpu.rrd";
$memrrd = $rrd_dir . "/" . $device['hostname'] . "/mem.rrd";
$sysrrd = $rrd_dir . "/" . $device['hostname'] . "/sys.rrd";
if(is_file($Oloadrrd) && !is_file($loadrrd)) { rename($Oloadrrd, $loadrrd); echo("Moving $Oloadrrd to $loadrrd"); }
if(is_file($Ocpurrd) && !is_file($cpurrd)) { rename($Ocpurrd, $cpurrd); echo("Moving $Ocpurrd to $cpurrd"); }
if(is_file($Omemrrd) && !is_file($memrrd)) { rename($Omemrrd, $memrrd); echo("Moving $Omemrrd to $memrrd"); }
if(is_file($Osysrrd) && !is_file($sysrrd)) { rename($Osysrrd, $sysrrd); echo("Moving $Osysrrd to $sysrrd"); }
## Check Disks
$dq = mysql_query("SELECT * FROM storage WHERE host_id = '" . $device['device_id'] . "'");
@@ -18,9 +30,15 @@ while ($dr = mysql_fetch_array($dq)) {
$perc = round($used / $hrStorageSize * 100, 2);
$filedesc = str_replace("\"", "", str_replace("/", "_", $hrStorageDescr));
$storerrd = "rrd/" . $device['hostname'] . "-storage-" . $filedesc . ".rrd";
if (!is_file($storerrd)) {
`rrdtool create $storerrd \
$storage_rrd = $rrd_dir . "/" . $device['hostname'] . "/storage-" . $filedesc . ".rrd";
$ostorage_rrd = "rrd/" . $device['hostname'] . "-storage-" . $filedesc . ".rrd";
if(is_file($ostorage_rrd) && !is_file($storage_rrd)) { rename($ostorage_rrd, $storage_rrd); echo("Moving $ostorage_rrd to $storage_rrd"); }
if (!is_file($storage_rrd)) {
`rrdtool create $storage_rrd \
--step 300 \
DS:size:GAUGE:600:0:U \
DS:used:GAUGE:600:0:U \
@@ -34,7 +52,7 @@ while ($dr = mysql_fetch_array($dq)) {
RRA:MAX:0.5:24:800 \
RRA:MAX:0.5:288:800`;
}
rrdtool_update($storerrd, "N:$hrStorageSize:$used:$perc");
rrdtool_update($storage_rrd, "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') {

View File

@@ -9,10 +9,15 @@ while($temperature = mysql_fetch_array($temp_data)) {
echo("Checking temp " . $temperature['temp_descr'] . "... ");
$temprrd = addslashes("rrd/" . $device['hostname'] . "-temp-" . str_replace("/", "_", str_replace(" ", "_",$temperature['temp_descr'])) . ".rrd");
$temprrd = addslashes($rrd_dir . "/" . $device['hostname'] . "/temp-" . str_replace("/", "_", str_replace(" ", "_",$temperature['temp_descr'])) . ".rrd");
$temprrd = str_replace(")", "_", $temprrd);
$temprrd = str_replace("(", "_", $temprrd);
$otemprrd = addslashes("rrd/" . $device['hostname'] . "-temp-" . str_replace("/", "_", str_replace(" ", "_",$temperature['temp_descr'])) . ".rrd");
$otemprrd = str_replace(")", "_", $otemprrd);
$otemprrd = str_replace("(", "_", $otemprrd);
if(is_file($otemprrd) && !is_file($temprrd)) { rename($otemprrd, $temprrd); echo("Moving $otemprrd to $temprrd"); }
if (!is_file($temprrd)) {
`rrdtool create $temprrd \