Answers:
就像旧的gnome指示器一样:http : //www.webupd8.org/2011/05/network-memory-and-cpu-usage-indicator.html#more
从链接中注意:安装后,从Dash启动系统负载指示器。与旧的gnome小程序不同,这是将这些指示器添加到面板的方法。
我发现以下问答可以为我解决问题。它包含替换为应用程序指示符的旧小程序的列表。不幸的是,还没有全部可用,但是至少我有了一个非常基本的系统负载监视器(indicator-sysmonitor)和一个天气指示器(indicator-weather)。
点击按钮进行安装:
这是我用python破解的快速而肮脏的系统监视器:
它使用“系统监视器指示器”(此处)来调用我编写的脚本。要使用它:
安装indicator-sysmonitor
。为此,请运行以下命令:
sudo apt-add-repository ppa:alexeftimie/ppa && sudo apt-get update && sudo apt-get install indicator-sysmonitor
将下面的脚本复制到一个名为sysmonitor的文件中
使脚本可执行(chmod +x path-to-file
)
单击指示器,然后选择“首选项”。
选择“使用此命令”,并为其提供sysmonitor文件的路径。
这是代码:
#!/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 diskstatWrapper():
"""
Wrapper for the diskstats_parse function that returns just the in and out.
"""
ds = diskstats_parse("sda")
return (ds["sda"]["writes"], ds["sda"]["reads"])
def sampleDisk():
"""
Get a sample of I/O from the disk.
"""
return makeSample(diskstatWrapper)
def diskstats_parse(dev=None):
"""
I found this on stackoverflow.
(http://stackoverflow.com/questions/3329165/python-library-for-monitoring-proc-diskstats)
"""
file_path = '/proc/diskstats'
result = {}
# ref: http://lxr.osuosl.org/source/Documentation/iostats.txt
columns_disk = ['m', 'mm', 'dev', 'reads', 'rd_mrg', 'rd_sectors',
'ms_reading', 'writes', 'wr_mrg', 'wr_sectors',
'ms_writing', 'cur_ios', 'ms_doing_io', 'ms_weighted']
columns_partition = ['m', 'mm', 'dev', 'reads', 'rd_sectors', 'writes', 'wr_sectors']
lines = open(file_path, 'r').readlines()
for line in lines:
if line == '': continue
split = line.split()
if len(split) != len(columns_disk) and len(split) != len(columns_partition):
# No match
continue
data = dict(zip(columns_disk, split))
if dev != None and dev != data['dev']:
continue
for key in data:
if key != 'dev':
data[key] = int(data[key])
result[data['dev']] = data
return result
#MAIN: __ __ __ __ __ __ __ __ __ __ __ __
#__/ \__/ \__/ \__/ \__/ \__/ \__/ \__/ \__/ \__/ \__/ \__/ \__/ \_
(indiff, outdiff) = sampleNet()
outstr = ""
outstr += "cpu: "+str(int(psutil.cpu_percent()))+"%\t"
outstr += "net: "+str(indiff/1000)+"|"+str(outdiff/1000)+" K/s\t"
(diskin, diskout) = sampleDisk()
outstr += "disk: "
if(diskin):
outstr += "+"
else:
outstr += "o"
outstr += "|"
if(diskout):
outstr += "+"
else:
outstr += "o"
print outstr
编辑:如果您要使用内存(作为报告由“顶部”)添加行
memperc = int(100*float(psutil.used_phymem())/float(psutil.TOTAL_PHYMEM))
outstr += "mem: "+str(memperc)+"%\t"
如果您具有psutil的2.0版,则可以通过以下行获取GNOME系统监视器报告的内存使用情况:
memperc = int(100*float(psutil.used_phymem()-psutil.cached_phymem())/float(psutil.TOTAL_PHYMEM))
如果您的空间很小,并且希望有单位净速度(b,k,M),则也可以使用此单位
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)
您可以从以下位置下载并安装软件包(.deb)
https://launchpad.net/indicator-sysmonitor/+在此处下载。安装后,您可以在“ 应用程序”>“附件”>“ Sysyem Monitor Indicator”下找到它,它在Unity中看起来像这样;
我对这个问题的看法:https://gist.github.com/982939
屏幕截图:
有人在开发用于指示器小程序的硬件传感器。请参阅是否有硬件温度传感器指示灯?
您可以从以下位置安装gnome系统监视器指示器的端口:https : //launchpad.net/~indicator-multiload/+archive/stable-daily
它不在顶部面板中,但是您可以使用Conky。
我不使用Conky,但其中有一些苗条的主题,我认为您可以始终将其放在首位。(尽管我不知道屏幕的哪一部分可以覆盖...)