Re: Statistics Extraction
- From: "doni" <doni.sekar@xxxxxxxxx>
- Date: 26 Jan 2007 10:07:51 -0800
On Jan 25, 2:42 pm, Eric Schwartz <emsch...@xxxxxxxxx> wrote:
Can anyone let me know where I went wrong.It would help if you could include some data in the example, using the
__DATA__ keyword. And you could please let us know what it did, what
you expected, and how they differ-- almost nobody is interested in figuring all that out for you.
Here is the data that I was using. I have attached 1 copy of MAC, PHY
and NETWORK Stats in here but in the file there will be atleast 10
copies of MAC, PHY and NETWORK Stats.
__DATA__
MAC statistics:
0 frames with invalid header
546 confirmed frames sent succesfully
1693 confirmed frames sent unsuccesfully
542 confirmed frames received
4597 total frames received
851 data packets received
549 packets sent successfully
152 packets sent unsuccessfully
763 packets queued by network layer
61 packet transmissions timed out
0 packets with invalid length
0 out of order fragments received
87 duplicate fragments received
0 partial packets received
4 packet reassemblies timed out
0 no buffers
PHY statistics:
3404 frames transmitted
105 transmits aborted due to rx
0 transmit errors
0 late transmits
11 tx buffer loads interrupted
0 tx buffer load failures
4598 receive interrupts
4598 frames received
0 received frames lost
0 zero length frames received
0 receive cmd errors
Network statistics:
851 total packets received
0 bad packet length
0 bad version number
0 outgoing packets with no route
0 input packets with bad destination address
0 input packets from wrong channel
0 packets dropped for exceeding TTL
0 packets dropped due to full socket buffers
0 packets dropped due to no receiver
0 packets dropped due to running out of memory
762 total packets sent
549 packets succesfully transmitted
213 packets sent unsuccessfully
Let me please say again that the message in which you gave an example
of your data is 8 messages before this one, and I just happened to get
lucky that it was still on my newsserver. If you want the most help
possible, you really need to post, with your example code, an example
of the data you're working on, what you get when you run your code on
it, and what you expected, and how they are different.
I modified the code as per your suggestions but I am not sure whether I
modified it perfectly...
#! /usr/bin/perl
use warnings;
use strict;
my $ex_data = 'net.log';
open (NETSTAT,$ex_data) || die("Cannot Open File: $!");
my %stats = ();
my $message;
while (<NETSTAT>) {
chomp;
if (/^(\S+)\s+statistics:/)
{
$message = $1;
}
elsif (/^\s+(\d+)\s+(\S.*)/)
{
($value, $key) = ($1, $2);
if ($message =~ /mac/i) {
push @{$stats{mac}{$key}}, @value;
}
if ($message =~ /phy/i) {
push @{$stats{phy}{$key}}, @value;
}
if ($message =~ /network/i) {
push @{$stats{dli}{$key}}, @value;
}
}
else
{ }
}
close(NETSTAT) || die("Cannot close $ex_data: $!");
foreach my $type (keys %stats) {
print "$type stats:\n";
foreach my $messages (keys %{$stats{$type}}) {
print "\tmessages is: $messages\n";
foreach my $val (@{$type{$messages}}) {
print "\t\tMessage value is: $val\n";
}
}
}
The output I got when I ran the code is:
network stats:
messages is: packets dropped for exceeding TTL
messages is: packets dropped due to running out of memory
messages is: bad packet length
messages is: packets dropped due to full socket buffers
messages is: input packets from wrong channel
messages is: input packets with bad destination address
messages is: bad version number
messages is: total packets received
messages is: total packets sent
messages is: packets succesfully transmitted
messages is: packets dropped due to no receiver
messages is: packets sent unsuccessfully
messages is: outgoing packets with no route
phy stats:
messages is: tx buffer load failures
messages is: transmits aborted due to rx
messages is: receive interrupts
messages is: receive cmd errors
messages is: frames received
messages is: zero length frames received
messages is: received frames lost
messages is: late transmits
messages is: frames transmitted
messages is: transmit errors
messages is: tx buffer loads interrupted
mac stats:
messages is: packet transmissions timed out
messages is: confirmed frames sent succesfully
messages is: packet reassemblies timed out
messages is: confirmed frames sent unsuccesfully
messages is: duplicate fragments received
messages is: total frames received
messages is: packets sent successfully
messages is: frames with invalid header
messages is: data packets received
messages is: no buffers
messages is: packets sent unsuccessfully
messages is: packets with invalid length
messages is: packets queued by network layer
messages is: out of order fragments received
messages is: confirmed frames received
messages is: partial packets received
I would also like all the $val part to be printed for each $messages
but there was none when I ran the code. Is there anything wrong with
the code below...
foreach my $type (keys %stats) {
print "$type stats:\n";
foreach my $messages (keys %{$stats{$type}}) {
print "\tmessages is: $messages\n";
foreach my $val (@{$type{$messages}}) {
print "\t\tMessage value is: $val\n";
}
}
}
Thanks,
doni
.
- Follow-Ups:
- Re: Statistics Extraction
- From: Eric Schwartz
- Re: Statistics Extraction
- From: Ch Lamprecht
- 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
- Re: Statistics Extraction
- From: doni
- Re: Statistics Extraction
- From: Eric Schwartz
- Statistics Extraction
- Prev by Date: Re: Clickable mail link?
- Next by Date: Re: Bus error
- Previous by thread: Re: Statistics Extraction
- Next by thread: Re: Statistics Extraction
- Index(es):
Relevant Pages
|