OSCam Client-Verbindung überwachen (Satreceiver): Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
| Zeile 12: | Zeile 12: | ||
# ------------------------------- | # ------------------------------- | ||
filename="check_oscam_client" | filename="check_oscam_client" | ||
client="GigaBlue UHD QUAD 4K (receiver-seestadt)" | |||
# Debug | # Debug | ||
| Zeile 57: | Zeile 59: | ||
else | else | ||
{ | { | ||
s='<P id="chead">Clients <span id="ucs">'${strClientcount}'</span>/<span id="uca">1</span></P><DIV>'; | |||
if [ $debug -eq 1 ] ; then echo -e "Suchstring="$ | #echo "s="$s""; | ||
g=$(grep "$s" "$temp"/status.html) | |||
if [ $debug -eq 1 ] ; then echo -e "Suchstring="$g""; fi | |||
if [ $? -eq 0 ] | |||
then | then | ||
#Grep erfolgreich - aber noch nicht klar ob string gefunden | #Grep erfolgreich - aber noch nicht klar ob string gefunden | ||
if [ ! "$ | if [ ! "$g" == "" ] | ||
then | then | ||
if [ $debug -eq 1 ] ;then echo -e "Sieht gut aus - String wurde gefunden." ; fi | if [ $debug -eq 1 ] ;then echo -e "Sieht gut aus - String $s wurde gefunden." ; fi | ||
else | else | ||
if [ $debug -eq 1 ] ;then echo -e "Sieht schlecht aus - String nicht gefunden." ; fi | if [ $debug -eq 1 ] ;then echo -e "Sieht schlecht aus - String $s nicht gefunden." ; fi | ||
echo -e "OSCAM client of $client restarted at `date +"'%d.%m.%Y %H:%M'"`" | /usr/bin/mailx -A kirner.or.at -s "OSCAM client of $client restarted restarted" admin@kirner.or.at | |||
fi | fi | ||
else | else | ||
if [ $debug -eq 1 ] ;then echo -e "Sieht schlecht aus - String nicht gefunden." ; fi | if [ $debug -eq 1 ] ;then echo -e "Sieht schlecht aus - String $s nicht gefunden." ; fi | ||
fi | fi | ||
} | } | ||
fi | |||
} | } | ||
else | else | ||
| Zeile 79: | Zeile 86: | ||
echo "CRITICAL: Could not download status.html (StatusCheck)" | echo "CRITICAL: Could not download status.html (StatusCheck)" | ||
# Logging | # Logging | ||
if [ "$logsyslog" == "1" ] ; then logger "$filename | if [ "$logsyslog" == "1" ] ; then logger "$filename $version - CRITICAL: Could not download status.html (StatusCheck)"; fi | ||
exit 2; | exit 2; | ||
} | } | ||
Version vom 5. Dezember 2023, 15:47 Uhr
Noch in Bearbeitung
#!/bin/bash
#
# -------------------------------
# Requires: curl (opkg install curl)
# -------------------------------
# Changelog:
#
# -------------------------------
filename="check_oscam_client"
client="GigaBlue UHD QUAD 4K (receiver-seestadt)"
# Debug
# "1" Aktiviert
# "0" Deaktiviert
debug="1"
# Temporärer Pfad OHNE abschließendem Slash (/) am Ende
temp="/tmp"
# -------------------------------
howto='\nUsage: ./check_oscam_client <hostname> <port> <username> <password> <clientcount>'
if [ "$#" -lt "5" ]; then
echo -e "$howto" && exit "3"
fi
# General
strHostname=${1}
strPort=${2}
strUser=${3}
strPass=${4}
strClientcount=${5}
#echo "$strHostname:$strPort:$strUser:$strPass:$strClientcount"
rm -f "$temp"/status.html
# File Download
a=$(curl --connect-timeout 2 -vu ""$strUser":"$strPass"" --anyauth -o ""$temp"/status.html" "http://$strHostname:$strPort/status.html" >/dev/null 2>/dev/null)
if [ $? -eq 0 ]
then
{
lines=$(wc -l ""$temp"/status.html" | awk '{print $1}')
if [ $lines -lt 2 ] ; then
{
t=$(tail -n 1 ""$temp"/status.html")
echo "CRITICAL: " $t
# Logging
if [ "$logsyslog" == "1" ] ; then logger "$filename $version - CRITICAL: $t"; fi
if [ $debug -eq 1 ] ;then echo -e "Fehler - Status.html hat >2 Zeilen und sieht somit nicht korrekt aus." ; fi
exit 2;
}
else
{
s='<P id="chead">Clients <span id="ucs">'${strClientcount}'</span>/<span id="uca">1</span></P><DIV>';
#echo "s="$s"";
g=$(grep "$s" "$temp"/status.html)
if [ $debug -eq 1 ] ; then echo -e "Suchstring="$g""; fi
if [ $? -eq 0 ]
then
#Grep erfolgreich - aber noch nicht klar ob string gefunden
if [ ! "$g" == "" ]
then
if [ $debug -eq 1 ] ;then echo -e "Sieht gut aus - String $s wurde gefunden." ; fi
else
if [ $debug -eq 1 ] ;then echo -e "Sieht schlecht aus - String $s nicht gefunden." ; fi
echo -e "OSCAM client of $client restarted at `date +"'%d.%m.%Y %H:%M'"`" | /usr/bin/mailx -A kirner.or.at -s "OSCAM client of $client restarted restarted" admin@kirner.or.at
fi
else
if [ $debug -eq 1 ] ;then echo -e "Sieht schlecht aus - String $s nicht gefunden." ; fi
fi
}
fi
}
else
{
echo "CRITICAL: Could not download status.html (StatusCheck)"
# Logging
if [ "$logsyslog" == "1" ] ; then logger "$filename $version - CRITICAL: Could not download status.html (StatusCheck)"; fi
exit 2;
}
fi
Zurück zu Watchdog (Oscam)