-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.sh
executable file
·94 lines (78 loc) · 2.45 KB
/
main.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/bin/bash
#
# This shell script ATM is writen by wangxuan.
# ATM0.1 first released at 2015/7/21.
# The aim is to analyses the web log /var/log/httpd/access_log.
# The results will mail to root.
#
#Analyses items:
# 1.Page View
#
# I will add more functions later.
#
##################################################################
# INSTALL
#
# 1.creat work directory
# mkdir /usr/local/logfile
# tar -zxvf ATM-0.1.tgz -C /usr/local/logfile
# chmod 755 /usr/local/logfile/ATM0.1.sh
# chown root:root /usr/local/logfile/ATM0.1.sh
#
# 2.replace some parameters
# email=...
#
# 3.rewrite the crontab
# vi /etc/crontab
# 0 0 * * * root /usr/local/logfile/ATM0.1.sh > /dev/null 2>&1
#
#=====================================================================
# History Records
# Date and writer Item
#---------------------------------------------------------------------
# 2015/7/21 wangxuan PV summary
#
#
#---------------------------------------------------------------------
#######################################################################
# Parameters
#email="wangxuan9237@163.com"
email="wangxuan"
basedir="/usr/local/logfile/"
# Check the Environment
which awk > /dev/null 2>&1
if [ "$?" != "0" ];then
echo -e "No awk in your environment"|
mail -s "WARNING" $email
exit
fi
which sed > /dev/null 2>&1
if [ "$?" != "0" ];then
echo -e "No sed in your environment"|
mail -s "WARNING" $email
exit
fi
service sendmail status > /dev/null 2>&1
if [ "$?" != "0" ];then
echo -e "No start sendmail in your environment"|
mail -s "WARNING" $email
exit
fi
########################################################################
#
# version and logmail
versions="0.1"
logfile="$basedir/logfile.mail"
#######################################################################
echo "##########################################">$logfile
echo "Welcome use the ATM script" >>$logfile
echo "Version:$versions" >>$logfile
echo "If you have any question,contack me!" >>$logfile
echo "My blog:http://www.zifeiyu.pw" >>$logfile
echo "#########################################">>$logfile
echo " " >>$logfile
echo " " >>$logfile
sh /usr/local/logfile/sys.sh >>$logfile
sh /usr/local/logfile/pv.sh >>$logfile
# send mail to root.
mail -s "Results of ATM$versions" $email < $logfile