I developed the below script to log the status of my server throughout a given day. This can be used to investigate the moments leading up to a crash, or even investigate why load may have spiked at certain points during the day. Code below:
#!/bin/sh
day=$(date +%Y%m%d)
min=$(date +%H%M)
/bin/mkdir -p /var/log/system/$day
/usr/bin/top -b -n 1 > /var/log/system/$day/$min
/bin/netstat -an >> /var/log/system/$day/$min
/bin/ps aux >> /var/log/system/$day/$min
/usr/bin/free >> /var/log/system/$day/$min
exit 0
![Reblog this post [with Zemanta]](http://img.zemanta.com/reblog_e.png?x-id=c3c44533-e3a8-42b8-87fa-fed19eec2111)