cjacksonjr has asked for the wisdom of the Perl Monks concerning the following question:
#! /usr/local/bin/perl -w # A perl program to analyze the notifAlarmLog Table and quench times use FileHandle; use IPC::Open2; use Symbol; # use Tk; use Sybase::CTlib; use Time::Local; use strict; my(%dispatch) = (); my(%systemNames); systemNames(); # fill in the hash of PS system names my $dbAlarms = new Sybase::CTlib 'harmless','harmless','OPSYB1','notif +LogTable'; $dbAlarms->ct_sql("use TomTest"); %dispatch = (help =>\&Help, info =>\&GetAlarmInfo); my $numberOfArgs = @ARGV; if($numberOfArgs == 0) { Help(); exit 1; } my($what) = shift(@ARGV); my($whatLower) = $what; $whatLower =~ tr/[A-Z]/[a-z]/; if ($what eq undef) { Help(); exit 1; } if(exists($dispatch{$whatLower})) { &{$dispatch{$whatLower}}(@ARGV); exit 0; } Help(); exit; sub GetAlarmInfo { use strict; #Given a time in (X) seconds find the number of Alarms occurring for + each PS #Given a time in seconds find the number of Alarms occurring w/in (Y +) seconds AFTER a Quench Event for each PS #Both sorted by number of occurrences my $sql = "SELECT distinct name FROM notifAlarmLog"; my $NameCount = 0; # count number of PS my(@rows,$row); @rows = $dbAlarms->ct_sql($sql); foreach $row (@rows) { $NameCount++; # see how many power supplies there are $sql = "SELECT * FROM notifAlarmLog WHERE name like '$row->[0]'"; my($supply,@supplies); @supplies = $dbAlarms->ct_sql($sql); # count all alarms for each PS my $count = @supplies; # count how many alarms occur within user specified time given in +seconds my $AlarmCount = 0; # count how many alarms occur w/in (X) seconds after a QUENCH EVEN +T (user specified in seconds)? my $QuenchCount = 0; # work done here!!! my $AlarmFilter = $_[0]; if ($AlarmFilter >= 0) { my $QuenchFilter = $_[1]; foreach $supply (@supplies) { $AlarmCount++ if(($supply->[4] - $supply->[3]) <= <$AlarmFilter>) +; #Line 61 my $dbEvents = new Sybase::CTlib 'harmless','harmless','OPSYB1','f +illeventsT'; $dbEvents->ct_sql("use rhic_au_fy01_fill"); my $sql = "SELECT * FROM fillEventsT WHERE rhicTime like 'Oct%' and (event like 'ev-bque +nch' or event like 'ev-yquench')"; my(@fills,$fill); @fills = $dbEvents->ct_sql($sql); foreach $fill (@fills) { # how many alarms occur w/in 10 seconds a +fter a QUENCH EVENT? $QuenchCount++ if(($supply->[3] - $fill->[0]) <= <$QuenchFilter> +) and (($supply->[3] - $fill->[0]) > 0); } } } #filter out alarms that occur w/in 10 seconds after a Quench EVENT my $diff = $count - $QuenchCount; my ($f1,$adoName,$f3) = split(":",$row->[0]); my $SiteWideName = $main::systemNames{$adoName} . ":$f3"; # print ":$adoName: :$SiteWideName: \n"; print "$SiteWideName, $AlarmCount, $count, $QuenchCount, $diff \n" +; } print "There were $NameCount Power Supplies that alarmed in Oct. 200 +1. \n"; } sub systemNames { # fill in the systenName hash use strict; my $dbAdo = new Sybase::CTlib 'harmless','harmless','OPSYB1','notifL +ogTable'; $dbAdo->ct_sql("use serverAdo"); my $sql = "SELECT name,systemName from adoInst where name like 'psWa +tch%'"; my(@rows,$row); @rows = $dbAdo->ct_sql($sql); foreach $row (@rows) { $main::systemNames{$row->[0]} = $row->[1]; # print "<$row->[0]> <$row->[1]> \n"; } } sub Help { #display help for this tool print "Alarm and Quench Tool- A program for user to input times in +seconds to: \n 1. Exclude Alarms that last LESS THAN <X> seconds. \n 2. Exclude Alarms that occur within <Y> seconds AFTER a Quench. \n Both are sorted by number of occurrences \n List of Commands: <Info> Given the times in seconds, find the number of occurrencs + for Alarms and for Alarms after a Quench. Enter in form: XX YY \n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: help with user inputs
by tommyw (Hermit) on Aug 14, 2002 at 14:16 UTC | |
|
Re: help with user inputs
by suaveant (Parson) on Aug 14, 2002 at 14:16 UTC | |
|
Re: help with user inputs
by fruiture (Curate) on Aug 14, 2002 at 14:19 UTC |