From 85c9f77962317df30b6008f2a8e31e483814fe4d Mon Sep 17 00:00:00 2001 From: Ruairi Carroll Date: Thu, 3 Dec 2015 18:23:42 +0100 Subject: [PATCH 1/2] Adding polling and discovery code for fortigate_cpu --- .../discovery/processors/fortigate.inc.php | 31 ++++++++++++----- includes/polling/os/fortigate.inc.php | 33 +++++++++++-------- 2 files changed, 41 insertions(+), 23 deletions(-) diff --git a/includes/discovery/processors/fortigate.inc.php b/includes/discovery/processors/fortigate.inc.php index 3271978ba..b77d4fbd5 100644 --- a/includes/discovery/processors/fortigate.inc.php +++ b/includes/discovery/processors/fortigate.inc.php @@ -1,18 +1,31 @@ Num CPUs in the device + if ($device['os'] == 'fortigate') { - echo 'Fortigate : '; + echo 'Fortigate : '; - $descr = 'Processor'; - $usage = snmp_get($device, '.1.3.6.1.4.1.12356.101.4.1.3.0', '-Ovq'); +// Forti have logical CPU numbering - start at 1 and increment to $num_cpu in the box. +$num_cpu = snmp_get($device, 'FORTINET-FORTIGATE-MIB::fgProcessorCount.0', '-Ovq'); - if (is_numeric($usage)) { - discover_processor($valid['processor'], $device, '.1.3.6.1.4.1.12356.101.4.1.3.0', '0', 'fortigate-fixed', $descr, '1', $usage, null, null); - } -} +print "Forti-found $num_cpu CPUs\n"; + +for($i = 1; $i <= $num_cpu; $i++) { + // HERP DERP IM A FORTIGATE AND I PUT NON NUMERIC VALUES IN A GAUGE + $cpu_usage = snmp_get($device, "FORTINET-FORTIGATE-MIB::fgProcessorUsage.$i", '-Ovq'); + $usage = trim ( str_replace(" %", "", $cpu_usage ) ) ; + $descr = snmp_get($device, "FORTINET-FORTIGATE-MIB::fgProcModDescr.$i", '-Ovq'); + print "CPU: $num_cpu - USAGE: $cpu_usage - TYPE $descr\n"; + if (is_numeric($usage)) { + discover_processor($valid['processor'], $device, "FORTINET-FORTIGATE-MIB::fgProcessorUsage." . $num_cpu, '0', 'fortigate-fixed', $descr, '1', $usage, null, null); + } +} // END For loop for CPU discovery + +} // END if device is Fortigate unset($processors_array); diff --git a/includes/polling/os/fortigate.inc.php b/includes/polling/os/fortigate.inc.php index 6c7ceb922..98d394b9f 100644 --- a/includes/polling/os/fortigate.inc.php +++ b/includes/polling/os/fortigate.inc.php @@ -33,21 +33,26 @@ if (is_numeric($sessions)) { $graphs['fortigate_sessions'] = true; } +// Start somewhat automated discovery for processors in the chassis + $cpurrd = $config['rrd_dir'].'/'.$device['hostname'].'/fortigate_cpu.rrd'; -$cpu_usage = snmp_get($device, 'FORTINET-FORTIGATE-MIB::fgSysCpuUsage.0', '-Ovq'); +$num_cpu = snmp_get($device, 'FORTINET-FORTIGATE-MIB::fgProcessorCount.0', '-Ovq'); +#$cpu_usage = snmp_get($device, 'FORTINET-FORTIGATE-MIB::fgSysCpuUsage.0', '-Ovq'); -if (is_numeric($cpu_usage)) { - if (!is_file($cpurrd)) { - rrdtool_create($cpurrd, ' --step 300 DS:LOAD:GAUGE:600:-1:100 '.$config['rrd_rra']); - } +print "NUM CPU: $num_cpu\n"; - echo "CPU: $cpu_usage%\n"; - - $fields = array( - 'LOAD' => $cpu_usage, - ); - - rrdtool_update($cpurrd, $fields); - - $graphs['fortigate_cpu'] = true; +// Fortigate have a pretty logical CPU index going on. It's predictable. +for($i = 1; $i <= $num_cpu; $i++) { + $cpurrd = $config['rrd_dir'].'/'.$device['hostname'].'/fortigate_cpu_'.$i.'.rrd'; + $cpu_usage = snmp_get($device, "FORTINET-FORTIGATE-MIB::fgProcessorUsage.$i", '-Ovq'); + $usage = trim ( str_replace(" %", "", $cpu_usage ) ) ; + print "CPU: $num_cpu - USAGE: $usage\n"; + if (!is_file($cpurrd)) { + print "$cpurrd not found\n"; + rrdtool_create($cpurrd, ' --step 300 DS:LOAD:GAUGE:600:-1:100 '.$config['rrd_rra']); + } + $fields = array( 'LOAD' => $usage ); + rrdtool_update($cpurrd, $fields); } + + From b592689d2378638c02f016c7f2d856db3ea20987 Mon Sep 17 00:00:00 2001 From: Ruairi Carroll Date: Sun, 13 Dec 2015 17:05:07 +0100 Subject: [PATCH 2/2] Removing polling code for processors --- includes/polling/os/fortigate.inc.php | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/includes/polling/os/fortigate.inc.php b/includes/polling/os/fortigate.inc.php index 98d394b9f..f165b7503 100644 --- a/includes/polling/os/fortigate.inc.php +++ b/includes/polling/os/fortigate.inc.php @@ -33,26 +33,4 @@ if (is_numeric($sessions)) { $graphs['fortigate_sessions'] = true; } -// Start somewhat automated discovery for processors in the chassis - -$cpurrd = $config['rrd_dir'].'/'.$device['hostname'].'/fortigate_cpu.rrd'; -$num_cpu = snmp_get($device, 'FORTINET-FORTIGATE-MIB::fgProcessorCount.0', '-Ovq'); -#$cpu_usage = snmp_get($device, 'FORTINET-FORTIGATE-MIB::fgSysCpuUsage.0', '-Ovq'); - -print "NUM CPU: $num_cpu\n"; - -// Fortigate have a pretty logical CPU index going on. It's predictable. -for($i = 1; $i <= $num_cpu; $i++) { - $cpurrd = $config['rrd_dir'].'/'.$device['hostname'].'/fortigate_cpu_'.$i.'.rrd'; - $cpu_usage = snmp_get($device, "FORTINET-FORTIGATE-MIB::fgProcessorUsage.$i", '-Ovq'); - $usage = trim ( str_replace(" %", "", $cpu_usage ) ) ; - print "CPU: $num_cpu - USAGE: $usage\n"; - if (!is_file($cpurrd)) { - print "$cpurrd not found\n"; - rrdtool_create($cpurrd, ' --step 300 DS:LOAD:GAUGE:600:-1:100 '.$config['rrd_rra']); - } - $fields = array( 'LOAD' => $usage ); - rrdtool_update($cpurrd, $fields); -} -