Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Fabric: Tailing Log Files on Multiple Machines

DZone's Guide to

Fabric: Tailing Log Files on Multiple Machines

· DevOps Zone
Free Resource

The Nexus Suite is uniquely architected for a DevOps native world and creates value early in the development pipeline, provides precise contextual controls at every phase, and accelerates DevOps innovation with automation you can trust. Read how in this ebook.

We wanted to tail one of the log files simultaneously on 12 servers this afternoon to try and see if a particular event was being logged and rather than opening 12 SSH sessions decided to get Fabric to help us out.

My initial attempt to do this was the following:

fab -H host1,host2,host3 -- tail -f /var/www/awesome/current/log/production.log

It works but the problem is that by default Fabric runs the specified command one machine after the other so we’ve actually managed to block Fabric with the tail command on ‘host1′.

The output of host1′s log file will be printed to the terminal but nothing from the other two hosts.

Nathan showed me how to get around this problem by making use of Fabric’s parallel execution which we can enable with the ‘-P’ option:

fab -P --linewise -H host1,host2,host3 -- tail -f /var/www/awesome/current/log/production.log

We also used the ‘likewise’ flag to ensure that data between the different tail processes didn’t get mixed up although this wasn’t necessary because Fabric defaults to likewise if you’re using parallel execution mode anyway.

On a side-note, Paul Ingles wrote up the approach taken to make data from log files more accessible using a Kafka driven event pipeline but in this case we haven’t got round to wiring this data up yet so Fabric it is for now.



The DevOps Zone is brought to you in partnership with Sonatype Nexus.  See how the Nexus platform infuses precise open source component intelligence into the DevOps pipeline early, everywhere, and at scale. Read how in this ebook

Topics:

Published at DZone with permission of Mark Needham, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}