Add linux collection of cpu min/max.
Make cpu mhz default the current mhz.
This commit is contained in:
		
							parent
							
								
									5c8d1edbae
								
							
						
					
					
						commit
						09f3418c1a
					
				@ -471,9 +471,19 @@ use vars qw(%classes %cmds);
 | 
				
			|||||||
      },
 | 
					      },
 | 
				
			||||||
      {
 | 
					      {
 | 
				
			||||||
         name => 'mhz', type => 'Int',
 | 
					         name => 'mhz', type => 'Int',
 | 
				
			||||||
         desc => 'CPU speed',
 | 
					         desc => 'Current CPU speed',
 | 
				
			||||||
         plat => 'AFHLSW'
 | 
					         plat => 'AFHLSW'
 | 
				
			||||||
      },
 | 
					      },
 | 
				
			||||||
 | 
					      {
 | 
				
			||||||
 | 
					         name => 'mhz_max', type => 'Int',
 | 
				
			||||||
 | 
					         desc => 'Maximum CPU speed',
 | 
				
			||||||
 | 
					         plat => 'L'
 | 
				
			||||||
 | 
					      },
 | 
				
			||||||
 | 
					      {
 | 
				
			||||||
 | 
					         name => 'mhz_min', type => 'Int',
 | 
				
			||||||
 | 
					         desc => 'Maximum CPU speed',
 | 
				
			||||||
 | 
					         plat => 'L'
 | 
				
			||||||
 | 
					      },
 | 
				
			||||||
      {
 | 
					      {
 | 
				
			||||||
         name => 'cache_size', type => 'Long',
 | 
					         name => 'cache_size', type => 'Long',
 | 
				
			||||||
         desc => 'CPU cache size',
 | 
					         desc => 'CPU cache size',
 | 
				
			||||||
 | 
				
			|||||||
@ -11,6 +11,8 @@ puts num.to_s + " total CPUs.."
 | 
				
			|||||||
infos.each do |info|
 | 
					infos.each do |info|
 | 
				
			||||||
    puts "Vendor........" + info.vendor
 | 
					    puts "Vendor........" + info.vendor
 | 
				
			||||||
    puts "Model........." + info.model
 | 
					    puts "Model........." + info.model
 | 
				
			||||||
    puts "Mhz..........." + info.mhz.to_s
 | 
					    puts "Current Mhz..." + info.mhz.to_s
 | 
				
			||||||
 | 
					    puts "Maximum Mhz..." + info.mhz_max.to_s
 | 
				
			||||||
 | 
					    puts "Minimum Mhz..." + info.mhz_min.to_s
 | 
				
			||||||
    puts "Cache size...." + info.cache_size.to_s
 | 
					    puts "Cache size...." + info.cache_size.to_s
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
				
			|||||||
@ -188,6 +188,8 @@ typedef struct {
 | 
				
			|||||||
    char vendor[128];
 | 
					    char vendor[128];
 | 
				
			||||||
    char model[128];
 | 
					    char model[128];
 | 
				
			||||||
    int mhz;
 | 
					    int mhz;
 | 
				
			||||||
 | 
					    int mhz_max;
 | 
				
			||||||
 | 
					    int mhz_min;
 | 
				
			||||||
    sigar_uint64_t cache_size;
 | 
					    sigar_uint64_t cache_size;
 | 
				
			||||||
    int total_sockets;
 | 
					    int total_sockets;
 | 
				
			||||||
    int total_cores;
 | 
					    int total_cores;
 | 
				
			||||||
 | 
				
			|||||||
@ -1598,7 +1598,23 @@ static void get_cpuinfo_max_freq(sigar_cpu_info_t *cpu_info, int num)
 | 
				
			|||||||
        sigar_file2str(max_freq, max_freq, sizeof(max_freq)-1);
 | 
					        sigar_file2str(max_freq, max_freq, sizeof(max_freq)-1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (status == SIGAR_OK) {
 | 
					    if (status == SIGAR_OK) {
 | 
				
			||||||
        cpu_info->mhz = atoi(max_freq) / 1000;
 | 
					        cpu_info->mhz_max = atoi(max_freq) / 1000;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void get_cpuinfo_min_freq(sigar_cpu_info_t *cpu_info, int num)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    int status;
 | 
				
			||||||
 | 
					    char min_freq[PATH_MAX];
 | 
				
			||||||
 | 
					    snprintf(min_freq, sizeof(min_freq),
 | 
				
			||||||
 | 
					             "/sys/devices/system/cpu/cpu%d"
 | 
				
			||||||
 | 
					             "/cpufreq/cpuinfo_min_freq", num);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    status =
 | 
				
			||||||
 | 
					        sigar_file2str(min_freq, min_freq, sizeof(min_freq)-1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (status == SIGAR_OK) {
 | 
				
			||||||
 | 
					        cpu_info->mhz_min = atoi(min_freq) / 1000;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -1624,6 +1640,7 @@ int sigar_cpu_info_list_get(sigar_t *sigar,
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        info = &cpu_infos->data[cpu_infos->number];
 | 
					        info = &cpu_infos->data[cpu_infos->number];
 | 
				
			||||||
        get_cpuinfo_max_freq(info, cpu_infos->number);
 | 
					        get_cpuinfo_max_freq(info, cpu_infos->number);
 | 
				
			||||||
 | 
					        get_cpuinfo_min_freq(info, cpu_infos->number);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        info->total_cores = sigar->ncpu;
 | 
					        info->total_cores = sigar->ncpu;
 | 
				
			||||||
        info->cores_per_socket = sigar->lcpu;
 | 
					        info->cores_per_socket = sigar->lcpu;
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user