1 contributor
# vim: ft=sh
function nginx () {
nc -zw2 127.0.0.1 80 || echo "injoignable sur port 80 local"
nc -zw2 sebmarque.hd.free.fr 80 || echo "injoignable sur port 80 distant"
nc -zw2 sebmarque.hd.free.fr 443 || echo "injoignable sur port 443 distant"
}
function searx () {
nc -zw2 127.0.0.1 8888 || echo "injoignable sur port 8888"
}
function gitprep () {
nc -zw2 127.0.0.1 10020 || echo "injoignable sur port 10020"
}
function cherrymusic () {
nc -zw2 127.0.0.1 8080 || echo "injoignable sur port 8080"
}
function core_temp () {
local min=60
local level=("warning" "severe" "danger!")
local step=$(( $(</sys/class/thermal/thermal_zone0/temp) - (min * 1000) ))
if test $step -gt 0; then
step=$((step / 10000))
test $step -le 3 || step=2
echo "${level[step]}: température > $((min + step * 10))°"
fi
}
function core_alim () {
eval $(/opt/vc/bin/vcgencmd measure_volts core)
test $volt == "1.2000V" || echo "$volt"
}
function load_avg () {
local procs=4
local load=($(</proc/loadavg))
local avg=(1 5 15)
for ((i=0; i<${#avg[@]}; i++)); do
test ${load[i]%.*} -ge $procs && echo "charge moyenne à ${avg[i]}min = ${load[i]}"
done
}
function mem_pressure () {
local meminfo=($(</proc/meminfo))
local level=(danger severe warning)
local margin=30000
for ((i=0; i<${#meminfo[@]}; i+=3)); do
test ${meminfo[i]} == 'MemAvailable:' && break
done
meminfo[i+2]=$(( ( ${meminfo[i+1]} - $margin ) / 100000 ))
test ${meminfo[i+2]} -ge ${#range[@]} || echo "${level[${meminfo[i+2]}]}: available ${meminfo[i+1]}kB"
}
function mpd_tablette () {
local tablette=192.168.0.53
local port=6600
local nfs=$(ss -no state established 'sport = :nfs' dst $tablette | grep -c $)
test $nfs -lt 3 && echo "tablette non connectée à la zique"
nc -zw2 $tablette $port || echo "MPD injoignable"
}