Location: PHPKode > projects > LSMS SNMP to MRTG toolset > www/snmpmrtg/fortinet.inc
<?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(0);
/************************************************************\
*
\************************************************************/
function isfortinet($gethost,$getcommunity)
{   
    $tfortinet=trim(snmpstripq(snmpget($gethost, $getcommunity,".1.3.6.1.2.1.1.2.0")));
    if (($tfortinet=="enterprises.12356.50") || ($tfortinet==".1.3.6.1.4.1.12356.50")) return "1"; else return("0");
}


/************************************************************\
* Fortinet Model
\************************************************************/
function fortinetfnSysModel($gethost,$getcommunity)
{
    return(snmpstripq(snmpget($gethost, $getcommunity, ".1.3.6.1.4.1.12356.1.1.0")));
}

/************************************************************\
* Fortinet Serial Number
\************************************************************/
function fortinetfnSysSerial($gethost,$getcommunity)
{
    return(snmpstripq(snmpget($gethost, $getcommunity, ".1.3.6.1.4.1.12356.1.2.0")));
}

/************************************************************\
* Fortinet Software Version
\************************************************************/
function fortinetfnSysVersion($gethost,$getcommunity)
{
    return(snmpstripq(snmpget($gethost, $getcommunity, ".1.3.6.1.4.1.12356.1.3.0")));
}

/************************************************************\
* Fortinet AV Software Version
\************************************************************/
function fortinetfnSysVersionAv($gethost,$getcommunity)
{
    return(stripquotes(snmpget($gethost, $getcommunity, ".1.3.6.1.4.1.12356.1.4.0")));
}

/************************************************************\
* Fortinet NIDS DB versionSoftware Version
\************************************************************/
function fortinetfnSysVersionNids($gethost,$getcommunity)
{
    return(stripquotes(snmpget($gethost, $getcommunity, ".1.3.6.1.4.1.12356.1.5.0")));
}

/************************************************************\
* Fortinet High-availabilty mode (Standalone, A-A or A-P)
\************************************************************/
function fortinetfnSysHaMode($gethost,$getcommunity)
{
    $retvar=(stripquotes(snmpget($gethost, $getcommunity, ".1.3.6.1.4.1.12356.1.6.0")));
if ($retvar==1) return("Standalone");
if ($retvar==2) return("Active-Active");
if ($retvar==3) return("Active-{assive");
}

/************************************************************\
* Fortinet HA cluster group ID
\************************************************************/
function fortinetfnHaGroupId($gethost,$getcommunity)
{
    return(snmpstripq(snmpget($gethost, $getcommunity, ".1.3.6.1.4.1.12356.1.100.1.0")));
}

/************************************************************\
* Fortinet HA clustering priority (default - 127)
\************************************************************/
function fortinetfnHaPriority($gethost,$getcommunity)
{
    return(snmpstripq(snmpget($gethost, $getcommunity, ".1.3.6.1.4.1.12356.1.100.1.0")));
}

/************************************************************\
* Fortinet HA clustering priority (default - 127)
\************************************************************/
function fortinetfnHaOverride($gethost,$getcommunity)
{
$retvar=(stripquotes(snmpget($gethost, $getcommunity, ".1.3.6.1.4.1.12356.1.100.3.0")));

if ($retvar==1) return("Disabled");
if ($retvar==2) return("Enabled ");

}

/************************************************************\
* Fortinet Status of an automatic configuration synchronization
\************************************************************/
function fortinetfnHaAutoSync($gethost,$getcommunity)
{

$retvar=(stripquotes(snmpget($gethost, $getcommunity, ".1.3.6.1.4.1.12356.1.100.4.0")));
if ($retvar==1) return("Disabled");
if ($retvar==2) return("Enabled ");

}

/************************************************************\
* Fortinet Load-balancing schedule in A-A mode
\************************************************************/
function fortinetfnHaSchedule($gethost,$getcommunity)
{
$retvar=(stripquotes(snmpget($gethost, $getcommunity, ".1.3.6.1.4.1.12356.1.100.5.0")));
if ($retvar==1) return("None");
if ($retvar==2) return("Hub");
if ($retvar==3) return("Least-connections");
if ($retvar==4) return("Round-robin");
if ($retvar==5) return("Weighted-round-robin");
if ($retvar==6) return("Random");
if ($retvar==7) return("IP-based");
if ($retvar==8) return("IP-port-based");
	
}



