HomeFAQStatisticsVariousContact

Security : Linux : LiteSpeed webserver monitoring with Munin-node

Here are three plugins to monitor LiteSpeed HTTP webserver with Munin-node.

- Number of used and idle connections.
- Number of bits per second (in and out).
- Number of requests (in process and per second).

LiteSpeed records every second all informations in the '/tmp/lshttpd' directory inside one or more '.rtreport' files. The number of such files will be equal to the number of cores matching your license and they will be named '.rtreport', '.rtreport2', '.rtreport3' etc. In order to output accurate statistics, it is necessary to read them all.

- Number of used and idle connections :

#!/usr/bin/perl
##################################################
# LiteSpeed webserver : connections
##################################################
if ( $ARGV[0] eq 'autoconf' ) {
   if ( -e '/tmp/lshttpd/.rtreport' ) {
      print "yes\n";
      exit;
   } else {
      print "no\n";
      exit 1;
   }
}

if ( $ARGV[0] eq 'config' ) {
   open IN, "</tmp/lshttpd/.rtreport";
   while ( <IN> ) {
      if ( /^MAXCONN: (\d+),/ ) {
         $max = $1;
         last;
      }
   }
   close IN;
   print "graph_title Litespeed : connections (max. $max)\n";
   print "graph_args --base 1000 -l 0\n";
   print "graph_scale no\n";
   print "graph_vlabel connections\n";
   print "graph_category litespeed\n";
   print "graph_order used idle\n";
   print "used.label used\n";
   print "used.draw AREA\n";
   print "used.colour 96E78A\n";
   print "idle.label idle\n";
   print "idle.draw LINE1\n";
   print "idle.colour 5C6CAE\n";
   exit 0;
}

if ( ! -e '/tmp/lshttpd/.rtreport' ) {
   print "used.value 0\n";
   print "idle.value 0\n";
   exit;
}

@stats = `ls -a /tmp/lshttpd/.rtreport*`;
foreach $rep ( @stats ) {
   open IN, "<$rep";
   while ( <IN> ) {
      if ( /PLAINCONN: (\d+), AVAILCONN: \d+, IDLECONN: (\d+),/ ) {
         $used += $1;
         $idle += $2;
         last;
      }
   }
   close IN;
}
print "used.value $used\nidle.value $idle\n";
exit;

- Number of bits per second (in and out) :

#!/usr/bin/perl
##################################################
# LiteSpeed webserver : bits per second
##################################################
if ( $ARGV[0] eq 'autoconf' ) {
   if ( -e '/tmp/lshttpd/.rtreport' ) {
      print "yes\n";
      exit;
   } else {
      print "no\n";
      exit 1;
   }
}

if ( $ARGV[0] eq 'config' ) {
   print "graph_title Litespeed : bits/sec\n";
   print "graph_args --base 1000 -l 0\n";
   print "graph_scale no\n";
   print "graph_vlabel bits per second\n";
   print "graph_category litespeed\n";
   print "bpsout.label out\n";
   print "bpsout.draw AREA\n";
   print "bpsout.colour 96E78A\n";
   print "bpsin.label in\n";
   print "bpsin.draw LINE1\n";
   print "bpsin.colour 5C6CAE\n";
   exit 0;
}

if ( ! -e '/tmp/lshttpd/.rtreport' ) {
   print "bpsin.value 0\n";
   print "bpsout.value 0\n";
   exit 0;
}

@stats = `ls -a /tmp/lshttpd/.rtreport*`;
foreach $rep ( @stats ) {
   open IN, "<$rep";
   while ( <IN> ) {
      if ( /^BPS_IN: (\d+), BPS_OUT: (\d+),/ ) {
         $bpsin += $1;
         $bpsout += $2;
         last;
      }
   }
   close IN;
}
print "bpsout.value $bpsout\nbpsin.value $bpsin\n";
exit;

- Number of requests (in process and per second) :

#!/usr/bin/perl
##################################################
# LiteSpeed webserver : number of requests
##################################################
if ( $ARGV[0] eq 'autoconf' ) {
   if ( -e '/tmp/lshttpd/.rtreport' ) {
      print "yes\n";
      exit;
   } else {
      print "no\n";
      exit 1;
   }
}

if ( $ARGV[0] eq 'config' ) {
   print "graph_title Litespeed : requests\n";
   print "graph_args --base 1000 -l 0\n";
   print "graph_scale no\n";
   print "graph_vlabel requests\n";
   print "graph_category litespeed\n";
   print "rqip.label ReqInProcess\n";
   print "rqip.draw AREA\n";
   print "rqip.colour 96E78A\n";
   print "rqps.label ReqPerSecond\n";
   print "rqps.draw LINE1\n";
   print "rqps.colour 5C6CAE\n";
   exit 0;
}

if ( ! -e '/tmp/lshttpd/.rtreport' ) {
   print "rqip.value 0\n";
   print "rqps.value 0\n";
   exit 0;
}

@stats = `ls -a /tmp/lshttpd/.rtreport*`;
foreach $rep ( @stats ) {
   open IN, "<$rep";
   while ( <IN> ) {
      if ( /^REQ_RATE \[\]: REQ_PROCESSING: (\d+), REQ_PER_SEC: (\d+), TOT_REQS: / ) {
         $rqip += $1;
         $rqps += $2;
         last;
      }
   }
   close IN;
}
print "rqip.value $rqip\nrqps.value $rqps\n";
exit;