[ create a new paste ] login | about

Link: http://codepad.org/nIDxtZsP    [ raw code | output | fork ]

Perl, pasted on Aug 29:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/usr/bin/perl -w
# psrinfo.perl: emulate the Solaris psrinfo command
use strict;
use Sun::Solaris::Kstat;

my $kstat = Sun::Solaris::Kstat->new();

my $mh = $kstat->{cpu_info};

foreach my $cpu (keys(%$mh)) {
    my ($state, $when) = @{$kstat->{cpu_info}{$cpu}
       {"cpu_info".$cpu}}{qw(state state_begin)};
    my ($sec,$min,$hour,$mday,$mon,$year) = 
       (localtime($when))[0..5];
    printf("%d\t%-8s  since %.2d/%.2d/%.2d %.2d:%.2d:%.2d\n",
        $cpu,$state,$mon + 1,$mday,$year - 100,$hour,$min,$sec);

}


Output:
1
2
Can't locate Sun/Solaris/Kstat.pm in @INC (@INC contains: /usr/lib/perl5/5.8.0/i486-linux /usr/lib/perl5/5.8.0 /usr/lib/perl5/site_perl/5.8.0/i486-linux /usr/lib/perl5/site_perl/5.8.0 /usr/lib/perl5/site_perl .) at line 4.
BEGIN failed--compilation aborted at line 4.


Create a new paste based on this one


Comments: