John Rigler
Hello, I am a computer programmer who specializes in functional languages, scripting, visual mapping, unix, and devops. For more examples and tricks, check out my blog at DEAD1EC0FFEE





One area which I work on is quickly visualizing data in different formats through the shell and the web. Starting with collected vmstat output, we are able to view data in a few ways that make sense visually, first in a horizontal textual format, and then in PNG files created on the fly with PHP/GD.

The following is simply the output of vmstat, captures in a script file:

web> script 1_02.ts 
vmstat 4 4
exit
By running or scripting this from the command line, the output below is created.
Script started on Sun 23 Apr 2017 11:35:22 PM CDT
]0;john@purple: /var/www/html/sbstatsjohn@purple:/var/www/html/sbstats$ vmstat 4 4
procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
 2  0 1015984 171196  48300 745440    7   15    21    40   90    6  5  1 93  0  0
 0  0 1015984 181736  48308 734560    0    0     0    55  804  731  2  1 96  0  0
 0  0 1015984 181984  48320 734524    0    0     0   109  784  692  3  1 96  0  0
 0  0 1015980 180656  48340 735364    0    0     0    58  899 1407  6  2 91  0  0
]0;john@purple: /var/www/html/sbstatsjohn@purple:/var/www/html/sbstats$ exit
exit

Script done on Sun 23 Apr 2017 11:35:41 PM CDT
The following is captured and stored in simple CSV files:
web> head 20100821CDT:0206689D5:UNDEF:unixd26:aix:vmstat.sbstats
00:00 UNDEF 1,0,1066020,700067,0,0,0,0,0,0,9,667,196,2,3,96,0,0.02,5.8,1,8,8192,0.40
00:05 UNDEF 1,0,1065294,700791,0,0,0,0,0,0,8,322,193,1,2,96,0,0.02,5.5,1,8,8192,0.40
00:10 UNDEF 1,0,1066097,699711,0,0,0,0,0,0,11,572,172,5,3,93,0,0.04,8.9,1,8,8192,0.40
00:15 UNDEF 2,0,1065523,700271,0,0,0,0,0,0,17,570,206,5,3,93,0,0.04,9.0,1,8,8192,0.40
00:20 UNDEF 2,0,1065281,700507,0,0,0,0,0,0,12,505,177,11,3,86,0,0.06,15.6,1,8,8192,0.40
The following is a quick visual tool which I made to view the data in a more readable format. Note that this is meant to be run from the command line, but because I tie the command line and web together, you can easily show the command line on the web. It is also helpful in framing and organizing more sophisticated images, like the week graphical rollup below.
Script started on Sat 22 Apr 2017 07:56:40 PM CDT

cat 20100805CDT:0310F24A1:UNDEF:unixp25:aix:vmstat.sbstats |  vmstat_cpu | while read LINE
>do 
>percent_stack $LINE 
>done | egrep "^08|^09"

[00:00](---17---)(--12--)(0)
[08:00](-----------56-----------)(----22----)(2)
[08:05](-------36-------)(----20----)(3)
[08:10](--------41--------)(----21----)(2)
[08:15](--------44--------)(----23----)(2)
[08:20](---------46---------)(----21----)(2)
[08:25](---------49---------)(---18---)(2)
[08:30](--------43--------)(----20----)(2)
[08:35](-------38-------)(---17---)(2)
[08:40](----------52----------)(----20----)(2) [the server is getting busy here]
[08:45](-----------------87-----------------)(--11--)(0)
[08:50](------------------90------------------)(-9-)(0)
[08:55](------------------93------------------)(-6-)(0)
[09:00](------------------90------------------)(-9-)(0)
[09:05](-------------65-------------)(----22----)(1)
[09:10](---------47---------)(----20----)(2)
[09:15](-------39-------)(----20----)(2)
[09:20](-------------67-------------)(------30------)(2)
[09:25](-----------55-----------)(----23----)(2)
[09:30](---------49---------)(----23----)(2)
[09:35](---------48---------)(----20----)(2)
[09:40](-------38-------)(----21----)(2)
[09:45](----------52----------)(----23----)(2)
[09:50](---------46---------)(----23----)(2)
[09:55](-----------55-----------)(----21----)(2)
exit

Script done on Sat 22 Apr 2017 07:57:04 PM CDT
The following shows the same data accumulated on 5-minute increments over the course of a few weeks and shows as php/gd generated PNG files.