Friday, August 24, 2012

gnome applets

choose from
http://askubuntu.com/questions/30334/what-application-indicators-are-available

add ppas with
sudo add-apt-repository ppa:atareao/atareao

and then apt-get update

for indicator-sysmonitor
you can use this script from

http://askubuntu.com/questions/29757/what-can-replace-system-monitoring-in-the-top-gnome-panel-in-unity/37424#37424



#!/usr/bin/python

import re
import sys
import time
import psutil

#Functions:_    __    __    __    __    __    __    __    __    __    __    __
#__/  \__/  \__/  \__/  \__/  \__/  \__/  \__/  \__/  \__/  \__/  \__/  \__/  \_

#interface |bytes    packets errs drop fifo frame compressed multicast|bytes    packets errs drop fifo colls carrier compressed
net_re = re.compile(r"\s*\S+:\s+(\d+)\s+\d+\s+\d+\s+\d+\s+\d+\s+\d+\s+\d+\s+\d+\s+(\d+)\s+\d+\s+\d+\s+\d+\s+\d+\s+\d+\s+\d+\s+\d+\s+")

def getInOut():
  """
  Get a readout of bytes in and out from /proc/net/dev.
  """

  netfile = "/proc/net/dev"

  try: f = open(netfile)
  except:
    sys.stderr.write("ERROR: can't open "+netfile+".\n")
    sys.exit(2)

  f.readline()    #Burn the top header line.
  f.readline()    #Burn the second header line.

  inb = 0
  outb = 0
  for line in f:
    m = net_re.match(line)
    inb += int(m.group(1))
    outb += int(m.group(2))
  f.close()

  return (inb,outb)



def sampleNet():
  """
  Get a sample of I/O from the network interfaces.
  """
  return makeSample(getInOut)


def makeSample(function):
  inlist = list()
  outlist = list()

  (inbytes, outbytes) = function()
  inlist.append(inbytes)
  outlist.append(outbytes)
  time.sleep(1)

  (inbytes, outbytes) = function()
  inlist.append(inbytes)
  outlist.append(outbytes)

  return (inlist[1] - inlist[0], outlist[1] - outlist[0])




def withUnit(v):
    if v<1024:
      return "%03d" % v+"b";
    if v<1024**2:
      s= ("%f" % (float(v)/1024))[:3];
      if s[-1]=='.':
         s=s[:-1]
      return s +"k";

    return ("%f" % (float(v)/(1024**2)))[:3] +"M";


(indiff, outdiff) = sampleNet()
outstr = ""
outstr += "c"+ "%02d" % int(psutil.cpu_percent())+" "
outstr += "m"+ "%02d" % int((100*float(psutil.used_phymem())/float(psutil.TOTAL_PHYMEM)))+" "

outstr += "d"+withUnit(indiff)+" u"+withUnit(outdiff)




print outstr

No comments:

Post a Comment