Writing go in shell and awk

I’ve been using Go for a while now, and learning to think into the language.  Quite to my surprise, it’s improved my shell and awk.

I use shell and awk for prototyping programs I need immediately, and may need to rewrite quickly. One of these pulled data hourly out of a database under cron, and formatted it for Grafana graphs.

To my great pleasure, I recently found that some of the data was updated continuously.  I could read it each minute, subtract the previous minute from the current, and deliver a minute-by-minute measurement to our NOC.

That allowed them in turn to spot outages in important services in a matter of minutes. If any of the measures fell to zero, we only had to wait a few minutes to see if it was continuing, not an hour (!)

But how to do that kind of calculation, for several hundred matrics?

Well, I could share memory (awk tables) by communicating through channels (pipes).  Shell provides me the pipes, awk the tables, and Go provides me with the programming discipline to use them effectively.

Instead of rewriting, I can refactor, deliver the result when it’s needed, and learn if that’s the material the NOC really needs.  If so, then we know what a Go program will need to do, and I or one of My Smarter Colleagues can write it, whenever appropriate.

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s