MrBoogiee
Enthusiast
Enthusiast

retreive list of active processes from guest

Jump to solution

Hi all,

I'm trying to rewrite some of our monitoring checks so I can monitor our vCloud customers without needing any network connectivity for fe. snmp. I've tried writing something in Perl, but am now stuck at the following point:

I can get to the view of ProcessManager, but I can't get the listProcessesInGuest() method to work. If I execute the following bit of code, I just get the response: Undefined subroutine &GuestOperationsManager::listProcessesInGuest

The relevant piece of code is as follows:

my $serviceContent = Vim::get_service_content(

    filter => {'name' => $vmNameInVcenter }

);

my $operationsManager = Vim::get_view(mo_ref => $serviceContent->guestOperationsManager);

my $processManager = Vim::get_view(mo_ref => $operationsManager->processManager);

my $processlist = $processManager->listProcessesInGuest();

Regards,

MrBoogiee

0 Kudos
1 Solution

Accepted Solutions
MrBoogiee
Enthusiast
Enthusiast

After some searching based on your response, I came across   vGhetto / Code /  [r243]  /scripts/guestOpsManagement.pl where I found the solution:

my $vm_view = Vim::find_entity_views(view_type => 'VirtualMachine', filter => {'name' => $vmNameInVcenter});

my $guestOpMgr = Vim::get_view(mo_ref => Vim::get_service_content()->guestOperationsManager);

my $guestCreds = NamePasswordAuthentication->new(username => $guestusername, password => $guestpassword, interactiveSession => 'false');

my $procMgr = Vim::get_view(mo_ref => $guestOpMgr->processManager);

my $processlist = $procMgr->ListProcessesInGuest(vm => $vm_view, auth => $guestCreds);

View solution in original post

0 Kudos
3 Replies
Chiqos
Contributor
Contributor

Hi,

It seems you need to have:

Try theses lines:

my $vm_views = Vim::find_entity_views(view_type => 'VirtualMachine',

                        filter => {

                        'config.name' => qr/^$o_vmname$/i,

                        },

                        properties => ['config','name'],

                        );

my $processlist = $processManager->ListProcessesInGuest(vm => $vm_view, auth => GuestAuthentication);

To be honest I never used GuestAuthentication, so there is some missing code here...

Regards,

Jeremy

MrBoogiee
Enthusiast
Enthusiast

After some searching based on your response, I came across   vGhetto / Code /  [r243]  /scripts/guestOpsManagement.pl where I found the solution:

my $vm_view = Vim::find_entity_views(view_type => 'VirtualMachine', filter => {'name' => $vmNameInVcenter});

my $guestOpMgr = Vim::get_view(mo_ref => Vim::get_service_content()->guestOperationsManager);

my $guestCreds = NamePasswordAuthentication->new(username => $guestusername, password => $guestpassword, interactiveSession => 'false');

my $procMgr = Vim::get_view(mo_ref => $guestOpMgr->processManager);

my $processlist = $procMgr->ListProcessesInGuest(vm => $vm_view, auth => $guestCreds);

0 Kudos
Chiqos
Contributor
Contributor

Good to know, thanks for the information.

0 Kudos