File: Drives.pm

package info (click to toggle)
ocsinventory-agent 2%3A2.10.0-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 5,424 kB
  • sloc: perl: 26,492; xml: 773; objc: 528; sh: 386; ansic: 333; makefile: 12
file content (61 lines) | stat: -rw-r--r-- 1,986 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package Ocsinventory::Agent::Backend::OS::Solaris::Drives;

#Filesystem            kbytes    used   avail capacity  Mounted on
#/dev/vx/dsk/bootdg/rootvol 16525754 5423501 10936996    34%    /
#/devices                   0       0       0     0%    /devices
#ctfs                       0       0       0     0%    /system/contract
#proc                       0       0       0     0%    /proc
#mnttab                     0       0       0     0%    /etc/mnttab


use strict;
sub check {
  my $params = shift;
  my $common = $params->{common};
  $common->can_run ("df")
}

sub run {
    my $params = shift;
    my $common = $params->{common};

    my $free;
    my $filesystem;
    my $total;
    my $type;
    my $volumn;  

#Looking for mount points and disk space 
    for (`df -k`){
        if (/^Filesystem\s*/){next};
        # on Solaris 10 and up, /devices is an extra mount which we like to exclude
        if (/^\/devices/){next};
        # on Solaris 10 and up, /platform/.../libc_psr_hwcap1.so.1 is an extra mount which we like to exclude
        if (/^\/platform/){next};
        # exclude cdrom mount point
        if (/^\/.*\/cdrom/){next};
        if (/^swap.*/){next};
        # exclude special entries such as ctfs, proc, mnttab, etc...
        if (/^.*\s+0\s+0\s+0.*/){next};
        # skip nfs (dirty hack)
        if (/^\S+:\/.*/){next};
        # everything else is a local filesystem
        if (/^(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\n/){
            $filesystem = $6;
            $total = sprintf("%i",($2/1024));
            $free = sprintf("%i",($4/1024));
            $volumn = $1;
            chomp($type = `mount -v | grep  " $filesystem "`);
            $type =~ s/\S+\s+on\s+\S+\s+type\s+(\S+)\s+.*/$1/;
            $common->addDrive({
                FREE => $free,
                FILESYSTEM => $filesystem,
                TOTAL => $total,
                TYPE => $type,
                VOLUMN => $volumn
            });
        }
    }
}

1;