Now that I have a server running selenium tests against a magento-powered ecommerce site and logging those tests to a file, we need to integrate with nagios. First, I installed openSSH on that windows server (via copssh), and copied over the nagios user public key to authorized_keys. Then I wrote this nagios script:

#! /usr/bin/php -q
<?php
ini_set( 'max_execution_time', '55' );
ini_set( 'display_errors', false );
 
define( "STATUS_OK",       0 );
define( "STATUS_WARNING",  1 );
define( "STATUS_CRITICAL", 2 );
define( "STATUS_UNKNOWN",  3 );
 
$execCommand='ssh WINDOWS_SERVER_IP_GOES_HERE -l nagiosremote "tail -n 1 selenium.txt"';
exec($execCommand,$output);
list($id,$date,$time,$status,$avg,$std,$FLAG,$flagCnt,$statCnt)=split(',',$output[0],9);
if ((strpos($status,'OK')===false)||(strpos($FLAG,'ERROR')!==false))
{
        echo("ERROR: $status $FLAG\n");
        exit( STATUS_CRITICAL );
}
else
{
        echo("OK: time $time, status $status, avg $avg, std $std, FLAG $FLAG, flagCnt $flagCnt, statCnt $statCnt\n");
        exit( STATUS_OK );
}

Then I defined a check_command, a host, a host_group and a service in nagios and we’re in business!