Feb 26

Let's dance with DSH!

Fri, 02/26/2016 - 08:39 — peter

The Problem

You are a developer troubleshooting performance issues on production and you want to look at server logs. The web servers are in a load-balancing cluster that you have no access to, and the incredible folks responsible for the devops of this setup do not have the very basics of centralized logging configured... Not that I've found myself in this situation... Uh, I'm asking for a friend of a friend... ;)

The Solution

Enter the dancer's shell, or DSH for short. This utility, available via most package managers out there, allows you to run the same command on multiple hosts, like so:

dsh -Mm server1.example.com,server2.example.com,server3.example.com uptime
server1.example.com:  07:35:21 up 29 days, 19:03,  0 users,  load average: 2.56, 3.40, 3.63
server2.example.com:  07:35:22 up 29 days,  6:42,  0 users,  load average: 4.96, 5.49, 6.15

"So what?" you say, "Big deal. A simple for-loop can do that!" Well, that is true, but DSH does a bit more for you than that... You can pass commands like tail -f to it as well, and get an aggregated live stream of all remote server logs. "Now you are talking!" you think. I knew you'd come around!

DSH looks for some configuration files on /etc/dsh and /usr/local/dsh for machines and machine groups definitions.

Easy Peasy!

-PCP