[Nagiosplug-help] Plugin help and needed!
Subhendu Ghosh
sghosh at sghosh.org
Wed Apr 16 10:04:03 CEST 2003
One list only please.
have you tried the check_tcp plugin ?
On Thu, 17 Apr 2003, Jasmine wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hi gurus,
>
> does anyone know of a plugin that can check a port. If it is open I want it to
> return Ok status intead of critical? Because i have a script but its not
> working & On nagios web interface, it keeps reporting "no output!" error. I
> tested the script is working by itself , but somethings screwed when i tried
> to execute it as user 'nagios'.
> `su - nagios ./check_remote_port -H x.x.x.x -P 23`
>
> Here's the permissions:
> -rwxr-xr-x 1 nagios nagios 3247 Mar 27 18:41 check_remote_port
>
> Here's the script in Perl.
>
> #!/usr/bin/perl
> # Usage:
> # check_remote_port_closed -H <host>
>
> use IO::Socket;
> use Getopt::Long;
> Getopt::Long::Configure('bundling');
>
> $version=0.01;
>
> my %ERRORS = ('UNKNOWN' , '-1',
> 'OK' , '0',
> 'WARNING', '1',
> 'CRITICAL', '2');
>
>
> #
> # some default values
> #
>
>
> #
> # get command line options the regular way
> #
> GetOptions
> ("V" => \$opt_V, "version" => \$opt_V,
> "H=s" => \$opt_H, "hostname=s" => \$opt_H,
> "P=s" => \$opt_P, "port=s" => \$opt_P,
> "T=s" => \$opt_T, "timeout=s" => \$opt_T);
>
> #
> # handle the verbose stuff first
> #
> if ($opt_V) {
> print "\n";
> print "check_remote_port_closed plugin version $version\n";
> print "\n";
> print "\n";
> exit $ERRORS{'UNKNOWN'};
> }
>
>
> # now get options the weired way and set the defaults
> # if nothing else is provided
> #
> $opt_H = shift unless ($opt_H);
> $opt_P = shift unless ($opt_P);
> $opt_T = shift unless ($opt_T);
> print "No Host specified. (-H <hostname/ip>)\n" unless ($opt_H);
> exit $ERRORS{'UNKNOWN'} unless ($opt_H);
> print "No Port specified (-P <port>) \n" unless ($opt_P);
> exit $ERRORS{'UNKNOWN'} unless ($opt_P);
>
> $TIMEOUT= $opt_T || 15;
>
> $SIG{'ALRM'} = sub {
> print ("OK: Cannot connect to port (alarm)\n");
> exit $ERRORS{"OK"};
> };
> alarm($TIMEOUT);
>
>
> #
> # now we set things up for the real work
> # and fire up the request
> #
>
> # Build the socket connection.
>
> $socket = IO::Socket::INET->new(PeerAddr => $opt_H,
> PeerPort => $opt_P,
> Proto => "tcp",
> Type => SOCK_STREAM) or
> &error_can_connect;
> close ($socket);
> print "CRITICAL: Can connect to port!\n";
> exit $ERRORS{'CRITICAL'};
>
> sub error_can_connect {
> print "OK: Cannot connect to port\n";
> exit $ERRORS{'OK'};
> }
>
> Here's my service definition
>
> define service{
> host_name host abc
> service_description Telnet
> check_command check_remote_port!23!10
> active_checks_enabled 1
> passive_checks_enabled 0
> parallelize_check 1
> obsess_over_service 1
> check_freshness 0
> max_check_attempts 3
> normal_check_interval 1
> retry_check_interval 1
> check_period 24x7
> notification_interval 10
> notification_period 24x7
> notification_options n
> contact_groups admin
>
> }
>
> Here's my command definition:
>
> # 'check_remote_port' command definition
> define command{
> command_name check_remote_port
> command_line $USER1$/check_remote_port -H $HOSTADDRESS$ -P $ARG1$ \
> - -T $ARG2$
> }
>
> And, $USER1$ Macro points to the right directory where the plugin is.
>
>
> Thanks
> Jasmine Chua
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.2.1 (GNU/Linux)
>
> iD8DBQE+nYWlNgvTa7Hj2AURAgr8AJsEu7U/XllfCokjugDAQkE+oBoTxgCfdq1q
> h2XpirReC+Ac5/86izEnaq8=
> =amQO
> -----END PGP SIGNATURE-----
>
>
>
> -------------------------------------------------------
> This sf.net email is sponsored by:ThinkGeek
> Welcome to geek heaven.
> http://thinkgeek.com/sf
> _______________________________________________
> Nagiosplug-help mailing list
> Nagiosplug-help at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/nagiosplug-help
> ::: Please include plugins version (-v) and OS when reporting any issue.
> ::: Messages without supporting info will risk being sent to /dev/null
>
--
More information about the Help
mailing list