fortigate additions

git-svn-id: http://www.observium.org/svn/observer/trunk@222 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Adam Amstrong
2008-04-03 21:54:14 +00:00
parent 70b36878be
commit fa8ca69c0c
3 changed files with 119 additions and 0 deletions

View File

@@ -0,0 +1,60 @@
<?php
function graph_fortigate_sessions ($rrd, $graph, $from, $to, $width, $height, $title=NULL, $vertical=NULL) {
global $config;
$database = $config['rrd_dir'] . "/" . $rrd;
$imgfile = "graphs/" . "$graph";
$options = "-Y -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:sessions=$database:sessions:AVERAGE";
$options .= " COMMENT:Sessions\ \ \ \ \ \ Current\ \ \ \ Average\ \ \ \ Maximum\\\\n";
$options .= " LINE1.25:sessions#006600:Allocated";
$options .= " GPRINT:sessions:LAST:\ %6.0lf";
$options .= " GPRINT:sessions:AVERAGE:\ \ \ %6.0lf";
$options .= " GPRINT:sessions:MAX:\ \ \ %6.0lf\\\\n";
shell_exec($config['rrdtool'] . " graph $imgfile $options");
return $imgfile;
}
function graph_fortigate_cpu ($rrd, $graph, $from, $to, $width, $height, $title, $vertical) {
global $config;
$database = $config['rrd_dir'] . "/" . $rrd;
$imgfile = "graphs/" . "$graph";
$period = $to - $from;
$options = "-l 0 -Y -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:Usage\ \ \ \ \ \ \ Current\ \ \ \ \ Average\ \ \ \ Maximum\\\\n";
$options .= " LINE1.25:cpu#2020c0:Average";
$options .= " GPRINT:cpu:LAST:\ \ %5.2lf%%";
$options .= " GPRINT:cpu:AVERAGE:\ \ \ %5.2lf%%";
$options .= " GPRINT:cpu:MAX:\ \ \ %5.2lf%%\\\\n";
shell_exec($config['rrdtool'] . " graph $imgfile $options");
return $imgfile;
}
function graph_fortigate_memory ($rrd, $graph, $from, $to, $width, $height, $title=NULL, $vertical=NULL) {
global $config;
$database = $config['rrd_dir'] . "/" . $rrd;
$imgfile = "graphs/" . "$graph";
$options = "-b 1024 -l 0 -Y -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:mem=$database:mem:AVERAGE";
$options .= " DEF:kcap=$database:memcapacity:AVERAGE";
$options .= " CDEF:used=kcap,1024,*,100,/,mem,*";
$options .= " CDEF:cap=kcap,1024,*";
$options .= " COMMENT:Memory\ \ \ \ \ \ \ \ Current\ \ \ \ \ Average\ \ \ \ Maximum\\\\n";
$options .= " AREA:mem#ffcccc";
$options .= " LINE1.25:used#cc0000:Used\ \ \ \ \ ";
$options .= " GPRINT:used:MAX:%6.2lf%sB";
$options .= " GPRINT:used:AVERAGE:\ %6.2lf%sB";
$options .= " GPRINT:used:MAX:\ %6.2lf%sB\\\\n";
$options .= " LINE1.25:cap#0000cc:Total\ \ \ ";
$options .= " GPRINT:cap:MAX:\ %6.2lf%sB\\\\n";
shell_exec($config['rrdtool'] . " graph $imgfile $options");
return $imgfile;
}
?>

View File

@@ -0,0 +1,15 @@
<?php
if(!$os) {
$sysObjectId = shell_exec($config['snmpget'] . " -Ovq -v2c -c ". $community ." ". $hostname ." .1.3.6.1.2.1.1.2.0");
if(strstr($sysObjectId, "fortinet")) {
$fnSysVersion = shell_exec($config['snmpget'] . " -Ovq -v2c -c ". $community ." ". $hostname ." fnSysVersion.0");
if(strstr($fnSysVersion, "Fortigate")) {
$os = "Fortigate";
}
}
}
?>

View File

@@ -0,0 +1,44 @@
<?php
echo("Fortinet Fortigate Poller\n");
$fnSysVersion = shell_exec($config['snmpget']." -".$device['snmpver']." -Ovq -c ".$device['community']." ".$device['hostname']." fnSysVersion.0");
$serial = shell_exec($config['snmpget']." -".$device['snmpver']." -Ovq -c ".$device['community']." ".$device['hostname']." fnSysSerial.0");
$version = preg_replace("/(.+)\ (.+),(.+),(.+)/", "Fortinet \\1||\\2||\\3||\\4", $fnSysVersion);
list($hardware,$version,$features) = explode("||", $version);
$cpurrd = $rrd_dir . "/" . $device['hostname'] . "/fortigate-cpu.rrd";
$memrrd = $rrd_dir . "/" . $device['hostname'] . "/fortigate-memory.rrd";
$sessrrd = $rrd_dir . "/" . $device['hostname'] . "/fortigate-sessions.rrd";
$cmd = $config['snmpget'] . " -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'];
$cmd .= " fnSysCpuUsage.0 fnSysMemUsage.0 fnSysSesCount.0 fnSysMemCapacity.0";
$data = shell_exec($cmd);
list ($cpu, $mem, $ses, $memsize) = explode("\n", $data);
if (!is_file($cpurrd)) {
shell_exec($config['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");
}
if (!is_file($memrrd)) {
shell_exec($config['rrdtool'] . " create $memrrd --step 300 \
DS:mem:GAUGE:600:0:10000000000 DS:memcapacity:GAUGE:600:0:10000000000 \
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");
}
if (!is_file($sessrrd)) {
`rrdtool create $sessrrd --step 300 DS:sessions:GAUGE:600:0:3000000 \
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");
shell_exec($config['rrdtool'] . " update $memrrd N:$mem:$memsize");
shell_exec($config['rrdtool'] . " update $sessrrd N:$ses");
?>