Nagios CGI's in XHTML1?!


#1

Howdy all,

I’ve installed Nagios a few times in my wanderings, and find myself in a situation where it is (once again) the Best Option. I’ve been using the latest v3 betas in test mode, and found myself wondering (in a quiet moment over the holidays) just what would be needed to bring the CGIs over to XHTML1. I’m no C programmer, but I can hack away at logical code, so I started by replacing the initial HTML calls so the pages atleast say they’re XHTML1.

With that little change, I found (aside from a bazillion HTML standard errors heh) that I can now use SSI to insert a spiffy dropdown menu … and can finally remove the dreaded framed environment. This single thing alone has helped, if only from a bookmark point of view.

My next experiment will be to incorporate a few more “stupid web tricks” like making the menu always reside on the top of the page, but allow the content to scroll.

In any case, I’m starting to get the bug here, and was wondering if other people may have a) any advice if you’ve wandered down this path, or b) a desire to potentially review my (rather simple) patches. As I’ve said, I’ve no real experience coding in C (let alone using patch or diff tools) but I’d be more than happy to release whatever I alter to the community.

Am I on the right track?


#2

Hey there MWLimburg,

Sounds like you’re on the right track. The cgi’s are cumbersome to deal with. Modifying them is a pain!

There is a project called nagios-php which converts the nagios cgi interface to php though, which makes customizing your web interface much easier! The project page is here:
nagios-php.sourceforge.net/

Anyways, I haven’t tried it out but it looks like a neat idea. Right now i’m using the Nagios Nuvola theme, which adds some nice looking CSS and sidebar stuffs to the web interface. Looks loads better


#3

Yeah, I’ve seen that project … been tempted to do something akin to it myself (I code in PHP rather than C heh) but it is a rather significant level of work. As with most sysadmins now a days, I need a solution quick time. It’s been a simple bit of patching (hell, I just hand change the code on each beta before compile) but it’s really paid off.

I have been toying with the idea of seeing if I can integrate in php code into CGIs, as it would be way nice to be able to parse the content through one of the many template solutions out there. But, I’m not confident about mixing and matching .CGI and php code …


#4

If anyone does want to review/do this, all I’m doing is replacing the

[blockquote]printf("<html>\n");[/blockquote]
statements with

[blockquote]printf("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml2/DTD/xhtml1-strict.dtd\">"); printf("<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\">\n"); [/blockquote]
I’ve done this to all the .c files in the CGI directory.

This allows you to incorporate plenty of XHTML/CSS tricks, in my case, I now use cssplay.co.uk/menus/image_drop.html for my replacement menu system. Did require a little tweaking, but it took me less than a few hours to get it done along with some new CSS/icon replacements. Looks very swish.


#5

Just a quick update.

I’ve decided to take the plunge. I have started to rebuild the HTML output generated from Nagios as XHTML1 pages, and will be patching the CGI source files to serve this content over the older HTML.

My first aim is to get it working for me - which I seriously doubt will cover everything that needs to be done, as I’m forced to deal with my output rather than really understanding the C source and changing it as a whole. I do suspect I’ll hit 90% or more of what’s needed, but testing will be the key to ensuring it works to my/our satisfaction.

I was SERIOUSLY considering trying my hand at inserting a simple template system but my fears of introducing new actual C code having any impact on Nagios stability turned me away from that. To this day, the main reason I stick with Nagios is that it’s so damn stable, and I’m not going to cut off my nose to spite my face. So for now, it’s simple replacements of the existing printf commands.

The first revision of these changes will be functional. The aim is to get something in place that can be altered and built upon. The second revision will be expanding on these XHTML pages to provide better CSS control over the entire page.

Think I need to find myself a CVS environment to start keeping this … if only so I can share the code.


#6

Quick update … here’s the mockup I’ve done for the TAC screen. Just figuring out how I will display the Network Outages that makes sense and is part of the first viewable content.

img293.imageshack.us/my.php?imag … icaeg2.png

I am also considering what other information can be included, and may include a SSI call to a TAC-CONTENT file which would reside between the main Hosts/Services panel and the Monitoring Performance panel. Could be useful for things like inserting graphs and the like.

Now if I can just get my actual work to calm down some, I can spent a bit more quality time on this.


#7

Hey all, some good news … the TAC page has been finalised (for now).

http://img186.imageshack.us/img186/9661/newtactw2.png

The content is all valid XHTML1 Strict, and those nifty little boxes are all CSS so you can alter them to your hearts content. Placement could have been done better, but as a first cut, I’m quite happy with it - and personally, I think it’s heads and shoulders above the old one.

The next step is going to be the hosts and services CGIs. Wish me luck :slight_smile: