Move collection of system information to cache
This commit is contained in:
parent
1480f2eab4
commit
b9a43a41b6
@ -400,6 +400,15 @@ configure_node_info() {
|
|||||||
[nN]) info "System information disabled." ;;
|
[nN]) info "System information disabled." ;;
|
||||||
*) warn "Invalid selection. Defaulting to type 1."; ENABLE_SYSTEM_INFO=1; SYSTEM_INFO_TYPE=1 ;;
|
*) warn "Invalid selection. Defaulting to type 1."; ENABLE_SYSTEM_INFO=1; SYSTEM_INFO_TYPE=1 ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
if [[ "$ENABLE_SYSTEM_INFO" -eq 1 ]]; then
|
||||||
|
local cache_dir="/var/lib/pve-mod"
|
||||||
|
mkdir -p "$cache_dir"
|
||||||
|
local cache_file="${cache_dir}/dmidecode-type${SYSTEM_INFO_TYPE}.txt"
|
||||||
|
dmidecode -t "$SYSTEM_INFO_TYPE" > "$cache_file" 2>/dev/null || true
|
||||||
|
chmod 644 "$cache_file"
|
||||||
|
info "DMI data cached to $cache_file"
|
||||||
|
fi
|
||||||
#endregion System info
|
#endregion System info
|
||||||
}
|
}
|
||||||
#endregion node-info wizard
|
#endregion node-info wizard
|
||||||
|
|||||||
@ -44,10 +44,16 @@ sub get_system_information_data {
|
|||||||
sub _get_system_info {
|
sub _get_system_info {
|
||||||
my ($type) = @_;
|
my ($type) = @_;
|
||||||
|
|
||||||
my $output = `/usr/sbin/dmidecode -t $type 2>/dev/null`;
|
my $cache_file = "/var/lib/pve-mod/dmidecode-type${type}.txt";
|
||||||
|
my $output;
|
||||||
|
if (open(my $fh, '<', $cache_file)) {
|
||||||
|
local $/;
|
||||||
|
$output = <$fh>;
|
||||||
|
close($fh);
|
||||||
|
}
|
||||||
|
|
||||||
unless (defined $output && length($output) > 0) {
|
unless (defined $output && length($output) > 0) {
|
||||||
debug(__LINE__, "No output from dmidecode -t $type");
|
debug(__LINE__, "No cached DMI data at $cache_file — re-run pve-mod-configure as root to refresh");
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -151,7 +151,7 @@ sub _load_graphics_data {
|
|||||||
|
|
||||||
sub get_graphic_info {
|
sub get_graphic_info {
|
||||||
if (!$config{gpu}{intel_enabled} && !$config{gpu}{nvidia_enabled} && !$config{gpu}{amd_enabled}) {
|
if (!$config{gpu}{intel_enabled} && !$config{gpu}{nvidia_enabled} && !$config{gpu}{amd_enabled}) {
|
||||||
return null;
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
debug(__LINE__, "get_graphic_info called");
|
debug(__LINE__, "get_graphic_info called");
|
||||||
@ -169,7 +169,7 @@ sub get_graphic_info {
|
|||||||
|
|
||||||
sub get_sensors_info {
|
sub get_sensors_info {
|
||||||
if (!$config{lm_sensors}{enabled}) {
|
if (!$config{lm_sensors}{enabled}) {
|
||||||
return null;
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
debug(__LINE__, "get_sensors_info called");
|
debug(__LINE__, "get_sensors_info called");
|
||||||
@ -187,7 +187,7 @@ sub get_sensors_info {
|
|||||||
|
|
||||||
sub get_ups_info {
|
sub get_ups_info {
|
||||||
if (!$config{ups}{enabled}) {
|
if (!$config{ups}{enabled}) {
|
||||||
return null;
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
debug(__LINE__, "get_ups_info called");
|
debug(__LINE__, "get_ups_info called");
|
||||||
@ -216,7 +216,7 @@ sub get_pve_mod_version {
|
|||||||
|
|
||||||
sub get_system_information {
|
sub get_system_information {
|
||||||
if (!$config{system_info}{enabled}) {
|
if (!$config{system_info}{enabled}) {
|
||||||
return null;
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
debug(__LINE__, "get_system_information called");
|
debug(__LINE__, "get_system_information called");
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user