Heray-Was-Here
Server : Apache
System : Linux vps103298.mylogin.co 4.18.0-513.11.1.el8_9.x86_64 #1 SMP Wed Jan 17 02:00:40 EST 2024 x86_64
User : calvet ( 273824)
PHP Version : 7.4.33
Disable Function : NONE
Directory :  /usr/share/perl5/vendor_perl/Ocsinventory/Agent/Backend/Virtualization/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //usr/share/perl5/vendor_perl/Ocsinventory/Agent/Backend/Virtualization/XenCitrixServer.pm
package Ocsinventory::Agent::Backend::Virtualization::XenCitrixServer;

use strict;
use warnings;

sub check { 
    my $params = shift;
    my $common = $params->{common};
    $common->can_run('xe') 
}

sub run {

    my $params = shift;
    my $common = $params->{common};
    my $hostname = `hostname`;
    my $residenton;

    foreach (`xe host-list params=uuid hostname=$hostname`) {
        $residenton = $1 if /:\s+(.+)/;
    }

    foreach (`xe vm-list params=uuid resident-on=$residenton`) {
        if (/:\s+(.+)/) {
            my $uuid = $1 if /:\s+(.+)/;
            my $fname = `xe vm-list params=name-label uuid=$uuid`;
            my $name = $1 if $fname =~ /:\s+(.+)/;
            my $fstatus = `xe vm-list params=power-state uuid=$uuid`;
            my $status = $1 if $fstatus =~ /:\s+(.+)/;
            my $fvcpu = `xe vm-list params=VCPUs-max uuid=$uuid`;
            my $vcpu = $1 if $fvcpu =~ /:\s+(.+)/;
            my $fmemory = `xe vm-list params=memory-actual uuid=$uuid`;
            my $tmemory = $1 if $fmemory =~ /:\s+(.+)/;
            my $memory = $1 if $tmemory =~ /(\d+)\d{6}$/;

            my $machine = {
                MEMORY => $memory,
                NAME => $name,
                UUID => $uuid,
                STATUS => $status,
                SUBSYSTEM => "xe",
                VMTYPE => "XEN",
                VCPU => $vcpu,
            };
            $common->addVirtualMachine($machine);
          }
     }
}

1;

Hry