您好,登錄后才能下訂單哦!
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進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。