Sponsored Content
Top Forums Shell Programming and Scripting Check numeric fields greater than zero, and delete lines if appropriate Post 302370337 by Yorkie99 on Wednesday 11th of November 2009 06:00:05 AM
Old 11-11-2009
Check numeric fields greater than zero, and delete lines if appropriate

This be the latest in my problems sorting through router logs... I'm half way there on a problem, but I've hit the limitation of my knowledge

Got some router interface log files of type

Code:
router01:GigabitEthernet9/24 is up, line protocol is up (connected)
router01: 0 input errors, 0 CRC, 0 frame, 19 overrun, 0 ignored
router01:GigabitEthernet10/1 is up, line protocol is up (connected)
router01: 0 input errors, 0 CRC, 5 frame, 0 overrun, 0 ignored
router01:GigabitEthernet10/2 is up, line protocol is up (connected)
router01: 0 input errors, 0 CRC, 3 frame, 0 overrun, 0 ignored
router01:GigabitEthernet10/5 is up, line protocol is up (connected)
router01: 0 input errors, 0 CRC, 2 frame, 0 overrun, 0 ignored
router01:GigabitEthernet10/6 is up, line protocol is up (connected)
router01: 0 input errors, 0 CRC, 2 frame, 0 overrun, 0 ignored
router01:GigabitEthernet10/9 is up, line protocol is up (connected)
router01: 6297 input errors, 6297 CRC, 6298 frame, 0 overrun, 0 ignored
router01:GigabitEthernet10/10 is up, line protocol is up (connected)
router01: 0 input errors, 0 CRC, 1 frame, 0 overrun, 0 ignored
router01:GigabitEthernet10/14 is up, line protocol is up (connected)
router01: 0 input errors, 0 CRC, 1 frame, 0 overrun, 0 ignored

I don't care about frame errors or ignored errors, but I do want to take account of input errors, CRC errors and overrun errors, so I want to keep those lines (and the line above them) where those parameters are non zero, and I want to delete those lines where the important parameters are 0, and the lines above them. So... for the input above... I want the output to be

Code:
router01:GigabitEthernet9/24 is up, line protocol is up (connected)
router01: 0 input errors, 0 CRC, 0 frame, 19 overrun, 0 ignored
router01:GigabitEthernet10/9 is up, line protocol is up (connected)
router01: 6297 input errors, 6297 CRC, 6298 frame, 0 overrun, 0 ignored

I'm thinking the way to do it is to sort for lines with the string "input errors", and check if the second, or fifth, or ninth parameters are non zero, and if so keep that line and the line above it, otherwise delete the line and the line above it.

I'm doing this on ubuntu... (may or may not be relevant)

Last edited by Franklin52; 11-11-2009 at 07:05 AM.. Reason: Please use code tags!
 

10 More Discussions You Might Find Interesting

1. Programming

check the given string is numeric or not.

Hi, how to check the given string is numeric or not , without converting ( using strtol...). for ex: if string is C01 - non-numeric data if string is 001 - numeric data TIA (11 Replies)
Discussion started by: knowledge_gain
11 Replies

2. Shell Programming and Scripting

Select lines in which column have value greater than some percent of total file lines

i have a file in following format 1 32 3 4 6 4 4 45 1 45 4 61 54 66 4 5 65 51 56 65 1 12 32 85 now here the total number of lines are 8(they vary each time) Now i want to select only those lines in which the values... (6 Replies)
Discussion started by: vaibhavkorde
6 Replies

3. Shell Programming and Scripting

How to check for a Numeric Value?

Using shell, I have a variable, how can I check that variable for a numeric value such as "41.0"? My program needs to do one things if the numeric value is found, and another if something else such as a string of letter is found. is there a specific character that denotes a numeral? The... (2 Replies)
Discussion started by: chagan02
2 Replies

4. Shell Programming and Scripting

Delete words greater than a specific length

HI All, I have a file with contents like this: apple computer terminal applecomputernetworkrouterterminalrouter network router applecomputernetworkrouterterminalrouter I want to remove all lines with length greater than "18 alphabets". Hence, my output should be: apple computer... (1 Reply)
Discussion started by: shoaibjameel123
1 Replies

5. Shell Programming and Scripting

search column and delete row if greater than value

Hi, as the title states i need to find a way to search a column for values great than 1000, and if it is, then delete that row. An example 1 7.021 6.967 116.019 4 U 6.980E+07 0.000E+00 e 0 0 0 0 2 8.292 7.908 118.063 3 U 1.440E+07 0.000E+00 e 0 821 814 ... (3 Replies)
Discussion started by: olifu02
3 Replies

6. UNIX for Dummies Questions & Answers

check if a decimal number is greater than zero

Hello, In my code I am checking to see if a variable that contains a decimal number is greater than 0 in the following manner: if do something fi However I am getting the error message (if $i for the current iteration holds 9.6352) command 9.6352 is not found How can I rectify... (5 Replies)
Discussion started by: Gussifinknottle
5 Replies

7. Shell Programming and Scripting

To perform sum aggregation on numeric fields

