fisierul: cccam_version_servers
Code:
#!/bin/sh
# cccam_version_servers v0.51
#
# Monitoring CCcam's parameter using the WEBINFO HTTP port
#
### CONFIG - START
# List of Server versions you want to monitor, seperate by " "(<space>) (eg: "2.1.1 2.1.2")
SERVERversLIST="2.0.1 2.0.11 2.1.1 2.1.2 2.1.3 2.1.4 2.2.0 2.2.1 2.2.2"
# Get current connected or generate from above "SERVER vers LIST"? (yes/no)
USEversLIST="yes"
# /path/to/CCcam.cfg ... if your using USER/PASS ("" to disable and use below settings)
# CCcam-default: /var/etc/CCcam.cfg
CCcamCFG="/var/etc/CCcam.cfg"
# ONLY if you dont run CCcam-Server on same Box as Munin (else set above CCcamCFG)
USERNAME=""
PASSWORD=""
WEBINFOPORT=""
# IP/Host of your CCcam-Server to connect to...
CCCAMIP="localhost"
### CONFIG - END
# -------------------------------------------------------------- #
# >>> >> > DO NOT MESS WiTH ANYTHiNG BELOW THiS LiNE! < << <<< #
# -------------------------------------------------------------- #
# read CCcam.cfg and extract user/pass/port
proc_read_CCcamcfg() {
USERNAME=$(grep -i "WEBINFO USERNAME" $CCcamCFG | cut -d ":" -f2 | sed -e 's/ //g' | sed -e 's/\r//g')
PASSWORD=$(grep -i "WEBINFO PASSWORD" $CCcamCFG | cut -d ":" -f2 | sed -e 's/ //g' | sed -e 's/\r//g')
WEBINFOPORT=$(grep -i "WEBINFO LISTEN PORT" $CCcamCFG | cut -d ":" -f2 | sed -e 's/ //g' | sed -e 's/\r//g')
}
proc_get_infos() {
if [ ! -z "$CCcamCFG" ]; then
proc_read_CCcamcfg
fi
if [ -z "$WEBINFOPORT" ]; then
WEBINFOPORT="16001"
fi
if [ -z "$USERNAME" ]; then
URL="http://${CCCAMIP}:${WEBINFOPORT}"
else
URL="http://${USERNAME}:${PASSWORD}@${CCCAMIP}:${WEBINFOPORT}"
fi
}
if [ ! -z "$HOME" ]; then
TMPFILE="${HOME}/.tmpfile"
elif [ -d "/tmp" ]; then
TMPFILE="/tmp/.tmpfile"
elif [ -d "/var/tmp" ]; then
TMPFILE="/var/tmp/.tmpfile"
elif [ -d "/usr/tmp" ]; then
TMPFILE="/usr/tmp/.tmpfile"
elif [ -d "/usr/local/tmp" ]; then
TMPFILE="/usr/local/tmp/.tmpfile"
else
TMPFILE=".tmpfile"
fi
# create array SERVERvers[*]
proc_get_server_vers() {
if [ "$USEversLIST" = "yes" ]; then
sVERSIONS=`echo $SERVERversLIST | sort`
c=1
for V in $sVERSIONS; do
SERVERvers[${c}]="$V"
c=$(($c + 1))
done
else
wget -q -O - "${URL}/servers" >$TMPFILE
sVERSIONS=`grep "|[0-9].[0-9].[0-9]" $TMPFILE | cut -d "|" -f5 | sort`
c=1
for sVER in ${sVERSIONS}; do
SVadded=""
if [ -z "$SVsetted" ]; then
SERVERvers[${c}]="$sVER" ; SVsetted=1
else
for sVER2 in ${SERVERvers[*]}; do
if [ "$sVER2" = "$sVER" ]; then
SVadded=1
fi
done
if [ "$SVadded" != "1" ]; then
SERVERvers[${c}]="$sVER" ; SVsetted=2
fi
fi
c=$(($c + 1))
done
fi
}
proc_get_infos
if [ "$1" = "config" ]; then
proc_get_server_vers
echo 'graph_title CCcam Servers by version'
echo 'graph_category CCcam'
echo 'graph_args --lower-limit 0'
echo 'graph_scale no'
if [ ! -z "$sVERSIONS" ]; then
for SERVERver in ${SERVERvers[*]}; do
Sver2=`echo ${SERVERver} | tr -d "."`
echo "SV${Sver2}.label ${SERVERver}"
done
fi
rm -f $TMPFILE
exit 0
fi
proc_get_server_vers
if [ "$USEversLIST" = "yes" ]; then
wget -q -O - "${URL}/servers" >$TMPFILE
fi
if [ ! -z "$sVERSIONS" ]; then
for Sver in ${SERVERvers[*]}; do
sVc=`grep "|${Sver}" $TMPFILE | wc -l`
if [ -z "$sVc" ]; then
sVc=0
fi
Sver2=`echo ${Sver} | tr -d "."`
echo "SV${Sver2}.value ${sVc}"
done
fi
rm -f $TMPFILE
fisierul: cccam_version_clients
Code:
#!/bin/sh
# cccam_version_clients v0.51
#
# Monitoring CCcam's parameter using the WEBINFO HTTP port
#
### CONFIG - START
# List of Client versions you want to monitor, seperate by " "(<space>) (eg: "2.1.1 2.1.2")
CLIENTversLIST="2.0.1 2.0.11 2.1.1 2.1.2 2.1.3 2.1.4 2.2.0 2.2.1 2.2.2"
# Get current connected or generate from above "CLIENT vers LIST"? (yes/no)
USEversLIST="yes"
# /path/to/CCcam.cfg ... if your using USER/PASS ("" to disable and use below settings)
# CCcam-default: /var/etc/CCcam.cfg
CCcamCFG="/var/etc/CCcam.cfg"
# ONLY if you dont run CCcam-Server on same Box as Munin (else set above CCcamCFG)
USERNAME=""
PASSWORD=""
WEBINFOPORT=""
# IP/Host of your CCcam-Server to connect to...
CCCAMIP="localhost"
### CONFIG - END
# -------------------------------------------------------------- #
# >>> >> > DO NOT MESS WiTH ANYTHiNG BELOW THiS LiNE! < << <<< #
# -------------------------------------------------------------- #
# read CCcam.cfg and extract user/pass/port
proc_read_CCcamcfg() {
USERNAME=$(grep -i "WEBINFO USERNAME" $CCcamCFG | cut -d ":" -f2 | sed -e 's/ //g' | sed -e 's/\r//g')
PASSWORD=$(grep -i "WEBINFO PASSWORD" $CCcamCFG | cut -d ":" -f2 | sed -e 's/ //g' | sed -e 's/\r//g')
WEBINFOPORT=$(grep -i "WEBINFO LISTEN PORT" $CCcamCFG | cut -d ":" -f2 | sed -e 's/ //g' | sed -e 's/\r//g')
}
proc_get_infos() {
if [ ! -z "$CCcamCFG" ]; then
proc_read_CCcamcfg
fi
if [ -z "$WEBINFOPORT" ]; then
WEBINFOPORT="16001"
fi
if [ -z "$USERNAME" ]; then
URL="http://${CCCAMIP}:${WEBINFOPORT}"
else
URL="http://${USERNAME}:${PASSWORD}@${CCCAMIP}:${WEBINFOPORT}"
fi
}
if [ ! -z "$HOME" ]; then
TMPFILE="${HOME}/.tmpfile"
elif [ -d "/tmp" ]; then
TMPFILE="/tmp/.tmpfile"
elif [ -d "/var/tmp" ]; then
TMPFILE="/var/tmp/.tmpfile"
elif [ -d "/usr/tmp" ]; then
TMPFILE="/usr/tmp/.tmpfile"
elif [ -d "/usr/local/tmp" ]; then
TMPFILE="/usr/local/tmp/.tmpfile"
else
TMPFILE=".tmpfile"
fi
# create array CLIENTvers[*]
proc_get_client_vers() {
if [ "$USEversLIST" = "yes" ]; then
cVERSIONS=`echo $CLIENTversLIST | sort`
c=1
for V in $cVERSIONS; do
CLIENTvers[${c}]="$V"
c=$(($c + 1))
done
else
wget -q -O - "${URL}/clients" >$TMPFILE
cVERSIONS=`grep "|[0-9].[0-9].[0-9]" $TMPFILE | cut -d "|" -f5 | sort`
c=1
for cVER in ${cVERSIONS}; do
CVadded=""
if [ -z "$CVsetted" ]; then
CLIENTvers[${c}]="$cVER" ; CVsetted=1
else
for cVER2 in ${CLIENTvers[*]}; do
if [ "$cVER2" = "$cVER" ]; then
CVadded=1
fi
done
if [ "$CVadded" != "1" ]; then
CLIENTvers[${c}]="$cVER" ; CVsetted=2
fi
fi
c=$(($c + 1))
done
fi
}
proc_get_infos
if [ "$1" = "config" ]; then
proc_get_client_vers
echo 'graph_title CCcam Clients by version'
echo 'graph_category CCcam'
echo 'graph_args --lower-limit 0'
echo 'graph_scale no'
if [ ! -z "$cVERSIONS" ]; then
for CLIENTver in ${CLIENTvers[*]}; do
Cver2=`echo ${CLIENTver} | tr -d "."`
echo "CV${Cver2}.label ${CLIENTver}"
done
fi
rm -f $TMPFILE
exit 0
fi
proc_get_client_vers
if [ "$USEversLIST" = "yes" ]; then
wget -q -O - "${URL}/clients" >$TMPFILE
fi
if [ ! -z "$cVERSIONS" ]; then
for Cver in ${CLIENTvers[*]}; do
cVc=`grep "|${Cver}" $TMPFILE | wc -l`
if [ -z "$cVc" ]; then
cVc=0
fi
Cver2=`echo ${Cver} | tr -d "."`
echo "CV${Cver2}.value ${cVc}"
done
fi
rm -f $TMPFILE
fisierul: cccam_usercards
Code:
#!/bin/sh
# cccam_usercards v0.51
#
# Monitoring CCcam's parameter using the WEBINFO HTTP port
#
### CONFIG - START
# /path/to/CCcam.cfg ... if your using USER/PASS ("" to disable and use below settings)
# CCcam-default: /var/etc/CCcam.cfg
CCcamCFG="/var/etc/CCcam.cfg"
# ONLY if you dont run CCcam-Server on same Box as Munin (else set above CCcamCFG)
USERNAME=""
PASSWORD=""
WEBINFOPORT=""
# IP/Host of your CCcam-Server to connect to...
CCCAMIP="localhost"
# Create for each User/Peer you want to monitor, how many cards you get from him, an own array
# e.g.: USERCARDS[1]="dyndns.host"
# e.g.: USERCARDS[2]="74.125.79.99"
USERCARDS[1]="127.0.0.1"
### CONFIG - END
# -------------------------------------------------------------- #
# >>> >> > DO NOT MESS WiTH ANYTHiNG BELOW THiS LiNE! < << <<< #
# -------------------------------------------------------------- #
# read CCcam.cfg and extract user/pass/port
proc_read_CCcamcfg() {
USERNAME=$(grep -i "WEBINFO USERNAME" $CCcamCFG | cut -d ":" -f2 | sed -e 's/ //g' | sed -e 's/\r//g')
PASSWORD=$(grep -i "WEBINFO PASSWORD" $CCcamCFG | cut -d ":" -f2 | sed -e 's/ //g' | sed -e 's/\r//g')
WEBINFOPORT=$(grep -i "WEBINFO LISTEN PORT" $CCcamCFG | cut -d ":" -f2 | sed -e 's/ //g' | sed -e 's/\r//g')
}
proc_get_infos() {
if [ ! -z "$CCcamCFG" ]; then
proc_read_CCcamcfg
fi
if [ -z "$WEBINFOPORT" ]; then
WEBINFOPORT="16001"
fi
if [ -z "$USERNAME" ]; then
URL="http://${CCCAMIP}:${WEBINFOPORT}"
else
URL="http://${USERNAME}:${PASSWORD}@${CCCAMIP}:${WEBINFOPORT}"
fi
}
if [ ! -z "$HOME" ]; then
TMPFILE="${HOME}/.tmpfile"
elif [ -d "/tmp" ]; then
TMPFILE="/tmp/.tmpfile"
elif [ -d "/var/tmp" ]; then
TMPFILE="/var/tmp/.tmpfile"
elif [ -d "/usr/tmp" ]; then
TMPFILE="/usr/tmp/.tmpfile"
elif [ -d "/usr/local/tmp" ]; then
TMPFILE="/usr/local/tmp/.tmpfile"
else
TMPFILE=".tmpfile"
fi
if [ "$1" = "config" ]; then
echo 'graph_title CCcam User Cards'
echo 'graph_args --lower-limit 0'
echo 'graph_category CCcam'
echo 'graph_vlabel cards'
x=1
for UC in ${USERCARDS[*]}; do
echo "user${x}cards.label ${x}. User Cards (${UC})"
x=$(($x + 1))
done
exit 0
fi
proc_get_infos
wget -q -O - "${URL}/servers" >$TMPFILE
x=1
for UC in ${USERCARDS[*]}; do
RESULT=`grep ${UC} $TMPFILE | cut -d'|' -f7 | sed 's/ //g'`
if [ "$RESULT" = "remote" ]; then
RESULT=`grep ${UC} $TMPFILE | awk '{print $4}'`
fi
echo "user${x}cards.value $RESULT"
x=$(($x + 1))
done
rm -f $TMPFILE
fisierul: cccam_servers_clients
Code:
#!/bin/sh
# cccam_servers_clients v0.51
#
# Monitoring CCcam's parameter using the WEBINFO HTTP port
#
### CONFIG - START
# /path/to/CCcam.cfg ... if your using USER/PASS ("" to disable and use below settings)
# CCcam-default: /var/etc/CCcam.cfg
CCcamCFG="/var/etc/CCcam.cfg"
# ONLY if you dont run CCcam-Server on same Box as Munin (else set above CCcamCFG)
USERNAME=""
PASSWORD=""
WEBINFOPORT=""
# IP/Host of your CCcam-Server to connect to...
CCCAMIP="localhost"
### CONFIG - END
# -------------------------------------------------------------- #
# >>> >> > DO NOT MESS WiTH ANYTHiNG BELOW THiS LiNE! < << <<< #
# -------------------------------------------------------------- #
# read CCcam.cfg and extract user/pass/port
proc_read_CCcamcfg() {
USERNAME=$(grep -i "WEBINFO USERNAME" $CCcamCFG | cut -d ":" -f2 | sed -e 's/ //g' | sed -e 's/\r//g')
PASSWORD=$(grep -i "WEBINFO PASSWORD" $CCcamCFG | cut -d ":" -f2 | sed -e 's/ //g' | sed -e 's/\r//g')
WEBINFOPORT=$(grep -i "WEBINFO LISTEN PORT" $CCcamCFG | cut -d ":" -f2 | sed -e 's/ //g' | sed -e 's/\r//g')
}
proc_get_infos() {
if [ ! -z "$CCcamCFG" ]; then
proc_read_CCcamcfg
fi
if [ -z "$WEBINFOPORT" ]; then
WEBINFOPORT="16001"
fi
if [ -z "$USERNAME" ]; then
URL="http://${CCCAMIP}:${WEBINFOPORT}"
else
URL="http://${USERNAME}:${PASSWORD}@${CCCAMIP}:${WEBINFOPORT}"
fi
}
if [ ! -z "$HOME" ]; then
TMPFILE="${HOME}/.tmpfile"
elif [ -d "/tmp" ]; then
TMPFILE="/tmp/.tmpfile"
elif [ -d "/var/tmp" ]; then
TMPFILE="/var/tmp/.tmpfile"
elif [ -d "/usr/tmp" ]; then
TMPFILE="/usr/tmp/.tmpfile"
elif [ -d "/usr/local/tmp" ]; then
TMPFILE="/usr/local/tmp/.tmpfile"
else
TMPFILE=".tmpfile"
fi
if [ "$1" = "config" ]; then
echo 'graph_title CCcam Servers and Clients'
echo 'graph_category CCcam'
echo 'graph_args --lower-limit 0'
echo 'clients.label Connected Clients'
echo 'aclients.label Active Clients'
echo 'servers.label Connected Servers'
exit 0
fi
proc_get_infos
CLIENTSCONNECTED=CLIENTSACTIVE=SERVERSONLINE=0
wget -q -O - "${URL}" >$TMPFILE
CLIENTSCONNECTED=`grep Connected $TMPFILE | awk '{print $3}'`
CLIENTSACTIVE=`grep 'Active clients' $TMPFILE | awk '{print $3}'`
echo "clients.value $CLIENTSCONNECTED"
echo "aclients.value $CLIENTSACTIVE"
wget -q -O - "${URL}/servers" >$TMPFILE
SERVERSONLINE=`grep -e 'd [0-2][0-9]:[0-6][0-9]:[0-6][0-9]' $TMPFILE | wc -l`
echo "servers.value $SERVERSONLINE"
rm -f $TMPFILE
fisierul: cccam_cards
Code:
#!/bin/sh
# cccam_cards v0.51
#
# Monitoring CCcam's parameter using the WEBINFO HTTP port
#
### CONFIG - START
# /path/to/CCcam.cfg ... if your using USER/PASS ("" to disable or use below settings)
# CCcam-default: /var/etc/CCcam.cfg
CCcamCFG="/var/etc/CCcam.cfg"
# ONLY if you dont run CCcam-Server on same Box as Munin (else set above CCcamCFG)
USERNAME=""
PASSWORD=""
WEBINFOPORT=""
# IP/Host of your CCcam-Server to connect to...
CCCAMIP="localhost"
# How many Hops you share or only want to monitor?
MAXHOPS="2"
### CONFIG - END
# -------------------------------------------------------------- #
# >>> >> > DO NOT MESS WiTH ANYTHiNG BELOW THiS LiNE! < << <<< #
# -------------------------------------------------------------- #
# read CCcam.cfg and extract user/pass/port
proc_read_CCcamcfg() {
USERNAME=$(grep -i "WEBINFO USERNAME" $CCcamCFG | cut -d ":" -f2 | sed -e 's/ //g' | sed -e 's/\r//g')
PASSWORD=$(grep -i "WEBINFO PASSWORD" $CCcamCFG | cut -d ":" -f2 | sed -e 's/ //g' | sed -e 's/\r//g')
WEBINFOPORT=$(grep -i "WEBINFO LISTEN PORT" $CCcamCFG | cut -d ":" -f2 | sed -e 's/ //g' | sed -e 's/\r//g')
}
proc_get_infos() {
if [ ! -z "$CCcamCFG" ]; then
proc_read_CCcamcfg
fi
if [ -z "$WEBINFOPORT" ]; then
WEBINFOPORT="16001"
fi
if [ -z "$USERNAME" ]; then
URL="http://${CCCAMIP}:${WEBINFOPORT}"
else
URL="http://${USERNAME}:${PASSWORD}@${CCCAMIP}:${WEBINFOPORT}"
fi
}
if [ ! -z "$HOME" ]; then
TMPFILE="${HOME}/.tmpfile"
elif [ -d "/tmp" ]; then
TMPFILE="/tmp/.tmpfile"
elif [ -d "/var/tmp" ]; then
TMPFILE="/var/tmp/.tmpfile"
elif [ -d "/usr/tmp" ]; then
TMPFILE="/usr/tmp/.tmpfile"
elif [ -d "/usr/local/tmp" ]; then
TMPFILE="/usr/local/tmp/.tmpfile"
else
TMPFILE=".tmpfile"
fi
if [ "$1" = "config" ]; then
echo 'graph_title CCcam available Cards and Shares'
echo 'graph_args --lower-limit 0'
echo 'graph_scale no'
echo 'graph_category CCcam'
#echo 'graph_vlabel cards'
echo 'shares.label Total available Shares'
count=1
while [ ! $count -gt $MAXHOPS ]; do
echo "hop${count}.label Cards in hop${count}"
count=$(($count + 1))
done
exit 0
fi
proc_get_infos
wget -q -O - "${URL}/shares" >$TMPFILE
AVAILABLE=$(grep Available ${TMPFILE} | awk '{print $3}')
echo "shares.value ${AVAILABLE}"
count=1
while [ ! $count -gt $MAXHOPS ]; do
CARDS=$(cat ${TMPFILE} | cut -d'|' -f7 | cut -c1-3 | grep "${count}" | wc -l)
echo "hop${count}.value ${CARDS}"
count=$(($count + 1))
done
rm -f ${TMPFILE}
aceste fisiere trebuiesc create cu un editor de text UNIX (foarte important!!!). in fiecare din ele, editati
Code:
USERNAME=""
PASSWORD=""
WEBINFOPORT=""
cu setarile din . apoi, le transferati in . modificati permisiunile pentru fiecare in parte:
Code:
chmod 755 /usr/share/munin/plugins/cccam_user
. realizati legaturi simbolice pentru fiecare fisier in parte. exemplu:
Code:
ln -s /usr/share/munin/plugins/cccam_user /etc/munin/plugins/cccam_user
sau copiati-le, pur si simplu in
Code:
/etc/munin/plugins/cccam_user
. restartati sistemul sau serviciul si asteptati sa se stranga statisticile. accesati interfata munin
Code:
http://ip-ul.masinii.linux/munin
. valabil pentru Ubuntu 10.10. pentru cei ce au probleme cu eroarea de accesare a interfetei web a munin, editati
Code:
/etc/munin/apache.conf
linia
Code:
Allow from localhost 127.0.0.1/8
in .
succesuri! 
---------- Post added at 23:51 ---------- Previous post was at 23:38 ----------
monitorizare trafic CCcam folosind iptraf:
Code:
# Network Device on which your CCcam-Server runs on (default: eth0)
NETDEVICE="eth0"
# Directory where iptraf saves the logfiles (default: /var/log/iptraf)
IPTRAFlogdir="/var/log/iptraf"
# Display also Total Traffic? (yes/no)
WITHtotal="yes"
### CONFIG - END
# -------------------------------------------------------------- #
# >>> >> > DO NOT MESS WiTH ANYTHiNG BELOW THiS LiNE! < << <<< #
# -------------------------------------------------------------- #
if [ -z "$CCCAMPORT" ]; then
CCCAMPORT="12000"
elif [ -z "$NETDEVICE" ]; then
NETDEVICE="eth0"
elif [ -z "$IPTRAFlogdir" ]; then
IPTRAFlogdir="/var/log/iptraf"
fi
if [ "$1" = "config" ]; then
echo "graph_info This graph shows the CCcam traffic on the $NETDEVICE network interface."
echo 'graph_title CCcam Traffic'
echo 'graph_category CCcam'
echo 'graph_args --base 1024 -l 0'
echo 'graph_vlabel Bytes/sec'
if [ "$WITHtotal" = "yes" ]; then
echo 'graph_order traffictotal trafficin trafficout'
echo 'traffictotal.label Total traffic'
echo 'traffictotal.type DERIVE'
echo 'traffictotal.draw LINE1'
echo 'traffictotal.min 0'
echo 'traffictotal.cdef traffictotal,8,*'
else
echo 'graph_order trafficin trafficout'
fi
echo 'trafficin.label traffic IN'
echo 'trafficin.type DERIVE'
echo 'trafficin.draw LINE1'
echo 'trafficin.min 0'
echo 'trafficin.cdef trafficin,8,*'
echo 'trafficout.label traffic OUT'
echo 'trafficout.type DERIVE'
echo 'trafficout.draw LINE1'
echo 'trafficout.min 0'
echo 'trafficout.cdef trafficout,8,*'
exit 0
fi
LOG="$IPTRAFlogdir/tcp_udp_services-${NETDEVICE}.log"
TRAFFIC=$(grep "TCP/$CCCAMPORT" $LOG | tail -n1 | cut -f2 -d"," | cut -f2 -d" ")
TRAFFICIN=$(grep "TCP/$CCCAMPORT" $LOG | tail -n1 | cut -f4 -d"," | cut -f2 -d" ")
TRAFFICOUT=$(grep "TCP/$CCCAMPORT" $LOG | tail -n1 | cut -f6 -d"," | cut -f2 -d" ")
if [ -z "$TRAFFIC" ]; then
TRAFFIC=0
elif [ -z "$TRAFFICIN" ]; then
TRAFFICIN=0
elif [ -z "$TRAFFICOUT" ]; then
TRAFFICOUT=0
fi
if [ "$WITHtotal" = "yes" ]; then
echo "traffictotal.value ${TRAFFIC}"
fi
echo "trafficin.value ${TRAFFICIN}"
echo "trafficout.value ${TRAFFICOUT}"