Page 1 of 1

command_line commands

Posted: Fri Aug 05, 2011 3:19 pm
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
	}

Re: command_line commands

Posted: Tue Aug 09, 2011 10:00 am
by agriffin
Does the nagios user have permission to write to that file? The command is not run as root.

Re: command_line commands

Posted: Wed Aug 10, 2011 1:04 pm
by logc
Yep, that was the issue. Thanks so much, I can't beleive that never dawned on me. Thanks again.

Re: command_line commands

Posted: Wed Aug 10, 2011 3:46 pm
by agriffin
Glad I could help! Let me know if you have any further problems.