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.:
and
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.
Please describe what you believe JSON format is and show us EXACTLY what output you hope to produce in your output file (in CODE tags) corresponding to the two input samples you have shown us.
I am using bash, and the Linux version is RHEL 6.4
The reason I mentioned that I would need awk is because of the parsing. And perl would be, I considered, an appropriate choice here.
I am just giving an example code in javascript which uses the JSON format. Basically, this is the output I need to finally get. Before getting this is where I need the help, for getting CPU and device statistics, just like the code I have given for example provides output for "ps" command with paramters like rss, pcpu, vsz, etc. On similar lines, I need the output for parameters like:
avg-cpu: %user %nice %system %iowait %steal %idle
and
Device: tps kB_read/s kB_wrtn/s kB_read kB_wrtn
Once I get the parsed output, I need to convert it into JSON format which provides an output based readily with parameters like: Objects: CPU and Device Metric...kilobytes (kB) CPU-Properties....%user %nice %system %iowait %steal %idle; Device-Properties.... tps kB_read/s kB_wrtn/s kB_read kB_wrtn Value.....the values of the above CPU and device properties
Template Code:
Linux Example Code for "ps" command
---------- Post updated 06-01-16 at 12:35 AM ---------- Previous update was 05-31-16 at 12:47 PM ----------
Any update on this query folks?
Kindly let me know
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)
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)
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)
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)
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)
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)
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)
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)
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)