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
#}
####
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。