Xfce Wiki

Sub domains
 

Site Tools

Translations of this page?:

Simple network monitoring using Genmon plugin

Follow is the code of script that can make this I recomment to save in you home directory with name netmonitor.sh (with +x permissions), next have to add new item (On panel right click → 'Add New Item' → 'Generic Monitor') and for command type ~/netmonitor.sh . With no label tick and period for update 1

Screenshot:

Old picture was removed, please update

#!/usr/bin/env bash
#netmonitor.sh
 
#configuration part
####################
 
ICON_THEME="Tango"
ICON_SIZE="22"
 
 
#code part
if [ -n $1 ]; then
    interface=$1
else
    interface="eth0"
fi
 
MY_output=`netstat -i|grep $interface|awk '{print $12}'`
MY_icontheme="/usr/share/icons/${ICON_THEME}/${ICON_SIZE}x${ICON_SIZE}/status/"
 
if [ -n "${MY_output}" ]; then
    if [[ "${MY_output}" =~ "U" ]]; then
	echo "<img>${MY_icontheme}/network-idle.png</img>"
    else
        echo "<img>${MY_icontheme}/network-offline</img>"
    fi
else
    echo "<img>${MY_icontheme}/network-error.png</img>"
fi
MY_ip=`/sbin/ifconfig $interface|grep inet|awk {'print $2'}|cut -d":" -f2`
echo "<tool>
    Hostname: ${HOSTNAME}	
    Interface: ${interface}		
    IP: ${MY_ip}	
 
    </tool>"
exit
howto/simple_network_monitoring.txt · Last modified: 2010/10/02 17:26 (external edit)