Re: [foxboro] Reports
- From: "Kevin Fitzgerrell" <fitzgerrell@xxxxxxxxx>
- To: foxboro@xxxxxxxxxxxxx
- Date: Thu, 29 Mar 2007 08:59:35 +0900
Tom,
Daily query and reporting for system monitor is pretty easy if you
have access to remv/remd on your system (from Foxwatch).
First I use cron to run a remd/remv script each morning on both of our
I/A networks:
#!/bin/sh
rm /opt/ts_group/remv_ecb_counters.out
/opt/rem/remd/remd &
sleep 60
/opt/rem/remv/remv -d@ -s@ -e@ -c > /opt/ts_group/remv_ecb_counters.out
kill `ps -ef | grep remd | grep -v grep | awk '{print $2}'`
This task takes a while on a large system - about 1.5 hours on our
larger one. I run these on AWs that doesn't get much use so I don't
bother checking to see if smdh is running - if it becomes an issue
I'll add something to the script.
Then I ftp the results from these two to our sysadmin server and
process them with a little perl script. The results from remv and
other tasks go in a seperate directory for each of our systems, so I
use the same file names for the results in I/A system. I don't claim
to be a great programmer - please don't laugh too hard at my code If
this gets mangled by the email (or your mail client processing it as
html) you're welcome to ask for a copy off-list.
$data = "../*_data";
$date = `date /T`;
open(LOG, ">./SMON_Status.txt") or die "Can't open ./SMON_Status.txt.\n";
print LOG "\nDaily System Monitor status report.\n";
print LOG "(This is email and it\'s contents are generated automatically)\n\n";
$i = 0;
$found = 0;
$num_lines = 0;
while (<$data/remv_ecb_counters.out>) {
$INFILE = $_;
print "processing $INFILE\n\n";
open(INFILE) or die "Can't open $INFILE: $!\n";
while (defined ($line = <INFILE>)) {
$num_lines++;
chomp ($line);
($junk,$sysmon,$cstation,$device,$rest) = split(/\s+/,$line, 5);
if ( $cstation =~ /CP/ ) {
$type = "CP";
} elsif ( $cstation =~ /CB/ ) {
$type = "LAN";
} elsif ( $cstation =~ /AW/ ) {
$type = "AW";
} elsif ( $cstation =~ /WP/ ) {
$type = "WP";
} elsif ( $cstation =~ /FW/ ) {
$type = "CM";
} elsif ( $cstation =~ /CM/ ) {
$type = "CM";
} else {
$type = "GW";
}
if ( $line =~ /FT STATE\s*:\sNon Operational/ ) {
$found = 1;
$report[$i] = "0 $type $cstation is failed to single\t\n";
$i++;
} elsif ( $line =~ /^\s*\w*\s*\w*\s*ALARMING STATE\s*:\sInhibited/ ) {
$found = 1;
$report[$i] = "2 $type $cstation has alarms inhibited\t\n";
$i++;
} elsif ( $line =~ /ALARMING STATE\s*:\sInhibited/ ) {
$found = 1;
$report[$i] = "8 $type $cstation $device device has alarms
inhibited\t\n";
$i++;
} elsif ( $line =~ /FAIL DEV ATT\s*:\sYes/ ) {
$found = 1;
$report[$i] = "3 $type $cstation has failed attached device(s)\t\n";
$i++;
} elsif ( $line =~ /DEVICE STATE\s*:\sFailed/ ) {
$found = 1;
$report[$i] = "4 $type $cstation $device device is marked as
failed\t\n";
$i++;
} elsif ( $line =~ /DEVICE STATE\s*:\sComm Failure/ ) {
$found = 1;
$report[$i] = "5 $type $cstation $device device is not
communicating\t\n";
$i++;
} elsif ( $line =~ /FAIL STATE\s*:\sFailed/ ) {
$found = 1;
$report[$i] = "6 $type $cstation is marked as failed\t\n";
$i++;
} elsif ( $line =~ /LAST CABLE ACCESS.*Fail/ ) {
$found = 1;
$report[$i] = "7 $type $cstation $device device showed $rest\t\n";
$i++;
} elsif ( $line =~ /^\s*\w*\s*\w*\s*RUN MODE\s*:\sOff Line/ ) {
$found = 1;
$report[$i] = "1 $type $cstation is Off Line\t\n";
$i++;
} elsif ( $line =~ /RUN MODE\s*:\sOff Line/ ) {
$found = 1;
$report[$i] = "9 $type $cstation $device device is Off Line\t\n";
$i++;
}
}
}
$numlast = 1;
@sorted_report = sort @report;
$body = "\nDaily System Monitor status report.\t\n(This is email and
it\'s contents are generated automatically)\t\n\n";
if ( $num_lines < 50 ) {
$body = "$body \nData is insufficient or not current - no report
prepared\t\n";
} elsif ( $found == 0 ) {
$body = "$body \nNo system monitor faults to report.\t\n";
} else {
foreach $i (@sorted_report) {
($type_num,$rest) = split(/\s+/,$i, 2);
if ( $type_num > $numlast ) {
print LOG "\n";
$body = "$body\n";
$numlast = $type_num;
}
print LOG "$rest";
$body = "$body$rest";
}
}
close LOG;
#send email:
use Net::SMTP;
use MIME::Lite;
$mail_to = 'kevin_fitzgerrell@xxxxxxx';
$mail_from = 'Fox_IA_Admin_server';
$subject = "Daily System Monitor status report for $date";
$my_file = './SysMonMsg_Log.txt';
$filename = 'Detail.txt';
$msg = MIME::Lite->new (
From => $mail_from,
To => $mail_to,
Subject => $subject,
Type =>'multipart/mixed'
) or die "error creating multipart container: $!\n";
$msg->attach (
Type => 'TEXT',
Data => $body
) or die "error adding the text messages part: $!\n";
MIME::Lite->send('smtp', $host, Timeout=>60);
$msg->send;
_______________________________________________________________________
This mailing list is neither sponsored nor endorsed by Invensys Process
Systems (formerly The Foxboro Company). Use the info you obtain here at
your own risks. Read http://www.thecassandraproject.org/disclaimer.html
foxboro mailing list: http://www.freelists.org/list/foxboro
to subscribe: mailto:foxboro-request@xxxxxxxxxxxxx?subject=join
to unsubscribe: mailto:foxboro-request@xxxxxxxxxxxxx?subject=leave
- Follow-Ups:
- Re: [foxboro] Reports
- From: Kevin Fitzgerrell
- Re: [foxboro] Reports
- From: tjvandew@xxxxxxxxx
- References:
- [foxboro] Reports
- From: Kevin_Fitzgerrell
- Re: [foxboro] Reports
- From: tom.vandewater
Other related posts:
- » Re: [foxboro] Reports
- » Re: [foxboro] Reports
- » Re: [foxboro] Reports
- » Re: [foxboro] Reports
- » Re: [foxboro] Reports
- Re: [foxboro] Reports
- From: Kevin Fitzgerrell
- Re: [foxboro] Reports
- From: tjvandew@xxxxxxxxx
- [foxboro] Reports
- From: Kevin_Fitzgerrell
- Re: [foxboro] Reports
- From: tom.vandewater