HTTP(S)? on multiple ports - simple single-service definition

Stanley Hopcroft Stanley.Hopcroft at IPAustralia.Gov.AU
Sat Jun 14 05:19:49 CEST 2003


Dear Sir,

I am writing to thank you for your letter and say,

On Fri, Jun 13, 2003 at 05:02:02PM -0500, Skip Montanaro wrote:
> 
> I have one machine which listens for http requests on ports 80, 81 and 82
> and for https requests on ports 443 and 444.  At the moment besides
> http-service and https-service definitions, I have three others defined for
> the odd ports.  For one machine alone I thus have three special services and
> two special check commands defined.
> 
> This seems like a waste.  It's certainly going to be a scalability nightmare
> should this happen very often.  Is there a simpler way to do this which
> doesn't require me to always declare the port to connect to?  Something like
> 
>     define command{
>       command_name check_http
>       command_line $USER1$/check_http -H $HOSTADDRESS$ -u $ARG1$ -p $ARG2|80$
>     }
> 
> so when invoked without a second argument like so:
> 
>     check_http!/
> 
> $ARG2$ would default to 80:
> 
>     $USER1$/check_http -H $HOSTADDRESS$ -u $ARG1$ -p 80
> 
> Or is there another way to do this?  I read the "sanity" chapter in the
> docs.  It mostly seemed to concern itself with defining the same
> service/escalation/whatever across many hosts.  Maybe using that for other
> machines with identical services will make this problem bearable though...
> 

that a wrapper encapsulating check_http comes to mind

#!/usr/bin/perl -w

use strict ;
use utils qw(..) ;

# getopt the -p option and decide what to do with it

my $port = ( $opt_p =~ m#\S+\|80# ? _port_corresp_to_arg2 : 80 ) ;

# probably you would need to decode $ARG2 from what you say

system("check_http .. -p $port) && do {
  # nope. don't use system, otherwise no output
  exit $ERRORS{CRITICAL} ; # or whatever ..

  # actually, once the args are got exec() check_http and let it worry
  # about output and return code.
};

print "consoling message.\n" ;
exit $ERRORS{'OK'} ;


> Any suggestions appreciated.
> 
> -- 
> Skip Montanaro
> skip at pobox.com
> Check out Spambayes as a spam filter: http://spambayes.sf.net/
> 

HTH,

Yours sincerely.

------------------------------------------------------------------------
Stanley Hopcroft
------------------------------------------------------------------------

'...No man is an island, entire of itself; every man is a piece of the
continent, a part of the main. If a clod be washed away by the sea,
Europe is the less, as well as if a promontory were, as well as if a
manor of thy friend's or of thine own were. Any man's death diminishes
me, because I am involved in mankind; and therefore never send to know
for whom the bell tolls; it tolls for thee...'

from Meditation 17, J Donne.


-------------------------------------------------------
This SF.NET email is sponsored by: eBay
Great deals on office technology -- on eBay now! Click here:
http://adfarm.mediaplex.com/ad/ck/711-11697-6916-5
_______________________________________________
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