Changing the automatic sort of the host name


Hello all,

I am wanting to change the way that nagios sorts the hosts in the Nagios Web interface. It is only a small tweak that I would like to have in Nagios. Here are a couple of pics to show what I would like to do. The first pic is of what usually is in Nagios, and the second pic has shows the hosts being monitored in acsending order:


Sorted ascending:

I do not know whether or not this is possible. I am curious if this can be done in Nagios without having to select the option to sort the host by acsending order everytime you want it that way, instead configuring a possible config file for such an option to be done automatically. Main question, is this possible?


Good news!
Yes, it is possible!
but well…as it is open source, everything is possible :slight_smile:

anyway, I don’t know of any config files to change that…and never heard of it (which doesn’t mean that it doesn’t exist, btw!).

So, what I could suggest is to do a simple modification in the source files:
go in the directory where you put the sources of nagios (before you compiled them).
In this directory, you will find a “cgi” folder => go in there
You’ll find status.c and status.cgi.

Open status.c
Find this string: “servicefilter cgi var”; and then add the part in bold below (too bad: the bold balise doesn’t work in a code snippet…)

[code] /* servicefilter cgi var */
else if(!strcmp(variables[x],“servicefilter”)){

    **if (group_style_type==STYLE_HOST_DETAIL){
    /* free memory allocated to the CGI variables */

    return error;

Save the file and exit.
Remove the status.cgi file
and launch “make” in this folder…
this will create a new file “status.cgi”; you’ll just have to replace the old one in “nagios-dir/sbin” and here you go:
when you click on “host detail” in the web interface, the hosts will be sorted alphabetically!!
(I assumed you wanted it in the “host detail” panel … Hope I assumed correctly :))

Anyway, the good point is that I’ve “shown” you where and how you can change this kind of things …
So with a bit of pratice and curiosity, you can change pretty much everything.

good louck :wink:


That didnt work for some reason… I ran “make” as well as inserting the new code and replacing the old status.cgi in nagios/sbin. What did I miss? I would also like to have that for the “Service Detail” in the Nagios Webinterface, when the different hosts are displayed. Do you know where I need to configure that? Would I use the same code as before for the host detail?