diff options
| author | Christian Breunig <christian@breunig.cc> | 2026-04-12 09:31:58 +0200 |
|---|---|---|
| committer | Christian Breunig <christian@breunig.cc> | 2026-04-12 09:35:52 +0200 |
| commit | 5e0c08a3032fb748c88a6ac10f3cf2a31a232433 (patch) | |
| tree | 4551a77d73ebe9dd6b0cc8461e20e9a43484d01b | |
| parent | b7d191cd3053a736fa14ebfefe7a95093b0fcacd (diff) | |
| download | vyos-1x-5e0c08a3032fb748c88a6ac10f3cf2a31a232433.tar.gz vyos-1x-5e0c08a3032fb748c88a6ac10f3cf2a31a232433.zip | |
op-mode: T8483: fix /show_sensors.py: No such file or directory
After rewriting the op-mode handlind code and introducing virtualTagNodes for
op-mode, also all <command> statements will be executed by a runner. Executing
"bash -c ''" code within that runner lacks the proper environment.
This can be verified by adding "env" into the bash -c '' executions string.
Solve this issue by moving the hypervisor detection code to show_sensors.py.
| -rw-r--r-- | op-mode-definitions/show-environment.xml.in | 3 | ||||
| -rwxr-xr-x | src/op_mode/show_sensors.py | 8 |
2 files changed, 9 insertions, 2 deletions
diff --git a/op-mode-definitions/show-environment.xml.in b/op-mode-definitions/show-environment.xml.in index c71048ffc..5f4d38025 100644 --- a/op-mode-definitions/show-environment.xml.in +++ b/op-mode-definitions/show-environment.xml.in @@ -11,8 +11,7 @@ <properties> <help>Show hardware monitoring results</help> </properties> - <!-- Linux always adds "hypervisor" to CPU flags --> - <command>bash -c 'if ! grep -q hypervisor /proc/cpuinfo; then ${vyos_op_scripts_dir}/show_sensors.py; else echo "VyOS running under hypervisor, no sensors available"; fi'</command> + <command>${vyos_op_scripts_dir}/show_sensors.py</command> </leafNode> </children> </node> diff --git a/src/op_mode/show_sensors.py b/src/op_mode/show_sensors.py index 1efcc9aec..365a358ac 100755 --- a/src/op_mode/show_sensors.py +++ b/src/op_mode/show_sensors.py @@ -17,9 +17,17 @@ import re import sys + +from vyos.utils.file import read_file from vyos.utils.process import popen from vyos.utils.process import DEVNULL +cpu_info = read_file('/proc/cpuinfo') +# Linux always adds "hypervisor" to CPU flags +if 'hypervisor' in cpu_info: + print('VyOS running under hypervisor, no sensors available!') + sys.exit(1) + output,retcode = popen("sensors --no-adapter", stderr=DEVNULL) if retcode == 0: print (output) |
