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
+2 -2
View File
@@ -57,7 +57,7 @@ function temp_graph ($temp, $graph, $from, $to, $width, $height, $title, $vertic
} elseif($iter=="7") {$colour="FF0084"; unset($iter); }
$temperature['temp_descr_fixed'] = str_pad($temperature['temp_descr'], 28);
$temperature['temp_descr_fixed'] = substr($temperature['temp_descr_fixed'],0,28);
$temprrd = addslashes("rrd/$hostname-temp-" . str_replace("/", "_", str_replace(" ", "_",$temperature['temp_descr'])) . ".rrd");
$temprrd = addslashes("rrd/$hostname/temp-" . str_replace("/", "_", str_replace(" ", "_",$temperature['temp_descr'])) . ".rrd");
$temprrd = str_replace(")", "_", $temprrd);
$temprrd = str_replace("(", "_", $temprrd);
$opts[] = "DEF:temp" . $temperature[temp_id] . "=$temprrd:temp:AVERAGE";
@@ -117,7 +117,7 @@ function temp_graph_dev ($device, $graph, $from, $to, $width, $height, $title, $
} elseif($iter=="7") {$colour="FF0084"; unset($iter); }
$temperature['temp_descr_fixed'] = str_pad($temperature['temp_descr'], 28);
$temperature['temp_descr_fixed'] = substr($temperature['temp_descr_fixed'],0,28);
$temprrd = addslashes("rrd/$hostname-temp-" . str_replace("/", "_", str_replace(" ", "_",$temperature['temp_descr'])) . ".rrd");
$temprrd = addslashes("rrd/$hostname/temp-" . str_replace("/", "_", str_replace(" ", "_",$temperature['temp_descr'])) . ".rrd");
$temprrd = str_replace(")", "_", $temprrd);
$temprrd = str_replace("(", "_", $temprrd);
$options .= " DEF:temp" . $temperature[temp_id] . "=$temprrd:temp:AVERAGE ";
+13 -6
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;
+5 -1
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";
+9 -2
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`;
+1 -1
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 \
+26 -8
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') {
+6 -1
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 \
+33 -33
View File
@@ -3,8 +3,8 @@
// Start Graphing Functions
function mailerrorgraphUnix ($rrd, $graph, $from, $to, $width, $height, $title, $vertical) {
global $config, $rrdtool, $installdir, $mono_font;
$database = "rrd/" . $rrd;
global $config, $rrdtool, $installdir, $mono_font, $rrd_dir;
$database = $rrd_dir . "/" . $rrd;
$imgfile = "graphs/" . "$graph";
$period = $to - $from;
$options = "--alt-autoscale-max -E --start $from --end $to --width $width --height $height ";
@@ -14,7 +14,7 @@ function mailerrorgraphUnix ($rrd, $graph, $from, $to, $width, $height, $title,
$points_per_sample = 3;
$xpoints = '540';
$step = $range*$points_per_sample/$xpoints;
$database = "rrd/" . $rrd . "-mailstats.rrd";
$database = $rrd_dir . "/" . $rrd . "-mailstats.rrd";
$options .= " DEF:rejected=$database:reject:AVERAGE";
$options .= " DEF:mrejected=$database:reject:MAX";
@@ -62,8 +62,8 @@ function mailerrorgraphUnix ($rrd, $graph, $from, $to, $width, $height, $title,
}
function mailsgraphUnix ($rrd, $graph, $from, $to, $width, $height, $title, $vertical) {
global $config, $rrdtool, $installdir, $mono_font;
$database = "rrd/" . $rrd;
global $config, $rrdtool, $installdir, $mono_font, $rrd_dir;
$database = $rrd_dir . "/" . $rrd;
$imgfile = "graphs/" . "$graph";
$period = $to - $from;
$options = "--alt-autoscale-max -E --start $from --end $to --width $width --height $height ";
@@ -72,7 +72,7 @@ function mailsgraphUnix ($rrd, $graph, $from, $to, $width, $height, $title, $ver
$points_per_sample = 3;
$xpoints = '540';
$step = $range*$points_per_sample/$xpoints;
$rrd = "rrd/" . $rrd;
$rrd = $rrd_dir . "/" . $rrd;
$options .= " DEF:sent=$rrd:sent:AVERAGE";
$options .= " DEF:msent=$rrd:sent:MAX";
$options .= " CDEF:rsent=sent,60,*";
@@ -100,8 +100,8 @@ function mailsgraphUnix ($rrd, $graph, $from, $to, $width, $height, $title, $ver
}
function memgraphUnix ($rrd, $graph, $from, $to, $width, $height, $title, $vertical) {
global $config, $rrdtool, $installdir, $mono_font;
$database = "rrd/" . $rrd;
global $config, $rrdtool, $installdir, $mono_font, $rrd_dir;
$database = $rrd_dir . "/" . $rrd;
$imgfile = "graphs/" . "$graph";
$options = "--alt-autoscale-max -E --start $from --end $to --width $width --height $height -b 1024";
if($width <= "300") { $options .= " --font LEGEND:7:$mono_font --font AXIS:6:$mono_font --font-render-mode normal "; }
@@ -165,8 +165,8 @@ function memgraphUnix ($rrd, $graph, $from, $to, $width, $height, $title, $verti
}
function loadgraphUnix ($rrd, $graph, $from, $to, $width, $height, $title, $vertical) {
global $config, $rrdtool, $installdir, $mono_font;
$database = "rrd/" . $rrd;
global $config, $rrdtool, $installdir, $mono_font, $rrd_dir;
$database = $rrd_dir . "/" . $rrd;
$imgfile = "graphs/" . "$graph";
$period = $to - $from;
$options = "--alt-autoscale-max -E --start $from --end $to --width $width --height $height ";
@@ -198,8 +198,8 @@ function loadgraphUnix ($rrd, $graph, $from, $to, $width, $height, $title, $vert
function usersgraphUnix ($rrd, $graph, $from, $to, $width, $height, $title, $vertical) {
global $config, $rrdtool, $installdir, $mono_font;
$database = "rrd/" . $rrd;
global $config, $rrdtool, $installdir, $mono_font, $rrd_dir;
$database = $rrd_dir . "/" . $rrd;
$imgfile = "graphs/" . "$graph";
$period = $to - $from;
$options = "--alt-autoscale-max -E --start $from --end $to --width $width --height $height -l 0";
@@ -217,8 +217,8 @@ function usersgraphUnix ($rrd, $graph, $from, $to, $width, $height, $title, $ver
}
function procsgraphUnix ($rrd, $graph, $from, $to, $width, $height, $title, $vertical) {
global $config, $rrdtool, $installdir, $mono_font;
$database = "rrd/" . $rrd;
global $config, $rrdtool, $installdir, $mono_font, $rrd_dir;
$database = $rrd_dir . "/" . $rrd;
$imgfile = "graphs/" . "$graph";
$period = $to - $from;
$options = "--alt-autoscale-max -E --start $from --end $to --width $width --height $height -l 0";
@@ -239,8 +239,8 @@ function procsgraphUnix ($rrd, $graph, $from, $to, $width, $height, $title, $ver
function cpugraphUnix ($rrd, $graph, $from, $to, $width, $height, $title, $vertical) {
global $config, $rrdtool, $installdir, $mono_font;
$database = "rrd/" . $rrd;
global $config, $rrdtool, $installdir, $mono_font, $rrd_dir;
$database = $rrd_dir . "/" . $rrd;
$imgfile = "graphs/" . "$graph";
$period = $to - $from;
$options = "--alt-autoscale-max -E --start $from --end $to --width $width --height $height ";
@@ -276,8 +276,8 @@ function cpugraphUnix ($rrd, $graph, $from, $to, $width, $height, $title, $verti
}
function couriergraphUnix ($rrd, $graph, $from, $to, $width, $height, $title, $vertical) {
global $config, $rrdtool, $installdir, $mono_font;
$database = "rrd/" . $rrd;
global $config, $rrdtool, $installdir, $mono_font, $rrd_dir;
$database = $rrd_dir . "/" . $rrd;
$imgfile = "graphs/" . "$graph";
$period = $to - $from;
$options = "--alt-autoscale-max -E --start $from --end $to --width $width --height $height ";
@@ -326,8 +326,8 @@ function couriergraphUnix ($rrd, $graph, $from, $to, $width, $height, $title, $v
}
function apachehitsgraphUnix ($rrd, $graph, $from, $to, $width, $height, $title, $vertical) {
global $config, $rrdtool, $installdir, $mono_font;
$database = "rrd/" . $rrd;
global $config, $rrdtool, $installdir, $mono_font, $rrd_dir;
$database = $rrd_dir . "/" . $rrd;
$imgfile = "graphs/" . "$graph";
$options = "--alt-autoscale-max -E --start $from --end $to --width $width --height $height -l 0";
if($width <= "300") { $options .= " --font LEGEND:7:$mono_font --font AXIS:6:$mono_font --font-render-mode normal "; }
@@ -343,8 +343,7 @@ function apachehitsgraphUnix ($rrd, $graph, $from, $to, $width, $height, $title,
}
function unixfsgraph ($id, $graph, $from, $to, $width, $height, $title, $vertical) {
global $config, $rrdtool, $installdir, $mono_font;
$database = "rrd/" . $rrd;
global $config, $rrdtool, $installdir, $mono_font, $rrd_dir;
$imgfile = "graphs/" . "$graph";
$options = "--alt-autoscale-max -E --start $from --end $to --width $width --height $height -b 1024 -l 0";
if($width <= "300") { $options .= " --font LEGEND:7:$mono_font --font AXIS:6:$mono_font --font-render-mode normal "; }
@@ -360,9 +359,10 @@ function unixfsgraph ($id, $graph, $from, $to, $width, $height, $title, $vertica
$descr = str_pad($fs[hrStorageDescr], 14);
$descr = substr($descr,0,14);
$text = str_replace("/", "_", $fs['hrStorageDescr']);
$options .= " DEF:$fs[storage_id]=rrd/$hostname-storage-$text.rrd:used:AVERAGE";
$options .= " DEF:$fs[storage_id]s=rrd/$hostname-storage-$text.rrd:size:AVERAGE";
$options .= " DEF:$fs[storage_id]p=rrd/$hostname-storage-$text.rrd:perc:AVERAGE";
$rrd = $rrd_dir . "/$hostname/storage-$text.rrd";
$options .= " DEF:$fs[storage_id]=$rrd:used:AVERAGE";
$options .= " DEF:$fs[storage_id]s=$rrd:size:AVERAGE";
$options .= " DEF:$fs[storage_id]p=$rrd:perc:AVERAGE";
$options .= " LINE1.25:$fs[storage_id]p#" . $colour . ":'$descr'";
$options .= " GPRINT:$fs[storage_id]s:LAST:%6.2lf%SB";
$options .= " GPRINT:$fs[storage_id]:LAST:%6.2lf%SB";
@@ -375,8 +375,8 @@ function unixfsgraph ($id, $graph, $from, $to, $width, $height, $title, $vertica
function unixfsgraph_dev ($device, $graph, $from, $to, $width, $height, $title, $vertical) {
global $config, $rrdtool, $installdir, $mono_font;
$database = "rrd/" . $rrd;
global $config, $rrdtool, $installdir, $mono_font, $rrd_dir;
$database = $rrd_dir . "/" . $rrd;
$imgfile = "graphs/" . "$graph";
$options = "--alt-autoscale-max -E --start $from --end $to --width $width --height $height -b 1024 -l 0";
if($width <= "300") { $options .= " --font LEGEND:7:$mono_font --font AXIS:6:$mono_font --font-render-mode normal "; }
@@ -391,11 +391,11 @@ function unixfsgraph_dev ($device, $graph, $from, $to, $width, $height, $title,
$descr = str_pad($fs[hrStorageDescr], 14);
$descr = substr($descr,0,14);
$text = str_replace("/", "_", $fs['hrStorageDescr']);
$options .= " DEF:$fs[storage_id]=rrd/$hostname-storage-$text.rrd:used:AVERAGE";
$options .= " DEF:$fs[storage_id]s=rrd/$hostname-storage-$text.rrd:size:AVERAGE";
$options .= " DEF:$fs[storage_id]p=rrd/$hostname-storage-$text.rrd:perc:AVERAGE";
$rrd = $rrd_dir . "/$hostname/storage-$text.rrd";
$options .= " DEF:$fs[storage_id]=$rrd:used:AVERAGE";
$options .= " DEF:$fs[storage_id]s=$rrd:size:AVERAGE";
$options .= " DEF:$fs[storage_id]p=$rrd:perc:AVERAGE";
$options .= " LINE1.25:$fs[storage_id]p#" . $colour . ":'$descr'";
$options .= " GPRINT:$fs[storage_id]s:LAST:%6.2lf%SB";
$options .= " GPRINT:$fs[storage_id]:LAST:%6.2lf%SB";
@@ -407,8 +407,8 @@ function unixfsgraph_dev ($device, $graph, $from, $to, $width, $height, $title,
}
function apachebitsgraphUnix ($rrd, $graph, $from, $to, $width, $height, $title, $vertical) {
global $config, $rrdtool, $installdir, $mono_font;
$database = "rrd/" . $rrd;
global $config, $rrdtool, $installdir, $mono_font, $rrd_dir;
$database = $rrd_dir . "/" . $rrd;
$imgfile = "graphs/" . "$graph";
$options = "--alt-autoscale-max -E --start $from --end $to --width $width --height $height -l 0";
if($width <= "300") { $options .= " --font LEGEND:7:$mono_font --font AXIS:6:$mono_font --font-render-mode normal "; }