1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
|
package Ocsinventory::Agent::Backend::OS::MacOS;
use strict;
require Exporter;
our @ISA = qw /Exporter/;
our @EXPORT = qw /get_sysprofile_devices_names/;
sub check {
my $r;
# we check far darwin because that's the _real_ underlying OS
$r = 1 if (uc($^O) =~ /^DARWIN$/);
return($r);
}
sub run {
my $params = shift;
my $common = $params->{common};
my $OSName;
my $OSComment;
my $OSVersion;
# if we can load the system profiler, gather the information from that
if(can_load("Mac::SysProfile")){
my $profile = Mac::SysProfile->new();
my $data = $profile->gettype('SPSoftwareDataType');
return(undef) unless(ref($data) eq 'ARRAY');
my $h = $data->[0];
my $SystemVersion = $h->{'os_version'};
if ($SystemVersion =~ /^(.*?)\s+(\d+.*)/) {
$OSName=$1;
$OSVersion=$2;
} else {
# Default values
$OSName="Mac OS X";
$OSVersion="Unknown";
}
} else {
# we can't load the system profiler, use the basic BSD stype information
# Operating system informations
chomp($OSName=`uname -s`);
chomp($OSVersion=`uname -r`);
}
# add the uname -v as the comment, not really needed, but extra info never hurt
chomp($OSComment=`uname -v`);
$common->setHardware({
OSNAME => $OSName,
OSCOMMENTS => $OSComment,
OSVERSION => $OSVersion,
});
}
1;
|