Options

External Monitor Script

Hi,

I have a developed bash script that I need to be able to "convert" to an A10 external monitor script.

The script is
`#!/bin/bash
TOKEN=curl -s -k https://<name of server>/icoauth/oauth2/token -d &#039;grant_type=client_credentials&client_id=as-client&client_secret=<secret key>&principal_attribute_extRef=exr999999&#039; | sed &#039;s/.*access_token":"//g&#039; | sed &#039;s/".*//g&#039;
curl -k -w "%{http_code}" -s -H "Authorization: Bearer ${TOKEN}" -H "Content-Type: application/json" -X POST -d '{ "service": "<service name>", "siteId": "<site #>", "data": {"customerAccount": "<acc #>", "contactIds": [ "<id #>" ] } }' https://<name of server>


What is does:
The TOKEN line obtains a token from a given server (lets call it server1) and uses SED to extract the token out of the returned response

The CURL line used the TOKEN from server1 and does a health check against server2-5 and returns a status code (200=good.... not 200=bad)

How would I go about doing this?

Comments

  • Options
    dcase99dcase99 Member
    edited March 2017
    `#!/bin/bash
    TOKEN=curl -s -k https://portal.lab.intelligent-home.jp/icoauth/oauth2/token -d &#039;grant_type=client_credentials&client_id=as-client&client_secret=02875f01-6add-48fc-8c4f-d1693ba0695e&principal_attribute_extRef=exr999999&#039; | sed &#039;s/.*access_token":"//g&#039; | sed &#039;s/".*//g&#039;
    curl -k -w "%{http_code}" -s -H "Authorization: Bearer ${TOKEN}" -H "Content-Type: application/json" -X POST -d '{ "service": "sgs", "siteId": "123.4", "data": {"customerAccount": "140601002", "contactIds": [ "140601002" ] } }' https://ias.lab.intelligent-home.jp/alarm/icontrol
  • Options
    dcase99dcase99 Member
    edited March 2017
    well darn it, lets try this one more time

    #!/bin/bash
    TOKEN=curl -s -k https://portal.lab.intelligent-home.jp/icoauth/oauth2/token -d 'grant_type=client_credentials&client_id=as-client&client_secret=02875f01-6add-48fc-8c4f-d1693ba0695e&principal_attribute_extRef=exr999999' | sed 's/.*access_token":"//g' | sed 's/".*//g'
    curl -k -w "%{http_code}" -s -H "Authorization: Bearer ${TOKEN}" -H "Content-Type: application/json" -X POST -d '{ "service": "sgs", "siteId": "123.4", "data": {"customerAccount": "140601002", "contactIds": [ "140601002" ] } }' https://ias.lab.intelligent-home.jp/alarm/icontrol
Sign In or Register to comment.