1
/******************************************************************************
2
* Copyright (C) 2011 Michael Hofmann <mh21@piware.de> *
4
* This program is free software; you can redistribute it and/or modify *
5
* it under the terms of the GNU General Public License as published by *
6
* the Free Software Foundation; either version 3 of the License, or *
7
* (at your option) any later version. *
9
* This program is distributed in the hope that it will be useful, *
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12
* GNU General Public License for more details. *
14
* You should have received a copy of the GNU General Public License along *
15
* with this program; if not, write to the Free Software Foundation, Inc., *
16
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
17
******************************************************************************/
19
public class CpuIconData : IconData {
20
private uint64[] lastdata;
22
public CpuIconData() {
23
base("cpuload", 4, 1, 1);
26
public override void update_traces() {
28
GTop.get_cpu(out cpu);
30
uint64[] newdata = new uint64[5];
31
newdata[0] = cpu.user;
32
newdata[1] = cpu.nice;
34
newdata[3] = cpu.iowait + cpu.irq + cpu.softirq;
35
newdata[4] = cpu.idle;
37
if (this.lastdata.length == 0) {
38
foreach (unowned IconTraceData trace in this.traces)
42
for (uint i = 0, isize = newdata.length; i < isize; ++i)
43
total += newdata[i] - this.lastdata[i];
44
for (uint i = 0, isize = this.traces.length; i < isize; ++i)
45
this.traces[i].add_value((newdata[i] - this.lastdata[i]) / total);
47
this.lastdata = newdata;