AW: check_http question?
Helmut Januschka
h.januschka at krone.at
Fri Apr 30 15:07:03 CEST 2004
I did such a plugin:
you also need a perl script within you plugins dir, returns downloaded bytes and time in seconds how long it took
just run check_site.sh -h , and enyjoy :)
:
image_leecher.pl:
#!/usr/bin/perl
use HTTP::Request;
use LWP::UserAgent;
use POSIX;
$BYTES=0;
while(<>) {
$BYTES += length($_);
if($_ =~ /^.*"(.*?).gif".*$/) {
downloadPic($1 . ".gif");
}
if($_ =~ /^.*'(.*?).gif'.*$/) {
downloadPic($1 . ".gif");
}
if($_ =~ /^.*"(.*?).jpg".*$/) {
downloadPic($1 . ".gif");
}
if($_ =~ /^.*'(.*?).jpg'.*$/) {
downloadPic($1 . ".gif");
}
}
sub downloadPic {
$myPic = shift;
if($myPic !~ /^http:.*$/) {
$myPic = "http://wcm.krone.at" . $myPic;
}
if($GOT_P{$myPic} != 1) {
$ua = LWP::UserAgent->new(agent => 'Nagios Plugin Browser :)');
$request = HTTP::Request->new(GET => $myPic);
$response = $ua->request($request);
$BYTES += length($response->content);
}
$GOT_P{$myPic}=1;
}
print ceil($BYTES/1024);
check_site.sh:
#!/bin/bash
export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
PROGNAME=`basename $0`
PROGPATH=/usr/local/nacl/plugins/
REVISION=`echo '$Revision: 1.1 $' | sed -e 's/[^0-9.]//g'`
. $PROGPATH/utils.sh
print_usage() {
echo -e "Site Load Time (HTTP Request)\nWritten by Helmut Januschka(klewan at chello.at)"
echo "---------------------Usage-----------------------------------------------"
echo "-S site to check Def: http://wcm.krone.at/krone/kmprog/C4/S00/index_c.html"
echo "-X Xtra Url (e.g.: Javascript Urls wich wget cant do) maybe used more then one time :) Def:"
echo "-w WARN if time is greater";
echo "-c CRIT if time is greater";
echo "-h Show This Help"
echo "------------------------------------------------------------------
-------"
print_revision
}
#Defs:
SITE="http://wcm.krone.at/krone/kmprog/C4/S00/index_c.html"
XTRA=" ";
WARN=10;
CRIT=20;
LOW=" Low Links: ";
while getopts S:X:w:c:h o
do
case $o in
S) SITE=$OPTARG;;
X) XTRA="${XTRA} $OPTARG ";;
w) WARN=$OPTARG;;
c) CRIT=$OPTARG;;
h) print_usage; exit $STATE_UNKOWN;;
esac
done
START_TIME=`date +%s`;
FOLDER=checkSite_plg.$$
cd /var/tmp/
mkdir $FOLDER
cd $FOLDER;
wget -O dummy.html -q $SITE
BYTE=`cat dummy.html|perl $PROGPATH/image_leecher.pl`;
if [ "$XTRA" != " " ];
then
for x in $XTRA;
do
FOR_TIME_START=`date +%s`;
wget -q $x;
BNM=`basename $x`;
BNN=`cat $BNM|perl $PROGPATH/image_leecher.pl`;
BYTE=`expr $BYTE \+ $BNN`;
FOR_TIME_END=`date +%s`;
FOR_TIME_DIFF=`expr $FOR_TIME_END \- $FOR_TIME_START`;
if [ $FOR_TIME_DIFF -gt 3 ];
then
LOW="${LOW} $x";
fi;
done;
fi;
END_TIME=`date +%s`;
DIFF=`expr $END_TIME \- $START_TIME`;
SIZE="${BYTE}K";
rm -fr /var/tmp/$FOLDER/
if [ $DIFF -gt $CRIT ];
then
echo "CRITICAL CheckPageLoad($SITE, $XTRA, $DIFF, $SIZE) $LOW";
exit $STATE_CRITICAL;
fi;
if [ $DIFF -gt $WARN ];
then
echo "WARNING CheckPageLoad($SITE, $DIFF, $SIZE) $LOW";
exit $STATE_WARNING;
fi;
echo "OK CheckPageLoad($SITE, $DIFF, $SIZE) $LOW";
exit $STATE_OK;
-----Ursprüngliche Nachricht-----
Von: Upayavira [mailto:uv at upaya.co.uk]
Gesendet: Freitag, 30. April 2004 13:22
Cc: nagios-users at lists.sourceforge.net
Betreff: Re: [Nagios-users] check_http question?
Trying /usr/lib/nagios/plugins/check_http -h
It'll show these options:
-w, --warning=INTEGER
Response time to result in warning status (seconds)
-c, --critical=INTEGER
Response time to result in critical status (seconds)
This allows you to use check_http to send warnings or critical messages
based upon response time. It won't give you anything that you can use
for reporting though.
Regards, Upayavira
Hugh Jones wrote:
>I've used something like "time lynx -source http://blah.thing
>
>
>>/dev/null" if I want the time that it takes to retreive it. In a bash
>>
>>
>shell script you can assign the output to a variable and use sed and
>cut etc to retrieve numeric values which you could then evaluate...
>
>
>
>>-----Original Message-----
>>From: nagios-users-admin at lists.sourceforge.net
>>[mailto:nagios-users-admin at lists.sourceforge.net] On Behalf
>>Of Reuben Pearse
>>Sent: 30 April 2004 10:03
>>To: jnichols at pbp.net
>>Cc: nagios-users at lists.sourceforge.net
>>Subject: Re: [Nagios-users] check_http question?
>>
>>
>>You could try using curl
>>
>>http://curl.haxx.se/
>>
>>It is a command line tool for retrieving webpages. When grabbing
>>webpages you can get it to report how many seconds it takes
>>to download
>>a page. You could probably wrap up a call to curl into a Nagios check
>>script.
>>
>>Has anyone done this already?
>>
>>--
>>
>>Reuben Pearse
>>Senior Systems Consultant
>>reuben at presence-systems.com
>>
>>
>>
>>Jonathan Nichols wrote:
>>
>>
>>
>>>Greetings!
>>>
>>>Can the check_http plugin also measure page load times, or does it
>>>just check to see if the http port is open?
>>>
>>>I have a project that I've been tasked with - need to measure page
>>>load times & also graph them.
>>>
>>>Can I do this with Nagios? If yes, how could I graph this? I know,
>>>"rrdtool" or something.. but has anyone done this? :)
>>>
>>>Thanks for any information! :D
>>>
>>>-Jonathan
>>>
>>>
>>>-------------------------------------------------------
>>>This SF.Net email is sponsored by: Oracle 10g
>>>Get certified on the hottest thing ever to hit the market... Oracle
>>>10g. Take an Oracle 10g class now, and we'll give you the exam FREE.
>>>http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click
>>>_______________________________________________
>>>Nagios-users mailing list
>>>Nagios-users at lists.sourceforge.net
>>>https://lists.sourceforge.net/lists/listinfo/nagios-users
>>>::: Please include Nagios version, plugin version (-v) and OS when
>>>reporting any issue. ::: Messages without supporting info will risk
>>>being sent to /dev/null
>>>
>>>
>>
>>-------------------------------------------------------
>>This SF.Net email is sponsored by: Oracle 10g
>>Get certified on the hottest thing ever to hit the market...
>>Oracle 10g.
>>Take an Oracle 10g class now, and we'll give you the exam FREE.
>>http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click
>>_______________________________________________
>>Nagios-users mailing list
>>Nagios-users at lists.sourceforge.net
>>https://lists.sourceforge.net/lists/listinfo/nagios-users
>>::: Please include Nagios version, plugin version (-v) and OS
>>when reporting any issue.
>>::: Messages without supporting info will risk being sent to /dev/null
>>
>>
>>
>
>
>-------------------------------------------------------
>This SF.Net email is sponsored by: Oracle 10g
>Get certified on the hottest thing ever to hit the market... Oracle
>10g.
>Take an Oracle 10g class now, and we'll give you the exam FREE.
>http://ads.osdn.com/?ad_id149&alloc_id66&op=click
>_______________________________________________
>Nagios-users mailing list
>Nagios-users at lists.sourceforge.net
>https://lists.sourceforge.net/lists/listinfo/nagios-users
>::: Please include Nagios version, plugin version (-v) and OS when reporting any issue.
>::: Messages without supporting info will risk being sent to /dev/null
>
>
>
-------------------------------------------------------
This SF.Net email is sponsored by: Oracle 10g
Get certified on the hottest thing ever to hit the market... Oracle 10g.
Take an Oracle 10g class now, and we'll give you the exam FREE. http://ads.osdn.com/?ad_id149&alloc_id66&op=ick
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue.
::: Messages without supporting info will risk being sent to /dev/null
-------------------------------------------------------
This SF.Net email is sponsored by: Oracle 10g
Get certified on the hottest thing ever to hit the market... Oracle 10g.
Take an Oracle 10g class now, and we'll give you the exam FREE.
http://ads.osdn.com/?ad_id149&alloc_id66&op=click
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue.
::: Messages without supporting info will risk being sent to /dev/null
More information about the Users
mailing list