@@ -31,16 +31,20 @@ def getCpuInfo(self):
31
31
32
32
[{
33
33
'channel': 'sys:cpu;load',
34
- 'value': 12.8
34
+ 'value': 12.8,
35
+ 'type': 'cpuload',
36
+ 'unit': 'p'
35
37
}, {
36
38
'channel': 'sys:cpu;temp',
37
- 'value': 50.843
39
+ 'value': 50.843,
40
+ 'type': 'temp',
41
+ 'unit': 'c'
38
42
}]
39
43
"""
40
44
cpu_info = []
41
45
try :
42
- cayennemqtt .DataChannel .add (cpu_info , cayennemqtt .SYS_CPU , suffix = cayennemqtt .LOAD , value = psutil .cpu_percent (1 ))
43
- cayennemqtt .DataChannel .add (cpu_info , cayennemqtt .SYS_CPU , suffix = cayennemqtt .TEMPERATURE , value = CpuInfo .get_cpu_temp ())
46
+ cayennemqtt .DataChannel .add (cpu_info , cayennemqtt .SYS_CPU , suffix = cayennemqtt .LOAD , value = psutil .cpu_percent (1 ), type = 'cpuload' , unit = 'p' )
47
+ cayennemqtt .DataChannel .add (cpu_info , cayennemqtt .SYS_CPU , suffix = cayennemqtt .TEMPERATURE , value = CpuInfo .get_cpu_temp (), type = 'temp' , unit = 'c' )
44
48
except :
45
49
exception ('Error getting CPU info' )
46
50
return cpu_info
@@ -55,19 +59,23 @@ def getMemoryInfo(self, types):
55
59
56
60
[{
57
61
'channel': 'sys:ram;capacity',
58
- 'value': 968208384
62
+ 'value': 968208384,
63
+ 'type': 'memory',
64
+ 'type': 'b'
59
65
}, {
60
66
'channel': 'sys:ram;usage',
61
- 'value': 296620032
67
+ 'value': 296620032,
68
+ 'type': 'memory',
69
+ 'type': 'b'
62
70
}]
63
71
"""
64
72
memory_info = []
65
73
try :
66
74
vmem = psutil .virtual_memory ()
67
75
if not types or cayennemqtt .USAGE in types :
68
- cayennemqtt .DataChannel .add (memory_info , cayennemqtt .SYS_RAM , suffix = cayennemqtt .USAGE , value = vmem .total - vmem .available )
76
+ cayennemqtt .DataChannel .add (memory_info , cayennemqtt .SYS_RAM , suffix = cayennemqtt .USAGE , value = vmem .total - vmem .available , type = 'memory' , unit = 'b' )
69
77
if not types or cayennemqtt .CAPACITY in types :
70
- cayennemqtt .DataChannel .add (memory_info , cayennemqtt .SYS_RAM , suffix = cayennemqtt .CAPACITY , value = vmem .total )
78
+ cayennemqtt .DataChannel .add (memory_info , cayennemqtt .SYS_RAM , suffix = cayennemqtt .CAPACITY , value = vmem .total , type = 'memory' , unit = 'b' )
71
79
except :
72
80
exception ('Error getting memory info' )
73
81
return memory_info
@@ -82,16 +90,24 @@ def getDiskInfo(self, types):
82
90
83
91
[{
84
92
'channel': 'sys:storage:/;capacity',
85
- 'value': 13646516224
93
+ 'value': 13646516224,
94
+ 'type': 'memory',
95
+ 'type': 'b'
86
96
}, {
87
97
'channel': 'sys:storage:/;usage',
88
- 'value': 6353821696
98
+ 'value': 6353821696,
99
+ 'type': 'memory',
100
+ 'type': 'b'
89
101
}, {
90
102
'channel': 'sys:storage:/mnt/cdrom;capacity',
91
- 'value': 479383552
103
+ 'value': 479383552,
104
+ 'type': 'memory',
105
+ 'type': 'b'
92
106
}, {
93
107
'channel': 'sys:storage:/mnt/cdrom;usage',
94
- 'value': 0
108
+ 'value': 0,
109
+ 'type': 'memory',
110
+ 'type': 'b'
95
111
}]
96
112
"""
97
113
storage_info = []
@@ -102,9 +118,9 @@ def getDiskInfo(self, types):
102
118
usage = psutil .disk_usage (partition .mountpoint )
103
119
if usage .total :
104
120
if not types or cayennemqtt .USAGE in types :
105
- cayennemqtt .DataChannel .add (storage_info , cayennemqtt .SYS_STORAGE , partition .mountpoint , cayennemqtt .USAGE , usage .used )
121
+ cayennemqtt .DataChannel .add (storage_info , cayennemqtt .SYS_STORAGE , partition .mountpoint , cayennemqtt .USAGE , usage .used , type = 'memory' , unit = 'b' )
106
122
if not types or cayennemqtt .CAPACITY in types :
107
- cayennemqtt .DataChannel .add (storage_info , cayennemqtt .SYS_STORAGE , partition .mountpoint , cayennemqtt .CAPACITY , usage .total )
123
+ cayennemqtt .DataChannel .add (storage_info , cayennemqtt .SYS_STORAGE , partition .mountpoint , cayennemqtt .CAPACITY , usage .total , type = 'memory' , unit = 'b' )
108
124
except :
109
125
pass
110
126
except :
0 commit comments