#!/usr/bin/python #-*- coding: ISO-8859-1 -*- #script escrito por Vinde __module_name__ = "Bandwidth Show" __module_version__ = "0.1" __module_description__ = "Exibe informacoes sobre consumo de banda" import commands import time import sys import xchat def bw(word, word_eol, userdata): try: iface = word[1] except IndexError: print 'Nenhuma interface foi especificada. Ex: eth0' return xchat.EAT_ALL try: data = commands.getoutput("cat /proc/net/dev | grep %s" % iface) data = data.split(':')[1].split() in1 = int(data[0]) out1 = int(data[8]) time.sleep(1) data = commands.getoutput("cat /proc/net/dev | grep %s" % iface) data = data.split(':')[1].split() in1 = (int(data[0]) - int(in1)) / 1024 out1 = (int(data[8]) - int(out1)) / 1024 xchat.command("say Velocidade atual de download: %s KB/s e upload %s KB/s" % (in1,out1)) except IndexError: print "Interface %s inválida" % iface return xchat.EAT_ALL return xchat.EAT_ALL xchat.hook_command("bw", bw, help="/bw interface")