sending external commands remotely

frank ratty at they.org
Tue Mar 17 05:53:56 CET 2009


Here are 2 ways to do this:

1. Click thru the web interface the normal way you would (un)silence the 
service(s)/servicegroup(s) in question but before submitting the form do a 
View-Source and use the variables and values there to create yourself a 
properly encoded URI and call it with wget. ex:
(silence)
wget -O - http://nagios-server/nagios/cgi-bin/cmd.cgi?cmd_typ=23&cmd_mod=2&host=hostname&service=svcdesc > /dev/null
(unsilence)
wget -O - http://nagios-server/nagios/cgi-bin/cmd.cgi?cmd_typ=22&cmd_mod=2&host=hostname&service=svcdesc > /dev/null

I haven't read thru the source or tried these examples so I don't know if 
you also need to include "&btnSubmit=Commit" to the URI. Or perhaps it 
won't work at all as a GET instead of a POST.


2. Write a CGI that accepts host, service, and silence/unsilence 
variables. Feed the results directly to the Nagios command pipe 
(/var/log/nagios/rw/nagios.cmd). Once you've verified your input args, 
feed them to the pipe like:

my $time = time();
open(CMD,">>/var/log/nagios/rw/nagios.cmd");
print CMD "[$time] DISABLE_SVC_NOTIFICATIONS;hostname;servicename\n";
close(CMD);

Again, I haven't tested any of this, but it oughtta work in theory.

-f

On Mon, 16 Mar 2009, Eric Pearce wrote:

> Date: Mon, 16 Mar 2009 14:48:55 -0700
> From: Eric Pearce <epearce at amberpoint.com>
> To: nagios-users at lists.sourceforge.net
> Subject: [Nagios-users] sending external commands remotely
> 
>  
> I'd like to be able to remotely turn off/turn on service/host checks.  For example, a remote
> machine could turn off a service check while running a backup and turn it back on after it is
> done.  Ideally, this is a simple perl script, wrapper for 'wget', batch file, etc that could run
> on Unix or Windows (maybe using SSL for securing the password?).   I assume it would talk
> directly to cgi on the nagios server.  I've seen some others asking for something similar, but
> no definitive replies.   My understanding of NSCA is that is simply for collecting passive
> information, and can't actually change things, right?
>  
> Yes, I could schedule downtime via Nagios, but the downtime is of variable length, the so the
> exact backup window is not known in advance.  The machine doing the actual backup "knows
> best" when turn monitoring on and off.   NFS mounting the nagios command file is not an
> option.    I did see the old remote_ctl.pl script on nagiosexchange but I don't want to
> do anything non-standard on the nagios server if possible.  I understand that I could use ssh to
> run local commands on nagios server, but I'm looking for something more elegant.
>  
> My setup is Linux server running Nagios 3.0.6 and 1.4.13 plugins monitoring Linux, Solaris and
> Windows 2000/XP/2003/Vista/2008 hosts.
>  
> Thanks
> -e
>  
> 
>
-------------- next part --------------
------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
-------------- next part --------------
_______________________________________________
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