Earlier in the week when moving Nagios from one server to another I ran into a bunch of random issues with Monarch which is the Nagios configuration file manager I use. After I got everything installed and thought that I was past any errors I ran a Pre Flight Test on the Nagios configuration files which returned an error. In the article below I describe in more detail the error that displayed, how I went about troubleshooting the error, and what I finally did to resolve the error.
Nagios Pre Flight Test Error:
Error(s) executing /usr/bin/nagios -v /usr/share/nagios/monarch/workspace/nagios.cfg Permission Denied
Monarch Pre Flight Test On Nagios Configuration Files Error:
So this error could mean a couple different things but remember for Monarch to operate properly with Nagios you will need to provide Apache access to read and execute the nagios program file typically located in the /usr/bin/ directory. In this scenario my suggestion would be to look at the nagios.cfg file in the “/usr/share/nagios/monarch/workspace” directory as well as the nagios application located in the “/usr/bin” directory. Below are the permissions for each of these files before I made any changes.
Monarch Generated Nagios Configuration File, named nagios.cfg, Permissions On CentOS:
- [root@server ~]# ls -alh /usr/share/nagios/monarch/workspace/ | grep nagios.cfg
- -rw-r--r-- 1 apache apache 6.0K Jan 29 13:02 nagios.cfg
Nagios Application File, which is /usr/bin/nagios, Permissions On CentOS:
- [root@server ~]# ls -alh /usr/bin/ | grep nagios
- -rwxrwxr-- 1 root root 617K Aug 27 08:35 nagios
- -rwxrwxr-- 1 root root 48K Aug 27 08:35 nagiostats
When looking at the above two Monarch and Nagios related files you can see that the issue resides with the nagios application executable. Monarch operates through the web server and in most scenarios on Linux the web server will be Apache which means that Apache will need to have read/write permissions to some files and read/execute permissions for other files. In my case you can see that the nagios application file is not readable or executable from the apache user. To resolve this issue the below command.
Modify The Nagios Application File So Monarch Has Read/Execute Permissions:
- [root@server ~]# chmod 775 /usr/bin/nagios*
- [root@server ~]# ls -alh /usr/bin/ | grep nagios
- -rwxrwxr-x 1 root root 617K Aug 27 08:35 nagios
- -rwxrwxr-x 1 root root 48K Aug 27 08:35 nagiostats
Changing nagios Executable File Permission Explanation:
Notice in the above example the ‘*’ directly after nagios which indicates to modify permissions for any file in that directory that begins with “nagios”. This will include the nagiostats application file which may not be needed for this specific error but it could cause an issue later so its best to go ahead and keep things consistent.
The nagios.cfg Monarch temporary Nagios Configuration File Information:
As for the nagios.cfg file you can see in the first example above that the file is owned by apache as well as part of the apache group. The permissions are 644 or read/write-read-read. If this is not the case on your server running Monarch to manage Nagios configuration files then you should go ahead and modify not only the nagios.cfg file in the workspace directory but every other file in this directory as well. This is the directory that Monarch will use to rebuild the configuration files before pushing them to the actual files used by Nagios which reside by default on CentOS Linux in the /etc/nagios directory.
Use Monarch To Run Another Nagios Configuration File Pre Flight Test:
After you have resolved the permission issues run another Pre Flight Test to see if you receive an errors or warnings relating to your configuration. Warnings don’t always have to be resolved though it is a good idea to look into any warnings mentioned in the Pre Flight Test to make sure you have not forgotten a configuration option. The image below displays parts of a successful Monarch Pre Flight Test.
Monarch Pre Flight Test After Resolving Nagios Configuration File Permission Errors:
More than likely you should now be able to go ahead and backup and then commit the configuration changes you have made. Once you have Monarch configured properly in makes modifying, adding, and deleting Nagios configuration files much easier.
Good post… I’m always on the lookout for good blogs.
Hello how to ollie,
Thanks for taking the time to leave feedback and for the compliment regarding the article posted about Nagios configuration file manager Monarch.We hope you continue to enjoy the articles we write.
Thanks.
alex