Page 1 of 1

Curl Command

Posted: Wed Aug 21, 2019 10:11 am
by vignesha
Hello Team,

We are planning to automate BAU task which are currently done by us like (adding, removing, editing). First we are going to test in Nagios DR and later we will implement the same in PROD, once the testing success we will raise a request in Servicenow for (adding, removing, editing) for testing and once the request got approved in snow it will hit the Mid-server and from it will use API key of Nagios xi and perform the action as requested by recipient.

Note:
We have integrated nagios xi to Servicenow for that we have used mid-server and it will act as a middle man to nagios xi and Servicenow server, mid-server will capture all alerts data and will send to Servicenow base on the alerts auto ticket will be created automatically and will sent to respective team to take necessary action.

Mid-server is installed in windows server and we have installed CURL packages and tested few commands in cmd, PFB output for the same.

C:\Users\V5FA6YI\Downloads\curl-7.65.1_3-win64-mingw\curl-7.65.1-win64-mingw\bin
>curl -v http://xx.xxx.xxx.xx/nagiosxi/
* Trying xx.xxx.xxx.xx...
* TCP_NODELAY set
* Connected to xx.xxx.xxx.xx (xx.xxx.xxx.xx) port 80 (#0)
> GET /nagiosxi/ HTTP/1.1
> Host: xx.xxx.xxx.xx
> User-Agent: curl/7.65.1
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 302 Found
< Date: Wed, 21 Aug 2019 11:17:17 GMT
< Server: Apache/2.2.15 (Red Hat)
< X-Powered-By: PHP/5.3.3
< Set-Cookie: nagiosxi=a66m726bjbu0eof95go2jgibl2; expires=Wed, 21-Aug-2019 11:4
7:18 GMT; path=/; HttpOnly
< Expires: Thu, 19 Nov 1981 08:52:00 GMT
< Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
< Pragma: no-cache
< X-Frame-Options: SAMEORIGIN
< Content-Security-Policy: frame-ancestors 'self'
< Location: http://xx.xxx.xxx.xx/nagiosxi/login.php ... /index.php
%3f&noauth=1
< Content-Length: 27
< Connection: close
< Content-Type: text/html; charset=UTF-8
<
Your session has timed out.* Closing connection 0

-----------------------

C:\Users\V5FA6YI\Downloads\curl-7.65.1_3-win64-mingw\curl-7.65.1-win64-mingw\bin
>curl -o out.json http://xx.xxx.xxx.xx/nagiosxi/
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 27 100 27 0 0 79 0 --:--:-- --:--:-- --:--:-- 80

----------------------

C:\Users\V5FA6YI\Downloads\curl-7.65.1_3-win64-mingw\curl-7.65.1-win64-mingw\bin
>curl -i -X HEAD http://xx.xxx.xxx.xx/nagiosxi/
Warning: Setting custom HTTP method to HEAD with -X/--request may not work the
Warning: way you want. Consider using -I/--head instead.
HTTP/1.1 302 Found
Date: Wed, 21 Aug 2019 12:07:00 GMT
Server: Apache/2.2.15 (Red Hat)
X-Powered-By: PHP/5.3.3
Set-Cookie: nagiosxi=isv0rnhlr352vbpja6gffhcdg5; expires=Wed, 21-Aug-2019 12:37:
00 GMT; path=/; HttpOnly
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
X-Frame-Options: SAMEORIGIN
Content-Security-Policy: frame-ancestors 'self'
Location: http://xx.xxx.xxx.xx/nagiosxi/login.php ... ndex.php%3
f&noauth=1
Connection: close
Content-Type: text/html; charset=UTF-8

Can you just help me with the CURL command to test from mid-server command prompt (CMD) for adding, removing, editing?

Re: Curl Command

Posted: Wed Aug 21, 2019 2:14 pm
by mbellerue
Are you needing help with curl commands for working with Nagios? The best place for that is actually in Nagios XI, if you go to Help -> Any link under the API Docs section of the left menu. We can definitely help getting specific commands to work if they're not working as expected.