1############################################################################### 2# 3# Sub Name: linux_proc_cpuinfo 4# 5# Description: Read the /proc/cpuinfo on a Linux server and return a 6# STRUCT with the information. 7# 8# Arguments: None. 9# 10# Returns: hashref 11# 12############################################################################### 13sub linux_proc_sysinfo 14{ 15 use strict; 16 17 my (%cpuinfo, $line, $key, $value); 18 local *F; 19 20 open(F, '/proc/cpuinfo') or 21 return RPC::XML::fault->new(501, "Cannot open /proc/cpuinfo: $!"); 22 23 while (defined($line = <F>)) 24 { 25 chomp $line; 26 next if ($line =~ /^\s*$/); 27 28 ($key, $value) = split(/\s+:\s+/, $line, 2); 29 $key =~ s/ /_/g; 30 $cpuinfo{$key} = ($key eq 'flags') ? [ split(/ /, $value) ] : $value; 31 } 32 close(F); 33 34 \%cpuinfo; 35} 36