I come beseeching the wisdom of the perl monks once again.
I am working on a script that I am using to monitor remote processes and I have an array "@sof_i" that is full of connection data. A start time, a stop time, connnection status etc, for several days worth of connections. Each connection is seperated by a line of "=" signs. Here is the code in question:
if (!defined($sof_i[2]))
{
print "There is no data in the ISTAT file\n";
print "The RTS/DPS monitor is down.\n";
close(PAGE);
system(@sendpage);
exit(1);
}
@sof_i=reverse @sof_i;
&get_i;
sub get_i
{
if ($sof_i[0]=~m/={30}/){shift(@sof_i);}
foreach(@sof_i)
{
last if $_=~/^={30}/;
($i_day, $i_month, $i_date, $i_hour, $i_minute, $i_second, $i_
+year)=$_=~/(^\D{3}) (\D{3})\s+(\d{1,2}) (\d{2}):(\d{2}):(\d{2}) (\d{4
+}) sw_eof \[.+\] try / if $_=~m/try/;
($i_con_day, $i_con_month, $i_con_date, $i_con_hour, $i_con_mi
+nute, $i_con_second, $i_con_year)=$_=~/(^\D{3}) (\D{3})\s+(\d{1,2}) (
+\d{2}):(\d{2}):(\d{2}) (\d{4}) sw_eof \[.+\]/ if $_=~m/connected/;
($i_socket_status)=$_=~/\[(.*)\]/ if $_=~m/EOF Socket Status/;
$sof_to_delete++
}
for ($i=0;$sof_to_delete>0;$sof_to_delete--)
{shift(@sof_i);}
$i_num_month=0 if $i_month=~m/Jan/;
$i_num_month=1 if $i_month=~m/Feb/;
$i_num_month=2 if $i_month=~m/Mar/;
$i_num_month=3 if $i_month=~m/Apr/;
$i_num_month=4 if $i_month=~m/May/;
$i_num_month=5 if $i_month=~m/Jun/;
$i_num_month=6 if $i_month=~m/Jul/;
$i_num_month=7 if $i_month=~m/Aug/;
$i_num_month=8 if $i_month=~m/Sep/;
$i_num_month=9 if $i_month=~m/Oct/;
$i_num_month=10 if $i_month=~m/Nov/;
$i_num_month=11 if $i_month=~m/Dec/;
$i_sof_time=timegm($i_second, $i_minute, $i_hour, $i_date,$i_num_m
+onth,$i_year);
}
if (!defined($i_sof_time))
{
print "I did not find any connection attempts in the istat file.\n
+";
print "RTS/DPS Monitor is down.\n";
close(PAGE);
system(@sendpage);
exit(1);
}
In the first step, it checks that the array has information in it. After it is reversed (to put the newest info first in the array) it attempts to extract information. Then when it comes back from the subroutine it should have an $i_sof_time that is defined. I have watched it using the debugger and sometimes (not always) the array has the data in it before going into the subroutine, but then once in the subroutine, the array is empty!
any ideas?
Thanx for your help!
-Kevin
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.