Monthly Archives: August 2015

Nagios – Improve User Experience with SSI and Javascript

Hello 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 – Use UTC and Nagios – Change date format too.) The problem with my previous solution was that you needed either Google Chrome or Mozilla Firefox with the Tampermonkey/Greasemonkey plugin to make it work. (And it would not work in Internet Explorer) And you needed to do this for every user who wanted this solution.

Ok. So here is the new solution. We will edit the Nagios web interface so that it will show date and time values in relative time on all browsers for all users.

Ok. Let´s get down to business 🙂 (Btw I did this on Ubuntu 14.04.2)


You need to download the following scripts first to make my RelativeTime.js Script work:

Now create a new folder in “/usr/local/nagios/share/js” to store your custom Javascript files: (I called mine custom)

sudo mkdir /usr/local/nagios/share/js/custom

Place moment.js and wgxpath.install.js into your “custom” folder.

And add the following script to your “custom” folder:

<code>function ConvertToRelativeTime()
textNodes = document.evaluate("//text()", document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);

var regexString = /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/;
var searchRE = new RegExp(regexString);

for(var i=0;i<textNodes.snapshotLength;i++)
var node = textNodes.snapshotItem(i); =, moment.utc(;

document.addEventListener("DOMContentLoaded", function(event){

(Remove the





The script will look for UTC ISO8601 date time values and will replace them with relative date time values. Ok. Now go to “/usr/local/nagios/share/ssi” and create a new file called “common-header.ssi“. (If you create a file called “common-header.ssi” or “common-footer.ssi” it will add a header or footer to all cgi files. If for example you create a file called “status-header.ssi” it will add a header to the status.cgi file. Example here:

<code><script type="text/javascript" src="/nagios/js/custom/moment.js"></script>
<script type="text/javascript" src="/nagios/js/custom/wgxpath.install.js"></script>
<script type="text/javascript" src="/nagios/js/custom/RelativeTime.js"></script>

(Remove the





Now run the following commands to restart the Apache webserver and the Nagios service to apply the changes:

sudo service apache2 restart
sudo service nagios restart

Here is a picture how your web interface will look before you apply the script:


Here is a picture how your web interface will look after you applied the script:


And here is a picture after you applied the script in Internet Explorer:


Here is some important information how I made my script work in Internet Explorer:


If you are using Internet Explorer please keep in mind that “XPathResult” will not work without solutions like “Wicked Good XPath“. And make sure that you are not using Internet Explorers Compatibility Mode otherwise the “DOMContentLoaded” function I use in my RelativeTime.js script will not work.



Well, that´s it. Now Nagios should display all date time values in relative time. I hope you liked my post and I hope to see you again next time 🙂

As always you can download my code from here.



Export and Import WLAN Profiles

Hello everyone, today I want to show you how you can transfer your WLAN Profile data to another computer. Here is the story behind this post: A few days ago my brother bought a new laptop and asked my if I know a comfortable way to teach his new laptop all necessary information it needed to automatically connect to his WLAN networks like his old laptop did since he did not want to connect to all needed WLAN networks again and enter all the passwords again. So, he basically asked me to configure his new laptop so that it would automatically connect to his WLAN networks at home, at his friends or at work like his old one did. Well, thanks to Google and some great posts mentioned in the Sources below I was able to do this and I will show you how you can do it.

Ok. Let´s begin 🙂

The first thing you need to do is to run cmd as Administrator.

Next run the following command to get a list of all WLAN network profiles saved on your computer:

netsh wlan show profiles

Next run the following command to export a specific WLAN network profile:

netsh wlan export profile "YourSSID" key=clear folder="C:\Users\You\Desktop"

The above command will create an XML file like this:

<?xml version="1.0"?>
<WLANProfile xmlns="">

Now transfer the above file to the computer (I´ll call it computer B) where you want to import the WLAN profile data.

Now run cmd as Administrator on computer B.

To import the WLAN profile run the following command: (The command will import the data for all users. If you want only your current user to get the data replace “user=all” with “user=current”)

netsh wlan add profile filename="C:\Users\You\Desktop\Wi-Fi-YourSSID.xml" user=all

Well, that´s it. Computer B has now all the necessary information about the WLAN network to connect to it.

I hope you liked my today´s post and I hope to see you again next time 🙂


Tagged ,