Skip to content
This repository was archived by the owner on Nov 24, 2021. It is now read-only.

Commit 3a60df9

Browse files
author
Aurélien HÉBERT
authored
Merge pull request #70 from othalla/add_cpu_idle
Add cpu idle
2 parents 3530fe7 + fe757df commit 3a60df9

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

Readme.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,19 +52,21 @@ Noderig have some built-in collectors.
5252
<tr><td><b>Level</b></td><td><b>Metric</b></td><td><b>Description</b></td><td><b>Module</b></td></tr>
5353
<tr><td>0</td><td></td><td>disabled metrics</td><td></td></tr>
5454
<tr><td>1</td><td>os.cpu{}</td><td>combined percentage of cpu usage</td><td></td></tr>
55-
<tr><td rowspan="6">2</td><td>os.cpu.iowait{}</td><td>combined percentage of cpu iowait</td><td></td></tr>
55+
<tr><td rowspan="7">2</td><td>os.cpu.iowait{}</td><td>combined percentage of cpu iowait</td><td></td></tr>
5656
<tr><td>os.cpu.user{}</td><td>combined percentage of cpu user</td><td></td></tr>
5757
<tr><td>os.cpu.systems{}</td><td>combined percentage of cpu systems</td><td></td></tr>
5858
<tr><td>os.cpu.nice{}</td><td>combined percentage of cpu nice</td><td></td></tr>
5959
<tr><td>os.cpu.irq{}</td><td>combined percentage of cpu irq</td><td></td></tr>
6060
<tr><td>os.cpu.steal{}</td><td>combined percentage of cpu stolen</td><td></td></tr>
61+
<tr><td>os.cpu.idlel{}</td><td>combined percentage of cpu idle</td><td></td></tr>
6162
<tr><td>os.cpu.temperature{id=n}</td><td>temperature of cpu n</td><td>temperature</td></tr>
62-
<tr><td rowspan="6">3</td><td>os.cpu.iowait{chore=n}</td><td>chore percentage of cpu iowait</td><td></td></tr>
63+
<tr><td rowspan="7">3</td><td>os.cpu.iowait{chore=n}</td><td>chore percentage of cpu iowait</td><td></td></tr>
6364
<tr><td>os.cpu.user{chore=n}</td><td>chore percentage of cpu user</td><td></td></tr>
6465
<tr><td>os.cpu.systems{chore=n}</td><td>chore percentage of cpu systems</td><td></td></tr>
6566
<tr><td>os.cpu.nice{chore=n}</td><td>chore percentage of cpu nice</td><td></td></tr>
6667
<tr><td>os.cpu.irq{chore=n}</td><td>chore percentage of cpu irq</td><td></td></tr>
6768
<tr><td>os.cpu.steal{chore=n}</td><td>chore percentage of cpu stolen</td><td></td></tr>
69+
<tr><td>os.cpu.idle{chore=n}</td><td>chore percentage of cpu idle</td><td></td></tr>
6870
<tr><td>os.cpu.temperature{core=n}</td><td>temperature of cpu core n</td><td>temperature</td></tr>
6971
</table>
7072

collectors/cpu.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,14 @@ func (c *CPU) scrape() error {
155155
steal = steal / float64(len(steals)) * 100
156156
gts = core.GetSeriesOutput(now, class+".steal", "{}", steal)
157157
c.sensision.WriteString(gts)
158+
159+
idle := 0.0
160+
for _, v := range idles {
161+
idle += v
162+
}
163+
idle = idle / float64(len(idles)) * 100
164+
gts = core.GetSeriesOutput(now, class+".idle", "{}", idle)
165+
c.sensision.WriteString(gts)
158166
}
159167

160168
if c.level == 3 {
@@ -194,6 +202,12 @@ func (c *CPU) scrape() error {
194202
fmt.Sprintf("{%v}", core.ToLabels("chore", i)), v*100)
195203
c.sensision.WriteString(gts)
196204
}
205+
206+
for i, v := range idles {
207+
gts := core.GetSeriesOutput(now, fmt.Sprintf("%v.idle", class),
208+
fmt.Sprintf("{%v}", core.ToLabels("chore", i)), v*100)
209+
c.sensision.WriteString(gts)
210+
}
197211
}
198212

199213
for _, m := range c.modules {

0 commit comments

Comments
 (0)