Nagios – Improve User Experience with Tampermonkey/Greasemonkey

Hello 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 show you how you can improve User Experience with a simple Greasemonkey/Tampermonkey script by converting all date time values into relative time values (as seen on Facebook or used by SharePoint).

Important: If you want to use the below script without altering the “regexString” value you will need to follow this post of mine to make Nagios use the ISO8601 date format. And you need to follow this post to make Nagios use UTC.

Ok. Let´s get down to business 🙂

If you use Firefox install the Greasemonkey plugin or if you use Google Chrome install the Tampermonkey plugin to run the below script (If you use Internet Explorer you are unfortunately out of luck because neither Greasemonkey nor Tampermonkey are available for it to my knowledge). And here is the script:

// ==UserScript==
// @name Nagios - Date time to relative time
// @namespace
// @version 1.0
// @description This script will turn every date time value into a relative time value (e.g. it will turn "2014-07-21 00:00:00" into "a year ago").
// @author theezitguy
// @match*
// @grant none
// @require
// ==/UserScript==

//Get all textNodes of the website
textNodes = document.evaluate("//text()", document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);

//Regex String - Search for date time values in ISO8601 format
var regexString = /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/;
var searchRE = new RegExp(regexString);

//Go through all textNodes and replace date time values with relative time values
for (var i=0;i<textNodes.snapshotLength;i++)
var node = textNodes.snapshotItem(i); =, moment.utc(;

The script will do the following:

It will go through every text node on the website and replace all date time values with relative time values.

Important: You need to alter the “@match” value to point to your Nagios server website before you can use it.

Here is a screenshot before I applied my script:


And here is a screenshot after I applied my script:


Well, that´s it. You can now easier read your data on your Nagios web interface.

Not bad, right? I hope you liked my today´s post and I hope to see you again next time 🙂



2 thoughts on “Nagios – Improve User Experience with Tampermonkey/Greasemonkey

  1. […] everyone, today I want to show you a little improvement I found for this previous post. (Btw This post has the same prerequisites. So have a look at my posts Nagios […]

  2. xsoft says:


    change “moment.utc” to “moment.parseZone” and skip timezone issue.

    Also you can change include from “”
    to “”
    and add “moment.locale(‘cs’);” to have it in your language
    (languages demo at bottom of )

Leave a Reply

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

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

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s

%d bloggers like this: