Nagios监控磁盘脚本解读
来自:网络
?
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
#!/bin/bash
#Filename:check_disk.sh if [ "$1" = "-w" ] && [ "$2" -gt "0" ] && [ "$3" = "-c" ] && [ "$4" -gt "0" ]; then
ROW=`df -h -P|wc -l`
STATUS=0
for i in `seq 2 $ROW` do
spare=`df -h -P|sed -n "$i"p|awk '{print $4}'` nagios培训 use_percentage=`df -h -P|sed -n "$i"p|sed -n "s/\%//"p|awk '{print $5}'`
spare_percentage=`expr 100 - $use_percentage`
partition_name=`df -h -P|sed -n "$i"p|awk '{print $6}'`
if [ "$spare_percentage" -lt "$4" ];then
echo -n "$partition_name CRITICAL ${spare_percentage}% $spare "
STATUS[$i]=2
elif [ "$spare_percentage" -lt "$2" ];then nagios实施 echo -n "$partition_name WARNING! ${spare_percentage}% $spare "
STATUS[$i]=1
else
echo -n "$partition_name OK ${spare_percentage}% $spare " 监控软件 STATUS[$i]=0
fi done
STATE=0 for j in `seq 2 $ROW` do
if [ "${STATUS[$j]}" -gt "$STATE" ];then
STATE=${STATUS[$j]}
fi done echo "" exit $STATE
else
echo "check_disk v1.1"
echo ""
echo "Usage:"
echo "check_disk.sh -w <warnlevel> -c <critlevel>"
echo ""
echo "warnlevel and critlevel is percentage value without %" nagios配置 echo ""
echo "Copyright (C) 2015 Nortorm (nortorm@yeah.net)"
exit
fi
开源监控软件nagios安装
想做Nagios, Zabbix,Cacti,iTop各种交流的,可以进入开源监控工具Nagios交流QQ群号 :476809427
页:
[1]