UnixServerAdmin

Server Administration & Management

daily_report.sh

#############################################################
## daily_report.sh ##
#############################################################
## Script for Daily Report of Server ##
#############################################################
## Make a Directory /REPORTS ##
## Make a file msg.txt under /REPORTS Directory ##
## Write Folowing in msg.txt file ##
#############################################################
## Hi, ##
## The Daily Server Report is attached with this mail. ##
## Thanks & Regards, ##
## Unixserveradmin.com Security Team ##
#############################################################
#! /bin/bash

/bin/mkdir /REPORTS 2> /dev/null

/bin/echo ”                                  DAILY SERVER REPORT FOR $(/bin/hostname | tr ‘a-z’ ‘A-Z’)” > /REPORTS/Daily_Report_$(date +%d%m%y)

/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                             ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                     DATE : $(date)” >> /REPORTS/Daily_Report_$(date +%d%m%y)

/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo “#######################################” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)

/bin/echo “INFRASTRUCTURE UP-TIME REPORT” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/usr/bin/uptime >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo “MAIN DOMAINS = $(/bin/cat /etc/domainusers | wc -l)” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo “TOTAL DOMAINS = $(/bin/ls /var/named/ | wc -l)” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo “SERVER INFORMATION” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo “Hardware Summary” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo “PROCESSOR [CPU]” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo “PROCESSOR I     Intel Xeon-Westmere 5620-Quadcore [2.4GHz]” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo “PROCESSOR II    Intel Xeon-Westmere 5620-Quadcore [2.4GHz]” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo “PHYSICAL MEMORY [RAM]” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo “RAM slot 1           OEM DDR3 2GB DDR3 [2GB]” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo “RAM slot 2           OEM DDR3 2GB DDR3 [2GB]” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo “RAM slot 3           OEM DDR3 2GB DDR3 [2GB]” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo “RAM slot 4           OEM DDR3 2GB DDR3 [2GB]” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo “RAM slot 5           OEM DDR3 2GB DDR3 [2GB]” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo “RAM slot 6           OEM DDR3 2GB DDR3 [2GB]” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo “HARD DISK DRIVE [HDD]” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo “Hard Drive 1            Western Digital WD RE4 WD2003FYYS      SIZE = 1TB     RAID” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo “Hard Drive 2            Western Digital WD RE4 WD2003FYYS      SIZE = 1TB     RAID” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo “Hard Drive 3            Western Digital WD RE4 WD2003FYYS      SIZE = 1TB [Backup]” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo “PARTITION & DISK SPACE UTILIZATION REPORT” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/df -hT >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo “MEMORY USAGE” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/usr/bin/vmstat -st | tr ‘a-z’ ‘A-Z’ | head  >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo “CPU STATISTICS & I/O STATISTICS FOR DEVICES, PARTITIONS AND NETWORK FILESYSTEMS (NFS)” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/usr/bin/iostat >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo “NETWORK & TRAFFIC INFORMATION” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo “Network Interface :  eth1 (Public)     Uplink speed:         1000 (Mbps)” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo “Server address:   X.X.X.X” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo “Gateway:          X.X.X.X” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo “Netmask:          X.X.X.X” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo “Secondary addresses:   X.X.X.X  to X.X.X.X” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                       X.X.X.X  to X.X.X.X” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo “Network Interface : eth0 (Private)     Uplink speed:         1000 (Mbps)” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo “Server address:    X.X.X.X” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo “Gateway:           X.X.X.X” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo “Netmask:           X.X.X.X” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/etc/init.d/httpd status | grep ‘Total Traffic’ >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo “SOFTWARE INFORMATION” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo “Operating System” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/cat /proc/version >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo “PHP & MYSQL” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/usr/local/bin/php -v   >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
mysql -V  >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo “USER ACCESS REPORT [CURRENT MONTH] ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/usr/bin/last | grep $(date | cut -c 5-7)| sed s/X.X.X.X/UnixserV/gi >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo “SERVER REBOOTS” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/usr/bin/last | grep boot >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo “SHELL ACCESS USER LIST” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/cat /etc/passwd | grep ‘/bin/bash’ | cut -d: -f1 | tr ‘a-z’ ‘A-Z’ >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo “SECURITY ANALYSIS” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
#/usr/bin/nmap -v $(ifconfig eth1 | grep ‘inet addr’ | cut -c 21-34) >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo “BACKUP INFORMATION” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/ls -l /disk2/ | cut -c 30-52 | tail -n3 | tr ‘a-z’ ‘A-Z’  >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo “DOMAINS INFORMATION” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/cat /etc/httpd/conf/httpd.conf | grep -A1 ‘<VirtualHost’ >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo “This report is generated by the Unixserveradmin.com Security Team” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
#/bin/mv /REPORTS/Daily_Report_$(date +%d%m%y) /REPORTS/Daily_Report_$(date +%d%m%y).txt

mutt -s “SERVER REPORT $(hostname | tr ‘a-z’ ‘A-Z’)” -a /REPORTS/Daily_Report_$(date +%d%m%y) unixserv@unixserveradmin.com < /REPORTS/msg.txt

mutt -s “SERVER REPORT $(hostname | tr ‘a-z’ ‘A-Z’)” -a /REPORTS/Daily_Report_$(date +%d%m%y) info@unixserveradmin.com < /REPORTS/msg.txt

Advertisements

May 8, 2011 Posted by | Shell Script | | 3 Comments