SysMonitor Indicator

Nel tentativo di visualizzare a schermo l’indirizzo IP del pc di un cliente per semplificare il collegamento remoto, ho scovato nei meandri del web questa piccola utility.

Sysmonitor Indicator è un programmino facilmente installabile presente in Launchpad ed attualmente alla versione 0.8 che risulta però compatibile solo da Ubuntu 14.xx in avanti ppa:fossfreedom/indicator-sysmonitor.

Per installarlo sulla 12.04 LTS è necessario installare la versione 0.41 presente o nel repository principale tramite .deb oppure tramite ppa:alexeftimie/ppa

Per farlo funzionare a dovere è necessario avere installato anche l’utility python3-psutil e nel mio caso avere curl installato.

Prima di eseguire il programma creiamo il file di configurazione personalizzato:

#!/bin/bash
#settings:
netspeed=true
ram=true
cpu=true
ip=true
#-------------------------------------------------------
#---------------- initialize ---------------------------
rm /tmp/.sysmon > /dev/null 2>&1
dstat --net --mem --cpu --output=/tmp/.sysmon 1 1 > /dev/null 2>&1
#----------- up/down speed -----------------------------
if [ $netspeed = true ]; then
upspeed=$(echo $(cat /tmp/.sysmon | tail -1 | cut -d ',' -f2)/1024*8 | bc)
upkbmb=$(if [ $upspeed -gt 1024 ]; then 
		up1=$(echo $(cat /tmp/.sysmon | tail -1 | cut -d ',' -f2)/1024/1024 | bc -l)
		echo $up1 | head -c 4
	else 
		echo $upspeed | head -c 3
	fi)
downspeed=$(echo $(cat /tmp/.sysmon | tail -1 | cut -d ',' -f1)/1024*8 | bc)
downkbmb=$(if [ $downspeed -gt 1024 ]; then 
		down1=$(echo $(cat /tmp/.sysmon | tail -1 | cut -d ',' -f1)/1024/1024*8 | bc -l)
		echo $down1 | head -c 4
	else 
		echo $downspeed | head -c 3
	fi)
#---------------- up/down speed unit --------------------
upunit=$(if [ $upspeed -gt 1024 ]; then echo "Mb/s"; else echo "Kb/s"; fi)
downunit=$(if [ $downspeed -gt 1024 ]; then echo "Mb/s"; else echo "Kb/s"; fi)
fi
#------------------- CPU % used -------------------------
if [ $cpu = true ]; then
cpufree=$(cat /tmp/.sysmon | tail -1 | cut -d ',' -f9)
cpuused=$(echo 100-$cpufree | bc | sed -e 's/\..*//')
fi
#------------------- RAM % used --------------------------
if [ $ram = true ]; then
memused=$(free -m | grep buffers/cache | tr -s ' ' | cut -d' ' -f 3)
memfree=$(free -m | grep buffers/cache | tr -s ' ' | cut -d' ' -f 4)
memtotal=$(echo $memused+$memfree | bc -l)
memusedpercent=$(echo 100-100*$memfree/$memtotal | bc)
fi
#------------------- MY IP Address --------------------------
if [ $ip = true ]; then
ipaddress=$(curl ipv4.icanhazip.com)
fi
#------------------ The Indicator Sysmonitor actual output -
echo $(if [ $ram = true ]; then echo Mem: $memusedpercent% \|; fi) $(if [ $cpu = true ]; then echo CPU: $cpuused% \|; fi) $(if [ $netspeed = true ]; then echo ↑ $upkbmb $upunit  ↓ $downkbmb $downunit; fi) $(if [ $ip = true ]; then echo IP: $ipaddress \|; fi)

salviamo il codice sopra come /home/xxx/.scripts/sysmon e rendiamolo eseguibile.

Una volta installato ed eseguito (lo si trova nella Dash) cliccate sull voce che appare nela barra e scegliendo Preference modifichiamo i valori:
alla voce Generale spuntiamo Run on Startup
alla voce Advanced spuntiamo Use this command ed inseriamo dentro il seguente comando: $HOME/.scripts/sysmon
salviamo ed usciamo.

Ora tutte le modifiche che effettueremo al file sysmon saranno immediatamente (o quasi) visibili nella barra delle notifiche.

Lascia un commento