Welcome to Pandora FMS Community!

Find answers, ask questions, and connect with our community around the world.

Bienvenido a la comunidad de Pandora FMS Forums Community support Returning DHCP Info using Powershell

  • Returning DHCP Info using Powershell

    Posted by m25m on abril 28, 2021 at 23:34

    I’m trying to learn how to create a custom module to monitor DHCP Address usage on a Windows DHCP server.
    Server is 7.0NG.750(Build 201111)

    Here’s what I have so far:

    This Powershell command returns the information:

    PS C:Windowssystem32> Get-DHCPServerv4ScopeStatistics | Select-Object -Property ScopeId,Free
    
    ScopeId     Free
    -------     ----
    10.100.0.0   137
    192.168.1.0  133

    I put that into pandora_agent.conf at the bottom of the file like this:

    # DHCP Stats
    module_begin
    module_name DHCPStats
    module_type generic_data
    module_exec C:WindowsSystem32WindowsPowerShellv1.0powershell.exe -Command "Get-DHCPServerv4ScopeStatistics | Select-Object -Property ScopeId,Free"
    module_description Show Available DHCP Addresses
    module_end

    After saving the file and restarting the agent, nothing appears, except 

    Warning: Non-initialized modules found

    However, I am not finding an explanation so far on what that means or how to resolve it.

    Thank you for your assistance.

    m25m replied 3 years, 8 months ago 2 Members · 2 Replies
  • 2 Replies
  • diego-m

    Moderator
    mayo 4, 2021 at 18:22
    500 Karma points
    Community rank: tentacle_master_icon Tentacle Master
    Like it
    Up
    0
    Down
    Drop it
    ::

    Hello,

    I think this may fail for several reasons, the first is the type of data you are trying to use, from what I see in the output of the command there are several letters and symbols, which does not support the type of module “generic_data”. When this happens is when we see that the modules are never initialized.

    On the other hand, I don’t think that changing the data type is going to work for you, since you are extracting several data and trying to register them in the same module… My advice is to make a script that creates one module per data obtained, ignoring the command header. If you do it this way, using the “generic_data” data type should work for you.

    Greetings
    Diego

  • m25m

    Member
    mayo 4, 2021 at 18:28
    13 Karma points
    Community rank: tentacle-noob-1 Tentacle noob
    Like it
    Up
    0
    Down
    Drop it
    ::

    Diego, thank you for your reply.