command_line commands

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
logc
Posts: 2
Joined: Fri Aug 05, 2011 3:03 pm

command_line commands

Post by logc »

Just got Nagios up and running (in a matter of minutes :D), with SNMP trapping enabled with no issues but I have command_line functionality question. We're not permitted to install sendmail, etc. on our machines so I need to run a simple system command to create a file in a directory. I thought this could be achieved by changing the notify-service-by-email comand_line to something like "/bin/echo alert > /sweep_dir/testfile.txt" but it doesn't seem to execute when the traps are received so I'm sure I'm missing something in the setup. What am I missing here?

In the host notification page, I'm seeing the notification is logged and using the notify-service-by-email command:

Code: Select all

Host   Service Type         Time            Contact     Notification Command     Information 
myhost TRAP     WARNING 08-05-2011 16:02:02 nagiosadmin notify-service-by-email  common alert 100 TestConfig TestConfig TestConfig TestConfig 

# 'notify-service-by-email' command definition
define command{
	command_name	notify-service-by-email
	command_line /bin/echo alert >/sweep_dir/testfile.txt
	}
agriffin
Posts: 876
Joined: Mon May 09, 2011 9:36 am

Re: command_line commands

Post by agriffin »

Does the nagios user have permission to write to that file? The command is not run as root.
logc
Posts: 2
Joined: Fri Aug 05, 2011 3:03 pm

Re: command_line commands

Post by logc »

Yep, that was the issue. Thanks so much, I can't beleive that never dawned on me. Thanks again.
agriffin
Posts: 876
Joined: Mon May 09, 2011 9:36 am

Re: command_line commands

Post by agriffin »

Glad I could help! Let me know if you have any further problems.
Locked