/************************************************************\
* Fortinet Operational mode (Transparent or Nat)
\************************************************************/
function fortinetfnSysOpMode($gethost,$getcommunity)
{
    $retvar=(stripquotes(snmpget($gethost, $getcommunity, ".1.3.6.1.4.1.12356.1.7.0")));
if ($retvar==1) return("Nat");
if ($retvar==2) return("Transparent");
}

/************************************************************\
* Fortinet Instantaneous CPU usage
\************************************************************/
function fortinetfnSysCpuUsage($gethost,$getcommunity)
{
    return(snmpstripq(snmpget($gethost, $getcommunity, ".1.3.6.1.4.1.12356.1.8.0")));
}

/************************************************************\
* Fortinet Instantaneous memory utilization
\************************************************************/
function fortinetfnSysMemUsage($gethost,$getcommunity)
{
    return(snmpstripq(snmpget($gethost, $getcommunity, ".1.3.6.1.4.1.12356.1.9.0")));
}

/************************************************************\
* Fortinet Instantaneous session count
\************************************************************/
function fortinetfnSysSesCount($gethost,$getcommunity)
{
    return(snmpstripq(snmpget($gethost, $getcommunity, ".1.3.6.1.4.1.12356.1.10.0")));
}

/************************************************************\
* Fortinet Instantaneous session count
\************************************************************/
function fortinetfnUserNumber($gethost,$getcommunity)
{
    return(snmpstripq(snmpget($gethost, $getcommunity, ".1.3.6.1.4.1.12356.1.102.1.0")));
}


/************************************************************\
* Returns array containing an array of any local users configured on Fortinet.
\************************************************************/
function fortinetuserlist($gethost,$getcommunity)
{
 $retarr=array();
    $tmp1=snmpwalk($gethost,$getcommunity, ".1.3.6.1.4.1.12356.1.102.2.1",2000000,10);
    $userarr=array();
    $tmpcnt=(count($tmp1)/4);
    $listcounter=0;
    while ($listcounter <= $tmpcnt-1) {
$usertype1=$tmp1[(2*$tmpcnt) +$listcounter];
if ($usertype1==1) $usertype="Local";
if ($usertype1==2) $usertype="Radius-single";
if ($usertype1==3) $usertype="Radius-multiple";
if ($usertype1==4) $usertype="LDAP";
if ($usertype1==-65535) $usertype="Disabled";

$userstatus1=$tmp1[(3*$tmpcnt) +$listcounter];
if ($userstatus1==1) $userstatus="Disabled";
if ($userstatus1==2) $userstatus="Enabled";
	
       $userarr[]=array($tmp1[$listcounter],snmpstripq($tmp1[(1*$tmpcnt) +$listcounter]),$usertype,$userstatus);
$listcounter++;
}
return $userarr;
}


/************************************************************\
* Returns array with users auth type count and enabeled and users disabled count
\************************************************************/
function fortinetuserstatuscount($gethost,$getcommunity)
{

    $tmp1=fortinetuserlist($gethost,$getcommunity);
    $userarr=array();
    $tmpcnt=(count($tmp1));
    $listcounter=0;
$userlocal=0;
$userradius=0;
$usermradius=0;
$userldap=0;
$userenable=0;
$userdisable=0;
    while ($listcounter <= $tmpcnt-1) {
$dispuser=$tmp1[$listcounter];
if ($dispuser[2]=="Local") $userlocal++;
if ($dispuser[2]=="Radius-single") $userradius++;
if ($dispuser[2]=="Radius-multiple") $userradius++;
if ($dispuser[2]=="LDAP") $userradius++;
if ($dispuser[3]=="Disabled") $userdisable++;
if ($dispuser[3]=="Enabled") $userenable++;
$listcounter++;
}
return array($userlocal,$userradius,$usermradius,$userldap,$userenable,$userdisable);
}


/************************************************************\
* Fortinet The number of virtual fnDomains in vdTable
\************************************************************/
function fortinetfnVdNumber($gethost,$getcommunity)
{
    return(snmpstripq(snmpget($gethost, $getcommunity, ".1.3.6.1.4.1.12356.2.1.0")));
}

/************************************************************\
* Returns array with a list of VirtualDomains index and name
\************************************************************/
function fortinetVirtualDomainList($gethost,$getcommunity)
{
    $tmp1=snmpwalk($gethost,$getcommunity,".1.3.6.1.4.1.12356.2.2.1.2",2000000,10);
    $virtarr=array();
    $tmpcnt=(count($tmp1));
    $listcounter=0;
    while ($listcounter <= $tmpcnt-1) {
$virtarr[]=array($tmp1[0],$tmp1[1]);
$listcounter++;
}
return $virtarr;
}
?>
Return current item: LSMS SNMP to MRTG toolset