Run a check command inside a python script



I want to call a check command inside a python script. I first thought to call the REST api using the requests package but I think it would be better to use NSCP.core but I’m not sure how to do that.

When I use:

   core = Core.get(plugin_id)
	cpu_result = core.simple_query('check_cpu',arguments)
	print cpu_result

But it gives me the following error:

C:\Program Files\NSClient++>nscp py execute --script=test_python_cyrille
UENKNOWN    Unknown command(s): check_cpu
 core Unknown command(s): checkcpu available commands: commands {}, plugins {, 0}

I didn’t find a lot of information on how to use the nscp package in python.



OK, I needed to load the necessary modules first:

def init(pid, plugin_alias, script_alias):
	global plugin_id, core
	plugin_id = pid
	#load necessary modules
	core = Core.get(plugin_id)

Now I’m wondering if It is possible to get the result of the check command as JSON