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

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

Copyt trusty code

File size: 803 bytes
Line 
1package Ocsinventory::Agent::Backend::OS::Linux;
2
3use strict;
4use vars qw($runAfter);
5$runAfter = ["Ocsinventory::Agent::Backend::OS::Generic"];
6
7sub check { $^O =~ /^linux$/ }
8
9sub run {
10  my $params = shift;
11  my $common = $params->{common};
12
13  chomp (my $osversion = `uname -r`);
14
15  my $lastloggeduser;
16  my $datelastlog;
17  my @query = runcmd("last -R");
18 
19  foreach ($query[0]) {
20    if ( s/^(\S+)\s+\S+\s+(\S+\s+\S+\s+\S+\s+\S+)\s+.*// ) {
21      $lastloggeduser = $1;
22      $datelastlog = $2;
23    }
24  }
25 
26  # This will probably be overwritten by a Linux::Distro module.
27  $common->setHardware({
28      OSNAME => "Linux",
29      OSCOMMENTS => "Unknown Linux distribution",
30      OSVERSION => $osversion,
31      LASTLOGGEDUSER => $lastloggeduser,
32      DATELASTLOGGEDUSER => $datelastlog
33    });
34}
35
361;
Note: See TracBrowser for help on using the repository browser.