Sponsored Content
Top Forums Shell Programming and Scripting Need help to get the parsed output of "iostat" command Post 302974461 by gopivallabha on Tuesday 31st of May 2016 12:20:16 AM
Old 05-31-2016
Need help to get the parsed output of "iostat" command

Hi,

I have a requirement where parsed output from various linux commands like top, netstat, iostat, etc. will be the input for one javascript with the parsed output from these commands converted to JSON format

For "iostat" command, since there are two outputs - one w.r.t CPU utilization and another w.r.t device statistics, ex.:
Code:
iostat -c
[root@rhel64 ~]# iostat -c
avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           0.59    0.00    0.32    0.46    0.00   98.63

and

Code:
iostat -d -p
[root@rhel64 ~]# iostat -d -p -k
Device:            tps    kB_read/s    kB_wrtn/s    kB_read    kB_wrtn
scd0              0.00         0.00         0.00        180          0
sda               1.21         1.00        22.27    1521773   33955953
sda1              0.00         0.01         0.00      10487          9
sda2              1.21         0.99        22.27    1510670   33955944
dm-0              5.60         0.99        22.27    1508485   33949224
dm-1              0.00         0.00         0.00       1288       6708
dm-2              0.00         0.00         0.00        489         12


My requirement here is to have a shell script or perl script which can awk the output for the above two usages of iostat command (i.e., for CPU and device statistics) but without any sampling interval taken into account (sampling interval will be done later by calling the code multiple time. For now, output displayed once is enough)
There should be two parsed outputs, one for CPU statistics and one for Device statistics both of which shall later be used as input data for conversion to JSON format (in node.js)

Can someone help me out here?

Last edited by Don Cragun; 05-31-2016 at 02:03 AM.. Reason: Add CODE and ICODE tags.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed substitute / for \ : error "Function can not be parsed"

Hello all, I have a weird issue when trying to substitute the slashes into backslashes. If I execute this on the command-line (bash / ksh) I get the path correctly translated with backslashes instead of slashes. > echo $PWD | sed 's/\//\\/g' However, when I put this in my script to... (3 Replies)
Discussion started by: candyflip2000
3 Replies

2. Debian

Debian: doubt in "top" %CPU and "sar" output

Hi All, I am running my application on a dual cpu debian linux 3.0 (2.4.19 kernel). For my application: <sar -U ALL> CPU %user %nice %system %idle ... 10:58:04 0 153.10 0.00 38.76 0.00 10:58:04 1 3.88 0.00 4.26 ... (0 Replies)
Discussion started by: jaduks
0 Replies

3. UNIX for Dummies Questions & Answers

Explanation of "total" field in "ls -l" command output

When I do a listing in one particular directory (ls -al) I get: total 43456 drwxrwxrwx 2 root root 4096 drwxrwxrwx 3 root root 4096 -rwxrwxr-x 1 nobody nobody 3701594 -rwxrwxr-x 1 nobody nobody 3108510 -rwxrwxr-x 1 nobody nobody 3070580 -rwxrwxr-x 1 nobody nobody 3099733 -rwxrwxr-x 1... (1 Reply)
Discussion started by: proactiveaditya
1 Replies

4. Shell Programming and Scripting

"Join" or "Merge" more than 2 files into single output based on common key (column)

Hi All, I have working (Perl) code to combine 2 input files into a single output file using the join function that works to a point, but has the following limitations: 1. I am restrained to 2 input files only. 2. Only the "matched" fields are written out to the "matched" output file and... (1 Reply)
Discussion started by: Katabatic
1 Replies

5. Shell Programming and Scripting

Storing output of "time" command to a variable

Hi all, I am new to Linux/shell scripting having moderate knowledge. In my script, I need to get execution time of a command (say 'ls') in mili seconds level. For this i tried using "time" command to retrieve the total execution time in milli seconds. But, the problem is that, how to save... (9 Replies)
Discussion started by: happening_linux
9 Replies

6. Shell Programming and Scripting

Retrieve RAM memory size from "top" command output

Hi, I am trying to get the system RAM size from "top" command's output by the following but it is not working. top | sed "s/^Mem.**\(*\), *//" (10 Replies)
Discussion started by: royalibrahim
10 Replies

7. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

