在运行程序时捕获涡轮速度

时间:2014-06-10 03:20:52

标签: linux perl automation

我想创建一个自动化程序,以便在程序运行时捕获CPU的涡轮速度。

我的自动化脚本应该使用perl语言。

我确实尝试过使用:

system("script mytest.txt");
system("./turbostat");

当我执行此程序时,只有脚本行可以工作但不能使用均匀稳定器。

有人可以建议我采用什么方法来捕捉涡轮增压?

1 个答案:

答案 0 :(得分:0)

查看Sys::Info::Device::CPU模块。

<强> 概要

   use Sys::Info;
   use Sys::Info::Constants qw( :device_cpu );
   my $info = Sys::Info->new;
   my $cpu  = $info->device( CPU => %options );

   printf "CPU: %s\n", scalar($cpu->identify)  || 'N/A';
   printf "CPU speed is %s MHz\n", $cpu->speed || 'N/A';
   printf "There are %d CPUs\n"  , $cpu->count || 1;
   printf "CPU load: %s\n"       , $cpu->load  || 0;