Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 29 lines (27 sloc) 1.11 KB
#!/bin/bash
function addCommand {
echo "$1" >> /tmp/report
$1 >> /tmp/report
}
PTS_COUNT=$(ls -1 /dev/pts/| wc -l)
PTS_SCREEN=$(find /var/run/screen/ -type p | wc -l)
PTS_W=$(w -h | grep -v ttyS0 | wc -l)
if [ $PTS_COUNT -ne $(( $PTS_SCREEN + $PTS_W )) ]; then
echo "PTS_COUNT=$PTS_COUNT" > /tmp/report
echo "PTS_SCREEN=$PTS_SCREEN" >> /tmp/report
echo "PTS_W=$PTS_W" >> /tmp/report
addCommand "ls -l /dev/pts"
addCommand "find /var/run/screen/ -type p"
addCommand "w"
addCommand "ps auxw"
addCommand "netstat -tnp"
addCommand "cat /proc/loadavg"
addCommand "free -m"
for i in /var/log/syslog /var/log/messages /var/log/auth.log /var/log/lastlog /var/log/wtmp; do
gzip -c $i > /tmp/$(basename $i).gz
done
# root@localhost is configured to send to the right email
cat /tmp/report | mutt -s "[ERROR] Count of pts is not the same as in utmp + screen" root@localhost -a /tmp/syslog.gz /tmp/messages.gz /tmp/auth.log.gz /tmp/lastlog.gz /tmp/wtmp.gz
# Clean up
rm -f /tmp/syslog.gz /tmp/messages.gz /tmp/auth.log.gz /tmp/lastlog.gz /tmp/wtmp.gz /tmp/report
fi