cmd/bat file help plz...running it via check_nrpe

Lori Adams ladams at cloudmark.com
Tue Aug 9 00:55:10 CEST 2005


I think the problem is that you're trying to use nrpe to run the
reboot-server script.  

If you can run your cmd/bat file on your remote machine by hand, then
you know that is written correctly.  

Once that works then you can set up an event handler on your service
check definition.   Using nrpe to shutdown your machine, you'll not get
a response back, as the machine will have been rebooted.  

Is there a way for you to use ssh, or some other method to reboot.

-Lori

-----Original Message-----
From: nagios-users-admin at lists.sourceforge.net
[mailto:nagios-users-admin at lists.sourceforge.net] On Behalf Of HP Geeza
Sent: Monday, August 08, 2005 11:32 AM
To: nagios-users at lists.sourceforge.net
Subject: [Nagios-users] cmd/bat file help plz...running it via
check_nrpe

Can somebody help me write a cmd/bat file please....

>From: "HP Geeza" <getbacktome3 at hotmail.com>
>To: Ludo.Bosmans at aureusim.be, nagios-users at lists.sourceforge.net
>Subject: RE: [Nagios-users] RE: run a script based on event??
>Date: Mon, 08 Aug 2005 10:37:41 +0100
>
>All,
>
>I have managed to install nrpe on the windows machine and nagios box.
I 
>can run a command such as:
>
>./check_nrpe -H <ip address of windows box> -c check_cmd
>
>which returns "hello from cmd" to my nagios box.  The check_cmd command

