#!/bin/sh # # system check script # PATH=/usr/sbin:/usr/bin:/bin ; export PATH LANG=ja_jp.UTF-8 ; export LANG SPOOL=/var/spool/mail/ MAILCMD=/usr/bin/mail NKFCMD=/usr/bin/nkf HOMEDIR=/home MAILMASTER=postmaster HOSTNAME=`hostname` ( echo "HOSTNAME: $HOSTNAME" echo "This machine is running in ..." uptime echo "" echo "--- Error report from syslog ---" grep -i error /var/log/syslog echo "--- Error report end ---" echo "" echo "--- Error report from message log ---" grep -i error /var/log/messages echo "--- Error report end ---" echo "" echo "--- Files modified in one day in /etc ---" find /etc -ctime -1 -print echo "--- Files modified end ---" echo "" echo "--- Disk usage ---" df -h echo "--- Disk usage end ---" echo "" #echo "--- Home directory eater ---" #du -s -b -h $HOMEDIR/* | sort -rn | head -5 #echo "--- Home directory eater end ---" #echo "" #echo "--- Mail spool directory size ---" #du -s -b -h $SPOOL #echo "--- Mail spool directory size end ---" #echo "" #echo "--- Mail spool eater ---" #ls -l $SPOOL | sort -rn | head -5 #echo "--- Mail spool eater end ---" echo "--- ssh accepted user list ---" grep -E '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' /var/log/auth.log | grep -E 'Accepted' | cut -d ' ' -f 10|sort |uniq echo "--- ssh accepted user list end ---" echo "" echo "--- ssh attempted IP address list ---" grep -E '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' /var/log/auth.log | cut -d ' ' -f 11 | grep -E '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | sort | uniq echo "--- ssh attempted IP address list end ---" echo "" echo "--- auth.log failure list ---" grep fail /var/log/auth.log echo "--- auth.log failure list end ---" echo "" echo "--- process status list ---" echo "inetd:` systemctl status inetd | grep Active|awk '{print $2$3}'`" echo "apache2:` systemctl status apache2 | grep Active|awk '{print $2$3}'`" echo "postfix:` systemctl status postfix | grep Active|awk '{print $2$3}'`" echo "bind9:` systemctl status bind9 | grep Active|awk '{print $2$3}'`" echo "ssh:` systemctl status ssh | grep Active|awk '{print $2$3}'`" echo "motion:` systemctl status motion | grep Active|awk '{print $2$3}'`" echo "systemd-journald:` systemctl status systemd-journald | grep Active|awk '{print $2$3}'`" echo "rsyslog:` systemctl status rsyslog | grep Active|awk '{print $2$3}'`" echo "--- process status list end ---" echo "") | $NKFCMD -j | $MAILCMD -s "Daily status of $HOSTNAME" $MAILMASTER