Hi,
I want to create a new plugin or using an existing one to create alert in Nagios for API Monitoring for 'POST' method.
For this I already tried Nagios 'check_http' plugin to post "Json". However we are getting expected response for "Failure" case whereas Json String is not recognized for 'Success' cases. I tried using both single & double quote (' '/" ") for the POST string but that gives me the same error. I try the same thing using 'cURL' command and it gives me the expected JSON response.
Pl. find below the 'cURL' & corresponding 'check_http' command we are using now , output screenshots are also attached---
cURL command ---> curl -X POST -H "Content-Type: application/json" -d "{'catalogRefId':'9780545791342'}" http://test.com/rest/model/api/v1/atg/c ... tInventory
check_http command----> ./check_http -H test.com -u /rest/model/api/v1/atg/commerce/inventory/InventoryActor/getInventory -T "Content-Type:application/json" -j 'POST' --post="{'catalogRefId':'9780545791342'}" -v
Develop a new Plugin or upda to post Json for APi monitoring
Re: Develop a new Plugin or upda to post Json for APi monito
The content-type header isn't formatted correctly. Try:
./check_http -H test.com -u /rest/model/api/v1/atg/commerce/inventory/InventoryActor/getInventory -T "application/json" -j 'POST' --post="{'catalogRefId':'9780545791342'}" -v
Please provide the output of both commands if this doesn't help resolve the problem.
./check_http -H test.com -u /rest/model/api/v1/atg/commerce/inventory/InventoryActor/getInventory -T "application/json" -j 'POST' --post="{'catalogRefId':'9780545791342'}" -v
Please provide the output of both commands if this doesn't help resolve the problem.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Re: Develop a new Plugin or upda to post Json for APi monito
Many many thanks for your early response. Following your suggestion I am getting success for those cases where 'post' required only one parameter and corresponding value(e.g post='{"skuId":"9780155061392"}), however for those cases where it's required multiple parameter and value(e.g --post="{'login':'bnmonitoring01\@gmail.com','password':'Bn\@123'}").
Below are commands I am using for single & multiple parameter cases, I also uploading the output for both cases for your reference ---
Single parameter case :---
./check_http -H bn-api.bn-web.com -u /rest/model/api/v1/atg/commerce/pricing/PricingActor/skuPrices -T "application/json" -j 'POST' --post='{"skuId":"9780155061392"}' -v
Multiple Parameter case :----
./check_http -H test.com -u /rest/model/api/v1/atg/userprofiling/ProfileActor/login -T "application/json" -j 'POST' --post="{'login':'bnmonitoring01\@gmail.com','password':'Bn\@123'}" -v
Once again thanks for your help. Appreciating your early response.
Re: Develop a new Plugin or upda to post Json for APi monito
The \ to escape @ isn't necessary. Try the following instead:
./check_http -H test.com -u /rest/model/api/v1/atg/userprofiling/ProfileActor/login -T "application/json" -j 'POST' --post="{'login':'bnmonitoring01@gmail.com','password':'Bn@123'}" -v
./check_http -H test.com -u /rest/model/api/v1/atg/userprofiling/ProfileActor/login -T "application/json" -j 'POST' --post="{'login':'bnmonitoring01@gmail.com','password':'Bn@123'}" -v
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Re: Develop a new Plugin or upda to post Json for APi monito
Hi cdienger,
Thanks for your prompt reply.
I tried the command without escape character '\' also, however same result is coming.
Please help.
Thanks for your prompt reply.
I tried the command without escape character '\' also, however same result is coming.
Please help.
Re: Develop a new Plugin or upda to post Json for APi monito
Can you provide us with the output of the command please?
./check_http -H test.com -u /rest/model/api/v1/atg/userprofiling/ProfileActor/login -T "application/json" -j 'POST' --post="{'login':'bnmonitoring01@gmail.com','password':'Bn@123'}" -v
./check_http -H test.com -u /rest/model/api/v1/atg/userprofiling/ProfileActor/login -T "application/json" -j 'POST' --post="{'login':'bnmonitoring01@gmail.com','password':'Bn@123'}" -v
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Re: Develop a new Plugin or upda to post Json for APi monito
Hi,
Thanks for your reply. Please find attached the output(login.txt) of below command for login API. Instead of '200', return code is coming '302', login success message is also not coming. However if we are using below URL, we are getting 'login successful' message ---
Nagios Command for Login ---
./check_http -H test.com -u /rest/model/api/v1/atg/userprofiling/ProfileActor/login -T "application/json" -j 'POST' --post="{'login':'bnmonitoring01@gmail.com','password':'Bn@123'}" -v
Login URL ---------------------
http://test.com/rest/model/api/v1/atg/u ... ord=Bn@123
Thanks for your reply. Please find attached the output(login.txt) of below command for login API. Instead of '200', return code is coming '302', login success message is also not coming. However if we are using below URL, we are getting 'login successful' message ---
Nagios Command for Login ---
./check_http -H test.com -u /rest/model/api/v1/atg/userprofiling/ProfileActor/login -T "application/json" -j 'POST' --post="{'login':'bnmonitoring01@gmail.com','password':'Bn@123'}" -v
Login URL ---------------------
http://test.com/rest/model/api/v1/atg/u ... ord=Bn@123
- Attachments
-
- login.txt
- Output of above 'Nogios Command for login'
- (2.85 KiB) Downloaded 540 times
Re: Develop a new Plugin or upda to post Json for APi monito
The 302 is a redirect. You can have the check follow the redirect with:
./check_http -H test.com -u /rest/model/api/v1/atg/userprofiling/ProfileActor/login -T "application/json" -j 'POST' --post="{'login':'bnmonitoring01@gmail.com','password':'Bn@123'}" -v -f follow
./check_http -H test.com -u /rest/model/api/v1/atg/userprofiling/ProfileActor/login -T "application/json" -j 'POST' --post="{'login':'bnmonitoring01@gmail.com','password':'Bn@123'}" -v -f follow
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Re: Develop a new Plugin or upda to post Json for APi monito
Hi cdienger,
Many many thanks for your excellent help. after adding the -f followup, command is working as expected.
Appreciate all your extended help.
Looking forward for your future help/suggestion.
Many many thanks for your excellent help. after adding the -f followup, command is working as expected.
Appreciate all your extended help.
Looking forward for your future help/suggestion.
Re: Develop a new Plugin or upda to post Json for APi monito
Glad to help
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.