Subversion Repositories camp_sysinfo_client_3

Rev

Rev 55 | 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
 
55 rodolico 35
 
48 rodolico 36
# check the commands for validity
37
foreach my $command ( keys %commands ) {
38
   $commands{$command} = &validCommandOnSystem( $command );
39
}
40
 
41
 
42
 
43
 
44
# category we will use for all values found
45
# see sysinfo for a list of valid categories
46
my $CATEGORY = 'system';
47
 
48
my $temp;
49
 
55 rodolico 50
$temp = getSysctlParameter( $commands{ 'sysctl' }, 'hw.ncpu' );
51
print "$CATEGORY\tnum_cpu\t$temp\n" if $temp;
48 rodolico 52
 
55 rodolico 53
$temp = getSysctlParameter( $commands{ 'sysctl' }, 'hw.clockrate' );
54
print "$CATEGORY\tcpu_speed\t$temp\n" if $temp;;
48 rodolico 55
 
55 rodolico 56
$temp = getSysctlParameter( $commands{ 'sysctl' }, 'hw.model' );
57
print "$CATEGORY\tcpu\t$temp\n" if $temp;
48 rodolico 58
 
59
# all this needs is uname
60
print "$CATEGORY\tcpu_sub\t" . &cleanUp('', qx(uname -m)) . "\n" if $commands{'uname'};
51 rodolico 61
print "$CATEGORY\tcpu_type\tUNK\n";
48 rodolico 62
 
55 rodolico 63
$temp = getSysctlParameter( $commands{ 'sysctl' }, 'hw.realmem' );
64
$temp /= 1024;
65
print "$CATEGORY\tmemory\t$temp\n";
48 rodolico 66
 
55 rodolico 67
$temp = getSysctlParameter( $commands{ 'sysctl' }, 'kern.boottime' );
68
$temp =~ m/sec = (\d+),/;
69
$temp = $1;
70
print "$CATEGORY\tlast_boot\t$temp\n";
71
 
72
$temp = time - $temp;
73
print "$CATEGORY\tuptime\t$temp\n";
74
 
75
 
76
 
48 rodolico 77
exit 0;