#!/bin/sh
# set -x
WEBUSER="cccam"
WEBPASS="password"
URL=192.168.178.1
PORT="16001"
tmpfile="/tmp/cccam.001"
tmpfile2="/tmp/cccam.002"
PID="$(pgrep -x CCcam.x86)"
PID2="$(pidof CCcam.x86)"
PID3="$(pidof CCcam.x86 | wc -w)"
DVB_CARDS=$(ls -l /dev/dvb 2>/dev/null | grep adapter | wc -l)
WUP=""
[ "$WEBUSER" != "" ] && WUP="$WEBUSER:$WEBPASS@"
rm -f /tmp/cccam.0*
if [[ ! -z $PID ]] ; then
echo "" >> $tmpfile
echo "$(date)" >> $tmpfile
echo "" >> $tmpfile
wget -q -O - "[URL]http://$WUP$URL:$PORT[/URL]" | grep "Welcome" | sed 's/^.*\(Welcome to CCcam [0-9.]* server\).*$/\1/' >> $tmpfile
echo "" >> $tmpfile
echo "DVB Cards: $DVB_CARDS" >> $tmpfile
echo "Running CCcams: ${PID3}" >> $tmpfile
echo "Process ID: ${PID2}" >> $tmpfile
else
echo "CCcam ist nicht gestartet"
exit
fi
wget -q -O - "[URL]http://$WUP$URL:$PORT[/URL]" | while
true
do
read line
upTime=${line#*Uptime:*}
echo "Uptime:"$upTime >> $tmpfile
break
done
echo "" >> $tmpfile
echo "-----------------------------------------------" >> $tmpfile
echo "Shareinfo:" >> $tmpfile
echo "" >> $tmpfile
wget -q -O - "[URL]http://$WUP$URL:$PORT/shares[/URL]" | while
true
do
read line
read line
echo $line >> $tmpfile
break
done
echo "" >> $tmpfile
wget -O - "[URL]http://$WUP$URL:$PORT/servers[/URL]" 2>/dev/null | grep -v "^<[(HTML|/PRE)]" | grep CCcam-s2s | cut -f 2,7 -d "|" > $tmpfile2
sed -e 's/|/ Cards: /g' $tmpfile2 >> $tmpfile
wget -O - "[URL]http://$WUP$URL:$PORT/servers[/URL]" 2>/dev/null | grep -v "^<[(HTML|/PRE)]" | grep newcamd | cut -f 2,7 -d "|" > $tmpfile2
sed -e 's/|/ Cards: /g' $tmpfile2 >> $tmpfile
wget -O - "[URL]http://$WUP$URL:$PORT/servers[/URL]" 2>/dev/null | grep -v "^<[(HTML|/PRE)]" | grep camd3 | cut -f 2,7 -d "|" > $tmpfile2
sed -e 's/|/ Cards: /g' $tmpfile2 >> $tmpfile
wget -O - "[URL]http://$WUP$URL:$PORT/servers[/URL]" 2>/dev/null | grep -v "^<[(HTML|/PRE)]" | grep radegast | cut -f 2,7 -d "|" > $tmpfile2
sed -e 's/|/ Cards: /g' $tmpfile2 >> $tmpfile
wget -O - "[URL]http://$WUP$URL:$PORT/servers[/URL]" 2>/dev/null | grep -v "^<[(HTML|/PRE)]" | grep gbox | cut -f 2,7 -d "|" > $tmpfile2
sed -e 's/|/ Cards: /g' $tmpfile2 >> $tmpfile
echo "" >> $tmpfile
echo "-----------------------------------------------" >> $tmpfile
echo "Serverinfo:" >> $tmpfile
echo "" >> $tmpfile
if [ $(wget -O - "[URL]http://$WUP$URL:$PORT/servers[/URL]" 2>/dev/null | grep -c CCcam-s2s) -ne 0 ] ; then
echo "CCcam-s2s:" >> $tmpfile
echo "-----------" >> $tmpfile
wget -O - "[URL]http://$WUP$URL:$PORT/servers[/URL]" 2>/dev/null | grep -v "^<[(HTML|/PRE)]" | grep CCcam-s2s | cut -f 2,3 -d "|" > $tmpfile2
sed -e 's/|/ up: /g' $tmpfile2 >> $tmpfile
echo "" >> $tmpfile
fi
if [ $(wget -O - "[URL]http://$WUP$URL:$PORT/servers[/URL]" 2>/dev/null | grep -c camd3) -ne 0 ] ; then
echo "camd3:" >> $tmpfile
echo "-----------" >> $tmpfile
wget -O - "[URL]http://$WUP$URL:$PORT/servers[/URL]" 2>/dev/null | grep -v "^<[(HTML|/PRE)]" | grep camd3 | cut -f 2,3 -d "|" > $tmpfile2
sed -e 's/|/ up: /g' $tmpfile2 >> $tmpfile
echo "" >> $tmpfile
fi
if [ $(wget -O - "[URL]http://$WUP$URL:$PORT/servers[/URL]" 2>/dev/null | grep -c gbox) -ne 0 ] ; then
echo "gbox:" >> $tmpfile
echo "-----------" >> $tmpfile
wget -O - "[URL]http://$WUP$URL:$PORT/servers[/URL]" 2>/dev/null | grep -v "^<[(HTML|/PRE)]" | grep gbox | cut -f 2,3 -d "|" > $tmpfile2
sed -e 's/|/ up: /g' $tmpfile2 >> $tmpfile
echo "" >> $tmpfile
fi
if [ $(wget -O - "[URL]http://$WUP$URL:$PORT/servers[/URL]" 2>/dev/null | grep -c newcamd) -ne 0 ] ; then
echo "newcamd:" >> $tmpfile
echo "-----------" >> $tmpfile
wget -O - "[URL]http://$WUP$URL:$PORT/servers[/URL]" 2>/dev/null | grep -v "^<[(HTML|/PRE)]" | grep newcamd | cut -f 2,3 -d "|" > $tmpfile2
sed -e 's/|/ up: /g' $tmpfile2 >> $tmpfile
echo "" >> $tmpfile
fi
if [ $(wget -O - "[URL]http://$WUP$URL:$PORT/servers[/URL]" 2>/dev/null | grep -c radegast) -ne 0 ] ; then
echo "Radegast:" >> $tmpfile
echo "-----------" >> $tmpfile
wget -O - "[URL]http://$WUP$URL:$PORT/servers[/URL]" 2>/dev/null | grep -v "^<[(HTML|/PRE)]" | grep radegast | cut -f 2,3 -d "|" > $tmpfile2
sed -e 's/|/ up: /g' $tmpfile2 >> $tmpfile
echo "" >> $tmpfile
fi
echo "-----------------------------------------------" >> $tmpfile
echo "Clientinfo:" >> $tmpfile
echo "" >> $tmpfile
wget -q -O - "[URL]http://$WUP$URL:$PORT[/URL]" | while
true
do
read line
read line
connectedClients=${line#*<BR>*}
echo $connectedClients >> $tmpfile
read line
activeClients=${line#*<BR>*}
echo $activeClients >> $tmpfile
break
done
echo "" >> $tmpfile
wget -O - "[URL]http://$WUP$URL:$PORT/activeclients[/URL]" 2>/dev/null | grep -v "^<[(HTML|/PRE)]" | grep 00d > $tmpfile2
cut -d\| -f2,3,9 $tmpfile2 | sed -e s/$/"\n"/g -e s/"|"/"\n"/2 -e s/"|"/" "/g >> $tmpfile
echo "-----------------------------------------------" >> $tmpfile
# echo "Client Connectinfo:" >> $tmpfile
# echo "" >> $tmpfile
# wget -O - "[URL]http://$WUP$URL:$PORT/clients[/URL]" 2>/dev/null | grep -v "^<[(HTML|/PRE)]" | grep [.] | cut -d\| -f2,4,8 > $tmpfile2
# sed -e 's/|/ /g' $tmpfile2 >> $tmpfile
# echo "" >> $tmpfile
# echo "-----------------------------------------------" >> $tmpfile
cat $tmpfile
rm -f /tmp/cccam.0*