Below is a program which tells the user what # of alarms occurred in the first table (notifLogTable) below (total, those <2 secs., those >=2 and <10 secs., and those >10 secs). Now I need to Use info from Table 2 (rhic_au_fy_01) to eliminate alarms that started (AlarmStart)w/in 10 secs of a Quench (ev-yquench or ev-bquench) and I'm having trouble.
notifLogTable: AlarmStart AlarmStop UTimeStart UTimeStop Site +WideName Oct 1 2001 3:11PM, Oct 1 2001 3:11PM, 1001963508,1001963508,bo11- +qd1-ps.watch : diffRefCurrentM Oct 1 2001 3:11PM, Oct 1 2001 3:11PM, 1001963510,1001963511,bo11- +qd1-ps.watch : diffRefCurrentM Oct 1 2001 3:12PM, Oct 1 2001 3:12PM, 1001963548,1001963549,bo11- +qd1-ps.watch : diffRefCurrentM Oct 1 2001 3:13PM, Oct 1 2001 3:13PM, 1001963600,1001963600,bo11- +qd1-ps.watch : diffRefCurrentM Oct 1 2001 3:13PM, Oct 1 2001 3:13PM, 1001963612,1001963612,bo11- +qd1-ps.watch : diffRefCurrentM Oct 1 2001 3:29PM, Oct 1 2001 3:40PM, 1001964598,1001965206,b2-q8 +9-ps.watch : diffRefWfgM Oct 1 2001 3:29PM, Oct 1 2001 3:40PM, 1001964598,1001965206,b6-q8 +9-ps.watch : diffRefWfgM Oct 1 2001 3:29PM, Oct 1 2001 3:50PM, 1001964598,1001965848,b2-q8 +9-ps.watch : diffRefCurrentM Oct 1 2001 3:29PM, Oct 1 2001 3:51PM, 1001964598,1001965874,b6-q8 +9-ps.watch : diffRefCurrentM Oct 1 2001 3:30PM, Oct 1 2001 3:30PM, 1001964600,1001964658,bo2-t +h4-ps.watch : diffRefWfgM Oct 1 2001 3:30PM, Oct 1 2001 3:30PM, 1001964601,1001964612,bi4-t +v4-ps.watch : diffRefWfgM Oct 1 2001 3:30PM, Oct 1 2001 3:30PM, 1001964601,1001964628,bo10- +th4-ps.watch : diffRefWfgM Oct 1 2001 3:30PM, Oct 1 2001 3:30PM, 1001964601,1001964656,bi5-t +h5-ps.watch : diffRefWfgM Oct 1 2001 3:30PM, Oct 1 2001 3:30PM, 1001964602,1001964603,bi12- +tv4-ps.watch : diffRefWfgM rhic_au_fy_01 Table: rhicTimeUS rhichTime fillNo event 1001964596.91503, Oct 1 2001 3:29PM, 1154, ev-bquench 1001966883.51251, Oct 1 2001 4:08PM, 1155, ev-bquench 1002000082.0685, Oct 2 2001 1:21AM, 1159, ev-bquench 1002036510.31338, Oct 2 2001 11:28AM, 1166, ev-yquench 1002042610.70097, Oct 2 2001 1:10PM, 1167, ev-bquench 1002068439.82812, Oct 2 2001 8:20PM, 1172, ev-bquench 1002105172.71504, Oct 3 2001 6:32AM, 1180, ev-bquench 1002105172.72965, Oct 3 2001 6:32AM, 1180, ev-yquench 1002121768.47786, Oct 3 2001 11:09AM, 1181, ev-bquench 1002121905.31127, Oct 3 2001 11:11AM, 1181, ev-yquench 1002145148.25541, Oct 3 2001 5:39PM, 1184, ev-yquench 1002145915.95759, Oct 3 2001 5:51PM, 1184, ev-bquench 1002161018.07564, Oct 3 2001 10:03PM, 1184, ev-bquench 1002161852.53742, Oct 3 2001 10:17PM, 1184, ev-bquench 1002162711.54149, Oct 3 2001 10:31PM, 1184, ev-bquench #! /usr/local/bin/perl -w # A perl program to analyze the notifAlarmLog Table through quench tim +es use FileHandle; use IPC::Open2; use Symbol; # use Tk; use Sybase::CTlib; use Time::Local; use strict; my(%systemNames); systemNames(); # fill in the hash # do some analysis of the notifAlarmLog Db use strict; my $dbEvents = new Sybase::CTlib 'harmless','harmless','OPSYB1','fille +ventsT'; $dbEvents->ct_sql("use rhic_au_fy01_fill"); my $sql = "SELECT * FROM fillEventsT WHERE rhicTime like 'Oct%' and (event like 'ev-bquench' or +event like 'ev-yquench')"; my(@fills,$fill); @fills = $dbEvents->ct_sql($sql); foreach $fill (@fills) { print "$fill->[0], $fill->[1], $fill->[2], $fill->[3] \n"; } my $dbAlarms = new Sybase::CTlib 'harmless','harmless','OPSYB1','notif +LogTable'; $dbAlarms->ct_sql("use TomTest"); my $sql = "SELECT distinct name FROM notifAlarmLog"; my(@rows,$row); @rows = $dbAlarms->ct_sql($sql); foreach $row (@rows) { $sql = "SELECT * FROM notifAlarmLog WHERE name like '$row->[0]'"; my($supply,@supplies); @supplies = $dbAlarms->ct_sql($sql); # count all alarms my $count = @supplies; # how many alarms are 2 seconds or less? my $OneSecCount = 0; # how many alarms are >2 and <10 seconds? my $TwoSecCount = 0; # how many alarms are >10 seconds? my $TenSecCount = 0; # how many alarms occur w/in 10 seconds of a QUENCH ENVENT? foreach $supply (@supplies) { $OneSecCount++ if(($supply->[4]-$supply->[3]) <= 2); $TwoSecCount++ if(($supply->[4]-$supply->[3]) > 2 and ($supply->[ +4]-$supply->[3]) <= 10); $TenSecCount++ if(($supply->[4]-$supply->[3]) >10); } my ($f1,$adoName,$f3) = split(":",$row->[0]); my $SiteWideName = $main::systemNames{$adoName} . ":$f3"; # print ":$adoName: :$SiteWideName: \n"; print "$SiteWideName , $count , $OneSecCount , $TwoSecCount , $TenS +ecCount \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"; } }

In reply to Getting info from 2 tables by cjacksonjr

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.