[system] / trunk / xmlrpc / RPC / RPC-XML-0.25 / ex / linux.proc.cpuinfo.code Repository:
ViewVC logotype

View of /trunk/xmlrpc/RPC/RPC-XML-0.25/ex/linux.proc.cpuinfo.code

Parent Directory Parent Directory | Revision Log Revision Log


Revision 279 - (download) (annotate)
Fri May 17 21:44:04 2002 UTC (17 years, 5 months ago) by gage
File size: 1066 byte(s)
Experimental xmlrpc WeBWorK webservices

    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:      NAME      IN/OUT  TYPE      DESCRIPTION
    9 #                   $srv      in      ref       Server object reference
   10 #
   11 #   Globals:        None.
   12 #
   13 #   Environment:    None.
   14 #
   15 #   Returns:        hashref
   16 #
   17 ###############################################################################
   18 sub linux_proc_sysinfo
   19 {
   20     use strict;
   21 
   22     my $srv = shift;
   23 
   24     my (%cpuinfo, $line, $key, $value);
   25     local *F;
   26 
   27     open(F, '/proc/cpuinfo') or
   28         return RPC::XML::fault->new(501, "Cannot open /proc/cpuinfo: $!");
   29 
   30     while (defined($line = <F>))
   31     {
   32         chomp $line;
   33         next if ($line =~ /^\s*$/);
   34 
   35         ($key, $value) = split(/\s+:\s+/, $line, 2);
   36         $key =~ s/ /_/g;
   37         $cpuinfo{$key} = ($key eq 'flags') ? [ split(/ /, $value) ] : $value;
   38     }
   39     close(F);
   40 
   41     \%cpuinfo;
   42 }

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9