Hi all, I have following scenario to perform sum aggregation on certain columns Node Allocated_Space Pool_Name CS_Group Utilized Space -------- ---------------- ---------- --------- -------------- bdw1a_lun01 300 bdw_p0 ... (2 Replies)
Discussion started by: ckwan
2 Replies

8. Shell Programming and Scripting

Need to check the value greater than or less than and give out put to a file

HI, I have one file which is as below cat /var/tmp/test1 | awk '{ print $3}'|grep -v affected Data ---------- 200.4 . The above 200 value is changable by the database script. Now I need a script that checks the value 200.4 and the script shoud give out put if value is more than 225 (2 Replies)
Discussion started by: phani4u
2 Replies

9. How to Post in the The UNIX and Linux Forums

Very Urgent ---Need to delete the log files when the disk used% greater than 85% using df -k*

Hi, I am new to Shell scripts. I have an urgent requirement to find the disk space using "df -k". from that output,I need to check the used% whether greater than 85%. if it is greater than 85% then need to delete my log files. It is very urgent please some one help me. Thanks in Advance... (1 Reply)
Discussion started by: Anandbarnabas
1 Replies

10. Shell Programming and Scripting

Need to delete the log files when the disk used% greater than 85% using df -k

Hi, I am new to Shell scripts. I have an urgent requirement to find the disk space using "df -k". from that output,I need to check the used% whether greater than 85%. if it is greater than 85% then need to delete my log files. It is very urgent please some one help me. Thanks in Advance... (2 Replies)
Discussion started by: Anandbarnabas
2 Replies
syncstat(1M)						  System Administration Commands					      syncstat(1M)

NAME
syncstat - report driver statistics from a synchronous serial link SYNOPSIS
/usr/sbin/syncstat [-c] device [interval] DESCRIPTION
The syncstat command reports the event statistics maintained by a synchronous serial device driver. The report may be a single snapshot of the accumulated totals, or a series of samples showing incremental changes. Prior to these it prints the device name being used to query a particular device driver, along with a number indicating the channel number (ppa) under control of that driver. Event statistics are maintained by a driver for each physical channel that it supports. They are initialized to zero at the time the driver module is loaded into the system, which may be either at boot time or when one of the driver's entry points is first called. The device argument is the name of the serial device as it appears in the /dev directory. For example, zsh0 specifies the first on-board serial device. The following is a breakdown of syncstat output: speed The line speed the device has been set to operate at. It is the user's responsibility to make this value correspond to the modem clocking speed when clocking is provided by the modem. ipkts The total number of input packets. opkts The total number of output packets. undrun The number of transmitter underrun errors. ovrrun The number of receiver overrun errors. abort The number of aborted received frames. crc The number of received frames with CRC errors. isize The average size (in bytes) of input pack- ets. osize The average size (in bytes) of output pack- ets. OPTIONS
-c Clear the accumulated statistics for the device specified. This may be useful when it is not desirable to unload a particu- lar driver, or when the driver is not capable of being unloaded. interval syncstat samples the statistics every interval seconds and reports incremental changes. The output reports line utiliza- tion for input and output in place of average packet sizes. These are the relationships between bytes transferred and the baud rate, expressed as percentages. The loop repeats indefinitely, with a column heading printed every twenty lines for convenience. EXAMPLES
Example 1: Sample output from the syncstat command: example# syncstat zsh0 speed ipkts opkts undrun ovrrun abort crc isize osize 9600 15716 17121 0 0 1 3 98 89 example# syncstat -c zsh0 speed ipkts opkts undrun ovrrun abort crc isize osize 9600 0 0 0 0 0 0 0 0 In the following sample output a new line of output is generated every five seconds: example# syncstat zsh0 5 ipkts opkts undrun ovrrun abort crc iutil outil 12 10 0 0 0 0 5% 4% 22 60 0 0 0 0 3% 90% 36 14 0 0 0 1 51% 2% ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWcsu | +-----------------------------+-----------------------------+ SEE ALSO
syncinit(1M), syncloop(1M), attributes(5), zsh(7D) DIAGNOSTICS
bad interval: arg The argument arg is expected to be an interval and could not be understood. device missing minor device number The name device does not end in a decimal number that can be used as a minor device number. baud rate not set The interval option is being used and the baud rate on the device is zero. This would cause a divide-by-zero error when computing the line utilization statistics. WARNINGS
Underrun, overrun, frame-abort, and CRC errors have a variety of causes. Communication protocols are typically able to handle such errors and initiate recovery of the transmission in which the error occurred. Small numbers of such errors are not a significant problem for most protocols. However, because the overhead involved in recovering from a link error can be much greater than that of normal operation, high error rates can greatly degrade overall link throughput. High error rates are often caused by problems in the link hardware, such as cables, connectors, interface electronics or telephone lines. They may also be related to excessive load on the link or the supporting sys- tem. The percentages for input and output line utilization reported when using the interval option may occasionally be reported as slightly greater than 100% because of inexact sampling times and differences in the accuracy between the system clock and the modem clock. If the percentage of use greatly exceeds 100%, or never exceeds 50%, then the baud rate set for the device probably does not reflect the speed of the modem. SunOS 5.10 9 Mar 1993 syncstat(1M)
All times are GMT -4. The time now is 10:30 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy