Following based on Centos 4.3 Linux distribution.
The SNMPD Bridge/Parser scripts and Cacti Templates are part of the LiteSpeed 2.2+ install. The scripts are backward compatible to LiteSpeed 2.1.18+.
yum install net-snmp-utils <-- install if not already
SNMPD Bridge scripts and Cacti Templates are part of the LiteSpeed Web Server 2.2+ installation in the /lswsinstall/add-ons/snmp_monitoring/ folder.
Copy 3 XML files from the snmp_monitoring folder to Cacti resource/snmp_queries directory
cd /lswsinstall/add-ons/snmp_monitoring/
cp litespeed_general.xml /cacti_install_path/resource/snmp_queries/
cp litespeed_vhostxml /cacti_install_path/resource/snmp_queries/
cp litespeed_extapp.xml /cacti_install_path/resource/snmp_queries/
Login to Cacti and visit “Import Templates” and either copy and paste the content “litespeed_cacti_template.xml” or just upload the file.
Make usre there are no errors.
Thats it. Your Cacti installation is complete. Time to install scripts on each to-be monitored server and get some graphs going.
Perform the following steps for each server with LiteSpeed you wish to monitor.
For CentOS 4.3 users. You can get PHP 5 easily via “CentOS Plus” yum repository:
nano /etc/yum.repos.d/CentOS-Base.repo
[centosplus]
name=CentOS-$releasever - Plus
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
#baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos4
yum install php
Check PHP Version
yum install net-snmp net-snmp-utils <-- install if not already
/etc/init.d/snmpd start <-- check to see if it exists and starts it
//working sample snmpd.conf
rocommunity public
pass .1.3.6.1.4.1.22253 /usr/bin/php /litespeed_snmp_scripts/sample.php
The most important line is the “pass” command which calls our sample.php script for all snmp data that starts with SNMP OID “.1.3.6.1.4.1.22253”.
.1.3.6.1.4.1.22253 is the official OID registered to LiteSpeed Technologies so there should not be any OID conflict.
Content of “sample.php” included with package.
<?
/*--------------------------------
assuming following entry in /etc/snmp/snmpd.conf
pass .1.3.6.1.4.1.22253 /usr/bin/php smaple.php
if you change the default parent oid node: .1.3.6.1.4.1.22253, you must also modify the .xml files.
--------------------------------*/
require_once("class.litespeed_snmp_bridge.php");
$processes = 1; //<-- value of > 1 only valid LiteSpeed Enterprise (num of cpus licensed)
$report_path = "/tmp/lshttpd/"; //<-- path to .rtreport folder. Default is /tmp/lshttpd/
$cache_time = 0; //<-- seconds to cache parsed data
$cache_file = "/tmp/_lsws_sampe_cache.txt"; //<-- cache file..full path.
//get params from snmpd pass mechanism
if(array_key_exists(1,$_SERVER["argv"]) && array_key_exists(2,$_SERVER["argv"])) {
$type = trim($_SERVER["argv"][1]);
$oid = trim($_SERVER["argv"][2]);
$bridge = new litespeed_snmp_bridge($processes, $report_path, $cache_time, $cache_file);
$bridge->process($type, $oid);
}
?>
If this server is running LiteSpeed Enterprise 2CPU license with 2 CPUS, you need to change the “processses” value to “2”.
Restart snmpd to make make changes to snmpd.conf effective.
/etc/init.d/snmpd restart
Test SNMP
snmpwalk -c public -v 1 localhost .1.3.6.1.4.1.22253.200 <-- display a list/count of avaialble virtual hosts
snmpwalk -c public -v 1 localhost .1.3.6.1.4.1.22253.201 <-- dispaly the names of the virtual hosts
snmpwalk -c public -v 1 localhost .1.3.6.1.4.1.22253.300 <-- display a list/count of avaialble extapps
snmpwalk -c public -v 1 localhost .1.3.6.1.4.1.22253.301 <-- dispaly the names of the extapps
Should look something like this. Sample output.
# snmpwalk -c public -v 1 127.0.0.1 .1.3.6.1.4.1.22253.300
SNMPv2-SMI::enterprises.22253.300.1 = INTEGER: 1
SNMPv2-SMI::enterprises.22253.300.2 = INTEGER: 2
# snmpwalk -c public -v 1 127.0.0.1 .1.3.6.1.4.1.22253.303
SNMPv2-SMI::enterprises.22253.303.1 = STRING: "phpLsapi"
SNMPv2-SMI::enterprises.22253.303.2 = STRING: "rubyLsapi"
Check output to see if it maches your LiteSpeed config. Make sure LiteSpeed server is running.
That’s all you have to do for this server. Repeat this section for each server that needs monitoring.
Time to generate all those pretty graphs everyone love so much.
Concepts of how everything ties together.
class.litespeed_stats.php : this is the parser which takes in the .rtreport files from LiteSpeed and generate a normalized data structure
class.litespeed_snmp_bridge : this is the bridge that translate litespeed_stats into snmp walkable/gettable data.
sample.php : this is the script that gets called by snmpd and passses request to snmp_bridge.
litespeed_cacti_template.xml : contains a serialized form of the Cacti host, data, query, and graph template objects.
litespeed_general.xml : data query def file for server general stats/discovery.
litespeed_vhost.xml : data query def file for virtual host stats/discovery.
litespeed_extapp.xml : data query def file for external application stats/discovery.
Under Devices within Cacti create new Device and enter a name + hostname/ip for the server to monitor and choose LiteSpeed in the Host Template field for this device.
Click on Generate Graphics for this Host.
You should now see 3 tables of data. There are total of 7 graph templates plotting/recording various forms of data from LiteSpeed.
1. Data Query [LiteSpeed General]
There should only be 1 item under this table.
There are 4 graph templates associated with with “LiteSpeed General”: Plain Traffic, SSL Traffic, Plain Connections, SSL Connections
2. Data Query [LiteSpeed Vhost]
There are minimum 2 vhost items under this table. “_Server” means server global and “_AdminVHost” is the administrative web gui instance.
There is 1 graph template associated with “LiteSpeed Vhost”: Requests. (As there is only one graph type, there will be no drop-down menu to select in Cacti)
3. Data Query [LiteSpeed ExtApp]
List of configured/discovered External Applications.
There are 2 graph templates associated with “LiteSpeed ExtApp”: Connections, Requests.
Check the objects and the type of graph to create and hit the Create button.
That’s it. You have succesfully created Cacti monitoring graphs for LiteSpeed.
It takes about 10-15 minutes for the new graphs to appear and for initial data to be generated.
Cacti is internally configured to generate delta-changes and grab new snmp info every “5” minutes. Some developers have created patches to lower this value. Very important to understand that because data is only gathered every 5 minutes by Cacti, the graphs will have much more obvious jagged edges as compared to the network interface graphs one might be used to. Traditional network interface stats values are counters, meaning aggregate values that increment, vs LiteSpeed values which are gauges, point-in-time values. As such, It really doesn’t matter if Cacti wait 5 or 10 minutes for Network interface stats as it will be cumulative. As LiteSpeed varies much more dynamically on a per second level, the lower the Cacti monitoring interval, the better the result.
Cacti cron job should be run as the LiteSpeed web server user (UID) and the LiteSpeed web server UID should have read/write access to the /cactiinstall/rra plus /cactiinstall/log folder. If permissions are incorrect, Cacti will not be able to create and update data/rra files and no graphs will be generated.