| 1 | #!/usr/bin/env perl | ||
| 2 | #=============================================================================== | ||
| 3 | # | ||
| 4 | # FILE: cpus.pl | ||
| 5 | # | ||
| 6 | # USAGE: ./cpus.pl | ||
| 7 | # | ||
| 8 | # DESCRIPTION: | ||
| 9 | # | ||
| 10 | # OPTIONS: --- | ||
| 11 | # REQUIREMENTS: --- | ||
| 12 | # BUGS: --- | ||
| 13 | # NOTES: --- | ||
| 14 | # AUTHOR: Jillian Rowe (), jir2004@qatar-med.cornell.edu | ||
| 15 | # COMPANY: Weill Cornell Medical College Qatar | ||
| 16 | # VERSION: 1.0 | ||
| 17 | # CREATED: 26/02/15 13:38:54 | ||
| 18 | # REVISION: --- | ||
| 19 | #=============================================================================== | ||
| 20 | |||
| 21 | package Main; | ||
| 22 | |||
| 23 | use Sys::Info; | ||
| 24 | use Sys::Info::Constants qw( :device_cpu ); | ||
| 25 | |||
| 26 | my $info = Sys::Info->new; | ||
| 27 | my %options; | ||
| 28 | my $cpu = $info->device( CPU => %options ); | ||
| 29 | |||
| 30 | printf "CPU: %s\n", scalar($cpu->identify) || 'N/A'; | ||
| 31 | printf "CPU speed is %s MHz\n", $cpu->speed || 'N/A'; | ||
| 32 | printf "There are %d CPUs\n" , $cpu->count || 1; | ||
| 33 | printf "CPU load: %s\n" , $cpu->load || 0; | ||
| 34 | |||
| 35 | if($cpu->ht){ | ||
| 36 | print "CPU hyperthreading enabled\n"; | ||
| 37 | printf "CPU hyperthreading: %s\n" , $cpu->ht; | ||
| 38 | } | ||
| 39 | else{ | ||
| 40 | print "CPU hyperthreading not enabled\n"; | ||
| 41 | } |