Skip to content

Commit e4bb253

Browse files
committed
refactor(about-me): report current cpu frequency and avoid dmidecode noise, new perfdata
1 parent d00a3ab commit e4bb253

File tree

4 files changed

+82
-43
lines changed

4 files changed

+82
-43
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ Icinga Director:
6363

6464
Monitoring Plugins:
6565

66+
* about-me: report current cpu frequency and avoid dmidecode noise, new perfdata
6667
* cpu-usage: non-blocking behaviour (interval=None + manual deltas via SQLite DB) so we get both accuracy and faster runtime
6768
* disk-io: modernize code
6869
* gitlab-health: increase timeout from 3 to 8 secs

check-plugins/about-me/README.md

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -67,17 +67,17 @@ Shortened output example:
6767

6868
```text
6969
Plugin Output
70-
server.example.com: Fedora Linux 39 (Workstation Edition) Kernel 6.8.4-200.fc39.x86_64 on Bare-Metal, Dell Inc. XPS 13 9310, Firmware: n/a, SerNo: 39d3e1cd, Proc: 11th Gen Intel Core i7-1185G7 @ 3.00GHz, #Cores: 4, #Threads: 8, Current Speed: 3000 MHz, 16.0GiB RAM, Disk nvme0n1 1.8T, UEFI boot, Display Server wayland, tuned profile "throughput-performance", born 2024-03-20. About-me v2024041001
71-
72-
Hardware Info:
73-
* BIOS: Dell Inc., Ver 3.21.0 (released 02/01/2024), ROM 32 MB
74-
* SysInfo: Dell Inc. XPS 13 9310, SerNo 39d3e1cd, SKU N/A, Wake-up Type "Other",
75-
UUID 4c4c4544-0044-5a10-8052-c4c04f334a33
76-
* Base Board: Type Motherboard Dell Inc. 07P9Y7, SerNo /2cc8a595/20ca3e48/, Ver A00
77-
* Chassis: Dell Inc., Type Notebook, SKU N/A, SerNo 875b42b9
70+
server.example.com: Fedora Linux 42 (Workstation Edition) Kernel 6.16.4-200.fc42.x86_64 on Bare-Metal, Dell Inc. XPS 13 9350, Firmware: 1.20, SerNo: 12345678, Proc: Intel Core Ultra 7 258V, CPUs: 8/8/8 (phys/lcpu/onln), Current Speed: 3943 MHz, 30.9GiB/4.0GiB RAM (virtmem/max; reboot recommended), Disk nvme0n1 1.8T, UEFI boot, Display Server x11, tuned profile "throughput-performance", born 2024-03-20. About-me v2025090901
71+
72+
Hardware Info from `dmidecode`:
73+
* BIOS: Dell Inc., Ver 1.13.0 (released 07/11/2025), ROM 64 MB
74+
* SysInfo: Dell Inc. XPS 13 9350, SerNo 12345678, SKU n/a, Wake-up Type "Other",
75+
UUID 4c4c4544-005a-5110-804a-b8c04f593834
76+
* Base Board: Type Motherboard Dell Inc. 0MMW13, SerNo /12345678/98765432/, Ver A01
77+
* Chassis: Dell Inc., Type Notebook, SKU n/a, SerNo 12345678
7878
States: boot-up=Safe, pwr-supply=Safe, thermal=Safe, security=None
79-
* Proc: Intel(R) Corporation, Ver 11th Gen Intel(R) Core(TM) i7-1185G7 @ 3.00GHz,
80-
Speed 3000 MHz/3000 MHz max., 4/4 Cores enabled, 8 Threads, Voltage 0.8 V
79+
* Proc: Intel(R) Corporation, Ver Intel(R) Core(TM) Ultra 7 258V,
80+
Speed 4700 MHz/4800 MHz max., 8/8 Cores enabled, 8 Threads, Voltage 1.0 V
8181
* System Boot: No errors detected
8282
8383
Interfaces (IPv4):
@@ -147,14 +147,13 @@ crontab:
147147

148148
| Name | Type | Description |
149149
|----|----|----|
150-
| cpu | Number | Number of CPUs (if `dmidecode` is not available) |
151-
| cpu_cores_enabled | Number | Number of enabled CPU cores (if `dmidecode` is available) |
152-
| cpu_speed | Number | CPU speed (if `dmidecode` is available) |
153-
| cpu_threads | Number | Number of CPU cores with Hyper-Threading enabled (if `dmidecode` is available) |
150+
| cpu_logical | Number | Number of physical cores multiplied by the number of threads that can run on each core (this is known as Hyper Threading) |
151+
| cpu_physical | Number | Number of physical cores |
152+
| cpu_usable | Number | The number of usable CPUs. This may not necessarily be equivalent to the actual number of CPUs the current process can use. That can vary in case process CPU affinity has been changed, Linux cgroups are being used or (in case of Windows) on systems using processor groups or having more than 64 CPUs. |
153+
| cpu_freq | Number | On Linux reports the current real-time value, on all other platforms this usually represents the nominal "fixed" value (never changing) |
154154
| disks | Number | Number of disks |
155155
| osversion | None | 'Fedora 33' becomes '33', 'CentOS 7.4.1708' becomes '741708' - to see when an upgrade happened |
156-
| ram | Bytes | Size of memory (if `dmidecode` is not available) |
157-
| ram | Bytes | Size of memory (if `dmidecode` is available) |
156+
| ram | Bytes | Size of memory |
158157

159158

160159
## Credits, License

check-plugins/about-me/about-me

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ except ImportError:
4040

4141

4242
__author__ = 'Linuxfabrik GmbH, Zurich/Switzerland'
43-
__version__ = '2025062002 / v2.1.1'
43+
__version__ = '2025090901 / v2.1.1'
4444

4545
DESCRIPTION = 'Provides a quick overview of host dimensions and software.'
4646

@@ -239,7 +239,7 @@ def get_hw_info():
239239
value.get('UUID', 'n/a').replace('Default string', 'n/a'),
240240
)
241241
if output:
242-
return 'Hardware Info:\n{}\n'.format(output)
242+
return 'Hardware Info (`dmidecode`):\n{}\n'.format(output)
243243
return output
244244

245245

@@ -626,7 +626,10 @@ def get_sys_dimensions():
626626
"""
627627
sys_dimensions = {}
628628
try:
629-
sys_dimensions['cpu'] = psutil.cpu_count(logical=True)
629+
sys_dimensions['cpu_logical'] = psutil.cpu_count(logical=True)
630+
sys_dimensions['cpu_physical'] = psutil.cpu_count(logical=False)
631+
sys_dimensions['cpu_usable'] = psutil.cpu_count(logical=True)
632+
sys_dimensions['cpu_freq'] = psutil.cpu_freq()
630633
sys_dimensions['ram'] = psutil.virtual_memory().total
631634
except:
632635
pass
@@ -811,9 +814,12 @@ def main():
811814
msg += 'Firmware: {}, '.format(lib.dmidecode.firmware(dmi))
812815
msg += 'SerNo: {}, '.format(lib.dmidecode.serno(dmi))
813816
msg += 'Proc: {}, '.format(lib.dmidecode.cpu_type(dmi))
814-
msg += '#Cores: {}, '.format(lib.dmidecode.cpu_cores_enabled(dmi))
815-
msg += '#Threads: {}, '.format(lib.dmidecode.cpu_threads(dmi))
816-
msg += 'Current Speed: {} MHz, '.format(lib.dmidecode.cpu_speed(dmi))
817+
msg += 'CPUs: {}/{}/{} (phys/lcpu/onln), '.format(
818+
sys_dimensions['cpu_physical'],
819+
sys_dimensions['cpu_logical'],
820+
sys_dimensions['cpu_usable'],
821+
)
822+
msg += 'Current Speed: {} MHz, '.format(int(sys_dimensions['cpu_freq'][0]))
817823
msg += '{}/{} RAM (virtmem/max'.format(
818824
lib.human.bytes2human(sys_dimensions['ram']),
819825
lib.human.bytes2human(lib.dmidecode.ram(dmi)),
@@ -826,14 +832,20 @@ def main():
826832
msg += 'Firmware: {}, '.format(lib.dmidecode.firmware(dmi))
827833
msg += 'SerNo: {}, '.format(lib.dmidecode.serno(dmi))
828834
msg += 'Proc: {}, '.format(lib.dmidecode.cpu_type(dmi))
829-
msg += '#Cores: {}, '.format(lib.dmidecode.cpu_cores_enabled(dmi))
830-
msg += '#Threads: {}, '.format(lib.dmidecode.cpu_threads(dmi))
831-
msg += 'Current Speed: {} MHz, '.format(lib.dmidecode.cpu_speed(dmi))
835+
msg += 'CPUs: {}/{}/{} (phys/lcpu/onln), '.format(
836+
sys_dimensions['cpu_physical'],
837+
sys_dimensions['cpu_logical'],
838+
sys_dimensions['cpu_usable'],
839+
)
840+
msg += 'Current Speed: {} MHz, '.format(int(sys_dimensions['cpu_freq'][0]))
832841
msg += '{} RAM, '.format(lib.human.bytes2human(lib.dmidecode.ram(dmi)))
833842
elif sys_dimensions:
834-
msg += '{} {}, {} RAM, '.format(
835-
sys_dimensions['cpu'],
836-
lib.txt.pluralize('CPU', sys_dimensions['cpu']),
843+
msg += 'CPUs: {}/{}/{} (phys/lcpu/onln), '.format(
844+
sys_dimensions['cpu_physical'],
845+
sys_dimensions['cpu_logical'],
846+
sys_dimensions['cpu_usable'],
847+
)
848+
msg += '{} RAM, '.format(
837849
lib.human.bytes2human(sys_dimensions['ram'])
838850
)
839851
else:
@@ -878,13 +890,13 @@ def main():
878890
re_search = re.search(r'[\d\.]+', os_info)
879891
if re_search:
880892
perfdata += lib.base.get_perfdata('osversion', re_search.group(0).replace('.', ''), None, None, None, None, None) # pylint: disable=C0301
893+
perfdata += lib.base.get_perfdata('cpu_logical', sys_dimensions['cpu_logical'], None, None, None, 0, None)
894+
perfdata += lib.base.get_perfdata('cpu_physical', sys_dimensions['cpu_physical'], None, None, None, 0, None)
895+
perfdata += lib.base.get_perfdata('cpu_usable', sys_dimensions['cpu_usable'], None, None, None, 0, None)
896+
perfdata += lib.base.get_perfdata('cpu_freq', int(sys_dimensions['cpu_freq'][0]), None, None, None, 0, lib.dmidecode.cpu_speed(dmi))
881897
if dmi:
882-
perfdata += lib.base.get_perfdata('cpu_cores_enabled', lib.dmidecode.cpu_cores_enabled(dmi), None, None, None, 0, None) # pylint: disable=C0301
883-
perfdata += lib.base.get_perfdata('cpu_threads', lib.dmidecode.cpu_threads(dmi), None, None, None, 0, None) # pylint: disable=C0301
884-
perfdata += lib.base.get_perfdata('cpu_speed', lib.dmidecode.cpu_speed(dmi), None, None, None, 0, None) # pylint: disable=C0301
885898
perfdata += lib.base.get_perfdata('ram', lib.dmidecode.ram(dmi), 'B', None, None, 0, None)
886899
elif sys_dimensions:
887-
perfdata += lib.base.get_perfdata('cpu', sys_dimensions['cpu'], None, None, None, 0, None)
888900
perfdata += lib.base.get_perfdata('ram', sys_dimensions['ram'], 'B', None, None, 0, None)
889901
perfdata += lib.base.get_perfdata('disks', disk_count, None, None, None, 0, None)
890902

check-plugins/about-me/grafana/about-me.yml

Lines changed: 38 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ spec:
4848

4949
panels:
5050

51-
- title: About me - CPU Cores, Threads and Disks
51+
- title: About me - CPUs and Disks
5252
type: timeseries
5353
gridPos:
5454
h: 8
@@ -80,8 +80,8 @@ spec:
8080

8181
targets:
8282

83-
- alias: cpu_cores_enabled
84-
refId: cpu_cores_enabled
83+
- alias: cpu_logical
84+
refId: cpu_logical
8585
groupBy:
8686
- params:
8787
- $interval
@@ -105,10 +105,10 @@ spec:
105105
- condition: AND
106106
key: metric
107107
operator: '='
108-
value: cpu_cores_enabled
108+
value: cpu_logical
109109

110-
- alias: cpu_threads
111-
refId: cpu_threads
110+
- alias: cpu_usable
111+
refId: cpu_usable
112112
groupBy:
113113
- params:
114114
- $interval
@@ -132,7 +132,34 @@ spec:
132132
- condition: AND
133133
key: metric
134134
operator: '='
135-
value: cpu_threads
135+
value: cpu_physical
136+
137+
- alias: cpu_usable
138+
refId: cpu_usable
139+
groupBy:
140+
- params:
141+
- $interval
142+
type: time
143+
measurement: $command
144+
resultFormat: time_series
145+
select:
146+
- - params:
147+
- value
148+
type: field
149+
- params: []
150+
type: mean
151+
tags:
152+
- key: hostname
153+
operator: '='
154+
value: $hostname
155+
- condition: AND
156+
key: service
157+
operator: '='
158+
value: $service
159+
- condition: AND
160+
key: metric
161+
operator: '='
162+
value: cpu_usable
136163

137164
- alias: disks
138165
refId: disks
@@ -162,7 +189,7 @@ spec:
162189
value: disks
163190

164191

165-
- title: About me - CPU Speed
192+
- title: About me - CPU Frequency
166193
type: timeseries
167194
gridPos:
168195
h: 8
@@ -197,8 +224,8 @@ spec:
197224

198225
targets:
199226

200-
- alias: cpu_speed
201-
refId: cpu_speed
227+
- alias: cpu_freq
228+
refId: cpu_freq
202229
groupBy:
203230
- params:
204231
- $interval
@@ -222,7 +249,7 @@ spec:
222249
- condition: AND
223250
key: metric
224251
operator: '='
225-
value: cpu_speed
252+
value: cpu_freq
226253

227254

228255
- title: About me - RAM

0 commit comments

Comments
 (0)