Skip to main content

Hi, I'm trying to modify a service changing the argument DISKNAME using the REST API. But it doesn't work.

centreon_edit

This is the steps I'm following:

  1. Creating the service:
    curl --silent --location 'http://pepe.com/centreon/api/index.php?action=action&object=centreon_clapi' --header 'Content-Type: application/json' --header 'centreon-auth-token: <token>' --data '{ "action": "add", "object": "service", "values": "windows_vm;Filesystem D;OS-Windows-Disk-Generic-Name-SNMP" }'

{"result":[]}

  1. Adding the check command to the service:
    curl --silent --location 'http://pepe.com/centreon/api/index.php?action=action&object=centreon_clapi' --header 'Content-Type: application/json' --header 'centreon-auth-token: <token>' --data '{ "action": "setparam", "object": "service", "values": "windows_vm;Filesystem D;check_command;OS-Windows-SNMP-Disk-Name" }'

{"result":[]}

  1. Adding the partition Letter (this is where i'm failing):
    curl --silent --location 'http://pepe.com/centreon/api/index.php?action=action&object=centreon_clapi' --header 'Content-Type: application/json' --header 'centreon-auth-token: <token>' --data '{ "action": "setparam", "object": "service", "values": "windows_vm;Filesystem D;check_command_arguments;!D:!^(..).*!$1!80!90!--filter-perfdata='\''storage.space|used|free'\'' --regexp" }'

{"result":[]}

But when I look at the service nothing changes. Where I'm failling? (I reload and export the configuration in every change I made)

PD: Excuse my English, I'm still working on improving it. If there is any problem with my explanation or if you need more clarity, please let me know. Thanks you!

Hello @ruben_mendez 

I think you should try the “setmacro” action instead of “setparam”

https://docs.centreon.com/fr/docs/api/clapi/#setmacro-1

If i assumed correctly, we use the same command  for Windows Disk with SNMP (the one provisioned by PluginPacks), the value DISKNAME is a macro, not an argument

So the data you should send to the API should be something like this

'{ "action": "setmacro", "object": "service", "values": "windows_vm;Filesystem D;DISKNAME;D;0;disk to monitor" }'

 

Hope it helps


Thanks!

curl --silent --location 'http://pepe.com/centreon/api/index.php?action=action&object=centreon_clapi' --header 'Content-Type: application/json' --header 'centreon-auth-token: <token>' --data '{
"action": "setmacro",
"object": "service",
"values": "windows_vm;Filesystem D;DISKNAME;D:;;"
}'

 

 


Reply