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

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

Copyt trusty code

File size: 986 bytes
Line 
1package Ocsinventory::Agent::Backend::OS::BSD::Storages;
2
3use strict;
4
5sub check {-r '/etc/fstab'}
6
7sub run {
8  my $params = shift;
9  my $common = $params->{common};
10
11  my @values;
12  my @devices;
13 
14  open FSTAB, "/etc/fstab";
15  while(<FSTAB>){
16    if(/^\/dev\/(\D+\d)/) {
17        push @devices, $1 unless grep(/^$1$/, @devices);
18    }
19  }
20  for my $dev (@devices) {
21    my ($model,$capacity,$found, $manufacturer);
22    for(`dmesg`){
23      if(/^$dev/) { $found = 1;}
24      if(/^$dev.*<(.*)>/) { $model = $1; }
25      if(/^$dev.*\s+(\d+)\s*MB/) { $capacity = $1;}
26    }
27
28    if ($model =~ s/^(SGI|SONY|WDC|ASUS|LG|TEAC|SAMSUNG|PHILIPS|PIONEER|MAXTOR|PLEXTOR|SEAGATE|IBM|SUN|SGI|DEC|FUJITSU|TOSHIBA|YAMAHA|HITACHI|VERITAS)\s*//i) {
29        $manufacturer = $1;
30    }
31
32    # clean up the model
33    $model =~ s/^(\s|,)*//;
34    $model =~ s/(\s|,)*$//;
35
36    $common->addStorages({
37        MANUFACTURER => $manufacturer,
38        MODEL => $model,
39        DESCRIPTION => $dev,
40        TYPE => '',
41        DISKSIZE => $capacity
42      });
43  }
44}
451;
Note: See TracBrowser for help on using the repository browser.