3 ms·
Here's how I do it: xargs -I'hostname' -a hosts.txt -P128 bash -c "ssh 'hostname' find / -type f -mmin -20 | xargs -P128 -Ifilename grep -cHia error filename
by chaps 4y ago
Here's how I do it:
xargs -I'hostname' -a hosts.txt -P128 bash -c "ssh 'hostname' find / -type f -mmin -20 | xargs -P128 -Ifilename grep -cHia error filename 2>/dev/null | sed 's/^/hostname:/' ; :" | sort -nrk3 -t':'
- The_Amp_Walrus 4y agonice one liner is that any file modified in the last 20 minutes on any machine in hosts.txt containing the word error?
- chaps 4y agoIt is, just... don't run it in prod :)
- aaronbwebber 4y agoThis is probably the best advertisement for loki I've ever seen.
- deleted 4y ago[deleted]
- flukus 4y agoPersonally I like to rsync the logs locally so I can have the context of the errors and also historical data, the later can be useful for blame avoidance. I also prefer awk's pattern matching for the filtering, counting, etc. Especially on legacy code where some errors aren't really errors, or errors that aren't for me, etc. The hardest/funnest bug I ever fixed was from grepping several years worth of log files and noticing that an error occasionally happened within 5 seconds of each other. From that realization I just had to search the code base for "sleep(5000)" to find the problem. If you have a lot of environments, servers or apps I highly recommend recutils over a hosts file too.