Hello!
On 09/01/04 10:41, Alexander Mayrhofer wrote:
On (01.09.04 08:53), Tirp?k Mikl?s wrote:
I have found it on this mailing list, it is written by Alex Mayrhofer and based on sipsak. My colleagues have modified some part in it, and I have written an UA which simply responds 200 OK to every request. We use this way:
are you willing to share your changes to the plugin?
Of course. I do not find the original to make a patch file, so I attach the modified version.
Miklos
#! /usr/bin/perl -wT # # check_ser: Nagios plugin for checking SER using sipsak. # Alex Mayrhofer, nic.at <axelm at nic.at> # no warranty, licensed GPL2
use lib "/usr/lib/nagios/plugins"; use vars qw($opt_H $opt_w $opt_c $opt_U $opt_r $param $PROGNAME $warning $url $host $password $runtimedir $remoteport);
BEGIN { if ($0 =~ m/^(.*?)[/\]([^/\]+)$/) { $runtimedir = $1; $PROGNAME = $2; } }
use Getopt::Long; use lib $main::runtimedir; use utils qw(%ERRORS &print_revision &support &usage); use strict;
sub print_help (); sub print_usage ();
delete @ENV{'PATH', 'IFS', 'CDPATH', 'ENV', 'BASH_ENV'};
Getopt::Long::Configure('bundling', 'no_ignore_case'); GetOptions ("V|version" => &version, "h|help" => &help, "w|warning=s" => $opt_w, "c|critical=s" => $opt_c, "H|hostname=s" => $opt_H, "U|url=s" => $opt_U, "r|remoteport=s" => $opt_r);
($opt_r) || ($opt_r = shift); $remoteport = $1 if ($opt_r =~ /([0-9]+)$/); ($remoteport) || usage("Invalid remote port: $opt_r\n");
($opt_U) || ($opt_U = shift) || usage("URL not specified\n"); # TODO: allow port and parameters? my $url = $1 if ($opt_U =~ m/^(sip:[a-zA-Z0-9+*#]+@[a-zA-Z0-9.]+)$/); ($url) || usage("Invalid URL: $opt_U\n");
($opt_H) || ($opt_H = shift); $host = $1 if ($opt_H =~ /^([a-z.0-9]+)$/); ($host) || usage("Invalid host: $opt_H\n");
($opt_w) || ($opt_w = shift) || usage("Warning threshold not specified\n"); $warning = $1 if ($opt_w =~ /([0-9]+)$/); ($warning) || usage("Invalid warning threshold: $opt_w\n");
($opt_c) || ($opt_c = shift) || usage("Critical threshold not specified\n"); my $critical = $1 if ($opt_c =~ /([0-9]+)$/); ($critical) || usage("Invalid critical threshold: $opt_c\n");
my $sig=0; my $param=0; $param = ($host) ? "-H $host -s $url -r $remoteport -vv" : "-s $url -vv"; $sig = `/usr/bin/sipsak $param`;
if ($sig !~ m/SIP/2.0 200 OK/) { print "SIP CRITICAL - missing 200 reply\n"; exit $ERRORS{'CRITICAL'}; }
if ($sig !~ m/reply received after ([0-9.]+) ms/) { if ($sig !~ m/reply received ([0-9.]+) ms after first send/) { print "SIP CRITICAL - missing duration value\n"; exit $ERRORS{'CRITICAL'}; } else { $sig = $1; } } else { $sig = $1; }
if ($sig>$critical) { print "SIP CRITICAL - Test Duration: $sig ms\n"; exit $ERRORS{'CRITICAL'}; }
if ($sig>$warning) { print "SIP WARNING - Test Duration: $sig ms\n"; exit $ERRORS{'WARNING'} }
print "SIP OK - Test Duration: $sig ms\n"; exit $ERRORS{'OK'};
sub print_usage () { print "Usage: $PROGNAME -H <host> -U <sip url> -w <warn> -c <crit>\n"; }
sub print_help () { print_revision($PROGNAME,'version 0.1'); print "Copyright (c) 2003 nic.at (Alexander Mayrhofer)
This plugin tests a SIP eXpress Router.
"; print_usage(); print " -U, --url=STRING SIP URL to use for check -w, --warning=INTEGER response time in ms above which a WARNING status will result -c, --critical=INTEGER response time in ms above which a CRITICAL status will result
"; support(); }
sub version () { print_revision($PROGNAME,'Version: 0.1'); exit $ERRORS{'OK'}; }
sub help () { print_help(); exit $ERRORS{'OK'}; }