scripts / supervision.d / raspberrypi /
Newer Older
63 lines | 1.928kb
ajout de la supervision
Sébastien MARQUE authored on 2017-02-22
1
# vim: ft=sh
2

            
3
function nginx () {
4
    nc -zw2 127.0.0.1 80 || echo "injoignable sur port 80 local"
5
    nc -zw2 sebmarque.hd.free.fr 80 || echo "injoignable sur port 80 distant"
6
    nc -zw2 sebmarque.hd.free.fr 443 || echo "injoignable sur port 443 distant"
7
}
8

            
9
function searx () {
10
    nc -zw2 127.0.0.1 8888 || echo "injoignable sur port 8888"
11
}
12

            
13
function gitprep () {
14
    nc -zw2 127.0.0.1 10020 || echo "injoignable sur port 10020"
15
}
16

            
17
function cherrymusic () {
18
    nc -zw2 127.0.0.1 8080 || echo "injoignable sur port 8080"
19
}
20

            
21
function core_temp () {
22
    local min=60
23
    local level=("warning" "severe" "danger!")
24
    local step=$(( $(</sys/class/thermal/thermal_zone0/temp) - (min * 1000) ))
25
    if test $step -gt 0; then
26
        step=$((step / 10000))
27
        test $step -le 3 || step=2
28
        echo "${level[step]}: température > $((min + step * 10))°"
29
    fi
30
}
31

            
32
function core_alim () {
33
    eval $(/opt/vc/bin/vcgencmd measure_volts core)
34
    test $volt == "1.2000V" || echo "$volt"
35
}
36

            
37
function load_avg () {
38
    local procs=4
39
    local load=($(</proc/loadavg))
40
    local avg=(1 5 15)
41
    for ((i=0; i<${#avg[@]}; i++)); do
42
        test ${load[i]%.*} -ge $procs && echo "charge moyenne à ${avg[i]}min = ${load[i]}"
43
    done
44
}
45

            
46
function mem_pressure () {
47
    local meminfo=($(</proc/meminfo))
48
    local level=(danger severe warning)
49
    local margin=30000
50
    for ((i=0; i<${#meminfo[@]}; i+=3)); do
51
        test ${meminfo[i]} == 'MemAvailable:' && break
52
    done
53
    meminfo[i+2]=$(( ( ${meminfo[i+1]} - $margin ) / 100000 ))
54
    test ${meminfo[i+2]} -ge ${#range[@]} || echo "${level[${meminfo[i+2]}]}: available ${meminfo[i+1]}kB"
55
}
56

            
57
function mpd_tablette () {
58
    local tablette=192.168.0.53
59
    local port=6600
60
    local nfs=$(ss -no state established 'sport = :nfs' dst $tablette | grep -c $)
61
    test $nfs -lt 3 && echo "tablette non connectée à la zique"
62
    nc -zw2 $tablette $port || echo "MPD injoignable"
63
}