<?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/
/************************************************************\
* Function to return if the host is a Bluecoat/Cacheflow unit
\************************************************************/
function isbluecoat($gethost,$getcommunity)
{
$tmpvar1=snmpwalk($gethost, $getcommunity, ".1.3.6.1.2.1.1.1");
$mystr="BOF ".$tmpvar1[0];
$bluecoatstr="Blue Coat";
$cacheflowstr="Cacheflow";
$pos1=stripos($mystr, $bluecoatstr);
$pos2=stripos($mystr, $cacheflowstr);
if ($pos1 !="")
{
return(1);
}
else
{
return(0);
}
if ($pos2 !="")
{
return(1);
}
else
{
return(0);
}
}
/************************************************************\
* Function to return the Bluecoat model
\************************************************************/
function BluecoatModel($gethost,$getcommunity)
{
$retstr="Unknown";
$tmpvar1=snmpstrip(snmpget($gethost,$getcommunity, ".1.3.6.1.2.1.1.2.0"));
$tmpvar2=(str_replace("enterprises.3417.1.","",$tmpvar1));
if ($tmpvar2=="1.1")
{
$retstr="sg1000";
$shenv=0;
}
if ($tmpvar2=="1.2")
{
$retstr="sg100";
$shenv=0;
}
if ($tmpvar2=="1.3")
{
$retstr="sg500";
$shenv=1;
}
if ($tmpvar2=="1.4")
{
$retstr="sg2000";
$shenv=0;
}
if ($tmpvar2=="1.5")
{
$retstr="sg5000";
$shenv=0;
}
if ($tmpvar2=="1.6")
{
$retstr="sg500A";
$shenv=0;
}
if ($tmpvar2=="1.7")
{
$retstr="sg3000";
$shenv=0;
}
if ($tmpvar2=="1.8")
{
$retstr="sg5x5";
$shenv=1;
}
if ($tmpvar2=="1.9")
{
$retstr="sg110";
$shenv=0;
}
if ($tmpvar2=="1.10")
{
$retstr="sg600";
$shenv=1;
}
if ($tmpvar2=="1.11")
{
$retstr="sg6000";
$shenv=1;
}
if ($tmpvar2=="1.12")
{
$retstr="sg610";
$shenv=1;
}
if ($tmpvar2=="1.13")
{
$retstr="sg6x5";
$shenv=1;
}
if ($tmpvar2=="1.14")
{
$retstr="sg3000s";
$shenv=0;
}
if ($tmpvar2=="1.15")
{
$retstr="sg5000s";
$shenv=0;
}
if ($tmpvar2=="1.16")
{
$retstr="sg7x5";
$shenv=1;
}
if ($tmpvar2=="1.17")
{
$retstr="sg710";
$shenv=1;
}
if ($tmpvar2=="1.18")
{
$retstr="sg7000";
$shenv=1;
}
if ($tmpvar2=="1.19")
{
$retstr="sg611";
$shenv=1;
}
if ($tmpvar2=="1.20")
{
$retstr="sg800";
$shenv=1;
}
if ($tmpvar2=="1.21")
{
$retstr="Undefined";
$shenv=0;
}
if ($tmpvar2=="1.22")
{
$retstr="sg400";
$shenv=0;
}
if ($tmpvar2=="1.23")
{
$retstr="sg8000";
$shenv=1;
}
if ($tmpvar2=="1.24")
{
$retstr="sg200";
$shenv=0;
}
if ($tmpvar2=="2.1")
{
$retstr="sgme710";
$shenv=1;
}
if ($tmpvar2=="2.2")
{
$retstr="sgme800";
$shenv=1;
}
return array($retstr,$shenv);
}
//blueCoatMgmt deviceWccpMIB
/************************************************************\
* BluecoatWCCP: Is WCCP enabeled on the Bluecoat
\************************************************************/
function BluecoatWCCP($gethost,$getcommunity)
{
if (snmpstripq(snmpget($gethost, $getcommunity, ".1.3.6.1.4.1.3417.2.5.1.0"))==2)
{
return("0");
}
else
{
return("1");
}
}
//proxySysPerf
/************************************************************\
* BluecoatproxyCpuLoad: The current percentage of the CPU being consumed by the proxy proccess at this time.
\************************************************************/
function BluecoatproxyCpuLoad($gethost,$getcommunity)
{
return(snmpstripq(snmpget($gethost, $getcommunity, ".1.3.6.1.3.25.17.3.1.1.0")));
}
/************************************************************\
* BluecoatproxyNumObjects: The number of objects currently held by the proxy.
\************************************************************/
function BluecoatproxyNumObjects($gethost,$getcommunity)
{
return(snmpstripq(snmpget($gethost, $getcommunity, ".1.3.6.1.3.25.17.3.1.2.0")));
}
//proxyProtoClient
/************************************************************\
* BluecoatproxyClientHttpRequests: The number of HTTP requests recieved from clients.
\************************************************************/
function BluecoatproxyClientHttpRequests($gethost,$getcommunity)
{
return(snmpstripq(snmpget($gethost, $getcommunity, ".1.3.6.1.3.25.17.3.2.1.1.0")));
}
/************************************************************\
* BluecoatproxyClientHttpHits: The number of HTTP hits that the proxy clients have produced.
\************************************************************/
function BluecoatproxyClientHttpHits($gethost,$getcommunity)
{
return(snmpstripq(snmpget($gethost, $getcommunity, ".1.3.6.1.3.25.17.3.2.1.2.0")));
}
/************************************************************\
* BluecoatproxyClientHttpErrors: The number of HTTP errors caused by client connections.
\************************************************************/
function BluecoatproxyClientHttpErrors($gethost,$getcommunity)
{
return(snmpstripq(snmpget($gethost, $getcommunity, ".1.3.6.1.3.25.17.3.2.1.3.0")));
}
/************************************************************\
* BluecoatproxyClientHttpInKbs: The number of kilobits recieved from the clients by the proxy.
\************************************************************/
function BluecoatproxyClientHttpInKbs($gethost,$getcommunity)
{
return(snmpstripq(snmpget($gethost, $getcommunity, ".1.3.6.1.3.25.17.3.2.1.4.0")));
}
/************************************************************\
* BluecoatproxyClientHttpOutKbs: The number of kilobits delivered to clients from the proxy.
\************************************************************/
function BluecoatproxyClientHttpOutKbs($gethost,$getcommunity)
{
return(snmpstripq(snmpget($gethost, $getcommunity, ".1.3.6.1.3.25.17.3.2.1.5.0")));
}
//proxyProtoServer
/************************************************************\
* BluecoatproxyServerHttpRequests: The number of HTTP requests that the proxy has issued.
\************************************************************/
function BluecoatproxyServerHttpRequests($gethost,$getcommunity)
{
return(snmpstripq(snmpget($gethost, $getcommunity, ".1.3.6.1.3.25.17.3.2.2.1.0")));
}
/************************************************************\
* BluecoatproxyServerHttpErrors: The number of HTTP errors while fetching objects.
\************************************************************/
function BluecoatproxyServerHttpErrors($gethost,$getcommunity)
{
return(snmpstripq(snmpget($gethost, $getcommunity, ".1.3.6.1.3.25.17.3.2.2.2.0")));
}
/************************************************************\
* BluecoatproxyServerHttpInKbs: The number of Kbs recieved by the proxy from remote servers.
\************************************************************/
function BluecoatproxyServerHttpInKbs($gethost,$getcommunity)
{
return(snmpstripq(snmpget($gethost, $getcommunity, ".1.3.6.1.3.25.17.3.2.2.3.0")));
}
/************************************************************\
* BluecoatproxyServerHttpOutKbs: The number of kbs transmitted by the proxy to remote servers.
\************************************************************/
function BluecoatproxyServerHttpOutKbs($gethost,$getcommunity)
{
return(snmpstripq(snmpget($gethost, $getcommunity, ".1.3.6.1.3.25.17.3.2.2.4.0")));
}
//proxySystem
/************************************************************\
* BluecoatproxyMemUsage: The memory in use by the proxy independant of the support processes on the system running the proxy
\************************************************************/
function BluecoatproxyMemUsage($gethost,$getcommunity)
{
return(snmpstripq(snmpget($gethost, $getcommunity, ".1.3.6.1.3.25.17.1.1.0")));
}
/************************************************************\
* BluecoatproxyStorage: The quantity of storage in use by the proxy in KB. This value can be zero if there is no caching occuring.
\************************************************************/
function BluecoatproxyStorage($gethost,$getcommunity)
{
return(snmpstripq(snmpget($gethost, $getcommunity, ".1.3.6.1.3.25.17.1.2.0")));
}
/************************************************************\
* BluecoatproxyCpuUsage: The amount of CPU consumed over the life of the process in seconds.
\************************************************************/
function BluecoatproxyCpuUsage($gethost,$getcommunity)
{
return(snmpstripq(snmpget($gethost, $getcommunity, ".1.3.6.1.3.25.17.1.3.0")));
}
/************************************************************\
* BluecoatproxyUpTime: The amount of time the proxy has been running, in TimeTicks.
\************************************************************/
function BluecoatproxyUpTime($gethost,$getcommunity)
{
return(snmpstripq(snmpget($gethost, $getcommunity, ".1.3.6.1.3.25.17.1.4.0")));
}
/************************************************************\
* BluecoatEnvCount: The number of Environmental Entires
\************************************************************/
function BluecoatEnvCount($gethost,$getcommunity)
{
$envcnt = snmpwalk($gethost,$getcommunity, ".1.3.6.1.4.1.3417.2.1.1.1.1.1.2");
return count($envcnt);
}
/************************************************************\
* BluecoatSensorName Returns string containing the senor dname for sensor int
\************************************************************/
function BluecoatSensorName($gethost,$getcommunity,$sensorname)
{
$sennum=99;
$sensorint1 = snmpwalk($gethost,$getcommunity, ".1.3.6.1.4.1.3417.2.1.1.1.1.1.9");
reset($sensorint1);
while (list($key, $val) = each($sensorint1))
{
if (strtoupper($val) == strtoupper(stripquotes($sensorname)))
{
$sennum=$key;
}
}
return($sennum);
}
/************************************************************\
* BluecoatSensorInt2str: Returns string containing the senor data type
\************************************************************/
function BluecoatSensorInt2str($sensorint)
{
$retstr="ERROR UNKNOWN";
if ($sensorint==1)
{
$retstr="other";
}
if ($sensorint==2)
{
$retstr="truthvalue";
}
if ($sensorint==3)
{
$retstr="specialEnum";
}
if ($sensorint==4)
{
$retstr="volts";
}
if ($sensorint==5)
{
$retstr="celsius";
}
if ($sensorint==6)
{
$retstr="rpm";
}
return($retstr);
}
/************************************************************\
* DecShift: Shift a number by the $shiftdec decimal places
\************************************************************/
function DecShift($num,$shiftdec)
{
$retvar=$num;
if ($shiftdec=="-1")
{
$retvar=($num / 10);
}
if ($shiftdec=="-2")
{
$retvar=($num / 100);
}
if ($shiftdec=="-3")
{
$retvar=($num / 1000);
}
if ($shiftdec=="-4")
{
$retvar=($num / 10000);
}
if ($shiftdec=="-5")
{
$retvar=($num / 100000);
}
if ($shiftdec=="0")
{
$retvar=$num;
}
if ($shiftdec=="1")
{
$retvar=($num * 10);
}
if ($shiftdec=="2")
{
$retvar=($num * 100);
}
if ($shiftdec=="3")
{
$retvar=($num * 1000);
}
if ($shiftdec=="4")
{
$retvar=($num * 10000);
}
if ($shiftdec=="5")
{
$retvar=($num * 100000);
}
return $retvar;
}
/************************************************************\
* BluecoatSensorInt2Status: Returns string containing the senor Status
\************************************************************/
function BluecoatSensorInt2Status($sensorint)
{
$retstr="ERROR UNKNOWN";
if ($sensorint==1)
{
$retstr="ok";
}
if ($sensorint==2)
{
$retstr="unknown";
}
if ($sensorint==3)
{
$retstr="not-installed";
}
if ($sensorint==4)
{
$retstr="voltage-low-warning";
}
if ($sensorint==5)
{
$retstr="voltage-low-critical";
}
if ($sensorint==6)
{
$retstr="no-power";
}
if ($sensorint==7)
{
$retstr="voltage-high-warning";
}
if ($sensorint==8)
{
$retstr="voltage-high-critical";
}
if ($sensorint==9)
{
$retstr="voltage-high-severe";
}
if ($sensorint==10)
{
$retstr="temperature-high-warning";
}
if ($sensorint==11)
{
$retstr="temperature-high-critical";
}
if ($sensorint==12)
{
$retstr="temperature-high-severe";
}
if ($sensorint==13)
{
$retstr="fan-slow-warning";
}
if ($sensorint==14)
{
$retstr="fan-slow-critical";
}
if ($sensorint==15)
{
$retstr="fan-stopped";
}
return($retstr);
}
/************************************************************\
* BluecoatEnvLine: returns array list of env vars for $envint
\ SensorName, corrected value, measurement type, sensor status
\************************************************************/
function BluecoatEnvLine($gethost,$getcommunity,$envint)
{
$ArrSensorTrap=snmpwalk($gethost, $getcommunity, ".1.3.6.1.4.1.3417.2.1.1.1.1.1.2");
$ArrSensorType=snmpwalk($gethost, $getcommunity, ".1.3.6.1.4.1.3417.2.1.1.1.1.1.3");
$ArrSensorMul=snmpwalk($gethost, $getcommunity, ".1.3.6.1.4.1.3417.2.1.1.1.1.1.4");
$ArrSensorValue=snmpwalk($gethost, $getcommunity, ".1.3.6.1.4.1.3417.2.1.1.1.1.1.5");
$ArrSensorCode=snmpwalk($gethost, $getcommunity, ".1.3.6.1.4.1.3417.2.1.1.1.1.1.6");
$ArrSensorStatus=snmpwalk($gethost, $getcommunity, ".1.3.6.1.4.1.3417.2.1.1.1.1.1.7");
$ArrSensorAge=snmpwalk($gethost, $getcommunity, ".1.3.6.1.4.1.3417.2.1.1.1.1.1.8");
$ArrSensorName=snmpwalk($gethost, $getcommunity, ".1.3.6.1.4.1.3417.2.1.1.1.1.1.9");
$EnvSensorTrap=$ArrSensorTrap[$envint];
$EnvSensorType=$ArrSensorType[$envint];
$EnvSensorMul=$ArrSensorMul[$envint];
$EnvSensorValue=$ArrSensorValue[$envint];
$EnvSensorCode=$ArrSensorCode[$envint];
$EnvSensorStatus=$ArrSensorStatus[$envint];
$EnvSensorAge=$ArrSensorAge[$envint];
$EnvSensorName=snmpstripq($ArrSensorName[$envint]);
return array($EnvSensorName,DecShift($EnvSensorValue,$EnvSensorMul),BluecoatSensorInt2str($EnvSensorType), BluecoatSensorInt2Status($EnvSensorStatus));
}
/************************************************************\
* BluecoatEnvArray: returns array containg array of env vars
\************************************************************/
function BluecoatEnvArrayOld($gethost,$getcommunity)
{
$tmp2=array();
$listcnt=0;
$endline=BluecoatEnvCount($gethost,$getcommunity);
while ($listcnt <= ($endline-1))
{
$tmp2[]=BluecoatEnvLine($gethost,$getcommunity,$listcnt);
$listcnt++;
}
return ($tmp2);
}
/************************************************************\
deviceSensorIndex INTEGER,
deviceSensorTrapEnabled TruthValue,
deviceSensorUnits SensorUnits,
deviceSensorScale ExpBase10,
deviceSensorValue SensorValue,
deviceSensorCode SensorCode,
deviceSensorStatus SensorStatus,
deviceSensorTimeStamp TimeStamp,
deviceSensorName DisplayString
\************************************************************/
/************************************************************\
* BluecoatEnvArray: returns array containg array of env vars
return array(, BluecoatSensorInt2Status($EnvSensorStatus));
\************************************************************/
function BluecoatEnvArray($gethost,$getcommunity)
{
$retarr=array();
$listcounter=0;
$tmp1=snmpwalk($gethost,$getcommunity, ".1.3.6.1.4.1.3417.2.1.1.1.1.1",200000000,10);
$tmpcnt=(count($tmp1) / 8);
while ($listcounter <= $tmpcnt-1) {
$retarr2=array(
snmpstripq($tmp1[(7*$tmpcnt) +$listcounter]),
DecShift(snmpstripq($tmp1[(3*$tmpcnt) +$listcounter]),snmpstripq($tmp1[(2*$tmpcnt) +$listcounter])),
BluecoatSensorInt2str(snmpstripq($tmp1[(1*$tmpcnt) +$listcounter])),
BluecoatSensorInt2Status(snmpstripq($tmp1[(5*$tmpcnt) +$listcounter])),snmpstripq($tmp1[(2*$tmpcnt) +$listcounter]) );
$retarr[]=$retarr2;
$listcounter++;
}
return($retarr);
}
/************************************************************\
* BluecoatDiskInt2str: Returns string containing the disk data type
\************************************************************/
function BluecoatDiskInt2str($sensorint)
{
$retstr="ERROR UNKNOWN";
if ($sensorint==1)
{
$retstr="present";
}
if ($sensorint==2)
{
$retstr="initializing";
}
if ($sensorint==3)
{
$retstr="inserted";
}
if ($sensorint==4)
{
$retstr="offline";
}
if ($sensorint==5)
{
$retstr="removed";
}
if ($sensorint==6)
{
$retstr="not-present";
}
if ($sensorint==7)
{
$retstr="empty";
}
if ($sensorint==8)
{
$retstr="bad";
}
if ($sensorint==9)
{
$retstr="unknown";
}
return($retstr);
}
/************************************************************\
* BluecoatDiskCount: The number of Environmental Entires
\************************************************************/
function BluecoatDiskCount($gethost,$getcommunity)
{
$envcnt = snmpwalk($gethost,$getcommunity, ".1.3.6.1.4.1.3417.2.2.1.1.1.1.2");
return count($envcnt);
}
/************************************************************\
* BluecoatEnvLine: returns array list of disk vars for $envint
\
\************************************************************/
function BluecoatDiskLine($gethost,$getcommunity,$envint)
{
$ArrDiskdeviceDiskTrapEnabled=snmpwalk($gethost, $getcommunity, ".1.3.6.1.4.1.3417.2.2.1.1.1.1.2");
$ArrDiskdeviceDiskStatus=snmpwalk($gethost, $getcommunity, ".1.3.6.1.4.1.3417.2.2.1.1.1.1.3");
$ArrDiskdeviceDiskVendor=snmpwalk($gethost, $getcommunity, ".1.3.6.1.4.1.3417.2.2.1.1.1.1.5");
$ArrDiskdeviceDiskProduct=snmpwalk($gethost, $getcommunity, ".1.3.6.1.4.1.3417.2.2.1.1.1.1.6");
$ArrDiskdeviceDiskRevision=snmpwalk($gethost, $getcommunity, ".1.3.6.1.4.1.3417.2.2.1.1.1.1.7");
$ArrDiskdeviceDiskSerialN=snmpwalk($gethost, $getcommunity, ".1.3.6.1.4.1.3417.2.2.1.1.1.1.8");
$ArrDiskdeviceDiskBlockSize=snmpwalk($gethost, $getcommunity, ".1.3.6.1.4.1.3417.2.2.1.1.1.1.9");
$ArrDiskdeviceDiskBlockCount=snmpwalk($gethost, $getcommunity, ".1.3.6.1.4.1.3417.2.2.1.1.1.1.10");
$EnvDiskTrap=stripquotes($ArrDiskdeviceDiskTrapEnabled[$envint]);
$EnvDiskStatus=BluecoatDiskInt2str(stripquotes($ArrDiskdeviceDiskStatus[$envint]));
$EnvDiskVendor=stripquotes($ArrDiskdeviceDiskVendor[$envint]);
$EnvDiskProduct=stripquotes($ArrDiskdeviceDiskProduct[$envint]);
$EnvDiskRevision=stripquotes($ArrDiskdeviceDiskRevision[$envint]);
$EnvDiskSerialN=stripquotes($ArrDiskdeviceDiskSerialN[$envint]);
$EnvDiskSize=snmpstripq($ArrDiskdeviceDiskBlockSize[$envint]) * snmpstripq($ArrDiskdeviceDiskBlockCount[$envint]);
return array($EnvDiskTrap,$EnvDiskStatus,$EnvDiskVendor,$EnvDiskProduct,$EnvDiskRevision,$EnvDiskSerialN,$EnvDiskSize);
}
// custom code
/************************************************************\
* BluecoatDiskArray: returns array containg array of env vars
\************************************************************/
function BluecoatDiskArray($gethost,$getcommunity)
{
$tmp2=array();
$listcnt=0;
$endline=BluecoatDiskCount($gethost,$getcommunity);
while ($listcnt <= ($endline-1))
{
$tmp2[]=BluecoatDiskLine($gethost,$getcommunity,$listcnt);
$listcnt++;
}
return ($tmp2);
}
/************************************************************\
* BluecoatSWVer: Returns a string containing Bluecoat SW Version
\************************************************************/
function BluecoatSWVer($gethost,$getcommunity)
{
$tmp1=getsysdesc($gethost,$getcommunity);
$versionis=strpos($tmp1,"Version:");
$tmp2=substr($tmp1,(8 + $versionis));
return ($tmp2);
}
/************************************************************\
*This table lists the various attacks that are
detected.
\************************************************************/
function BluecoatdeviceAttackTable($gethost,$getcommunity)
{
$retarr=array();
$listcounter=0;
$tmp1=snmpwalk($gethost,$getcommunity, ".1.3.6.1.4.1.3417.2.3.1.1.1",20000000,10);
$tmpcnt=count($tmp1)/3;
while ($listcounter <= $tmpcnt-1) {
if (snmpstripq($tmp1[(1*$tmpcnt) +$listcounter])==1) $tmp2="Not under attack";
if (snmpstripq($tmp1[(1*$tmpcnt) +$listcounter])==2) $tmp2="Attack in progress";
$retarr2=array(snmpstripq($tmp1[($listcounter)]),
$tmp2,
timestrip($tmp1[(2*$tmpcnt) +$listcounter]),
stripafter(($tmp1[(3*$tmpcnt) +$listcounter]),"(")
);
$retarr[]=$retarr2;
$listcounter++;
}
return($retarr);
}
/************************************************************\
* A deviceUsage entry describes the
present usage of a resource.
deviceUsageIndex INTEGER,
deviceUsageTrapEnabled TruthValue,
deviceUsageName DisplayString,
deviceUsagePercent Percent,
deviceUsageHigh Percent,
deviceUsageStatus UsageStatus,
deviceUsageTime TimeStamp
\************************************************************/
function BluecoatdeviceUsageTable($gethost,$getcommunity)
{
$retarr=array();
$listcounter=0;
$tmp1=snmpwalk($gethost,$getcommunity, ".1.3.6.1.4.1.3417.2.4.1.1.1",20000000,10);
$tmpcnt=count($tmp1)/6;
while ($listcounter <= $tmpcnt-1) {
$retarr2=array(
snmpstripq($tmp1[(1*$tmpcnt) +$listcounter]),
snmpstripq($tmp1[(2*$tmpcnt) +$listcounter]),
snmpstripq($tmp1[(3*$tmpcnt) +$listcounter]),
snmpstripq($tmp1[(4*$tmpcnt) +$listcounter])
);
$retarr[]=$retarr2;
$listcounter++;
}
return($retarr);
}
?>