WebServer API

The WebServer to manage the API is based on the Host.it Agent Framework.

The config files are provided in the directory hsm_webserver. To run the hostit monitoring webserver:

hagent-run ws_scripts/config.ini ws_scripts/logging.ini

Manage Rest Entity

It’s possible to manage these entities:

  • service
    Measurements performed by Workers on websites. By defaults response_time and render_time
  • time
    The time frame in which an analysis cycle on a SLA must complete
  • tolerance
    The time limit in which we consider valid a single analysis in a cycle
  • sla
    Entity composed by a service, a time and a tolerance
  • website
    The list of websites to test
  • extra_info
    Additional informations about each analysis

Service

Service Model Definitions:

  • _id: ObjectId()
  • remote_id: String, id apt to link external services
  • name: String

By default only two services are performed by monitoring (response_time and render_time).

Reference:

Time

Time Model Definitions:

  • _id: ObjectId()
  • time_slice: Int, represented in seconds without units
  • name: String

Reference:

  • Get the list of every time:

    GET http://0.0.0.0:8181/v1/time

    Response example:

    {
     "code": 0,
     "errors": {},
     "result": [
       {
         "_id": "58ac10a7c42d753997c6ce82",
         "name": "1minute",
         "time_slice": 60
       },
       {
         "_id": "58ac10a7c42d753997c6ce83",
         "name": "15minute",
         "time_slice": 900
       },
       {
         "_id": "58ac10a7c42d753997c6ce84",
         "name": "30minute",
         "time_slice": 1800
       },
       {
         "_id": "58ac10a7c42d753997c6ce85",
         "name": "1hour",
         "time_slice": 3600
       },
       {
         "_id": "58ac10a7c42d753997c6ce86",
         "name": "2hour",
         "time_slice": 7200
       }
     ]
    }
    
  • Get a single time:

    GET http://0.0.0.0:8181/v1/time/{time_id}

    e.g. GET http://0.0.0.0:8181/v1/time/5

    Response example:

    {
     "code": 0,
     "errors": {},
     "result": {
       "_id": "58ac10a7c42d753997c6ce82",
       "name": "1minute",
       "time_slice": 60
     }
    }
    
  • Post a new time:

    POST http://0.0.0.0:8181/v1/time

    e.g. POST http://0.0.0.0:8181/v1/time/

    body:

    {
        "name": "1minute",
        "time_slice": 60
    }
    

    Response example:

    {
     "code": 0,
     "errors": {},
     "result": {
       "_id": "58ac10a7c42d753997c6ce82",
       "name": "1minute",
       "time_slice": 60
     }
    }
    
  • Delete a single time:

    DELETE http://0.0.0.0:8181/v1/time/{time_id}

    e.g. DELETE http://0.0.0.0:8181/v1/time/5

    Response example:

    {
     "code": 0,
     "errors": {},
     "result": "Deleted element: 1"
    }
    
  • Modify a time:

    PUT http://0.0.0.0:8181/v1/time/{time_id}

    e.g. PUT http://0.0.0.0:8181/v1/time/5

    body:

    {
        "name": "1minute",
        "time_slice": 60
    }
    

    Response example:

    {
     "code": 0,
     "errors": {},
     "result": {
       "_id": "58ac10a7c42d753997c6ce82",
       "name": "1minute",
       "time_slice": 60
     }
    }
    

Tolerance

Tolerance Model Definitions:

  • _id: ObjectId()
  • time_slice: Int, represented in seconds without units
  • name: String

Reference:

SLA

SLA Model Definitions:

  • _id: ObjectId()
  • name: String
  • _service_id: ObjectId()
  • _time_id: ObjectId()
  • _tolerance_id: ObjectId()
  • max_worker: Int, maximum Workers operating on a SLA. The default -1 means no limits.

