Subversion Repositories camp_sysinfo_client_3

Rev

Rev 201 | Blame | Last modification | View Log | Download | RSS feed

#!/usr/bin/env perl
use warnings;
use strict;  

# Description: Gets information on Unix based systems

our $VERSION = '1.0';

# Basic Unix module for sysinfo client
# Author: R. W. Rodolico
# Date:   2016-04-08

# gets additional systems information on BSD machine using some standard
# utilities


BEGIN {
   push @INC, shift;
}

use library;

exit 1 unless &getOperatingSystem() =~ m/bsd/i;

# the commands this script will use
my %commands = ( 
                  'grep' => '',
                  'dmesg' => '',
                  'uname' => '',
                  'sysctl' => ''

               );

# check the commands for validity
foreach my $command ( keys %commands ) {
   $commands{$command} = &validCommandOnSystem( $command );
}




# category we will use for all values found
# see sysinfo for a list of valid categories
my $CATEGORY = 'system';

my $temp;

# following removed as they are now gotten through dmidecode module
#$temp = getSysctlParameter( $commands{ 'sysctl' }, 'hw.ncpu' );
#print "$CATEGORY\tnum_cpu\t$temp\n" if $temp;

#$temp = getSysctlParameter( $commands{ 'sysctl' }, 'hw.clockrate' );
#print "$CATEGORY\tcpu_speed\t$temp\n" if $temp;;

#$temp = getSysctlParameter( $commands{ 'sysctl' }, 'hw.model' );
#print "$CATEGORY\tcpu\t$temp\n" if $temp;

# all this needs is uname
#print "$CATEGORY\tcpu_sub\t" . &cleanUp('', qx(uname -m)) . "\n" if $commands{'uname'};
#print "$CATEGORY\tcpu_type\tUNK\n";

#$temp = getSysctlParameter( $commands{ 'sysctl' }, 'hw.realmem' );
#$temp /= 1024;
#print "$CATEGORY\tmemory\t$temp\n";

$temp = getSysctlParameter( $commands{ 'sysctl' }, 'kern.boottime' );
$temp =~ m/sec = (\d+),/;
$temp = $1;
print "$CATEGORY\tlast_boot\t$temp\n";

$temp = time - $temp;
print "$CATEGORY\tuptime\t$temp\n";



exit 0;