Subversion Repositories camp_sysinfo_client_3

Rev

Rev 237 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
48 rodolico 1
#!/usr/bin/env perl
2
use warnings;
3
use strict;  
4
 
5
# Description: Gets information on Unix based systems
6
 
7
our $VERSION = '1.0';
8
 
9
# Basic Unix module for sysinfo client
10
# Author: R. W. Rodolico
11
# Date:   2016-04-08
12
 
51 rodolico 13
# gets additional systems information on BSD machine using some standard
48 rodolico 14
# utilities
15
 
16
 
17
BEGIN {
18
   push @INC, shift;
19
}
20
 
21
use library;
22
 
23
exit 1 unless &getOperatingSystem() =~ m/bsd/i;
24
 
25
# the commands this script will use
26
my %commands = ( 
27
                  'grep' => '',
28
                  'dmesg' => '',
55 rodolico 29
                  'uname' => '',
30
                  'sysctl' => ''
31
 
48 rodolico 32
               );
33
 
34
# check the commands for validity
35
foreach my $command ( keys %commands ) {
36
   $commands{$command} = &validCommandOnSystem( $command );
37
}
38
 
39
 
40
 
41
 
42
# category we will use for all values found
43
# see sysinfo for a list of valid categories
44
my $CATEGORY = 'system';
45
 
46
my $temp;
47
 
153 rodolico 48
# following removed as they are now gotten through dmidecode module
49
#$temp = getSysctlParameter( $commands{ 'sysctl' }, 'hw.ncpu' );
50
#print "$CATEGORY\tnum_cpu\t$temp\n" if $temp;
48 rodolico 51
 
153 rodolico 52
#$temp = getSysctlParameter( $commands{ 'sysctl' }, 'hw.clockrate' );
53
#print "$CATEGORY\tcpu_speed\t$temp\n" if $temp;;
48 rodolico 54
 
153 rodolico 55
#$temp = getSysctlParameter( $commands{ 'sysctl' }, 'hw.model' );
56
#print "$CATEGORY\tcpu\t$temp\n" if $temp;
48 rodolico 57
 
58
# all this needs is uname
153 rodolico 59
#print "$CATEGORY\tcpu_sub\t" . &cleanUp('', qx(uname -m)) . "\n" if $commands{'uname'};
60
#print "$CATEGORY\tcpu_type\tUNK\n";
48 rodolico 61
 
153 rodolico 62
#$temp = getSysctlParameter( $commands{ 'sysctl' }, 'hw.realmem' );
63
#$temp /= 1024;
64
#print "$CATEGORY\tmemory\t$temp\n";
48 rodolico 65
 
55 rodolico 66
$temp = getSysctlParameter( $commands{ 'sysctl' }, 'kern.boottime' );
67
$temp =~ m/sec = (\d+),/;
68
$temp = $1;
69
print "$CATEGORY\tlast_boot\t$temp\n";
70
 
71
$temp = time - $temp;
72
print "$CATEGORY\tuptime\t$temp\n";
73
 
74
 
75
 
48 rodolico 76
exit 0;