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

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

Copyt trusty code

File size: 1.6 KB
Line 
1package Ocsinventory::Agent::Backend::OS::MacOS::Video;
2use strict;
3
4
5sub check {
6    # make sure the user has access, cause that's the command that's gonna be run
7    return(undef) unless -r '/usr/sbin/system_profiler';
8    return(undef) unless can_load("Mac::SysProfile");
9    return 1;
10}
11
12sub run {
13    my $params = shift;
14    my $common = $params->{common};
15
16    # run the profiler to get our datatype
17    my $profile = Mac::SysProfile->new();
18    my $data = $profile->gettype('SPDisplaysDataType');
19
20    # unless we get a valid return, bail out
21    return(undef) unless(ref($data) eq 'ARRAY');
22
23    # we get video card because system_profiler XML output does not provide a human readable value
24    my $video_names = $common->get_sysprofile_devices_names('SPDisplaysDataType');
25    return(undef) unless(ref($video_names) eq 'ARRAY');
26
27    my $count = 0;
28
29    # add the video information
30    foreach my $video (@$data){
31        my $memory = $video->{'spdisplays_vram'};
32        $memory =~ s/ MB$//;
33
34        $common->addVideo({
35                'NAME'        => $$video_names[$count],
36                'CHIPSET'     => $video->{'sppci_model'},
37                'MEMORY'    => $memory,
38                'RESOLUTION'    => $video->{'spdisplays_ndrvs'}[0]->{'spdisplays_resolution'},
39        });
40
41 
42        foreach my $display (@{$video->{'spdisplays_ndrvs'}}){
43            next unless(ref($display) eq 'HASH');
44            next if($display->{'_name'} eq 'spdisplays_display_connector');
45
46            $common->addMonitor({
47                'CAPTION'   => $display->{'_name'},
48            })
49        }
50
51        $count++;
52    }
53
54}
551;
Note: See TracBrowser for help on using the repository browser.