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

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

Copyt trusty code

File size: 723 bytes
Line 
1package Ocsinventory::Agent::Backend::OS::Linux::Uptime;
2use strict;
3
4sub check { can_read("/proc/uptime") }
5
6sub run {
7  my $params = shift;
8  my $common = $params->{common};
9
10  # Uptime
11  open UPTIME, "/proc/uptime";
12  my $uptime = <UPTIME>;
13  $uptime =~ s/^(.+)\s+.+/$1/;
14  close UPTIME;
15
16  # Uptime conversion
17  my ($UYEAR, $UMONTH , $UDAY, $UHOUR, $UMIN, $USEC) = (gmtime ($uptime))[5,4,3,2,1,0];
18
19  # Write in ISO format
20  $uptime=sprintf "%02d-%02d-%02d %02d:%02d:%02d", ($UYEAR-70), $UMONTH, ($UDAY-1), $UHOUR, $UMIN, $USEC;
21 
22  chomp(my $DeviceType =`uname -m`);
23#  TODO$h->{'CONTENT'}{'HARDWARE'}{'DESCRIPTION'} = [ "$DeviceType/$uptime" ];
24  $common->setHardware({ DESCRIPTION => "$DeviceType/$uptime" });
25}
26
271
Note: See TracBrowser for help on using the repository browser.