1 contributor
# vim: ft=sh
function nginx () {
nc -zw2 127.0.0.1 80 || echo "injoignable sur port 80 local"
nc -zw2 paris12.pcf.fr 80 || echo "injoignable sur port 80 distant"
nc -zw2 paris12.pcf.fr 443 || echo "injoignable sur port 443 distant"
}
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 1; then
# if test $step -gt 5000; then # en été il fait plus chaud, c'est normal que ça monte à 60° régulièrement
step=$((step / 10000))
test $step -le 2 || step=2
echo "${level[step]}: température > $((min + step * 10))°"
fi
}
function core_alim () {
eval $(/opt/vc/bin/vcgencmd measure_volts core)
volt_fmt=${volt/\.}
volt_fmt=${volt_fmt/V}
test $volt_fmt -lt 12000 -o $volt_fmt -gt 15000 && echo "$volt"
}
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"
}