Skip to content

Commit 93ea95b

Browse files
committed
feat(about-me): add option to avoid dmidecode and sudo (closes #948)
1 parent efa199e commit 93ea95b

File tree

5 files changed

+52
-10
lines changed

5 files changed

+52
-10
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
1111

1212
Monitoring Plugins:
1313

14+
* about-me: add option to avoid dmidecode and sudo ([#948](https://github.com/Linuxfabrik/lib/issues/948))
1415
* ntp-\*: add `--stratum` parameter and modernize code
1516
* sprint-boot-actuator-health: derived from [PR #940](https://github.com/Linuxfabrik/monitoring-plugins/pull/940), thanks to [Dominik Riva](https://github.com/slalomsk8er) - a monitoring plugin for the Spring Boot Actuator `/health` endpoint
1617
* virustotal-scan-url: analyses URLs to detect malware and other breaches using VirusTotal

check-plugins/about-me/README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,19 @@ Plugin execution may take up to 30 seconds, depending on the amount or type of i
3333
## Help
3434

3535
```text
36-
usage: about-me [-h] [-V] [--insecure] [--no-proxy]
36+
usage: about-me [-h] [-V] [--dmidecode] [--insecure] [--no-proxy]
3737
[--public-ip-url PUBLIC_IP_URL] [--tags] [--timeout TIMEOUT]
3838
3939
Provides a quick overview of host dimensions and software.
4040
4141
options:
4242
-h, --help show this help message and exit
4343
-V, --version show program's version number and exit
44+
--dmidecode Use the `dmidecode` command to gather additional
45+
hardware information, such as a list of the system's
46+
components, as well as other useful details like
47+
serial numbers and BIOS revisions. If enabled, this
48+
feature requires sudo permissions. Default: False
4449
--insecure This option explicitly allows to perform "insecure"
4550
SSL connections. Default: False
4651
--no-proxy Do not use a proxy. Default: False
@@ -60,7 +65,7 @@ options:
6065
## Usage Examples
6166

6267
```bash
63-
./about-me
68+
./about-me --dmidecode
6469
```
6570

6671
Shortened output example:

check-plugins/about-me/about-me

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,11 @@ except ImportError:
4040

4141

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

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

47+
DEFAULT_DMIDECODE = False
4748
DEFAULT_INSECURE = False
4849
DEFAULT_NO_PROXY = False
4950
DEFAULT_PUBLIC_IP_URL = None
@@ -61,6 +62,17 @@ def parse_args():
6162
version='{0}: v{1} by {2}'.format('%(prog)s', __version__, __author__)
6263
)
6364

65+
parser.add_argument(
66+
'--dmidecode',
67+
help='Use the `dmidecode` command to gather additional hardware information, such as a list '
68+
'of the system\'s components, as well as other useful details like serial numbers and '
69+
'BIOS revisions. If enabled, this feature requires sudo permissions. '
70+
'Default: %(default)s',
71+
dest='DMIDECODE',
72+
action='store_true',
73+
default=DEFAULT_DMIDECODE,
74+
)
75+
6476
parser.add_argument(
6577
'--insecure',
6678
help='This option explicitly allows to perform "insecure" SSL connections. '
@@ -806,7 +818,10 @@ def main():
806818
if firmware_device_model:
807819
msg += '{}, '.format(firmware_device_model)
808820

809-
dmi = lib.dmidecode.get_data()
821+
if args.DMIDECODE:
822+
dmi = lib.dmidecode.get_data()
823+
else:
824+
dmi = False
810825
sys_dimensions = get_sys_dimensions()
811826
if dmi and sys_dimensions:
812827
# combine the best from both worlds
@@ -845,6 +860,7 @@ def main():
845860
sys_dimensions['cpu_logical'],
846861
sys_dimensions['cpu_usable'],
847862
)
863+
msg += 'Current Speed: {} MHz, '.format(int(sys_dimensions['cpu_freq'][0]))
848864
msg += '{} RAM, '.format(
849865
lib.human.bytes2human(sys_dimensions['ram'])
850866
)
@@ -865,7 +881,8 @@ def main():
865881

866882

867883
# multi-line content - print further lines -----------------------------------------------------
868-
msg += get_hw_info()
884+
if args.DMIDECODE:
885+
msg += get_hw_info()
869886
msg += get_interfaces()
870887
msg += get_listening_ports()
871888
msg += get_nondefault_software()
@@ -893,7 +910,7 @@ def main():
893910
perfdata += lib.base.get_perfdata('cpu_logical', sys_dimensions['cpu_logical'], None, None, None, 0, None)
894911
perfdata += lib.base.get_perfdata('cpu_physical', sys_dimensions['cpu_physical'], None, None, None, 0, None)
895912
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))
913+
perfdata += lib.base.get_perfdata('cpu_freq', int(sys_dimensions['cpu_freq'][0]), None, None, None, 0, lib.dmidecode.cpu_speed(dmi) if args.DMIDECODE else None)
897914
if dmi:
898915
perfdata += lib.base.get_perfdata('ram', lib.dmidecode.ram(dmi), 'B', None, None, 0, None)
899916
elif sys_dimensions:

check-plugins/about-me/icingaweb2-module-director/about-me.json

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
"Command": {
33
"cmd-check-about-me": {
44
"arguments": {
5+
"--dmidecode": {
6+
"set_if": "$about_me_dmidecode$"
7+
},
58
"--insecure": {
69
"set_if": "$about_me_insecure$"
710
},
@@ -45,6 +48,11 @@
4548
"datafield_id": 5,
4649
"is_required": "n",
4750
"var_filter": null
51+
},
52+
{
53+
"datafield_id": 6,
54+
"is_required": "n",
55+
"var_filter": null
4856
}
4957
],
5058
"imports": [],
@@ -99,6 +107,7 @@
99107
"use_var_overrides": null,
100108
"vars": {
101109
"criticality": "C",
110+
"about_me_dmidecode": true,
102111
"about_me_insecure": false,
103112
"about_me_no_proxy": false,
104113
"about_me_tags": false,
@@ -111,6 +120,15 @@
111120
},
112121
"Datafield": {
113122
"1": {
123+
"varname": "about_me_dmidecode",
124+
"caption": "About Me: Dmidecode?",
125+
"description": "Use the `dmidecode` command to gather additional hardware information, such as a list of the system's components, as well as other useful details like serial numbers and BIOS revisions. If enabled, this feature requires sudo permissions.",
126+
"datatype": "Icinga\\Module\\Director\\DataType\\DataTypeBoolean",
127+
"format": null,
128+
"settings": {},
129+
"uuid": "0cecc7e6-6684-4e66-b3aa-ab98cab75eca"
130+
},
131+
"2": {
114132
"varname": "about_me_insecure",
115133
"caption": "About Me: Insecure?",
116134
"description": "This option explicitly allows to perform \"insecure\" SSL connections.",
@@ -119,7 +137,7 @@
119137
"settings": {},
120138
"uuid": "42dbeb20-a8c7-43ff-89d2-771e8c8fc5d0"
121139
},
122-
"2": {
140+
"3": {
123141
"varname": "about_me_no_proxy",
124142
"caption": "About Me: No Proxy?",
125143
"description": "Do not use a proxy.",
@@ -128,7 +146,7 @@
128146
"settings": {},
129147
"uuid": "1ef7aa98-4d41-4973-aecc-bf0f438f6f57"
130148
},
131-
"3": {
149+
"4": {
132150
"varname": "about_me_public_ip_url",
133151
"caption": "About Me: Public Ip URL",
134152
"description": "If you want this check to return the public IP address, specify one ore more comma-separated URLs to \"what is my ip\" online services. For example: \"https://ipv4.icanhazip.com,https://ipecho.net/plain,https://ipinfo.io/ip\" (these examples are located in the United States).",
@@ -139,7 +157,7 @@
139157
},
140158
"uuid": "d8dad468-3de3-4ffd-9db8-ff414b55e619"
141159
},
142-
"4": {
160+
"5": {
143161
"varname": "about_me_tags",
144162
"caption": "About Me: Tags?",
145163
"description": "Guess a list of tags to apply in Icinga Director (Linuxfabrik Basket Config).",
@@ -148,7 +166,7 @@
148166
"settings": {},
149167
"uuid": "c1687513-03a9-4599-bac4-468e29b45ae2"
150168
},
151-
"5": {
169+
"6": {
152170
"varname": "about_me_timeout",
153171
"caption": "About Me: Timeout",
154172
"description": "Network timeout in seconds.",

check-plugins/about-me/icingaweb2-module-director/about-me.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ overwrites:
55
'["ServiceTemplate"]["tpl-service-about-me"]["check_interval"]': 86400
66
'["ServiceTemplate"]["tpl-service-about-me"]["enable_perfdata"]': true
77
'["ServiceTemplate"]["tpl-service-about-me"]["retry_interval"]': 3600
8+
'["ServiceTemplate"]["tpl-service-about-me"]["vars"]["about_me_dmidecode"]': true

0 commit comments

Comments
 (0)