Live data from Hacker News

Show HN: Tail out log files from multiple remote hosts with one command

github.com

11–20 of 20 posts

Re: Show HN: Tail out log files from multiple remote hosts with one command

#11
post #5

So it's basically: tail -f + I need to install nodejs?

The interface to this tool is far nicer to work with. Can you replicate that interface with your command?

Serious question - I actually would like to see how you'd do it.

Re: Show HN: Tail out log files from multiple remote hosts with one command

#14
post #11
post #5

So it's basically: tail -f + I need to install nodejs?

The interface to this tool is far nicer to work with. Can you replicate that interface with your command? Serious question - I actually would like to see how you'd do it.

You can have something like this in your .bashrc:

    multitail() {
        com="tail -f "

        for arg; do
            IFS=':' read -a array 
This will take the host:file syntax of remtail and turn it into Plugawy's example. I haven't tested it, but if you echo "$com" it'll spit out Plugawy's code.

Re: Show HN: Tail out log files from multiple remote hosts with one command

#15
post #12

I use pssh [1]. pssh -H h1 -H h2 -P "tail -n 1000 /var/log/x.log" It is very easy to install on every platform since is on most package managers. [1]: http://linux.die.net/man/1/pssh

pssh is great.

You'll want -i to avoid the buffered output that would make the log output hard to read.

And if your command doesn't contain anything that you need to escape from the shell, you don't need to quote the command.

And finally, since it implements BSD-style short flags correctly, so you can do "-Pi" instead of "-P -i".

Handy with a pre-defined list of hosts, too:

    pssh -Pi -H "hosts.txt" tail -f /var/log/haproxy.log
or a specific set of hosts:

    pssh -Pi -H `cat hosts.txt | grep prod` tail -f /var/log/haproxy.log

Re: Show HN: Tail out log files from multiple remote hosts with one command

#16
post #12

I use pssh [1]. pssh -H h1 -H h2 -P "tail -n 1000 /var/log/x.log" It is very easy to install on every platform since is on most package managers. [1]: http://linux.die.net/man/1/pssh

pssh is great. You'll want -i to avoid the buffered output that would make the log output hard to read. And if your command doesn't contain anything that you need to escape from the shell, you don't need to quote the command. And finally, since it implements BSD-style short flags correctly, so you can do "-Pi" instead of "-P -i". Handy with a pre-defined list of hosts, too: pssh -Pi -H "hosts.txt" tail -f /var/log/ha…

Nice tips, thank you!

Re: Show HN: Tail out log files from multiple remote hosts with one command

#17
post #12

I use pssh [1]. pssh -H h1 -H h2 -P "tail -n 1000 /var/log/x.log" It is very easy to install on every platform since is on most package managers. [1]: http://linux.die.net/man/1/pssh

pssh is great. You'll want -i to avoid the buffered output that would make the log output hard to read. And if your command doesn't contain anything that you need to escape from the shell, you don't need to quote the command. And finally, since it implements BSD-style short flags correctly, so you can do "-Pi" instead of "-P -i". Handy with a pre-defined list of hosts, too: pssh -Pi -H "hosts.txt" tail -f /var/log/ha…

[deleted]

Re: Show HN: Tail out log files from multiple remote hosts with one command

#18
In my company, we have hundred machines and tailing done with ansible. If we want customize the log view, we can simply edit the playbook. I think it is very handy compared to we need additional npm package (and not to mention additional effort for customization).

Re: Show HN: Tail out log files from multiple remote hosts with one command

#19
post #14
post #11

Earlier quoted context omitted.

The interface to this tool is far nicer to work with. Can you replicate that interface with your command? Serious question - I actually would like to see how you'd do it.

You can have something like this in your .bashrc: multitail() { com="tail -f " for arg; do IFS=':' read -a array This will take the host:file syntax of remtail and turn it into Plugawy's example. I haven't tested it, but if you echo "$com" it'll spit out Plugawy's code.

nice solution! bash looping and arrays always seemed overly complex and confusing to me, but this is not nearly as complicated as I expected.

Re: Show HN: Tail out log files from multiple remote hosts with one command

#20
post #7

Earlier quoted context omitted.

or ssh config?

ssh config support is the first thing on the roadmap. I'd be happy to take a pull request for it.

Support would be good. I imagine a lot of people use their ssh config like I do; as a directory of servers that I have various scripts work with.
Post reply on HN