commit - 64f346d50926b5d9473a31d58031572fab73c51f
commit + 6aee18206b3632763643bf255e706057add1470b
blob - 0e828eb7f0d9f8f97a99b8ce8af3e9a6ba875a72
blob + 6b625eb50f4fa3a0f3049030dba3e1ef87696bd4
--- sysinfo.pl
+++ sysinfo.pl
}
if ($netbsd) {
if ($alpha) {
- @cpu = grep( /^COMPAQ/, @dmesgboot );
- $cpu = join( "\n", $cpu[0] );
- @cpu = split( /, /, $cpu );
- $cpu = $cpu[0];
+ my @alpha_cpu_lines = grep( /^COMPAQ/, @dmesgboot );
+ $cpu = join( "\n", $alpha_cpu_lines[0] // '' );
+ my @alpha_parts = split( /, /, $cpu );
+ $cpu = $alpha_parts[0] // $cpu;
}
else {
- @cpu = grep( /^v?cpu0.*MHz/, @dmesgboot );
- @cpu = grep( !/apic/, @cpu );
- @cpu = split( /: /, $cpu[0] );
- $cpu = $cpu[1];
- $cpu =~ s/, id.*//;
- $mhz = $cpu;
- $mhz =~ s/.* ([.0-9]+) *MHz.*$/$1/;
- $cpu =~ s/,.*//;
- $cpu = "$cpu ($mhz MHz)";
- my $ncpu_output = run_command_scalar("$sysctl -n hw.ncpu");
+ my ($cpu_line) =
+ grep { /^v?cpu0.*MHz/ && !/apic/ } @dmesgboot;
+ if ( defined $cpu_line ) {
+ my ( undef, $cpu_details ) = split( /: /, $cpu_line, 2 );
+ if ( defined $cpu_details ) {
+ $cpu_details =~ s/, id.*//;
+ my $local_mhz;
+ if ( $cpu_details =~ /([.0-9]+)\s*MHz/ ) {
+ $local_mhz = $1;
+ }
+ $cpu_details =~ s/,.*//;
+ $cpu = defined $local_mhz
+ ? "$cpu_details ($local_mhz MHz)"
+ : $cpu_details;
+ }
+ }
- if ( defined $ncpu_output ) {
- $smp = $ncpu_output;
- if ( $smp eq "1" ) {
- $smp = "";
+ if ( !defined $cpu || $cpu eq '' ) {
+ my $brand = run_command_scalar("$sysctl -n machdep.cpu_brand");
+ $brand = run_command_scalar("$sysctl -n machdep.cpu_name")
+ unless defined $brand && $brand ne '';
+ $brand = run_command_scalar("$sysctl -n machdep.cpu_model")
+ unless defined $brand && $brand ne '';
+ if ( defined $brand && $brand ne '' ) {
+ $cpu = $brand;
}
+ my $freq_hz = run_command_scalar("$sysctl -n machdep.tsc_freq");
+ if ( defined $freq_hz && $freq_hz =~ /^\d+$/ && $freq_hz > 0 ) {
+ my $local_mhz = sprintf( "%.2f", $freq_hz / 1_000_000 );
+ $cpu =
+ defined $cpu && $cpu ne ''
+ ? "$cpu ($local_mhz MHz)"
+ : "$local_mhz MHz";
+ }
}
}
+
+ $cpu = 'Unknown CPU' unless defined $cpu && $cpu ne '';
+
+ my $ncpu_output = run_command_scalar("$sysctl -n hw.ncpu");
+
+ if ( defined $ncpu_output ) {
+ $smp = $ncpu_output;
+ if ( $smp eq "1" ) {
+ $smp = "";
+ }
+ }
}
if ($openbsd) {
@cpu = grep( /cpu0: /, @dmesgboot );
blob - /dev/null
blob + 9d656dd0284c86b8a6912e18d261520b630469cb (mode 644)
--- /dev/null
+++ changelog.md
+# Changelog
+
+## Original import (277-281.16)
+
+...
+
+## [3.0.1] - 2025-11-01
+
+### Added
+
+- NetBSD detection improvements using dmesg with fallback to `sysctl -n machdep.*`. New POSIX _NPROCESSORS_CONF fallback.
+
+## [3.0.0] - 2025-11-01
+
+### Added
+
+- Command helpers and refreshed distro/CPU discovery so the script no longer depends on crude shell pipelines.
+- Linux distro detection nos prefers /etc/os-release with a fallback to legacy *-release files.
+- Simplified Solaris/macOS CPU parsing and now feed every platform’s count through detect_cpu_count, which relies on getconf _NPROCESSORS_CONF when available (thanks, Monkfish!).
+- Normalised one-off command calls (incl. initial uname probes) to go through run_command_scalar, with warnings enabled.
+- Helper routines for command exec and os-release parsing.
+- Network stats helpers now use lexical scratch variables instead of shared globals.
+- Modernised file/process/uptime utilities to use Perl parsing rather than shell pipes.
\ No newline at end of file