Parse mtr stats


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Parse mtr stats
# 1  
Old 05-15-2013
Parse mtr stats

Hi,

I am trying to parse mtr stats.

On each hop if Loss > 0 then I need to email the entire stats.

Code:
IFS='
';for i in `cat mtrres `; do VAL=$(echo $i|awk -F" " '{print $2}' | awk -F"." '{print $1}'); if [ $VAL -ne 0 ]; then echo "send email"; exit 0; fi;done

Filename: mtrres
Code:
192.168.1.10                   Snt: 10    Loss%  Last   Avg  Best  Wrst StDev
192.168.1.1                                 0.0%   6.5   3.0   0.5   8.4   3.2
 ge-11-0-0-xcr1.nyk.cw.net                0.0%   0.3   0.3   0.2   0.3   0.0
 ge-11-0-0-xcr1.nyk.cw.net                0.0%  57.1  61.1  57.1  75.4   6.3
ir1.fp.vip.gq1.yahoo.com                  0.0%  58.5  58.2  58.1  59.0   0.3

Please advise if there is a better way... It helps me and someone who is looking..

Thanks
Ashok
# 2  
Old 05-15-2013
You can do it in awk..

Code:
 
awk 'NR>1{sub(/%/,"",$2);if($2>0.0){print "Send Email"}else{print $2}}' filename

Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

'time' for disk stats

we all know the time shell command Is there a way to test disk i/o of a process in a similar fashion? I am trying different methods to limit disk writes in a 24/7 daemon process and would like to measure. I know pidstat does it but only to a running process, i want to do one shot test... (7 Replies)
Discussion started by: bigearsbilly
7 Replies

2. Linux

Stats on subdirectories

Please help me with a shell script to get the stats on many subdirectories (sub1), (sub2) etc under a mother directory (big) /big | |_______sub1 |_______sub2 |_______sub3 --------- I want to know 1. What is the last file accessed in each subdirectory with date and by whom 2.... (2 Replies)
Discussion started by: digipak
2 Replies

3. Shell Programming and Scripting

Using Stats in Php

So, I have a php program that i need to delete ALL files in a directory that are older than a certain age. <?php /* Get file stat */ $stat = stat('/apps/security/ajaba'); This is as far as I've been able to get. I know in shell programming you can easily do something like this. but I'm... (2 Replies)
Discussion started by: SkySmart
2 Replies

4. AIX

IO Stats

Aix 5.3 I am trying to view the IO stats. I do the sar 5 5 but that is the WIO and si different than the IO stats right? I am just blanking on this. I know there is a command that I used to run that brings up a whole bunch of live stats that run live such as mem and so on just can't rememeber... (4 Replies)
Discussion started by: rocker40
4 Replies

5. Shell Programming and Scripting

How to parse a list of data to find the missin stats.

HI ALL, Thanks for helping me with my last post. :b: I have one more doubt, i want to parse a set of data. which is consisting of some values that occured in particular period of time. And when i parse down if there is a missing time period then it should show the two rows between which the... (3 Replies)
Discussion started by: asirohi
3 Replies

6. AIX

system stats

I recieved this out put below soemhow. Unfortunatly I did not write down the command I used to get it. Can someone tell me what command I use to gather these stats? OS = AIX 5.3 64Bit System Model: IBM,7026-6H1 Machine Serial Number:... (2 Replies)
Discussion started by: rocker40
2 Replies

7. UNIX for Advanced & Expert Users

I/O Stats Metrics

What do others use for measuring I/O statistics? I'd like something versatile, as in being able to watch (like iostat, but easier to trend), generate load (like iozone, but more realistic), and perform somewhat generalized benchmarks (like bonnie, but more current.) It would scale from a few... (0 Replies)
Discussion started by: LivinFree
0 Replies
Login or Register to Ask a Question