little scripts
This commit is contained in:
parent
5cb3932f01
commit
04c26a9df4
4 changed files with 58 additions and 0 deletions
44
programs/rdl_ssh_touch
Normal file
44
programs/rdl_ssh_touch
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
#!/bin/bash
|
||||
# rdl_ssh_touch -- try and fix connection
|
||||
|
||||
login=$1
|
||||
file=$2
|
||||
|
||||
RDL_PROM_LINES+="
|
||||
job rdl_ssh_touch
|
||||
login $login
|
||||
file $file
|
||||
"
|
||||
|
||||
try_connection() {
|
||||
timeout 20 ssh "$login" touch "$file"
|
||||
}
|
||||
|
||||
should_reset() {
|
||||
last_run=$(< /var/rdl_ssh_touch/"$login")
|
||||
|
||||
if ! test "$last_run" ; then
|
||||
echo Can\'t get a last timestamp in echo /var/rdl_ssh_touch/"$login"
|
||||
mkdir -v /var/rdl_ssh_touch
|
||||
return 0
|
||||
else
|
||||
# (time now) - (last time) > 6 hours?
|
||||
if test $(( $(date +%s) - "$last_run" )) -gt $(( 60 * 60 * 6 )); then
|
||||
return 0
|
||||
else
|
||||
echo Already resetted at $(date -d @"$last_run" +"%F %T")
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
if ! rdl_prometheus try_connection; then
|
||||
echo Can\'t ssh "$login" touch "$file".
|
||||
if should_reset; then
|
||||
echo Resetting...
|
||||
date +%s > /var/rdl_ssh_touch/"$login" \
|
||||
&& rdl_prometheus rdl_restart_network \
|
||||
&& echo Ok
|
||||
fi
|
||||
fi
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue