Working REST API examples


Hello members,

I try to address the NSClient ++ via REST.

I can get to the web interface of the WebModule. Unfortunately, I have nowhere found how to authenticate myself. Where did the user “admin” come from, as described in the description “”.

I first wanted to log in locally to the same VM on which the NSClient ++ runs using curl. My system is a Windows 2012 R2 with a NSClient ++ v0.5.1.44.

I have already tried the following commands: Request: curl -k -i -u admin:MyPassword https://localhost:8433/ Responds: 302

Request: curl -k -i -u admin:MyPassword https://localhost:8433/api/v1 Responds: 404 …Not found “/api/v1”

Request: curl -k -i -u admin:MyPassword https://localhost:8433/query/check_cpu Responds: 403 Please login first

I’ll probably have to pass an authentication token. I do not know which.

Can you help me?


When I try the following Get-Request: https://v893w2012r2:8443/query/check_cpu?password=MyPassword then I get the Response:

{“header”:{“source_id”:""},“payload”:[{“command”:“check_cpu”,“lines”:[{“message”:“Invalid command line: unrecognised option ‘password=MyPassword’\nfilter=core = ‘total’\t\t\tFilter which marks interesting items.\nwarning=load > 80\t\t\tFilter which marks items which generates a warning state.\nwarn=\t\t\t\t\tShort alias for warning\ncritical=load > 90\t\t\tFilter which marks items which generates a critical state.\ncrit=\t\t\t\t\tShort alias for critical.\nok=\t\t\t\t\tFilter which marks items which generates an ok state.\ndebug\t\t\t\t\tShow debugging information in the log\nshow-all\t\t\t\tShow details for all matches regardless of status (normally details are only showed for warnings and criticals).\nempty-state=ignored\t\t\tReturn status to use when nothing matched filter.\nperf-config=\t\t\t\tPerformance data generation configuration\nescape-html\t\t\t\tEscape any < and > characters to prevent HTML encoding\nhelp\t\t\t\t\tShow help screen (this screen)\nhelp-pb\t\t\t\tShow help screen as a protocol buffer payload\nshow-default\t\t\t\tShow default values for a given command\nhelp-short\t\t\t\tShow help screen (short format).\ntop-syntax=${status}: ${problem_list}\tTop level syntax.\nok-syntax=%(status): CPU load is ok.\tok syntax.\nempty-syntax=\t\t\t\tEmpty syntax.\ndetail-syntax=${time}: ${load}%\tDetail level syntax.\nperf-syntax=${core} ${time}\t\tPerformance alias syntax.\ntime=\t\t\t\t\tThe time to check\n”}],“result”:“UNKNOWN”}]}

But it seems not right.

Edit2: Ok-It’s done with a custom module “iissitestatevalidator” written in ".Net" Command-Request:

curl --insecure --header “password:MyPassword” “https://localhost:8443/query/iissitestatevalidator?State=Started&SiteName=MySite


{“header”:{},“payload”:[{“command”:“iissitestatevalidator”,“lines”:[{“message”:“Site is in the right state ‘Started’.”}],“result”:“OK”}]}

But how can I parse the JSON-Result in Nagios? I think Nagios expected always a output in the form of “|”?