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

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

Copyt trusty code

File size: 1.1 KB
Line 
1package Ocsinventory::Agent::Backend::OS::MacOS::Drives;
2
3use strict;
4
5# yea BSD theft!!!!
6# would have used Mac::SysProfile, but the xml isn't quite fully supported
7# the drives come back in apple xml tree's, and the module can't handle it yet (soon as I find the time to fix the patch)
8
9sub check {1}
10
11sub run {
12    my $params = shift;
13    my $common = $params->{common};
14
15    my $free;
16    my $filesystem;
17    my $total;
18    my $type;
19    my $volumn;
20
21
22    for my $t ("ffs","ufs", "hfs") {
23  # OpenBSD has no -m option so use -k to obtain results in kilobytes
24      for(`df -P -k -t $t`){ # darwin needs the -t to be last
25        if(/^(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\n/){
26            $type = $1;
27            $filesystem = $t;
28            $total = sprintf("%i",$2/1024);
29            $free = sprintf("%i",$4/1024);
30            $volumn = $6;
31
32          $common->addDrive({
33              FREE => $free,
34              FILESYSTEM => $filesystem,
35              TOTAL => $total,
36              TYPE => $type,
37              VOLUMN => $volumn
38            })
39        }
40      }
41    }
42}
431;
Note: See TracBrowser for help on using the repository browser.