Reference:

  • Get the list of every SLA:

    GET http://0.0.0.0:8181/v1/sla

    Response example:

    {
      "code": 0,
      "errors": {},
      "result": [
        {
          "_id": "58ac10a7c42d753997c6ce8a",
          "name": "response_time_1minute_5second",
          "_service_id": "58ac10a7c42d753997c6ce80",
          "_time_id": "58ac10a7c42d753997c6ce82",
          "_tolerance_id": "58ac10a7c42d753997c6ce87",
          "max_worker": -1
        },
        {
          "_id": "58ac10a7c42d753997c6ce8b",
          "name": "response_time_15minute_10second",
          "_service_id": "58ac10a7c42d753997c6ce80",
          "_time_id": "58ac10a7c42d753997c6ce83",
          "_tolerance_id": "58ac10a7c42d753997c6ce88",
          "max_worker": -1
        },
        {
          "_id": "58ac10a7c42d753997c6ce8f",
          "name": "render_time_2hour_15second",
          "_service_id": "58ac10a7c42d753997c6ce81",
          "_time_id": "58ac10a7c42d753997c6ce86",
          "_tolerance_id": "58ac10a7c42d753997c6ce89",
          "max_worker": -1
        }
      ]
    }
    
  • Get a single SLA:

    GET http://0.0.0.0:8181/v1/sla/{sla_id}

    e.g. GET http://0.0.0.0:8181/v1/sla/58ac10a7c42d753997c6ce8a

    Response example:

    {
      "code": 0,
      "errors": {},
      "result":
        {
          "_id": "58ac10a7c42d753997c6ce8a",
          "name": "response_time_1minute_5second",
          "_service_id": "58ac10a7c42d753997c6ce80",
          "_time_id": "58ac10a7c42d753997c6ce82",
          "_tolerance_id": "58ac10a7c42d753997c6ce87",
          "max_worker": -1
        }
    }
    
  • Post a new SLA:

    POST http://0.0.0.0:8181/v1/sla

    e.g. POST http://0.0.0.0:8181/v1/sla/

    body:

    {
      "name": "response_time_1minute_5second",
      "_service_id": "58ac10a7c42d753997c6ce80",
      "_time_id": "58ac10a7c42d753997c6ce82",
      "_tolerance_id": "58ac10a7c42d753997c6ce87",
      "max_worker": -1
    }
    

    Response example:

    {
      "code": 0,
      "errors": {},
      "result":
        {
          "_id": "58ac10a7c42d753997c6ce8a",
          "name": "response_time_1minute_5second",
          "_service_id": "58ac10a7c42d753997c6ce80",
          "_time_id": "58ac10a7c42d753997c6ce82",
          "_tolerance_id": "58ac10a7c42d753997c6ce87",
          "max_worker": -1
        }
    }
    
  • Delete a single SLA:

    DELETE http://0.0.0.0:8181/v1/sla/{sla_id}

    e.g. DELETE http://0.0.0.0:8181/v1/sla/58ac10a7c42d753997c6ce8a

    Response example:

    {
      "code": 0,
      "errors": {},
      "result":
        {
          "_id": "58ac10a7c42d753997c6ce8a",
          "name": "response_time_1minute_5second",
          "_service_id": "58ac10a7c42d753997c6ce80",
          "_time_id": "58ac10a7c42d753997c6ce82",
          "_tolerance_id": "58ac10a7c42d753997c6ce87",
          "max_worker": -1
        }
    }
    
  • Modify a SLA:

    PUT http://0.0.0.0:8181/v1/sla/{sla_id}

    e.g. PUT http://0.0.0.0:8181/v1/sla/58ac10a7c42d753997c6ce8a

    body:

    {
      "name": "response_time_1minute_5second",
      "_service_id": "58ac10a7c42d753997c6ce80",
      "_time_id": "58ac10a7c42d753997c6ce82",
      "_tolerance_id": "58ac10a7c42d753997c6ce87",
      "max_worker": -1
    }
    

    Response example:

    {
      "code": 0,
      "errors": {},
      "result":
        {
          "_id": "58ac10a7c42d753997c6ce8a",
          "name": "response_time_1minute_5second",
          "_service_id": "58ac10a7c42d753997c6ce80",
          "_time_id": "58ac10a7c42d753997c6ce82",
          "_tolerance_id": "58ac10a7c42d753997c6ce87",
          "max_worker": -1
        }
    }
    

WebSites

