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.:
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
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?