How to publish a service via command line

Scope

You may want to publish services to be monitored via an automated mean, i.e. by using command line tools (such as curl). This documentation provides you with the basic knowledge to

  • publish new service via an HTTP POST request

What you need

  • username and password of an user who is allowed to publish services

Step by step

Publish new service to be monitored (json service description)

Please see the following json snippet describing a service to be monitored.

Some of the element might need to be changed according to the service you would like to monitor:

name

title of the service

url

the url to the service endpoint

type

the service type

job/name

the name of the job inside of the service element

job/monitoringTemplateId

the id of the template can be found in the browser’s address bar, when you view a concrete template, http://products.conterra.de/monitor/rest/triggerTemplates

job/notification/templateId

the id of the template can be found in the browser’s address bar, when you view a concrete template, http://products.conterra.de/monitor/rest/notificationTemplates

Sample JSON Content for service publishing
{
    "name": "Basemap WMS",
    "url": "http://services.conterra.de/arcgis/services/common/basemap/MapServer/WMSServer",
    "type": "WMS",
    "httpauth": {
        "username": "optional",
        "password": "optional"
    },
    "job": [
        {
            "name": "GetCapabilities",
            "category": "",
            "status": "active",
            "protectionlevel": "public",
            "monitoringTemplateId": "<MONITORING_TEMPLATE_ID>",
            "request": {
                "type": "HTTP_GET",
                "query": "?request=GetCapabilities&service=WMS",
                "body": ""
            },
            "notification": {
                "active": true,
                "templateid": "<NOTIFICATION_TEMPLATE_ID>"
            },
            "rules": {
                "timeout": 2500,
                "dead": true,
                "exception": true,
                "capacity": 1,
                "availability": 99
            }
        }
    ]
}
The httpauth element can be removed if the service to be monitored does not require authentication.

After changing the JSON snippet for the concrete service, you can POST it via such a statement

Publish JSON, authenticate http/BASIC
curl "http://products.conterra.de/monitor/rest/admin/services" --basic -u <USER>:<PASSWORD> -H "Accept: application/json, text/javascript, */*; q=0.01" --data-binary "<ESCAPED_JSON_DATA>"
HTTP Response (success)
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
Content-Location: http://products.conterra.de/monitor/rest/ui?lang=en&e=false
Expires: -1
Server: Microsoft-IIS/7.5
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: POST, GET, OPTIONS, PUT, DELETE, HEAD
X-Powered-By: ASP.NET
Date: Wed, 25 Mar 2015 08:59:28 GMT
Content-Length: 2
{}