Website Model Definitions:

  • _id: ObjectId()
  • name: String
  • url: String
  • sla []: List of Str(ObjectId), related to SLAs
  • last_update: Datetime
  • delete_date: Datetime

Reference:

  • Get the list of every website:

    GET http://0.0.0.0:8181/v1/website

    Response example:

    {
      "code": 0,
      "errors": {},
      "result": [
        {
          "_id": "58ac10a7c42d753997c6ce90",
          "url": "http://www.etimax.net",
          "last_update": "2017-02-21 10:04:23.554000",
          "name": "etimax.net",
          "sla": [
            "58ac10a7c42d753997c6ce8a",
            "58ac10a7c42d753997c6ce8d"
          ]
        },
        {
          "_id": "58ac10a7c42d753997c6ce91",
          "url": "http://www.eziobosso.com",
          "last_update": "2017-02-21 10:04:23.560000",
          "name": "eziobosso.com",
          "sla": [
            "58ac10a7c42d753997c6ce8a",
            "58ac10a7c42d753997c6ce8d"
          ]
        },
        {
          "_id": "58ac10a7c42d753997c6ce92",
          "url": "http://www.herbalvit.it",
          "last_update": "2017-02-21 10:04:23.561000",
          "name": "herbalvit.it",
          "sla": [
            "58ac10a7c42d753997c6ce8a",
            "58ac10a7c42d753997c6ce8d"
          ]
        }
      ]
    }
    
  • Get a single website:

    GET http://0.0.0.0:8181/v1/website/{website_id}

    e.g. GET http://0.0.0.0:8181/v1/website/58ac10a7c42d753997c6ce90

    Response example:

    {
      "code": 0,
      "errors": {},
      "result":
        {
          "_id": "58ac10a7c42d753997c6ce90",
          "url": "http://www.etimax.net",
          "last_update": "2017-02-21 10:04:23.554000",
          "name": "etimax.net",
          "sla": [
            "58ac10a7c42d753997c6ce8a",
            "58ac10a7c42d753997c6ce8d"
          ]
        }
    }
    
  • Post a new website:

    POST http://0.0.0.0:8181/v1/website

    e.g. POST http://0.0.0.0:8181/v1/website/

    body:

    {
      "url": "http://www.etimax.net",
      "name": "etimax.net",
      "sla": [
        "58ac10a7c42d753997c6ce8a",
        "58ac10a7c42d753997c6ce8d"
      ]
    }
    

    Response example:

    {
      "code": 0,
      "errors": {},
      "result":
        {
          "_id": "58ac10a7c42d753997c6ce90",
          "url": "http://www.etimax.net",
          "last_update": "2017-02-21 10:04:23.554000",
          "name": "etimax.net",
          "sla": [
            "58ac10a7c42d753997c6ce8a",
            "58ac10a7c42d753997c6ce8d"
          ]
        }
    }
    
  • Delete a single website:

    DELETE http://0.0.0.0:8181/v1/website/{website_id}

    e.g. DELETE http://0.0.0.0:8181/v1/website/58ac10a7c42d753997c6ce90

    Response example:

    {
      "code": 0,
      "errors": {},
      "result":
        {
          "_id": "58ac10a7c42d753997c6ce90",
          "url": "http://www.etimax.net",
          "last_update": "2017-02-21 10:04:23.554000",
          "delete_date": "2017-02-21 10:04:23.554000",
          "name": "etimax.net",
          "sla": [
            "58ac10a7c42d753997c6ce8a",
            "58ac10a7c42d753997c6ce8d"
          ]
        }
    }
    
  • Modify a website:

    PUT http://0.0.0.0:8181/v1/website/{website_id}

    e.g. PUT http://0.0.0.0:8181/v1/website/58ac10a7c42d753997c6ce90

    body:

    {
      "url": "http://www.etimax.net",
      "name": "etimax.net",
      "sla": [
        "58ac10a7c42d753997c6ce8a",
        "58ac10a7c42d753997c6ce8d"
      ]
    }
    

    Response example:

    {
      "url": "http://www.etimax.net",
      "name": "etimax.net",
      "sla": [
        "58ac10a7c42d753997c6ce8a",
        "58ac10a7c42d753997c6ce8d"
      ]
    }