source: ocsinventory-agent/trunk/fuentes/lib/Ocsinventory/Agent/Backend/OS/BSD.pm @ 468

Last change on this file since 468 was 468, checked in by mabarracus, 4 years ago

Copyt trusty code

File size: 1.0 KB
Line 
1package Ocsinventory::Agent::Backend::OS::BSD;
2
3use strict;
4
5use vars qw($runAfter);
6$runAfter = ["Ocsinventory::Agent::Backend::OS::Generic"];
7
8sub check { $^O =~ /freebsd|openbsd|netbsd|gnukfreebsd|gnuknetbsd/ }
9
10sub run {
11  my $params = shift;
12  my $common = $params->{common};
13
14  my $OSName;
15  my $OSComment;
16  my $OSVersion;
17  my $OSLevel;
18  my $OSArchi;
19
20  # Operating system informations
21  chomp($OSName=`uname -s`);
22  chomp($OSVersion=`uname -r`);
23  chomp($OSArchi=`uname -p`);
24
25  # Retrieve the origin of the kernel configuration file
26  my ($date, $origin, $kernconf);
27  for (`sysctl -n kern.version`) {
28      $date = $1 if /^\S.*\#\d+:\s*(.*)/;
29      ($origin,$kernconf) = ($1,$2) if /^\s+(.+):(.+)$/;
30  }
31  $kernconf =~ s/\/.*\///; # remove the path
32  $OSComment = $kernconf." (".$date.")\n".$origin;
33  # if there is a problem use uname -v
34  chomp($OSComment=`uname -v`) unless $OSComment; 
35 
36  $common->setHardware({
37      OSNAME => $OSName." ".$OSArchi,
38      OSCOMMENTS => $OSComment,
39      OSVERSION => $OSVersion,
40    });
41}
421;
Note: See TracBrowser for help on using the repository browser.