File: Drives.pm

package info (click to toggle)
ocsinventory-agent 2%3A2.0.5-1.2
  • links: PTS
  • area: main
  • in suites: stretch
  • size: 4,120 kB
  • ctags: 899
  • sloc: perl: 20,687; sh: 576; objc: 468; ansic: 333; makefile: 55
file content (62 lines) | stat: -rw-r--r-- 1,677 bytes parent folder | download | duplicates (2)
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
62
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 { 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 /devices is an extra mount which we like to exclude
    if (/^\/devices/){next};
    # on Solaris 10 /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};

    if(/^(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\n/){	
      $filesystem = $1;
      $total = sprintf("%i",($2/1024));	
      $free = sprintf("%i",($4/1024));
      $volumn = $6;

      if($filesystem =~ /^\/dev\/\S*/){	 
	chomp($type=`fstyp $filesystem`);
        $type = '' if $type =~ /cannot stat/;
      }
      else {$type="";}	 
#print "FILESYS ".$filesystem." FILETYP ".$type." TOTAL ".$total." FREE ".$free." VOLUMN ".$volumn."\n";
      $common->addDrive({
	  FREE => $free,
	  FILESYSTEM => $filesystem,
	  TOTAL => $total,
	  TYPE => $type,
	  VOLUMN => $volumn
	  })

    }


  }
}

1;