Skip to content

Instantly share code, notes, and snippets.

@flores
Created May 20, 2011 07:35
Show Gist options
  • Save flores/982506 to your computer and use it in GitHub Desktop.
Save flores/982506 to your computer and use it in GitHub Desktop.
for sporadic wtfs.
#!/usr/bin/env bash
#
# because sometimes a server sporadically acts funny and we're all like wtf.
# date and -+ separated list of general os, system, and network stuff.
echo -e "#!/usr/bin/env bash\n(date; top -n1; ps axfu; iostat; vmstat; df -h; lsof -n -i; netstat -ano; w; echo -e '\n-----------------\n\n') >> /var/log/wtf.log" > /root/wtf.sh
chmod +x /root/wtf.sh
# put it in the crontab.
echo '* * * * * /root/wtf.sh' >> /var/spool/cron/crontabs/root
crontab /var/spool/cron/crontabs/root
# log rotate it in case we forget about it (and run into disk issues)
echo -e "/var/log/wtf.log {\nrotate 5\ndaily\ncompress\nmissingok\nnotifempty\n}" >> /etc/logrotate.d/wtf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment