Location: PHPKode > projects > LSMS SNMP to MRTG toolset > www/snmpmrtg/fortinetmrtg.php
<?php
// (C)Copyright John Baker 2004/2005/2006
//
// This file is part of lsms2mrtg.
//
// lsms2mrtg is free software;you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation;either version 2 of the License, or
// (at your option) any later version.
//
// lsms2mrtg is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY;without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with lsms2mrtg;if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// For more informationn please visit http://gnulsms2mrtg.sourceforge.net/
error_reporting(2);
include 'generic.inc';
include 'jbsnmplib.inc';
include 'BrickSNMPlib.inc';
echo $htmlheader;
$mrtgtop="$mrtgheader
EnableIPv6: no
WorkDir: $mrtgwwwdir/fortinet
RunAsDaemon: yes
Interval: 5
Refresh: 600

";
$fortinetstats="
";
$mrtgoptions="noinfo, nolegend, nobanner, gauge";
if ($runcommand=="cpuusage")
{
$fortinetstats="Options[Fortinet_".$host."_cpu]: $mrtgoptions
Target[Fortinet_".$host."_cpu]: .1.3.6.1.4.1.12356.1.8.0&.1.3.6.1.4.1.12356.1.8.0:$community"."@"."$host
MaxBytes[Fortinet_".$host."_cpu]: 100
Title[Fortinet_".$host."_cpu]: CPU Usage on $host
PageTop[Fortinet_".$host."_cpu]: <h1>CPU Usage on $host</h1>
YLegend[Fortinet_".$host."_cpu]: CPU 
ShortLegend[Fortinet_".$host."_cpu]: CPU 
LegendI[Fortinet_".$host."_cpu]: CPU
LegendO[Fortinet_".$host."_cpu]:
Background[Fortinet_".$host."_cpu]: $globalbgcolour

";
}

if ($runcommand=="memusage")
{
$fortinetstats="Options[Fortinet_".$host."_Memory]: $mrtgoptions
Target[Fortinet_".$host."_Memory]: .1.3.6.1.4.1.12356.1.9.0&.1.3.6.1.4.1.12356.1.9.0:$community"."@"."$host
MaxBytes[Fortinet_".$host."_Memory]: 100
Title[Fortinet_".$host."_Memory]: Memory Usage on $host
PageTop[Fortinet_".$host."_Memory]: <h1>Memory Usage on $host</h1>
YLegend[Fortinet_".$host."_Memory]: Memory 
ShortLegend[Fortinet_".$host."_Memory]: Memory 
LegendI[Fortinet_".$host."_Memory]: Memory
LegendO[Fortinet_".$host."_Memory]:
Background[Fortinet_".$host."_Memory]: $globalbgcolour

";
}

if ($runcommand=="activesessions")
{
$fortinetstats="Options[Fortinet_".$host."_Activesessions]: $mrtgoptions
Target[Fortinet_".$host."_Activesessions]: .1.3.6.1.4.1.12356.1.10.0&.1.3.6.1.4.1.12356.1.10.0:$community"."@"."$host
MaxBytes[Fortinet_".$host."_Activesessions]: 1000000
Title[Fortinet_".$host."_Activesessions]: Active Sessions on $host
PageTop[Fortinet_".$host."_Activesessions]: <h1>Active Sessions on $host</h1>
YLegend[Fortinet_".$host."_Activesessions]: Sessions
ShortLegend[Fortinet_".$host."_Activesessions]: Sessions
LegendI[Fortinet_".$host."_Activesessions]: Sessions
LegendO[Fortinet_".$host."_Activesessions]:
Background[Fortinet_".$host."_Activesessions]: $globalbgcolour

";
}

if ($runcommand=="usercount")
{
$fortinetstats="Options[Fortinet_".$host."_UserCount]: $mrtgoptions
Target[Fortinet_".$host."_UserCount]: .1.3.6.1.4.1.12356.1.102.1.0&.1.3.6.1.4.1.12356.1.102.1.0:$community"."@"."$host
MaxBytes[Fortinet_".$host."_UserCount]: 1000000
Title[Fortinet_".$host."_UserCount]: User Accounts on $host
PageTop[Fortinet_".$host."_UserCount]: <h1>User Accounts on $host</h1>
YLegend[Fortinet_".$host."_UserCount]: Accounts
ShortLegend[Fortinet_".$host."_UserCount]: Accounts
LegendI[Fortinet_".$host."_UserCount]: Accounts
LegendO[Fortinet_".$host."_UserCount]:
Background[Fortinet_".$host."_UserCount]: $globalbgcolour

";
}

if ($runcommand=="virtualcount")
{
$fortinetstats="Options[Fortinet_".$host."_VirtualDomains]: $mrtgoptions
Target[Fortinet_".$host."_VirtualDomains]: .1.3.6.1.4.1.12356.2.1.0&.1.3.6.1.4.1.12356.2.1.0:$community"."@"."$host
MaxBytes[Fortinet_".$host."_VirtualDomains]: 100
Title[Fortinet_".$host."_VirtualDomains]: Virtual Domain Count on $host
PageTop[Fortinet_".$host."_VirtualDomains]: <h1>Virtual Domain Count on $host</h1>
YLegend[Fortinet_".$host."_VirtualDomains]: Virtual Domains
ShortLegend[Fortinet_".$host."_VirtualDomains]: Virtual Domains
LegendI[Fortinet_".$host."_VirtualDomains]: Virtual Domains
LegendO[Fortinet_".$host."_VirtualDomains]:
Background[Fortinet_".$host."_VirtualDomains]: $globalbgcolour

";
}

$newfilewrite=$fortinetstats;
//echo $fortinetstats;
if (file_exists($fortinetmrtgfile)) {
// append into file
if (!$handle = fopen($fortinetmrtgfile, 'a')) {
print "Cannot open file ($fortinetmrtgfile)";
fclose ($handle);
exit;
}
if (!fwrite($handle, $fortinetstats)) {
print "Cannot write to file ($fortinetmrtgfile)";
fclose ($handle);
exit;
}
echo "<CENTER><font size=+2><B>File Updated</b></font><BR><BR><HR><B>".$fortinetmrtgfile."<HR>";
}
else
{
// create new file
if (!$handle = fopen($fortinetmrtgfile, 'w')) {
print "Cannot open file ($fortinetmrtgfile)";
fclose ($handle);
exit;
}
$newfilewrite=$mrtgtop.$fortinetstats;
if (!fwrite($handle, $newfilewrite)) {
print "Cannot write to file ($fortinetmrtgfile)";
fclose ($handle);
exit;
}
echo "<CENTER><font size=+2><B>File Created</b></font><BR><BR><HR><B>".$fortinetmrtgfile."<HR>";
}
jsbackindow();
?>
Return current item: LSMS SNMP to MRTG toolset