Re: Statistics Extraction
- From: "doni" <doni.sekar@xxxxxxxxx>
- Date: 25 Jan 2007 14:00:25 -0800
On Jan 25, 12:13 am, Josef Moellers
<josef.moell...@xxxxxxxxxxxxxxxxxxx> wrote:
It is a common understanding in this group that we don't write code for
you, but we're willing to comment on any code that you post. Our
comments may very well contain code e.g. when we want to suggest a
different approach, as I did in my reply.
So, play around with the code that was posted and come back if you have
(unworking) code. Post that code and we're glad to suggest modifications.
--
Joseph,
Can you take a look at the code below...
MAC, PHY and Network stats gets generated every 30 minutes and are
copied to a file.
I want to extract all the stats information that is copied to a file
into an hash of hashes and print them.
The file has multiple MAC, PHY and Network Statistics in it and I am
extracting the MAC data in a MAC hash of hashes, PHY data in a PHY hash
of hashes and Network data in a Network hash of hashes.
Here is how the data that is represented in a file. There will be
multiple MAC, PHY and Network Statistics in the file but I am showing
only one of them in here as an example.
For example, if there were 10 MAC Statistics in the file, this is how I
want the data from the "frames with invalid header" stats message to be
copied to a hash.
$mac{'frames with invalid header'}{1} = 0
$mac{'frames with invalid header'}{2} = 0
........ $mac{'frames with invalid header'}{10} = 0
Here is the program I wrote to do the above operation but its not
working as expected. Can anyone let me know where I went wrong.
Thanks,
doni
### Open the netstat file copied to this location ###
my $ex_data = 'netstat.log';
open (NETSTAT,$ex_data) || die("Cannot Open File: $!");
my %mac = (); # Will be the HOH for MAC Statistics
my %phy = (); # Will be the HoH for PHY Statistics
my %bbu = (); # Will be the HoH for BBU Statistics
my %dli = (); # Will be the HoH for DLI Statistics
my $stats; # State Variable
my $i = 0; # Count variable for MAC
my $j = 0; # Count Variable for PHY
my $a = 0; # Count Variable for Network
my $x = 0; # Count Varialbe for Hash
while (<NETSTAT>) {
chomp;
if (/^(\S+)\s+statistics:/) {
$stats = $1;
if ($stats =~ /mac/i)
{ $i++; }
elsif ($stats =~ /phy/i)
{ $j++; }
else
{ $a++; }
}
elsif (/^\s+(\d+)\s+(\S.*)/)
{
($value, $key) = ($1, $2);
if ($stats =~ /mac/i) {
next unless defined $stats;
$mac{$key}{$i} = $value;
}
if ($stats =~ /phy/i) {
next unless defined $stats;
$phy{$key}{$j} = $value;
}
if ($stats =~ /network/i) {
next unless defined $stats;
$network{$key}{$a} = $value;
}
}
else { }
}
foreach $key (keys (%mac)) {
foreach $x (keys %{$mac{$key} })
{
while ($x <= $i) {
print "Message Value is: $mac{$key}{$i}\n";
$i++;
}
}
}
close(NETSTAT) || die("Cannot close $ex_data: $!");
.
- Follow-Ups:
- Re: Statistics Extraction
- From: Josef Moellers
- Re: Statistics Extraction
- From: Eric Schwartz
- Re: Statistics Extraction
- From: doni
- Re: Statistics Extraction
- References:
- Statistics Extraction
- From: doni
- Re: Statistics Extraction
- From: doni
- Re: Statistics Extraction
- From: Josef Moellers
- Re: Statistics Extraction
- From: DJ Stunks
- Re: Statistics Extraction
- From: Josef Moellers
- Re: Statistics Extraction
- From: doni
- Re: Statistics Extraction
- From: Josef Moellers
- Statistics Extraction
- Prev by Date: MacPerl, OS 9, move file to Trash
- Next by Date: Hash of Hashes
- Previous by thread: Re: Statistics Extraction
- Next by thread: Re: Statistics Extraction
- Index(es):
Relevant Pages
|