Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

AT command from script

Status
Not open for further replies.

mjoyner

IS-IT--Management
Jul 26, 2009
46
US
I need to write a nagios plugin that will send a job to the background and return to nagios.

If I let nagios wait for the job to finish, it will be 3 minutes. This will hold all other service checks.

So what I would like to do it have nagios call a script, and then have the script start the process (send to background) and the return to nagios.

I would have to do this as nagios user.

Thanks.........

[root@netwatch ~]# yum remove windows
Loaded plugins: fastestmirror
Setting up Remove Process
No Match for argument: windows
No Packages marked for removal

OH YEAH!
 
You don't need to use "at". This would be the script that Nagios runs...
Code:
#!/bin/ksh

nohup /path/to/myscript.sh > /path/to/myscript.log 2>&1 &

This will run the script in the background, but returns immediately, not waiting for it to complete.

 
Sam, I guess I need to return a "OK" status with exit code "2" for ok.

How should I do that?

[root@netwatch ~]# yum remove windows
Loaded plugins: fastestmirror
Setting up Remove Process
No Match for argument: windows
No Packages marked for removal

OH YEAH!
 
Um............ dope! and no.... Im not on crack!

:)

[root@netwatch ~]# yum remove windows
Loaded plugins: fastestmirror
Setting up Remove Process
No Match for argument: windows
No Packages marked for removal

OH YEAH!
 
That hack doesn't working:
#./telica_poller.sh
./telica_poller.sh: line 4: syntax error near unexpected token `2'
./telica_poller.sh: line 4: `nohup /usr/local/nagios/libexec/telica_poller.pl -d -c /usr/local/nagios/libexec/ > 2>&1 &'

Here's the script:
#!/bin/bash
nohup /usr/local/nagios/libexec/telica_poller.pl -d -c /usr/local/nagios/libexec/ > 2>&1 &

[root@netwatch ~]# yum remove windows
Loaded plugins: fastestmirror
Setting up Remove Process
No Match for argument: windows
No Packages marked for removal

OH YEAH!
 
You've left out the log file name that you are redirecting output to:

Bash:
!/bin/bash
nohup /usr/local/nagios/libexec/telica_poller.pl -d -c /usr/local/nagios/libexec/ > [COLOR=red]/some/log/file.out[/color] 2>&1 &

Annihilannic.
 
Yep....... I tried it with the file name and it worked.

THANKS

[root@netwatch ~]# yum remove windows
Loaded plugins: fastestmirror
Setting up Remove Process
No Match for argument: windows
No Packages marked for removal

OH YEAH!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top