File tree Expand file tree Collapse file tree 1 file changed +62
-0
lines changed Expand file tree Collapse file tree 1 file changed +62
-0
lines changed Original file line number Diff line number Diff line change
1
+ #!/usr/bin/awk -f
2
+
3
+ #
4
+ # Converts output of `ipmitool dcmi power reading` to prometheus format.
5
+ #
6
+ # With GNU awk:
7
+ # ipmitool dcmi power reading | ./ipmitool_dcmi > dcmi.prom
8
+
9
+ # With BSD awk:
10
+ # ipmitool dcmi power reading | awk -f ./ipmitool_dcmi > dcmi.prom
11
+ #
12
+
13
+ BEGIN {
14
+ namespace = " node_ipmi_dcmi_power_" ;
15
+
16
+ power_count = 0 ;
17
+ sample_period = 0 ;
18
+ }
19
+
20
+ # Parse power readings
21
+ /Instantaneous power reading:[ ]+ [0 -9 ]+ Watts / {
22
+ power[ " instantaneous" ] = $4 ;
23
+ power_count++ ;
24
+ }
25
+
26
+ /Minimum during sampling period:[ ]+ [0 -9 ]+ Watts / {
27
+ power[ " minimum" ] = $5 ;
28
+ power_count++ ;
29
+ }
30
+
31
+ /Maximum during sampling period:[ ]+ [0 -9 ]+ Watts / {
32
+ power[ " maximum" ] = $5 ;
33
+ power_count++ ;
34
+ }
35
+
36
+ /Average power reading over sample period:[ ]+ [0 -9 ]+ Watts / {
37
+ power[ " average" ] = $7 ;
38
+ power_count++ ;
39
+ }
40
+
41
+ # Parse sampling period
42
+ /Sampling period:[ ]+ [0 -9 ]+ Seconds / {
43
+ sample_period = $3 ;
44
+ }
45
+
46
+ END {
47
+ if (power_count > 0 ) {
48
+ printf (" # HELP %swatts Power reading from ipmitool dcmi\n " , namespace);
49
+ printf (" # TYPE %swatts gauge\n " , namespace);
50
+
51
+ for (type in power) {
52
+ printf (" %swatts{type=\" %s\" } %s\n " , namespace, type, power[ type] );
53
+ }
54
+ }
55
+
56
+ if (sample_period > 0 ) {
57
+ printf (" # HELP %ssample_period_seconds Sampling period for aggregate power readings\n " , namespace);
58
+ printf (" # TYPE %ssample_period_seconds counter\n " , namespace);
59
+ printf (" %ssample_period_seconds %d\n " , namespace, sample_period);
60
+ }
61
+ }
62
+
You can’t perform that action at this time.
0 commit comments