Nagios – Use UTC


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:

use_timezone=UTC

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:

nagios_web_interface_before_utc

And here is a screenshot after we applied our changes:

nagios_web_interface_utc

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 🙂

Sources:

http://scratching.psybermonkey.net/2011/04/nagios-time-within-nagios-is-incorrect.html

https://ihazem.wordpress.com/2012/03/14/changing-timezone-on-nagios-core-web-interface/

Advertisements
Tagged ,

2 thoughts on “Nagios – Use UTC

  1. […] everyone, in these last few posts: Nagios – Change date format and Nagios – Use UTC I showed you how you can alter the date format and timezone of your Nagios server. Today I want to […]

  2. […] for this previous post. (Btw This post has the same prerequisites. So have a look at my posts Nagios – Use UTC and Nagios – Change date format too.) The problem with my previous solution was that you […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: