2011
11.28

For a while I wanted to graph the HTTP response time of my server(s). I already had Nagios monitor it but now I wanted a nice Cacti image. Based on the check_http script I created (thanks to guy2006) a Perl wrapper to return the response time part:

# /usr/lib/nagios/plugins/check_http -H foo.bar.com -f follow -t 60
HTTP OK: HTTP/1.1 200 OK - 17235 bytes in 0.135 second response time |time=0.134897s;;;0.000000 size=17235B;;;0

The response time part is used as a “Data Input Method” for Cacti.

Implementation:

Create the file check_http.pl in /usr/share/cacti/site/scripts/.

#!/usr/bin/env perl
$response = `/usr/lib/nagios/plugins/check_http -H $ARGV[0] -f follow -t 60`;
chomp $response;
($load) = ($response =~ /time=(\d+\.\d+|\d+\.|\.\d+|\d+)/);
print "$load\n";

Make sure you have the file check_http (it’s in the nagios-plugins-basic package) and it’s located in /usr/lib/nagios/plugins/.

# apt-file search check_http
kannel-extras: /usr/lib/kannel/checks/check_http.sh
kannel-extras: /usr/lib/kannel/checks/check_httpsmsc_kannel.sh
nagios-plugins-basic: /usr/lib/nagios/plugins/check_http
nagiosgrapher: /usr/share/nagiosgrapher/debian/cfg/ngraph.d/standard/check_http.ncfg
# locate check_http
/usr/lib/nagios/plugins/check_http

Test the Perl wrapper, preferably as user cacti:

# perl check_http.pl foo.bar.com
0.425045

Import the XML Template into Cacti (it’s under Import/Export).

Make sure to change the “Consolidation Function” (of Item # 1) from LAST to Average (it’s under Templates -> Graph Templates). Also make sure to fill in an ip address or hostname. Otherwise your graph will be blank.

Your graph will look something like this:

Cacti - HTTP Response Time

Cacti - HTTP Response Time

References:

2011
11.08

While installing RMySQL on OS X and Linux is really simple this is not the case for Windows. After trying several how to’s RMySQL still wasn’t working. Then I started experimenting my self… With success!

This is what I did:

  • Install R 2.14
  • Install R tools (2.14) (with modifying path option)
  • Install MySQL (5.5.17) (with modifying path option)
  • Create the file Renviron.site in the folder C:\Program Files\R\R-2.14.0\etc and add:

    MYSQL_HOME=C:/Program Files/MySQL/MySQL Server 5.5
    
  • Copy libmysql.lib and libmysql.dll from

    C:\Program Files\MySQL\MySQL Server 5.5\lib to
    C:\Program Files\MySQL\MySQL Server 5.5\lib\opt (must be created)

  • Copy libmysql.dll from
    C:\Program Files\MySQL\MySQL Server 5.5\lib to
    C:\Program Files\R\R-2.14.0\bin\i386
  • Open R and install RMYSQL

    install.packages('RMySQL', type = 'source');
    

If everything went well you’ll now be able to load the RMySQL package by invoking:

library(RMySQL);

in R.

Resources: