Checkmk 2.0 is here! See what's new.

The Problem

When updating the Nagios web interface with the F5 key or by pressing the ʻRefresh’ button in the browser, the Nagios web page jumps back to the main page.

This behaviour first appeared with Nagios version 3.2.0. Previously, when updating the page – e.g., by pressing F5 – the currently active page was reloaded, and the user could continue working as usual on the updated page.

The cause

In Nagios version 3.2.0 the former index.html, which represents the frameset of the Nagios web interface, was renamed to index.php. As a result, the web server and browser no longer know whether this page may be kept in the cache or not.

The solution

Add the following line to the beginning of the index.php file:

<?php header("Cache-Control: max-age=7200, public"); ?>

The index.php file is usually located in the file path /usr/local/nagios/share.

The first lines of the file should look like this after editing:

/usr/local/nagios/share/index.php:<?php header("Cache-Control: max-age=7200, public"); ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" 
 "http://www.w3.org/TR/html4/frameset.dtd">

<html>
<head>
<meta name="ROBOTS" content="NOINDEX, NOFOLLOW">
<title>Nagios</title>
<link rel="shortcut icon" href="images/favicon.ico" type="image/ico">
</head>

<frameset cols="180,*">
<frame src="side.php" name="side" frameborder="0">
<frame src="main.php" name="main" frameborder="0">

<noframes>

… and so on.

Attention: Following the change, the browser should be restarted, because e.g., Firefox uses temporarily stored information at this point.

The background

As the components involved (browser, web server and possibly even proxy) in the case of PHP files  do not know whether the request may be cached, this page is always requested and created completely new by the web server.

This causes the page to be reloaded by the browser. The current page in the frameset cannot be taken over. Therefore the default page of the frameset is loaded.

Within individual PHP pages the caching behaviour of the web server and the browser can be influenced by PHP functions. The caching behaviour is influenced by the HTTP Cache-Control header. This header can be set with the PHP function header().

HTTP headers must be set before the first output of the page, so the code must be inserted directly into the first line of the index.php.

Linux knowledge

These articles were written by the founder of Checkmk many years ago.
They are still valid though and thus we keep them on our website.
Mathias has since then developed a monitoring software called Checkmk

Find out more