SHELL一些监控的脚本(模块)
1,apache的源码安装脚本
武进网站建设公司创新互联,武进网站设计制作,有大型网站制作公司丰富经验。已为武进数千家提供企业网站建设服务。企业网站搭建\成都外贸网站建设公司要多少钱,请找那个售后服务好的武进做网站的公司定做!
#!/bin/bash
##auther xiaosonglin
##date 2013-06-08
###apache install
PATH=`echo $PATH`
rpm -qa |grep httpd
if [ $? -eq 0 ];then
echo "apache alredy install" >apac.log
rpm -e httpd
else
echo "apache not install" >>apac.log
wget http://192.168.18.254/abc/httpd-2.2.16.tar.bz2 局域网类的地址
if [ $? -ne 0 ];then
echo "wget ERROR" >>apac.log
else
tar fjvx httpd-2.2.16.tar.bz2
cd httpd-2.2.16
./configure
make && make install
fi
fi
#######
一个httpd启动脚本,放到/etc/init.d/下,可以使用service apache2 start|restart|status|stop
中apache可自定义
#!/bin/bash
##apache replace httpd
##auther xsl
##date
start () {
/usr/sbin/httpd
}
stop () {
kill -s QUIT httpd
}
status () {
elinks http://192.168.18.213 -dump >/dev/null 本机
if [ $? -eq 0 ];then
echo "apache is running"
else
echo "apache is down"
fi
}
restart () {
kill -s QUIT httpd
sleep 3
/usr/sbin/httpd
}
## main
case $1 in
start)
start;;
stop)
stop;;
status)
status;;
restart)
restart;;
*)
echo "Usage: ./case start|stop|restart|status "
esac
######
2,监控磁盘
#DISK
#disk () {
#show disk
IP=` ifconfig eth0|awk 'NR==2'|awk '{print $2}'|awk -F: '{print $2}'`
DISK_LIST=`fdisk -l |grep Disk |awk -F , '{print $1}'> disk_list`
DISK_COUNT1=`cat disk_list|wc -l`
let DISK_COUNT2=" $DISK_COUNT1 + 1 "
for (( i=1;i<$DISK_COUNT2;i++ ))
do
DISK_NAME=`awk NR==$i disk_list|awk '{print $2}'|tr -d ":" `
echo "`awk NR==$i disk_list`"
df -Th|grep $DISK_NAME
# echo -e "\n"
##disk_use_mom
df -Th|grep $DISK_NAME|awk '{print $6}'|tr -d "%" > disk_use
for i in `cat disk_use`
do
if [ $i -gt 90 ]
then
echo "$IP disk full,please check"
fi
done
done
#}
#######
3,监控内存
#!/bin/bash
IP=` ifconfig eth0|awk 'NR==2'|awk '{print $2}'|awk -F: '{print $2}'`
#Mem_mom
#mem () {
MEM_TOTAL=`free |awk 'NR==2'|awk '{print $2}'`
MEM_USE=`free |awk 'NR==2'|awk '{print $3}'`
MEM_FREE=`free |awk 'NR==2'|awk '{print $4}'`
let USE=" $MEM_USE * 100/ $MEM_TOTAL"
echo -e "\t\t\t $IP"
echo
echo mem_total = $MEM_TOTAL
echo mem_use = "$MEM_USE use "$USE"%"
echo mem_free = $MEM_FREE
#}
####
网站标题:SHELL一些监控的脚本(模块)
网页路径:http://azwzsj.com/article/jesodh.html