File tree 1 file changed +13
-5
lines changed
1 file changed +13
-5
lines changed Original file line number Diff line number Diff line change 1
- #! /bin/bash
1
+ #! /usr/ bin/env bash
2
2
# check_load.sh - Shell script that checks load, intended
3
3
# for nagios style monitoring systems
4
4
#
@@ -23,11 +23,19 @@ FiveMinLoadCrit=${4:-$DefaultCrit}
23
23
FiveteenMinLoadWarn=${5:- $DefaultWarn }
24
24
FiveteenMinLoadCrit=${6:- $DefaultCrit }
25
25
26
- OneMinLoad=$( cat /proc/loadavg | sed -r ' s/\ +/\ /g' | cut -d \ -f 1)
27
- FiveMinLoad=$( cat /proc/loadavg | sed -r ' s/\ +/\ /g' | cut -d \ -f 2)
28
- FiveteenMinLoad=$( cat /proc/loadavg | sed -r ' s/\ +/\ /g' | cut -d \ -f 3)
26
+ OS=$( uname -s)
29
27
30
- numberOfCores=$( grep -c processor /proc/cpuinfo)
28
+ if [ " ${OS} " = " Linux" ]; then
29
+ OneMinLoad=$( cat /proc/loadavg | sed -r ' s/\ +/\ /g' | cut -d \ -f 1)
30
+ FiveMinLoad=$( cat /proc/loadavg | sed -r ' s/\ +/\ /g' | cut -d \ -f 2)
31
+ FiveteenMinLoad=$( cat /proc/loadavg | sed -r ' s/\ +/\ /g' | cut -d \ -f 3)
32
+ numberOfCores=$( grep -c processor /proc/cpuinfo)
33
+ elif [ " ${OS} " = " FreeBSD" ]; then
34
+ OneMinLoad=$( sysctl -n vm.loadavg | cut -d" " -f 2)
35
+ FiveMinLoad=$( sysctl -n vm.loadavg | cut -d" " -f 3)
36
+ FiveteenMinLoad=$( sysctl -n vm.loadavg | cut -d" " -f 4)
37
+ numberOfCores=$( sysctl -n hw.ncpu)
38
+ fi
31
39
32
40
OneMinLoadpct=$( bc <<< " 100*$OneMinLoad/$numberOfCores" )
33
41
FiveMinLoadpct=$( bc <<< " 100*$FiveMinLoad/$numberOfCores" )
You can’t perform that action at this time.
0 commit comments