Hello everyone, today I want to show you how you can configure your Nagios server to use UTC time format. This is useful to prevent confusion if you have people from multiple time zones looking at your web interface and it makes reports from your web interface much more useful since you do not need to convert times to UTC first. Ok, let´s do this 🙂 (I did this on Ubuntu 14.04.2 – Btw the server was configured to use CEST as default time zone)
First we will open the nagios.cfg file by running the following command:
sudo nano /usr/local/nagios/etc/nagios.cfg
Now search for “use_timezone” and add the following line of code:
To configure the Nagios web interface to use UTC too we will need to do the following to:
First open the nagios.conf file by running the following command:
sudo nano /etc/apache2/sites-available/nagios.conf
And add this line of code to the “/usr/local/nagios/sbin” section:
SetEnv TZ "UTC"
Your nagios.conf file should now look like this:
# SAMPLE CONFIG SNIPPETS FOR APACHE WEB SERVER # # This file contains examples of entries that need # to be incorporated into your Apache web server # configuration file. Customize the paths, etc. as # needed to fit your system. ScriptAlias /nagios/cgi-bin "/usr/local/nagios/sbin" <Directory "/usr/local/nagios/sbin"> # SSLRequireSSL Options ExecCGI AllowOverride None Order allow,deny Allow from all # Order deny,allow # Deny from all # Allow from 127.0.0.1 AuthName "Nagios Access" AuthType Basic AuthUserFile /usr/local/nagios/etc/htpasswd.users Require valid-user SetEnv TZ "UTC" </Directory> Alias /nagios "/usr/local/nagios/share" <Directory "/usr/local/nagios/share"> # SSLRequireSSL Options None AllowOverride None Order allow,deny Allow from all # Order deny,allow # Deny from all # Allow from 127.0.0.1 AuthName "Nagios Access" AuthType Basic AuthUserFile /usr/local/nagios/etc/htpasswd.users Require valid-user </Directory>
Now you need to restart the Nagios and Apache services to apply the changes.
Run the following command to restart Nagios:
sudo service nagios restart
And run this command to restart Apache:
sudo service apache2 restart
And that´s it.
Here is a screenshot before we applied our changes:
And here is a screenshot after we applied our changes:
Well, that´s it. Now your Nagios server will use UTC.
I hope you liked my today´s post and I hope to see you again next time 🙂