Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > Linux Forums > Programming/Scripts

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Thread Tools Display Modes
Old 3rd August 2013, 05:18
forrie forrie is offline
Junior Member
Join Date: Sep 2006
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default Assemble a report from Nagios email alerts

Nagios cycles its data (at least ours has) -- I have several hundred email alerts provided to me (by my boss!) who's asked me to tabulate them into some meaningful graph (RRD) and/or report.

He provided these all one big fat TXT file. Each entry is standard format (email) and has the standard Nagios email alert formatting. From this, I should be able to parse out and graph these... it's just not something I've done before.

I wonder if someone else has any tips or tricks on accomplishing this.

Here is a sample entry:

^LFrom: nagios@ourhost.com
Subject: [PROD] ** RECOVERY Service Alert: core-river-gw-vl671.network-provider.com/check_ping
Date: July 30, 2013 9:31:05 AM EDT
To: "My Boss" <myboss@ourhost.com>

***** Nagios *****

Notification Type: RECOVERY

Service: check_ping
Host: core-river-gw-vl671.network-provider.com
State: OK

Date/Time: Tue Jul 30 09:31:05 EDT 2013

Additional Info:

PING OK - Packet loss = 0%, RTA = 0.68 ms

Thanks in advance!
Reply With Quote
Sponsored Links
Old 16th December 2013, 14:15
RandomGuy RandomGuy is offline
Junior Member
Join Date: Dec 2013
Posts: 9
Thanks: 1
Thanked 1 Time in 1 Post

Use a programing language and do something like

InputFile in;
String line;
List output;
String[] row;
// Read input
while(line = in.readLine()) {
if(line.equals("***** Nagios *****") {
// Start a new entry and push it to the output list
output.add(row = new String[3]);
} else if(line.startsWith("Service") {
// Read your fields
row[0] = line.split(":")[1].trim();
} else if(line.startWith("Host") {
// Read your fields
row[1] = line.split(":")[1].trim();
/** Read the other fields you need in the same fashion **/

// Produce output
OutputFile out;
for(String[] row : output){
out.println(row[0] + "," + row[1] + "," + row[2]
/** Write all your output fields to a row **/

This will generate a csv (comma separated values) files where each entry is one row with each field in one column. You can then open this file in any office suite like OpenOffice, Microsoft office or even with Google Docs. There you can generate all kinds of statistics and graphs you require and then export the whole thing to something like pdf.
Personaly I would use java to write somthing like that, but you can really do something like that in any programming language that you are familiar with.
Reply With Quote


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Gmail and Port25 Email Test Require IPv6 addresses now bpmee Server Operation 0 3rd April 2013 08:40
hotmail rejects outgoing email nzimas Server Operation 3 1st May 2009 04:39
email receiving died ??? + report a bug in ispconfig email add/remove coolen Installation/Configuration 14 4th November 2008 20:34
Ubuntu 8.04 Spamsnake - all SA scores 0.00 Thomas_Powers HOWTO-Related Questions 23 24th June 2008 18:37
email forwarding locally consumes all resources rdells General 20 1st May 2006 20:43

All times are GMT +2. The time now is 23:50.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.