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

May 8, 2011 - Posted by | Shell Script |

3 Comments »

  1. I had been really searching for anything on this subject and your writing perfectly suits my recent needs. Will you please write much more along these lines? Visitors must discover this knowledge as well as the type of unbiased judgment that you supply.

    Comment by clean water | June 15, 2011 | Reply

  2. Many thanks for bothering to line all this out for all of us. This kind of write-up was in fact quite useful in my opinion.

    Comment by Inell Lubin | June 15, 2011 | Reply

  3. Nice one for revealing this information. I find it very valuable and will forward it to close friends, too. If you carry on posting about this subject I will definitely carry on checking your upcoming blog posts.

    Comment by blog about water | June 16, 2011 | Reply


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: