security fixes and some juniper graphing stuff.

git-svn-id: http://www.observium.org/svn/observer/trunk@245 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Adam Amstrong
2008-07-22 08:24:34 +00:00
parent 0ee570b762
commit 96cc0308fd
20 changed files with 85 additions and 24 deletions
+6
View File
@@ -22,6 +22,12 @@ include_once($config['install_dir'] . "/includes/syslog.php");
function mres($string) {
// short function wrapper because the real one is stupidly long and ugly. aestetics.
return mysql_real_escape_string($string);
}
function validate_hostip($host) {
}
function write_dev_attrib($device_id, $attrib_type, $attrib_value) {
+15
View File
@@ -315,6 +315,21 @@ function bgpupdatesgraph ($rrd, $graph , $from, $to, $width, $height) {
return $imgfile;
}
function graph_cpu_generic_single ($rrd, $graph , $from, $to, $width, $height) {
global $config;
$database = $config['rrd_dir'] . "/" . $rrd;
$imgfile = "graphs/" . "$graph";
$options = "--alt-autoscale-max -l 0 -E --start $from --end $to --width $width --height $height ";
if($width <= "300") {$options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; }
$options .= " DEF:cpu=$database:cpu:AVERAGE";
$options .= " COMMENT:\ \ \ \ \ \ \ \ \ \ Current\ \ Minimum\ \ Maximum\ \ Average\\\\n";
$options .= " AREA:cpu#ffee99: LINE1.25:cpu#aa2200:Load\ %";
$options .= " GPRINT:cpu:LAST:%6.2lf\ GPRINT:cpu:AVERAGE:%6.2lf\ ";
$options .= " GPRINT:cpu:MAX:%6.2lf\ GPRINT:cpu:AVERAGE:%6.2lf\\\\n";
$thing = shell_exec($config['rrdtool'] . " graph $imgfile $options");
return $imgfile;
}
function cpugraph ($rrd, $graph , $from, $to, $width, $height) {
global $config, $installdir;
+23
View File
@@ -1,5 +1,7 @@
<?php
echo("Doing Juniper JunOS");
$jun_ver = trim(str_replace("\"", "", shell_exec($config['snmpget'] . " -".$device['snmpver']." -Oqv -c ".$device['community']." ".$device['hostname']." .1.3.6.1.2.1.25.6.3.1.2.2")));
$hardware = trim(str_replace("\"", "", shell_exec($config['snmpget'] . " -".$device['snmpver']." -Oqv -c ".$device['community']." ".$device['hostname']." .1.3.6.1.4.1.2636.3.1.2.0")));
$serial = trim(str_replace("\"", "", shell_exec($config['snmpget'] . " -".$device['snmpver']." -Oqv -c ".$device['community']." ".$device['hostname']." .1.3.6.1.4.1.2636.3.1.3.0")));
@@ -9,6 +11,27 @@ $features = preg_replace("/.+\ \((.+)\)$/", "\\1", $jun_ver);
echo("$hardware - $version - $features - $serial\n");
$cpurrd = $rrd_dir . "/" . $device['hostname'] . "/junos-cpu.rrd";
$cpu_cmd = $config['snmpget'] . " -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'];
$cpu_cmd .= " .1.3.6.1.4.1.2636.3.1.13.1.8.9.1.0.0";
$cpu_usage = trim(shell_exec($cpu_cmd));
if (!is_file($cpurrd)) {
`rrdtool create $cpurrd \
--step 300 \
DS:cpu:GAUGE:600:0:100 \
RRA:AVERAGE:0.5:1:800 \
RRA:AVERAGE:0.5:6:800 \
RRA:AVERAGE:0.5:24:800 \
RRA:AVERAGE:0.5:288:800 \
RRA:MAX:0.5:1:800 \
RRA:MAX:0.5:6:800 \
RRA:MAX:0.5:24:800 \
RRA:MAX:0.5:288:800`;
}
shell_exec($config['rrdtool'] . " update $cpurrd N:$cpu_usage");
?>