Ad Widget

Collapse

Zabbix PowerCli

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Sergey Serov
    Junior Member
    • Oct 2018
    • 24

    #1

    Zabbix PowerCli

    Hello everyone.
    I want to say right away, maybe I'm on the wrong path
    And if someone tells me a way how to collect IOPs more correctly. I will be grateful.


    I had an idea to collect OIPs metrics from PowerCli.
    Wrote a script.


    param(
    [Parameter()]
    [String]$server
    )

    Import-Module VMware.VimAutomation.Core
    $vCenter='vca.local.local'
    $username='[email protected]'
    $password='pass'

    Connect-VIServer -Server $vCenter -User $username -Password $password

    Get-Stat -Entity $server -Realtime -MaxSamples 1 -Stat virtualDisk.writeOIO.latest | Select @{L='{#HDDLOCATION}';E={$_.Instance}} | ConvertTo-Json
    Disconnect-VIServer -Server $vCenter -Force -confirm:$false -ErrorAction SilentlyContinue -WarningAction 0 | Out-Null


    From bash all right

    ./pw_getHDD.sh -server win10

    Name Port User
    ---- ---- ----
    vca.local.local 443 VSPHERE.LOCAL\user
    [
    {
    "{#HDDLOCATION}": "scsi0:0"
    },
    {
    "{#HDDLOCATION}": "scsi0:1"
    }
    ]
    But from the zabbix web
    new item
    pw_getHDD.sh["-server","win10"]
    output "test" button

    [91mImport-Module:
    [96mLine |
    [96m 12 | [0m [96mImport-Module VMware.VimAutomation.Core[0m
    [96m | [91m ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    [91m[96m | [91mThe type initializer for 'VMware.VimAutomation.ViCore.Util10.SettingsManage r' threw an exception.[0m
    [91mConnect-VIServer:
    [96mLine |
    [96m 19 | [0m [96mConnect-VIServer[0m -Server $vCenter -User $username -Password $passwo …
    [96m | [91m ~~~~~~~~~~~~~~~~
    [91m[96m | [91mThe 'Connect-VIServer' command was found in the module 'VMware.VimAutomation.Core', but the module could not be loaded. For more information, run 'Import-Module VMware.VimAutomation.Core'.[0m
    [91mGet-Stat:
    [96mLine |
    [96m 24 | [0m [96mGet-Stat[0m -Entity $server -Realtime -MaxSamples 1 -Stat virtualDisk.wr …
    [96m | [91m ~~~~~~~~
    [91m[96m | [91mThe 'Get-Stat' command was found in the module 'VMware.VimAutomation.Core', but the module could not be loaded. For more information, run 'Import-Module VMware.VimAutomation.Core'.[0m
    [91mDisconnect-VIServer:
    [96mLine |
    [96m 25 | [0m Disconnect-VIServer -Server [96m$vCenter[0m -Force -confirm:$false -ErrorA …
    [96m | [91m ~~~~~~~~
    [91m[96m | [91mCannot process argument transformation on parameter 'Server'. The type initializer for 'VMware.VimAutomation.Sdk.Interop.V1.CoreServiceFa ctory' threw an exception.[0m
    Connect-VIServer' command was found in the module 'VMware.VimAutomation.Core', but the module could not be loaded. For more information, run 'Import-Module VMware.VimAutomation.Core'



    Any ideas what's wrong?
  • incama
    Member
    • Jan 2015
    • 65

    #2
    When using bash, which user did you use? Normally Zabbix runs under the zabbix user. Just a thought.

    Comment

    • Sergey Serov
      Junior Member
      • Oct 2018
      • 24

      #3
      Hello Incama.
      Execution under the user zabbix. (Installed modules on powershell with -scope AllUsers)

      At first there was another error, more informative from which it was clear that the zabbix user did not have modules.

      Comment

      • rpi_dwillis77
        Junior Member
        • Jun 2023
        • 4

        #4
        Hello Sergey Serov just wondering if you ever figured this out? I'm running into the same exact issue in a very similar scenario (PowerCLI module installed for all users, works fine when called from shell script manually but not through Zabbix).

        *UPDATE: Shortly after posting this I actually found the solution - turns out it was an issue related to $HOME not being set properly. Thanks very much to j2clerck at the link below for sharing the solution:

        Last edited by rpi_dwillis77; 22-05-2024, 11:19.

        Comment

        Working...