Hi,
excellent question!
I have the same problem, and I didn’t really find a really good way to monitor this.
Anyway, if you can’t find better (if you do, please post it, I’m interested :)), here is what I did:
I installed wget
and I wrote this little script (sorry, some variable names are in french, but it should be ok anyway):
[code]#!/usr/bin/perl
use strict;
use IPC::Open3;
my $URL = $ARGV[0];
my $seuil = $ARGV[1];
my $path = “$ENV{NAGIOS_HOME}/libexec/wget”;
my $command = “time $path/bin/wget -x --no-cache -P $path/download/ -p --delete-after -nv -erobots=off --no-proxy --no-dns-cache --cache=off -H --header=‘Cache-Control: max-age=0, no-cache’ $URL”;
my $seconds = 60;
my $i = 0;
eval {
local $SIG{ALRM} = sub { die “TIMEOUT\n” };
alarm($seconds);
open3(*WRITEHANDLE, *READHANDLE, *ERRHANDLE, $command);
alarm(0); # cancel alarm (if code ran fast)
};
alarm(0); # cancel alarm (if eval failed)
if ( $@ eq “TIMEOUT\n” ) {
print “No response from server\n”;
exit 2;
}
my @result = ;
my $temps_de_recup;
my $previous_line;
my $temps_de_recup_sec;
my $temps_de_recup_milli;
my $temps_de_recup_min;
foreach my $result (@result) {
chomp($result);
if ( $result =~ /wget:(.*)$/ ) {
print “Error while getting the page $URL: $1\n”;
exit 2;
}
if ( ($result =~ /ERROR 404/ || $result =~ /not found/ ) && ( $previous_line!~ /favicon/ && $previous_line!~ /%5C%22/ ) ) {
print “Error 404 found on page $URL: $previous_line\n”;
exit 1;
}
if ( $result =~ /real\s+(\d+)m(\d+).(\d+)/ ) {
$temps_de_recup_min = $1;
$temps_de_recup_sec = $2;
$temps_de_recup_milli = $3;
}
$previous_line = $result;
}
$temps_de_recup = $temps_de_recup_min*60 + $temps_de_recup_sec + $temps_de_recup_milli/1000;
print “Time to get everything: $temps_de_recup sec (seuil: $seuil sec)\n”;
if ( $temps_de_recup > $seuil ) {
exit 1;
}
exit 0;[/code]
the script runs wget, which “gets” the page, and all its elements
So, if a gif is missing, or something like that, you’ll get a warning.
The problem is that wget doesn’t understand flash or javascript …
and it doesn’t take into account the global layout.
So, all it does is get the time it takes to load the page, and check that all your components are accessible.
It’s not much, but it’s better than nothing