Shrikrishna Khare wrote: ... > - I did not find diff(1) option that can compute arithmetic difference. > > - Moreover, even if there is some diff variant that can do it, consider the > use case as in example above: > Diff "current receive side per hardware lane stats" with the stats saved in > snap1.txt and display. > > It is still cumbersome to do an additional > dlstat -k -p > snap3.txt > <arithmatic diff> snap1.txt snap3.txt > and then hunt through the machine parsable format to look for > specific fields of your interest - per hardware lane stats in our example. >
Hunting for specific fields is no harder or easier with what you are proposing, unless your "dlstat -r -h -d <file>" somehow reads my mind to know which fields I want. "Hardware lane" sounds more like a group of statistics, to me, not specific fields. But if you gave me a set of output from "dlstat -k -p" and "dlstat -r -h -p" (assuming -k to be a superset of -h) and then asked me to find the lines from -k-p that changed in -r-h-p, I'd probably apply commands line comm, join, diff, awk, etc. The architecture of Un*x is to provide lots of small utilities that have a specific purpose that all output data to stdout/stderr (and take input from files/stdin), data that can then be used in various ways by various programs to achieve more. > Having a complete snapshot at particular instant (dlstat -k -p <file> and > then having ability to request diff against statistics of our interest (e.g. > dlstat -r -h -d <file>) looks appealing to me in comparison. > > Moreover, you can then do fancier stuff like: > dlstat -r -h -d <file> -i 2 > > which will report diffs with the file after every 2 seconds. When using commands such as "vmstat" and "netstat" with an option like "-i 2", the general goal is to understand the change in activity for that period of time. Then again, not all of the statistics displayed with "vmstat 1" are progressive changes - memory (swap/free) are an example - but this makes sense: as swap/free drop, you can see the effect of this on other stats, such as "sr", and friends. To what purpose do you see printing out the difference in the value of a statistic, every second, from a known starting point? I can see the use in "dlstat -r -h -i 2", but to display relative to a snapshot? why? > Essentially, the proposed approach is aimed at catering to all 'reset' > stats requirement, without really resetting anything. In which case it would be much better to have a completely new command written that computed arithmetic differences, based on a particular type of output. Then that could be uses on the output of flowstat or dlstat or any other command rather than use an internal feature of one specific command. It also reduces the complexity of dlstat whilst providing us with more chances to reuse the arithmetic difference without needing to build it into every statistical command. Darren