System watcher


Every system administrator must look after his system. This script make self-diagnostics, then mail result to you. Don't forget that you can re-look about these things "by hand" too, at least one time in mounth...

#!/bin/sh

RCPT="nmmm@nmmm.nu"

cat > /tmp/stat.txt << [DONE]

<HTML><BODY>

<H1>SERVER STATISTICS</H1>
<Hr>
<H1>Misc Information</H1>
<Table Border = 1>

<TR><TD>Hostname</TD><TD>`cat /etc/HOSTNAME`</TD></TR>

<TR><TD>OS / Kernel</TD><TD>`cat /proc/version`</TD></TR>

<TR><TD>Up time</TD><TD>`uptime`</TD></TR>
</Table>

<HR>
<H1>Modules</H1>
<PRE>`lsmod`</PRE>

<HR>
<H1>Memory info:</H1>
     
<PRE>`cat /proc/meminfo`</PRE>

<HR>
<H1>Disk usage and mounts:</H1>

<PRE>`df -m`</PRE>

<HR>
<H1>Mail q:</H1>
<PRE>`mailq`</PRE>

<HR>
<H1>Last 25 logins:</H1>
<PRE>`last -25`</PRE>

<HR>
<H1>Last 25 lines from system log:</H1>
<PRE>`tail -n 25 /var/log/syslog`</PRE>

<HR>
<H1>Last 25 lines from message log:</H1>
<PRE>`tail -n 25 /var/log/messages`</PRE>


<Hr>
<H1>Services</H1>
<Table Border = 1>
`
lookup(){
        printf "<TR><TD>$1</TD><TD>"

        if ( ps -axe | grep $1 > /dev/null ) ;  then 
                printf "OK" ; 
        else 
                printf "FAIL" ; 
        fi

        printf "</TD>\n"
}

lookup httpd
lookup named
lookup inetd
lookup sendmail
`

</Table>

[DONE]

uuencode stat.html < /tmp/stat.txt | \
	mail $RCPT -s "server statistics"

rm /tmp/stat.txt

Do you see another idea here??? You can write HTML with embedded SHell script:)))))

#!/bin/sh

printf "content-type: text/html\n\n"

cat << [END]

<HTML>
<BODY>
<H1>The passwd file:</H1>
<Hr>
<PRE>`cat /etc/passwd`</PRE>
</BODY>
</HTML>

[END]

Copyleft 16.Sep.1999,
Nikolay Mijaylov
nmmm@nmmm.nu
http://www.nmmm.nu/