LiteSpeed SNMPD Bridge + Cacti Graphing

Following based on Centos/RHEL 5 Linux distribution. The following guide is applicable to both the LiteSpeed Load Balancer and LiteSpeed Web Server products.

1) Install LiteSpeed Web Server 4.0+/Load Balancer 1.7+

The SNMPD Bridge/Parser scripts and Cacti Templates are part of LiteSpeed and accessible via the /add-ons/ folder within the installer package. Please make sure you are using the scripts and Cacti templates from LiteSpeed 4.0.17+ version as the files have been updated to be compatible with the latest versions of Cacti.

2) Install Cacti

Download/Install Cacti version 0.8.7g or higher:

3) Install Net-SNMP-Utils

yum install net-snmp-utils <-- install if not already

1) Copy LiteSpeed SNMPD Bridge scripts and Cacti Templates

SNMPD Bridge scripts and Cacti Templates are in the “/add-ons/snmp_monitoring/” folder of the latest LiteSpeed installer packages.

Copy 3 XML files from the snmp_monitoring folder to Cacti resource/snmp_queries directory

cd /usr/local/lsws/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/

2) Import LiteSpeed Cacti Template

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.

3) Server Monitoring

Perform the following steps for each server with LiteSpeed you wish to monitor.

I. Install PHP 5

As of latest versions of LiteSpeed WebServer, PHP comes preinstalled. Check if it is installed and if it is at least PHP5 by running the following:

/usr/local/lsws/lsphp5/bin/php -v

If not follow the steps here:

For CentOS 5/6/7 users.

yum install php

Check PHP Version

/usr/bin/php -v

Makse sure you have PHP 5 installed. The scripts will not operate under PHP 4.

II. Install Net-SNMP (snmpd) service

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

III. Modify /etc/snmp/snmpd.conf

#working sample snmpd.conf
rocommunity  public
pass . /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 “.”.

. is the official OID registered to LiteSpeed Technologies so there should not be any OID conflict.

Be sure to replace /usr/bin/php and /litespeed_snmp_scripts/sample.php with the paths that you have setup on your server.

Content of “sample.php” included with package.



//Processes: number of CPUs/cores licensed for LiteSpeed. Standard version is always 0. 
//Usage: Set this to your licensed cpus/cores. 
$processes = 1; 

//Report Path: path to .rtreport folder.
//Usage: For Litespeed Web Server use '/tmp/lshttpd/'. For LiteSpeed Load Balancer use '/tmp/lslbd/'.
$report_path = "/tmp/lshttpd/"; 

$cache_time = 0; //<-- seconds to cache parsed data
$cache_file = "/tmp/_lsws_sample_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”. If you are using LiteSpeed Load Balancer, please update the report_path value to “/tmp/lslbd/”

IV. Restart SNMPD and Test SNMP

Restart snmpd to make make changes to snmpd.conf effective.

/etc/init.d/snmpd restart


snmpwalk -c public -v 1 localhost . <-- display a list/count of avaialble virtual hosts
snmpwalk -c public -v 1 localhost . <-- dispaly the names of the virtual hosts

snmpwalk -c public -v 1 localhost . <-- display a list/count of avaialble extapps
snmpwalk -c public -v 1 localhost . <-- dispaly the names of the extapps

Should look something like this. Sample output.

# snmpwalk -c public -v 1 .
SNMPv2-SMI::enterprises.22253.300.1 = INTEGER: 1
SNMPv2-SMI::enterprises.22253.300.2 = INTEGER: 2

# snmpwalk -c public -v 1 .
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.

IV. Issues

Sometimes people run into issues setting up Cacti with LiteSpeed. Here are a couple of the most common.

Double check PHP

# If you installed via yum
/usr/bin/php -v
# If you are using prebuilt
/usr/local/lsws/lsphp5/bin/php -v

Receiving error “End of MIB” when running snmpwalk?

This usually means there is an error with you snmpd.conf . Try replacing your snmpd.conf with the sample we provide above.

Bad paths in snmpd.conf.

Double check your paths for PHP and snmp_monitoring in your snmpd.conf . If there is a mistake with either, it will not communicate with cacti.

Make sure snmp is running.

service snmpd status

1) Overview

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.

2. "LiteSpeed" Device

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 Create Graphs 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.

3. Notes

Do not create graphs via the “Graph Templates” menu or table. If you did, remove those graphs and their associated data sources. Graphs and data sources create via this method will not work.

To create a graph, use the “Data Query” menu or table and choose from “LiteSpeed General, LiteSpeed Vhost, LiteSpeed ExtApp”.

There are 4 graphs for “LiteSpeed General”: Plain Connections, Plain (bits/s), SSL connections, SSL (bits/s). The selection screen for Cacti is confusing as to make it appears you can only choose 1 graph max for “LiteSpeed General”. You need to use the drop down menu to select the graph type and if it hasn't been created yet, it will allow you to check the item. Otherwise, it will be grayed out. For each graph type, select the graph, check item, then add.

It takes about 10-15 minutes for the new graphs to appear and for initial data to be generated.

Cacti by default generate delta-changes and grab new snmp info using cron every 5 minutes. For best results, upgrade to the latest Cacti and go to cacti settings and change both the poller and cron settings to 60 seconds/1minute.

If 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.

4. Sample Graphs

  • Admin
  • Last modified: 2017/05/11 21:20
  • by Michael Alegre