LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to write a wrapper script for iostat (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-write-a-wrapper-script-for-iostat-849039/)

stress_junkie 12-09-2010 07:41 AM

Quote:

Originally Posted by srrijith (Post 4185547)
what is the equivalent of iostat –E in linux ( it display all device error statics).
Linux which am using dosent support iostat -E

Why didn't you say that in the first place? This is the first post in which you made a clear statement about what you are trying to achieve. Now we can begin to help you. That's all that we want.

You can get raw error reports for different types of devices using sar. You do not need to have the sar data collector running if you just want to view system information that is happening right now. Then you can use the sar command line utility to report device errors for different classes of devices. Here are a few examples.

This example will show network device errors.
Code:

sar -n EDEV
This example will show IPv4 errors.
Code:

sar -n EIP
This example will show ICMP errors.
Code:

sar -n EICMP
I got all of these examples from the man page for sar. There are numerous other device error reports available in sar.

These error reports show raw numbers, not percentages. Now that you can collect the data you will (probably) have to create your own function for calculating percentages/rates.

You should be able to get awk to do the parsing and calculations.

srrijith 12-09-2010 07:18 PM

dmesg with which option displays all device error statistics as iostat -E does .. any idea ?

TB0ne 12-09-2010 07:51 PM

Quote:

Originally Posted by srrijith (Post 4186550)
dmesg with which option displays all device error statistics as iostat -E does .. any idea ?

No options, you look in the file for any errors.

You can also pay attention, since folks are giving you answers, like stress_junkie did with the sar command. Try reading the man pages.

srrijith 12-09-2010 11:01 PM

any idea from which directory and file iostat -E commands reads the device error statistics details for displaying as below

iostat -En
c0t0d0 Soft Errors: 0 Hard Errors: 0 Transport Errors: 0
Model: ST3120026A Revision: 8.01 Serial No: 3JT4H4C2
Size: 120.03GB <120031641600 bytes>
Media Error: 0 Device Not Ready: 0 No Device: 0 Recoverable: 0
Illegal Request: 0
c0t2d0 Soft Errors: 0 Hard Errors: 0 Transport Errors: 0
Vendor: LITE-ON Product: COMBO SOHC-4832K Revision: O3K1 Serial No:
Size: 0.00GB <0 bytes>
Media Error: 0 Device Not Ready: 0 No Device: 0 Recoverable: 0
Illegal Request: 0 Predictive Failure Analysis: 0

genderbender 12-10-2010 04:48 AM

Quote:

Originally Posted by srrijith (Post 4186669)
any idea from which directory and file iostat -E commands reads the device error statistics details for displaying as below

iostat -En
c0t0d0 Soft Errors: 0 Hard Errors: 0 Transport Errors: 0
Model: ST3120026A Revision: 8.01 Serial No: 3JT4H4C2
Size: 120.03GB <120031641600 bytes>
Media Error: 0 Device Not Ready: 0 No Device: 0 Recoverable: 0
Illegal Request: 0
c0t2d0 Soft Errors: 0 Hard Errors: 0 Transport Errors: 0
Vendor: LITE-ON Product: COMBO SOHC-4832K Revision: O3K1 Serial No:
Size: 0.00GB <0 bytes>
Media Error: 0 Device Not Ready: 0 No Device: 0 Recoverable: 0
Illegal Request: 0 Predictive Failure Analysis: 0

Your asking a different question now - strace or truss will show you the system calls. If you want a wrapper script you don't need to find out which inidividual line of code gets the errors; a wrapper script is a script which runs a seperate script, you've been given a good example already. You need to specify exactly what you need help with?

1. An alternative to iostat in linux (an answer to this has already been provided).
2. A way to call iostat from within your own script (this has been provided already).
3. Your own script with the calls that the unix version of iostat uses to grab it's data (nobody will help you with this as it's pointless and impossibly hard).
4. More assistance with exactly how iostat works.
5. A way to get the same data as iostat provides (dmesg wont reaaaally do this).

TB0ne 12-10-2010 07:30 AM

Quote:

Originally Posted by srrijith (Post 4186669)
any idea from which directory and file iostat -E commands reads the device error statistics details for displaying as below

Yes, and we've told you several times. Again, PAY ATTENTION to what folks are posting. Try reading the man pages for programs. Posting the same question over and over, doesn't help.


All times are GMT -5. The time now is 03:44 PM.