8. UNIX for Advanced & Expert Users

AIX - io info get from "libperfstat" not match "iostat"

Hi, everyone. I need to write a program to get io info based on libperfstat. But the "write time" of a disk is just half of the value get from iostat. I'm confused and can't explain. Help please. How I calculate "write service time per sec": In iostat: write service... (0 Replies)
Discussion started by: jackliang
0 Replies

9. UNIX for Dummies Questions & Answers

Using "mailx" command to read "to" and "cc" email addreses from input file

How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address and column 3 contains “cc” e-mail address to include with same email. Sample input file, email.txt Below is an sample code where... (2 Replies)
Discussion started by: asjaiswal
2 Replies

10. Programming

Redirecting output to new file for command "perldoc perllocal"

Hi, I have to redirect output of the command "perldoc perllocal" to new file which contains all the perl module installed. Currently using perldoc perllocal >> mod_data This does not contain all perl modules installed locally on machine, and each character is doubled. Please... (3 Replies)
Discussion started by: asak
3 Replies
dxdw(8) 						      System Manager's Manual							   dxdw(8)

NAME
dxdw - Runs and repeats command line commands SYNOPSIS
/usr/bin/X11/dxdw [-c initial_command] OPTIONS
Specifies the command to run. The command string must be enclosed in double quotes if it contains any spaces or special characters inter- preted by the shell. Display Window accepts all of the standard X Toolkit command line options, which are documented in the OPTIONS section of the X(1X) refer- ence page. DESCRIPTION
The Display Window application, dxdw, can be used to run commands at specified time intervals. You can use Display Window to: Run a command and display a transcript of the output Repeat a command at regular intervals Print the output to the default printer Save the output to a file You can use Display Window to run common commands without starting up a full xterm. The optional -c option specifies an initial command. The Display Window application presents a transcript containing the current command, its output, and its command-line error messages. You can change the command after the application starts. The transcript area is output-only, so you cannot use Display Window to run commands that require user interaction on the command line. The Display Window application can be invoked from the CDE Application Manager from the following categories: Application Group: System_Admin System Admin Subgroup: Daily Admin When the Display Window main window invoked, the transcript is empty because there is no command running. Enter a command to run in the Command input text field. Because Display Window can be started with a default initial command, several launchpoints have been created in the Application Manager to run specific command-line applications. These applications include I/O Statistics (iostat), Network Statistics (netstat), Virtual Memory Statistics (vmstat), and Who? (who). To start one of the preceding applications within Display Window from the CDE desktop: Click on the Application Manager icon on the CDE front panel. Double click on the System_Admin application group icon. Double click on the Tools application group icon. Double click on the icon for the command you want to run in the Display Window application. The Display Window application invokes the command once. The output from the command is displayed in the transcript area. You can also start Display Window from the command line. To start Display Window from the command line, enter the following: /usr/bin/X11/dxdw [-c initial_command] The -c option specifies the command string to run when Display Window is started. On the command line, the command string must be enclosed in double quotes if it contains any spaces or special characters interpreted by the shell. The command string can be any of the following: A single command A series of commands in a pipeline (|) A series of commands separated by semicolons After Display Window starts, a new command string can be entered in the Command input text field. In the graphical user interface, it is not necessary to enclose the command string in double quotes. To enter a new command string: Clear the Command input text field if a command is already present. Enter a new command string in the Com- mand input text field. Press the Return key in the Command input text field to run the command. EXAMPLES
The following example runs the iostat command one time in the Display Window application. You can use the Repeat Every dialog box to repeat the command at regular intervals. dxdw -c iostat The following examples show how to use Display Window from the command line. dxdw -c df dxdw -c "ps -aef" dxdw -c "ps -aef | grep dxdw" dxdw -c "mount; showmount" You can view the Display Window online help volume without run- ning the application. To open the Display Window help volume from the command line, enter the following command: /usr/dt/bin/dthelpview -h /usr/dt/appconfig/help/C/Dxdw.sdl FILES
Contains the Display Window application executable Contains the Display Window help volume Contains the default values for the applica- tion's X resources SEE ALSO
Commands: iostat(1), netstat(1), vmstat(1), who(1), X(1X) dxdw(8)
All times are GMT -4. The time now is 05:45 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy