Skip to main content

Hi everyone,

I am asked to monitor some of our divices within Centreon.

Some templates are already used, so I was asked to edit a script for gatheing some Data.

We are in an SCCM Iinfrastructure, we have some Distribution Points and some PCs configured as Peer Cache.

So, for those PCs, I want to monitor some of theire characteristics. I can’t use SNMP on the PCs because it is deprecated and is no more available within Windows 10 OS.

Microsoft advise is to use the CIM model.

I have the request for the data I want to gather:

$namespace = "ROOT\ccm\Policy\Machine\ActualConfig"

$classname = "CCM_SuperPeerClientConfig"

 

$SPCParameters = Get-WmiObject -Class $classname -ComputerName $computer -Namespace $namespace | Select-Object CanBeSuperPeer, HttpsEnabled

$SPCParameters.CanBeSuperPeer

$SPCParameters.HttpsEnabled

 

if(($SPCParameters.CanBeSuperPeer -eq $true) -and ($SPCParameters.HttpsEnabled -eq $true)){

    # Rien à faire, tout est ok

}

else{

    Write-Host "Vérifier la présence du " $computer "dans la collection SPC"

}

 

My question:

How do I use WSMAN to implement this request ?

A full tutorial would be a real help. I am a newbie to Centreon.

Thanks for any help,

hello

what you ask is doable in 2 ways :

you make a script and you install an nrpe agent on your windows hosts, like nsclient or snclient, then create a custom command to run this script

or

you need to develop  your own plugin in perl looking at how it done for example here : 

centreon-plugins/src/os/windows/wsman/mode/filessize.pm at develop · centreon/centreon-plugins · GitHub

where you can see a wmi path, a wql query, then other stuff that will implement the output based on the result. 

you would need to know perl, and have a centreon setup where you have deployed WSMAN, and as I don’t really know this plugin, I don’t know if you will have access to a WMI root like the one you want to use (not cimv2)

you may need to adapt this documentation/how to  : Windows WSMAN Configuration tutorial | Centreon Documentation where you will need to add the “CCM” root in the access rights.

(perl, git, wmi, knowing how to develop a plugin in centreon, lots of knowledge you would need to accomplish this)

 

I would suggest the “easier” way is installing nsclient, modifying the nsclient.ini to create a new command, then making a script launched by this command. 

 

if you install nsclient given by centreon you will see a .ini with these line at the end

[/settings/external scripts/scripts]
check_logfiles=scripts\\centreon\\check_logfiles.exe $ARG1$
check_centreon_plugins=scripts\\centreon\\centreon_plugins.exe --plugin=$ARG1$ --mode=$ARG2$ $ARG3$

you just need to put you script in the script folder and then make a command line that will run the script

then you look how a nsclient command is run on centreon (you get them after installing the plugin pack in centreon) and copy the command line to make your own by changing the parameters.

 

the only thing you need is work on the output of the bit of powershell you gave above, here is how a powershell script should exit correcltly to be ran by nsclient (you need to give “-nonewline” on the text you return, and en exit code)

function checkExit() {Write-host -nonewline $rettext ; exit $retcode }



if(($SPCParameters.CanBeSuperPeer -eq $true) -and ($SPCParameters.HttpsEnabled -eq $true)){

# Rien à faire, tout est ok

$retText = "OK - all is fine"
$retcode = 0
checkExit
}

else{

$retText = "CRITICAL - Vérifier la présence du $computer dans la collection SPC"
$retcode = 2
checkExit
}

 

good luck


Reply