Custom Web Frontend


I’ve searched all over, but can’t seem to find a straight answer. Is there anyway to customize the Nagios Web Frontend? We are using Nagios ver. 3. Basically, what I’m trying to accomplish is to simply the tactical view so I can merge it with information from one of our other systems(a proprietary message board) and display it on a big screen in our NOC. I would be happy with removing the 2 boxes at the top labelel: “tactical monitoring overview” and “monitoring performance”. And I’d like to remove the “Monitoring Features” box at the bottom. Again, only for viewing on a large screen in our NOC. I’m open for other suggestions if anyone has any. Just want to see any outages on a big screen, along with updates from our web based message board.




I’m about to do something very similar. I intend to write a CGI script that does a wget on as an input to an array, outputs some standard HTML CGI header (adding autorefresh, referencing the nagios style-sheets etc as appropriate), then parses the array line by line, outputting only the tables I wan’t to display. I may have to muck about with it a bit more or use a custom style-sheet to change the colours to something more “corporate”, but if you’re happy with all that then I think you could pretty much start with a basic line count on the array and ‘ignore’ the lines for those top 2 tables (i.e. just don’t output any lines until after, say, line 75) as those really shouldn’t change, and then after that output everything that doesn’t match the 'Monotoring Features" line - when you hit that, stop outputting content from the array, close the (now empty) Monitoring features table, and close off the page. After parking the script in /usr/local/nagios/sbin/ and a quick bit of chown and chmod, I envisage the thing to work as advertised…

Easy-peasy… I hope :cry:




Ok… so not as simple as I 1st suspected, as I had to resport to using the LWP agent, but once I got my head round that, happy days. This is the script if anyone’s interested…

print "Content-type: text/html\n\n";
print "<html>\n" ;
print "\n" ;
print "<head>\n" ;
print "<title>some nagios-based title</title>\n" ;
print "<LINK REL='stylesheet' TYPE='text/css' HREF='/nagios/stylesheets/tac.css'>\n";
print "</head>\n" ;
print "\n" ;
print "<body CLASS='tac' marginwidth=2 marginheight=2 topmargin=10 leftmargin=10 rightmargin=10 bgcolor=\"#FFFFFF\" text=\"#000000\" link=\"#000000\" vlink=\"#000000\" alink=\"#000000\">\n" ;
print "\n" ;
use LWP::UserAgent;
$ua = LWP::UserAgent->new;
$req = HTTP::Request->new(GET => '');
$req->authorization_basic('nagiosadminusername', 'yourpassword');
$res = $ua->request($req);
if ($res->is_success) {
        $tacpage = $res->decoded_content;
        foreach $tacinline ( split( "\n", $tacpage )) {
                if ($taclinecount < 76) {
                        if ($_=~/Last Updated/) {
                                print "<center>$_</center>\n";
                elsif ($_=~/Monitoring Features/) {
                elsif ($stopcopy ==0)  {
                        print "$tacinline\n";
        print "</table>\n";
else {
        print "Error: " . $res->status_line . "\n";
print "</body></html>";


Looks good. I’m trying it now. What is LWP? I don’t believe I have that installed, because it’s giving me an error. Excuse my ignorance, I’m more of a networking guy than a programming guy! I also would assume, I could call this script from a web browser, if I thru this in the nagios cgi-bin directory?




In a nutshell, LWP is a set of perl modules that provide an API to the web (you can find much more on it here - I thought it was a generic perl module, but I could be wrong in which case it shouldn’t be too hard to get hold of, infact you can download a version of it from CPAN via that previous link).

You should just be able to place the script in the same directory as tac.cgi (/usr/local/nagios/sbin on my server), call it something like tac2.cgi, then do…

chown nagios:nagios tac2.cgi
chmod 775 tac2.cgi

…so it matches the permissions of tac.cgi. Once that’s done, you should be able to call it up on your web-browser. If you’re not sure of the url straight off, just open the original tactical overview page in a new window and change the url to tac2.cgi.

Oh, and make sure you change the following to accurately reflect the location of your perl executable and your nagios username and password

$req->authorization_basic('nagiosadminusername', 'yourpassword'); 


[Edit: Oh, and I’m a networking guy too, not a programmer. Sucks to be lumbered with monitoring stuff, eh…? !lol]


That worked perfect! Exactly what I was looking for, Thanks!! the only problem is I still have to enter a username/password, but I can live with that. And I did edit the portion of your script and put my username/password in there.


Splendid. Feel free to move it to somewhere else on your server, but you’ll probably need to change the relative link to the stylesheet. Oh, and I realised earlier I forgot to include the autorefresh :roll: . If you didn’t spot it was missing and haven’t fixed it yourself already, you need to put:

print "<meta http-equiv=\"refresh\" content=\"60\">\n";

in at the top betwixt the “style sheet” line and the “” one. That’ll refresh it every 60 seconds (or whatever value you want it to I guess)




too damn right!!
(that’s my problem too :()


Maybe NagLite is something you could use?


Thanks, but the script posted above worked fine. Plus I just installed and setup NagVis, which looks like I can do some customizing there.


Nuvola theme is also pretty popular. If you’re decent at CSS you can make anything visible/not visible, absolute positioning, etc etc. … 3.html;d=1