Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
HOWTO: Keep an eye on the server
08-16-2014, 05:52 AM,
#1
HOWTO: Keep an eye on the server
To keep an eye on what changes on my server I have the following script:
It is placed in /root/check (directory was created)
Code:
#!/bin/sh
cd /root/check
touch previous

find /var/www -wholename '*statistics*' -prune -o -type f -exec ls -l --time-style=+%Y%m%d_%H%M%S "{}" \; | \
grep -v _httpd.include | \
grep -v /var/www/webalizer > current
find /etc/. -type f -exec ls -l --time-style=+%Y%m%d_%H%M%S "{}" \; >> current
find /var/spool/. -type f -exec ls -l --time-style=+%Y%m%d_%H%M%S "{}" \; >> current
chmod 400 current
cmp previous current
if [ $? = 0 ]
then
  echo Same
else
  (
   echo Subject: Differences on server `hostname`
   echo ""
   echo "Verschillen gevonden"
   diff previous current
  ) | /usr/lib/sendmail -v webmaster@digdascloud.nl
fi
mv current previous
Mind the email address in this script if you are panning to use it!

This script is executed in cron every hour. If something has changed I will receive an email stating the differences.
Once a day some updates are known to be done. The mail stating this, is a message for me the script is running. And when there are changes not planned I am notified.

The grep's in the script allows me to skip specific files/directories.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)