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
|
#!/bin/bash
mo=`
date
|
cut
-c 5-10`
d=`
date
+%d`
yd=`
date
-d yesterday +%d`
echo
"max mem"
>
/script/dalirepo
sar -r -f
/var/log/sa/sa
$yd |
cut
-c 36-43 |
sort
-n |
tail
-n 1 >>
/script/dalirepo
echo
"current mem"
>>
/script/dalirepo
sar -r -f
/var/log/sa/sa
$d |
cut
-c 36-43 |
tail
-n 2 |
head
-n 1 >>
/script/dalirepo
echo
"max cpu"
>>
/script/dalirepo
sar -f
/var/log/sa/sa
$yd |
cut
-c 26-31 |
sort
-n |
tail
-n 1 >>
/script/dalirepo
echo
"current cpu"
>>
/script/dalirepo
sar -f
/var/log/sa/sa
$d |
cut
-c 26-31 |
tail
-n 2 |
head
-n 1 >>
/script/dalirepo
echo
"max load"
>>
/script/dalirepo
sar -q -f
/var/log/sa/sa
$yd |
cut
-c 36-44 |
sort
-n |
tail
-n 1 >>
/script/dalirepo
echo
"current load "
>>
/script/dalirepo
sar -q -f
/var/log/sa/sa
$d |
cut
-c 36-44 |
tail
-n 2 |
head
-n 1 >>
/script/dalirepo
df
-h >>
/script/dalirepo
ps
-ef |
grep
rsync
>>
/script/dalirepo
echo
"messages log"
>>
/script/dalirepo
cat
/var/log/messages
|
grep
"$mo"
|
grep
"error\|warning\|failure\|restart\|stop\|reboot"
>>
/script/dalirepo
echo
"secure log"
>>
/script/dalirepo
cat
/var/log/secure
|
grep
"$mo"
|
grep
"error\|warning\|failure\|restart\|stop\|reboot"
>>
/script/dalirepo
echo
"cron log"
>>
/script/dalirepo
cat
/var/log/cron
|
grep
"$mo"
|
grep
"error\|warning\|failure\|restart\|stop\|reboot"
>>
/script/dalirepo
echo
"services log"
>>
/script/dalirepo
cat
{
/var/log/httpd/error_log
,
/var/log/httpd/ssl_error_log
,
/var/log/mysqld
.log,
/var/log/vsftpd
.log,
/var/log/yum
.log} |
grep
"$mo"
|
grep
"error\|warning\|failure\|restart\|stop
\|reboot" >>
/script/dalirepo
mail -s subjectname name1@mail.com,name2@mail.com <
/script/dalirepo
|
把收集到的系统性能信息 写到/script/dalirepo 文件里,文件以文件的形式发送到各个需要接受的邮箱
本文转自wks9751CTO博客,原文链接:http://blog.51cto.com/wks97/1623849 ,如需转载请自行联系原作者