>looks like:
>
>command[check_cmd]=C:\source\nrpe\NoSSLbin\bin\test.cmd
>
>the contents of the test.cmd file looks like:
>
>@echo off
>echo hallo from cmd
>exit 1
>
>This proves that nrpe is working.  However i am a little stuck when it 
>comes to executing the reboot_server command which in turn calls a 
>shutdown.cmd file which will reboot my remote windows server.  I would
be 
>greatfully for any comments on what i am doing wrong and how i can
solve 
>this problem:
>
>command[reboot_server]=C:\source\psshutdown\shutdown.cmd
>
>the contents of the shutdown.cmd file is:
>
>C:\WINDOWS\system32\shutdown.exe -r
>echo system shutting down from cmd
>exit 1
>
>the command im running from my nagios box is:
>
>./check_nrpe -H 10.30.128.254 -c reboot_server
>
>BUT i then get a message saying:
>
><remote windows server machine name>: The system could not find the 
>environment option that was entered.(203)
>
>However when i double click on the shutdown.cmd file on my remote
windows 
>machine the machine reboots itself....
>
>
>>From: "Ludo Bosmans" <Ludo.Bosmans at aureusim.be>
>>To: "HP Geeza" 
>><getbacktome3 at hotmail.com>,<nagios-users at lists.sourceforge.net>
>>Subject: RE: [Nagios-users] RE: run a script based on event??
>>Date: Fri, 5 Aug 2005 13:19:14 +0200
>>
>>Geeza,
>>Yes of course this is possible.
>>
>>1) On your winserver install the nrpe service as documented in the
>>README or INSTALL guide and adapt nrpe.cfg as needed.
>>So in your nrpe.cfg file (on the win server) there should be a config
>>entry:
>>command[reboot_server]=c\reboot.bat
>>
>>2) Make a bat file that contain the shutdown.exe command with the
>>correct parameters.
>>
>>3) In your checkcommands.cfg file create a command(this is an
example):
>>
>># reboot_win_server
>>define command{
>>         command_name	reboot_win_server
>>         command line	$USER1$/reboot_win_server.sh $HOSTNAME$
>>$HOSTADDRESS$
>>}
>>
>>4) In your plugin directory make a small script(reboot_win_server.sh):
>>This example is just the minimum
>>
>>#bin/sh
>>HOST_NAME=$1
>>IP_ADDRESS=$2
>>/usr/lib/nagios/plugins/check_nrpe -H $HOST_ADDRESS -t 5 -c
>>reboot_server
>>
>>5) Of course there are alternatives, it is possible to define directly
>>in the checkcommands.cfg the check_nrpe instead of calling a script:
>>
>># reboot_win_server
>>define command{
>>         command_name	reboot_win_server
>>         command line	$USER1$/check_nrpe -H $HOSTADDRESS$ -t 5 -c
>>reboot_server
>>}
>>
>>6) To test, at least install the win site, try a manual execution of
the
>>check_nrpe ... reboot
>>
>>7) Finally I didn't really test this explanation, so I hope that I
>>didn't have make mistakes in my explanation.
>>Kind regards,
>>
>>Ludo
>>
>>
>>-----Original Message-----
>>From: HP Geeza [mailto:getbacktome3 at hotmail.com]
>>Sent: vrijdag 5 augustus 2005 12:43
>>To: Ludo Bosmans; nagios-users at lists.sourceforge.net
>>Subject: RE: [Nagios-users] RE: run a script based on event??
>>
>>Ok im a little confussed now...is the following possible via nagios?
>>
>>Monitor a temp probe in lab (this i know is possible via snmp)...if
the
>>temp
>>value goes critical then run check_nrpe (through an event
>>handler)...which
>>will then run a script on the windows machine?
>>
>>--->>> can check_nrpe be run as an event handler once the temp value
is
>>critical?
>>
>>I can shutdown the windows machine fine as i have already got the
>>commands
>>to do that.  I just need a way to call that script/bat flile when the
>>temp
>>value goes critical.
>>
>>
>> >From: "Ludo Bosmans" <Ludo.Bosmans at aureusim.be>
>> >To: "HP Geeza"
>> ><getbacktome3 at hotmail.com>,<nagios-users at lists.sourceforge.net>
>> >Subject: RE: [Nagios-users] RE: run a script based on event??
>> >Date: Fri, 5 Aug 2005 09:25:33 +0200
>> >
>> >Hi,
>> >
>> >Have a look to following link, it is quiet easy to make a windows
bat
>> >file with the correct options to reboot.
>> >http://windows.about.com/od/schedulingandbatchjobs/l/aa012400a.htm
>> >
>> >Install nrpe_nt on the windows server and and use check_nrpe to
execute
>> >the reboot bat file on the win server when it is necessary, f.e.
with
>>an
>> >eventhandler script.
>> >
>> >Kind regards,
>> >
>> >ludo
>> >
>> >
>> >-----Original Message-----
>> >From: nagios-users-admin at lists.sourceforge.net
>> >[mailto:nagios-users-admin at lists.sourceforge.net] On Behalf Of HP
Geeza
>> >Sent: donderdag 4 augustus 2005 17:17
>> >To: nagios-users at lists.sourceforge.net
>> >Subject: RE: [Nagios-users] RE: run a script based on event??
>> >
>> >I know that this isn't the best place to ask this sort of
>>question...but
>> >id
>> >be greatfull for any advice/help!!!
>> >
>> >I need a way to shutdown remote windows servers through an event
>>handler
>> >in
>> >nagios...i dont quiet know how to write a script (whether it be perl
or
>> >bash) which will allow me to do this.  the way i understand it is
there
>> >currently isnt a way to run a windwos command in linux.
>> >
>> >I can quiet easily run the shutdown command from a windows box to
>> >shutdown a
>> >remote windows machine...but becuase nagios runs in linux i need a
way
>> >to
>> >shutdown windows machines from linux.
>> >
>> >Any ideas????
>> >
>> > >From: "Marc Powell" <marc at ena.com>
>> > >To: <nagios-users at lists.sourceforge.net>
>> > >Subject: [Nagios-users] RE: run a script based on event??
>> > >Date: Wed, 3 Aug 2005 10:08:47 -0500
>> > >
>> > >
>> > >
>> > > > -----Original Message-----
>> > > > From: HP Geeza [mailto:getbacktome3 at hotmail.com]
>> > > > Sent: Wednesday, August 03, 2005 10:01 AM
>> > > > To: Marc Powell; nagios-users at lists.sourceforge.net
>> > > > Subject: run a script based on event??
>> > > >
>> > > > HI
>> > > >
>> > > > I was wondering if this is possible and whether anybody has
tried
>> >it?
>> > >- I
>> > > > am
>> > > > monitoring the temperature probe in our lab via snmp...and as a
>> >result
>> > >i
>> > > > was
>> > > > wondering whether it is possible in nagios to run a script of
some
>> > >sort
>> > > > (which will probably contain some sort of shutdown command)
when
>>the
>> > > > temperature triggers an event i.e when it goes above a certain
>> > >threshold.
>> > > >
>> > > > I would like to do this because if the AC busts and our lab
starts
>> >to
>> > > > overheat then i would like nagios to run a script which will
turn
>> >off
>> > >some
>> > > > of the machines?
>> > >
>> > >Oddly enough they're called event handlers.
>> > >
>> > >http://nagios.sourceforge.net/docs/1_0/eventhandlers.html
>> > >
>> > >--
>> > >Marc
>> > >
>> > >p.s. Please don't e-mail me directly. Even though I participate a
lot
>> > >here, I'm not dedicated Nagios support ;)
>> > >
>> > >
>> > >
>> > >
>> > >-------------------------------------------------------
>> > >SF.Net email is sponsored by: Discover Easy Linux Migration
>>Strategies
>> > >from IBM. Find simple to follow Roadmaps, straightforward
articles,
>> > >informative Webcasts and more! Get everything you need to get up
to
>> > >speed, fast. http://ads.osdn.com/?ad_idt77&alloc_id492&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
>> >
>> >_________________________________________________________________
>> >Want to block unwanted pop-ups? Download the free MSN Toolbar now!
>> >http://toolbar.msn.co.uk/
>> >
>> >
>> >
>> >-------------------------------------------------------
>> >SF.Net email is Sponsored by the Better Software Conference & EXPO
>> >September 19-22, 2005 * San Francisco, CA * Development Lifecycle
>> >Practices
>> >Agile & Plan-Driven Development * Managing Projects & Teams *
Testing &
>> >QA
>> >Security * Process Improvement & Measurement *
>> >http://www.sqe.com/bsce5sf
>> >_______________________________________________
>> >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
>> >
>> >
>> >-------------------------------------------------------
>> >SF.Net email is Sponsored by the Better Software Conference & EXPO
>> >September 19-22, 2005 * San Francisco, CA * Development Lifecycle
>>Practices
>> >Agile & Plan-Driven Development * Managing Projects & Teams *
Testing &
>>QA
>> >Security * Process Improvement & Measurement *
>>http://www.sqe.com/bsce5sf
>> >_______________________________________________
>> >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
>>
>>_________________________________________________________________
>>Be the first to hear what's new at MSN - sign up to our free
>>newsletters!
>>http://www.msn.co.uk/newsletters
>>
>
>_________________________________________________________________
>It's fast, it's easy and it's free. Get MSN Messenger 7.0 today! 
>http://messenger.msn.co.uk
>
>
>
>-------------------------------------------------------
>SF.Net email is Sponsored by the Better Software Conference & EXPO
>September 19-22, 2005 * San Francisco, CA * Development Lifecycle
Practices
>Agile & Plan-Driven Development * Managing Projects & Teams * Testing &
QA
>Security * Process Improvement & Measurement *
http://www.sqe.com/bsce5sf
>_______________________________________________
>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

_________________________________________________________________
Use MSN Messenger to send music and pics to your friends 
http://messenger.msn.co.uk



-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle
Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing &
QA
Security * Process Improvement & Measurement *
http://www.sqe.com/bsce5sf
_______________________________________________
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


-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
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