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

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

Copyt trusty code

File size: 537 bytes
Line 
1package Ocsinventory::Agent::Backend::OS::Generic::Hostname;
2
3sub check {
4  return 1 if can_load ("Sys::Hostname");
5  return 1 if can_run ("hostname");
6  0;
7}
8
9# Initialise the distro entry
10sub run {
11  my $params = shift;
12  my $common = $params->{common};
13
14  my $hostname;
15
16  if (can_load("Sys::Hostname")) {
17    $hostname = Sys::Hostname::hostname();
18  } else {
19    chomp ( $hostname = `hostname` ); # TODO: This is not generic.
20  }
21  $hostname =~ s/\..*//; # keep just the hostname
22
23  $common->setHardware ({NAME => $hostname});
24}
25
261;
Note: See TracBrowser for help on using the repository browser.