--------------------------------Linux Guide---------------------------------- by Ingo Blechschmidt (c) 2002 ----------------------------------------------------------------------------- ------------------------- Watchdog für Server ------------------------- Don Jun 27 15:01:42 MEST 2002 ------------------------- Watchdog Server free df mail bzip2 uuencode logs tail w ----------------------------------------------------------------------------- Haben Sie einen kleinen Server, den Sie überwachen wollen? Dann ist vielleicht watchdog.sh was für Sie. ----------------------------------------------------------------------------- watchdog.sh schickt in regelmäßigen Abständen komprimiert Mails an den Administrator mit allen wichtigen Statusreports (Arbeitsspeicher, Load Average, Festplattenspeicher, eingeloggte User, ...). Das Skript wird bereits erfolgreich in der Infothek des Holbein Gymnsasiums Augsburgs eingesetzt. Die Mails sind mit bzip2 komprimiert und mit uuencode steuerzeichenlos. Um sie klar lesbar anzuschauen muss die Mail nur an uudecode | bzcat | less gefüttert werden. In der Crontab muss dann noch ein Eintrag in der Art wie --------CODE--------: crontab */5 * * * * /pfad/zur/watchdog.sh --------/CODE-------- stehen. Das Skript, siehe <"down/watchdog.sh">Download: --------CODE--------: watchdog.sh #!/bin/bash # watchdog.sh - A little watchdog for Linux/Unix # Copyright (C) Don Jun 27 15:10:30 MEST 2002 - now by Ingo Blechschmidt # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # # Ingo Blechschmidt # Arberstraße 5 # 86179 Augsburg # E-Mail: iblech@web.de, http://www.way.to/uselinux/ # Tel.: +49 / 821 882955 # # { time { echo "WATCHDOG REPORT for `date`:" echo echo echo echo "Users logged in:" echo /usr/bin/w echo echo echo "Interface settings:" echo /sbin/ifconfig echo echo echo /sbin/route -n echo echo echo "Active processes:" echo /bin/ps -xua echo echo echo "Connections:" echo /bin/netstat -a echo echo echo "Load average and uptime:" echo /bin/cat /proc/loadavg /proc/uptime echo echo echo "Free space:" echo /bin/df -h echo /bin/df echo echo echo "Free RAM:" echo /usr/bin/free echo echo "Logs:" { find /var/log -type f; find /var/squid/logs -type f; } 2>&1 | grep -v gz | xargs tail -n 20 echo echo echo "Ping to google and to 1-5:" echo /bin/ping -c1 www.google.de /bin/ping -c1 192.168.0.101 /bin/ping -c1 192.168.0.102 /bin/ping -c1 192.168.0.103 /bin/ping -c1 192.168.0.104 /bin/ping -c1 192.168.0.105 echo echo echo "Time elapsed:" } 2>&1; } 2>&1 | /usr/bin/bzip2 | { /usr/bin/uuencode --base64 -; echo; echo; } | mail -s IFWATCHDOG iblech-ml@gmx.de sleep 3 /usr/sbin/sendmail -v -q --------/CODE-------- ... aber wozu brauch man einen Wachhund bei Linux? ;-) ----------------------------------------------------------------------------- ----------------------------------------------------------------------------- This document is distributed under the terms of the GNU Free Documentation License.