0

I've been banging my head against the wall for the past few days on this and promise I looked everywhere. If I'm wrong please teach me with a link :)

I'm trying to schedule downtime for some services and haven't been able to make it happen via the command line or the web GUI. For some reason the only thing I can do is commit host comments/downtime via the GUI and nothing else anywhere else. I should also mention that a cronjob of the scheduled downtime will show up in the Nagios web interface comments, but still doesn't work. The only difference I notice is the author as indicated by the GUI for host down time is "nagiosadmin" and of the non-working downtimes is "nagios" I did try chown'ing file paths with nagiosadmin.

Here are the relevant deets:

nagios.cfg

check_external_commands=1
nagios_user=nagios
nagios_group=nagios
command_file=/usr/local/nagios/var/rw/nagios.cmd

I have changed the permissions and owners for this directory MANY times, nothing seems to work: ls -l /usr/local/nagios/var/rw

prwxrwxrwx. 1 nagios nagcmd 0 Jan 29 21:27 nagios.cmd srw-rw----. 1 nagios nagcmd 0 Jan 29 14:09 nagios.qh

I added users to groups that they don't really need to be in to no avail: cat /etc/group:

nagcmd:x:505:nagios,nagiosadmin,apache
nagios:x:501:nagios,apache,nagiosadmin

The script is pointed to the correct file paths but again it won't work from the GUI anyway.

infra2 nagios: Error: External command failed -> SCHEDULE_HOST_DOWNTIME;deploy1;1422507601;1422536401;0;28800;neo-nagios;Scheduled Daily Downtime (low usage period) Jan 29 21:27:20 infra2 nagios: External command error: Command failed

I know this isn't the root of the problem as nothing works from command line but:

ls -l /usr/local/nagios/etc/cgi.cfg -rw-rw-r--. 1 nagios nagios 12015 Jan 29 14:06 /usr/local/nagios/etc/cgi.cfg

ls -l /usr/local/nagios/sbin/cmd.cgi -rwxrwxr-x. 1 nagios nagios 288424 Jan 28 10:17 /usr/local/nagios/sbin/cmd.cgi

GUI error I'm tired of seeing: "Sorry, but you are not authorized to commit the specified command...yada"

What am I missing?!?! Please help! and thanks in advance

CodeStardust
  • 5
  • 1
  • 6

2 Answers2

0

Personnally I use post/get while using the nagios cmd.cgi. You can use curl/wget/etc to call the command with the correct parameters to do what you want as if you used the GUI.

The easiest way is to look at what is sent when you execute a post/get command via the GUI and reproduce it through a wget/curl command. Works like a charm, I personally have automated processes while deploying that call the cmd.cgi from script and auto-downtime or disable/enable services by service or host.

drewboswell
  • 150
  • 6
0

There are some things that appear to be out of sync. In nagios.cfg, you have:

nagios_user=nagios
nagios_group=nagios

But then the group name on nagios.cmd is nagcmd, not nagios.

Additionally, you showed the group assignments for the nagios and nagcmd users, but what user is actually running the commands? Additionally, was nagcmd (or nagios) added as a group to the web user (www-data or apache, depending on the OS)?

Finally, there are some locations that need write permissions, as well. Making sure the correct permissions are added to those directories (and, again, the right users have the nagios or nagcmd group permissions) should help.

See this post for more information: Nagios - Could not open command file /usr/local/nagios/var/rw/nagios.cmd’ for update

Community
  • 1
  • 1
jlemley
  • 533
  • 1
  • 4
  • 15