Closed rdhatt closed 3 years ago
Thank you for this! Just for future compatibility, what are your thoughts on making different output modes? For example, if we used -o
then your output could be -o kv
. That way if somebody did want to add JSON output they could do -o json
. This way we wouldn't have to use up a letter for each output mode, and wouldn't have to worry about what happens when a user specifies multiple output modes at the same time.
I was taking the "do the simplest thing" approach , especially since I haven't written C since the last millennium. 😄
I think I managed to do what you asked, let me know what you think. Also remembered to update the help text this time.
I found a couple minor issues, like that it fails if you don't specify "-o". But I'll fix them up in a subsequent commit. Thank you!
I have the desire to track file cache diagnostics across many machines on regular basis, so having machine-friendly output is a must. My logging system can parse either KVP or JSON records.
My first attempt used
sed
andawk
. KVP is easy to read/write with these tools.This gets me most of what I want however the size units are a pain to deal with. I would need to figure out how to get
numfmt
/units
involved or rewrite in perl or the like. This was getting complicated quickly.I realized just adding my own printf inside vmtouch would be much simpler, so here we are. I realize JSON is the trending format these days, however I just stuck with kvp since it's simpler and it works for me.
Example output produced by -k switch:
This addresses the first item in TODO 🙂.