Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 5 of 5

Thread: Monitoring various CCcam parameters with Munin

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Standard RSP member
    Join Date
    13 Feb 2007
    Location
    Earth
    Posts
    1,977
    Mentioned
    0 Post(s)
    Rep Power
    84

    Post Monitoring various CCcam parameters with Munin

    Monitoring various CCcam parameters with Munin

    ''
    Munin is a network/system monitoring application that presents output in graphs through a web interface. Its emphasis is on simple plug and play capabilities. A large number of monitoring plugins are available. Using Munin you can easily monitor the performance of your computers, networks, SANs, and applications as well. It uses the RRDtool (written by Tobi Oetiker) and is written in Perl. It stores the data in RRD files, and (if needed) updates the graphs. One of the main goals has been ease of creating new plugins (graphs).

    Munin is available as a package in most distros. In Ubuntu for example, to install it, just type: sudo apt-get install munin.

    With the plugins below, you can very easily monitor vairous CCcam parameters along the many others inside your Munin installation on your Linux system.

    If you use Ubuntu, go to /usr/share/munin/plugins/ (other distros may have some other location for this) and create there a file called cccam_cards

    Paste the following text in the file, then save it:




    #!/bin/sh

    case $1 in
    config)
    cat <<'EOM'
    graph_title CCcam available cards
    graph_vlabel cards
    graph_category CCcam
    hop1.label Cards in hop1
    hop2.label Cards in hop2
    hop3.label Cards in hop3
    hop4.label Cards in hop4

    EOM
    exit 0;;
    esac

    echo -n "hop1.value "
    echo shares | nc localhost 16000 | grep "|1 " | wc -l

    echo -n "hop2.value "
    echo shares | nc localhost 16000 | grep "|2 " | wc -l

    echo -n "hop3.value "
    echo shares | nc localhost 16000 | grep "|3 " | wc -l

    echo -n "hop4.value "
    echo shares | nc localhost 16000 | grep "|4 " | wc -l



    Paste this into a new file, cccam_servers_clients:




    #!/bin/sh

    case $1 in
    config)
    cat <<'EOM'
    graph_title CCcam Servers and Clients
    #graph_vlabel CCcam
    graph_category CCcam
    clients.label Connected clients
    aclient.label Active clients
    servers.label Server connections

    EOM
    exit 0;;
    esac

    echo -n "clients.value "
    echo info | nc localhost 16000 | grep Connected | awk '{print $3}'

    echo -n "aclient.value "
    echo info | nc localhost 16000 | grep 'Active clients' | awk '{print $3}'

    echo -n "servers.value "
    echo servers | nc localhost 16000 | grep 'Server connections' | awk '{print $3}'



    Paste this into a new file, cccam_shares_ecm:



    #!/bin/sh

    case $1 in
    config)
    cat <<'EOM'
    graph_title CCcam Shares and ECM
    #graph_vlabel cccam
    graph_category CCcam
    shares.label Available shares
    ecms.label Total handled client ecms

    EOM
    exit 0;;
    esac

    echo -n "shares.value "
    echo shares | nc localhost 16000 | grep Available | awk '{print $3}'

    echo -n "ecms.value "
    echo info | nc localhost 16000 | grep ecm | awk '{print $5}'


    Make these files executable (change permissions with chmod to 755).

    Create symlinks for each file to folder /etc/munin/plugins.

    Restart munin: sudo service munin-node restart. Sit back and relax for 15 minutes, and look at your graphs growing.

    Lots of parameters of CCcam can be monitored. Based on the code above, with simple modifications almost anything can be graphed. ''
    Last edited by me1960; 12-02-10 at 01:34.
    Don't dream your life - live your DREAMbox ! DON'T FORGET TO SAY '' THANKS '' Note: Viewing Pay TV without a valid subscription is illegal All the files available here are kept for experimental and educational purpose only!

  2. #2
    Standard RSP member franta's Avatar
    Join Date
    24 Jun 2009
    Location
    Hamburg
    Posts
    1,430
    Mentioned
    3 Post(s)
    Rep Power
    73

    Default

    sal
    am facut ce s-a spus aici dar la sectiunea cccam nu imi arata decat cccam available cards.
    ma gandesc poate configul pt cccam_servers_clients si cccam_shares_ecm
    or avea ceva gesit sau poate am facut eu ceva in neregula
    am facut fiserele am copiat textul dat am salvat am skimbat atribtele am dat read wirght la toti useri si am bifat sa fie executabil.
    am facut shortcut unde este recomandat dar nu merge
    poate poti sa ma ajuti
    eu am ubuntu
    mersi

  3. #3
    Standard RSP member franta's Avatar
    Join Date
    24 Jun 2009
    Location
    Hamburg
    Posts
    1,430
    Mentioned
    3 Post(s)
    Rep Power
    73

    Default

    am renuntat sa folosesc munin pt ca imi bloca cccamu
    dar era foarte interesant

  4. #4
    Standard RSP member techcenter's Avatar
    Join Date
    02 Feb 2008
    Posts
    446
    Mentioned
    1 Post(s)
    Rep Power
    69

    Default

    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
    Code:
    CCcam.cfg
    . apoi, le transferati in
    Code:
    /etc/munin/plugins
    . 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
    Code:
    Allow from all
    .

    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}"

  5. #5
    Standard RSP member techcenter's Avatar
    Join Date
    02 Feb 2008
    Posts
    446
    Mentioned
    1 Post(s)
    Rep Power
    69

    Default

    monitorizarea activitatii Oscam-ului folosind iptraf si munin:

    Code:
    #!/bin/sh
    # oscam_traffic v0.22
    #
    # special thanx to: cyres
    #
    # Monitoring LOCAL running OScam's traffic using iptraf
    #
    # HowTo:
    # apt-get install iptraf
    # run ' iptraf ' as root and go to Configure... Timers...
    # change Logging interval... to your Munin-update-interval (default: 5min)
    # go to Additional ports... and add your OScam-Server-Port
    # Exit iptraf and start it into background:
    # iptraf -s eth0 -B
    # by default eth0 is the first network device of your server (check with: ifconfig)
    #
    ### CONFIG - START
    
    # SERVER PORT of your OScam-Server for iptraf (default: 33000)
    OSCAMPORT="33000"
    
    # Network Device on which your OScam-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"
    
    # If we'r displaying Total Traffic should it draw the complete
    # AREA or only a simple LINE1 like it does with traffic IN and OUT? (LINE1/AREA)
    # (area looks better)
    TOTALdraw="AREA"
    
    ### CONFIG - END
    
    # -------------------------------------------------------------- #
    # >>> >> >  DO NOT MESS WiTH ANYTHiNG BELOW THiS LiNE!  < << <<< #
    # -------------------------------------------------------------- #
    
    
    if [ "$TOTALdraw" != "AREA" ] && [ "$TOTALdraw" != "LINE1" ]; then
    	TOTALdraw="AREA"
    fi
    if [ -z "$OSCAMPORT" ]; then
    	OSCAMPORT="33000"
    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 OScam traffic on the $NETDEVICE network interface."
    	echo 'graph_title OScam Traffic'
    	echo 'graph_category OScam'	
    	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 '$TOTALdraw''
    		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/$OSCAMPORT" $LOG | tail -n1 | cut -f1 -d";" | cut -f4 -d" ")
    TRAFFICIN=$(grep "TCP/$OSCAMPORT" $LOG | tail -n1 | cut -f2 -d";" | cut -f4 -d" ")
    TRAFFICOUT=$(grep "TCP/$OSCAMPORT" $LOG | tail -n1 | cut -f3 -d";" | cut -f4 -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}"
    succesuri!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •