How can I get the CPUs speed without root permissions?
Thanks.
How can I get the CPUs speed without root permissions?
Thanks.
I think that the pstat system calls are available to ordinary users, but I'm not sure. Try this script:
#!/usr/contrib/bin/perl
local($PSTAT, $PSTAT_PROCESSOR) = (239, 10); # pstat_getprocessor
local($struct_pst_processor) = ("L30");
local($cpu_info, $cpu_ticks);
$cpu_info = "\0" x 120;
syscall($PSTAT, $PSTAT_PROCESSOR, $cpu_info, length($cpu_info), 1, 0);
($cpu_ticks) = (unpack($struct_pst_processor, $cpu_info))[26];
print $cpu_ticks/10000 . "\n";
It worked on B.10.20, B.11.00 and B.11.11 versions. It fails on two B.11.23 servers, it says that cpu speed is 0. Any thoughts?