Giter Club home page Giter Club logo

pimatic-probe's Introduction

pimatic-probe

npm version Build Status

A pimatic plugin to probe HTTP(S) and TCP services.

Contributions

Contributions to the project are welcome. You can simply fork the project and create a pull request with your contribution to start with. If you like this plugin, please consider ★ starring the project on github.

Configuration

Note, instead of editing config.json as suggested in the remainder it is easier to use the plugin and device configuration editors provided as part of the web frontend for pimatic 0.9.

You can load the plugin by editing your config.json to include the following in the plugins section. For debugging purposes you may set property debug to true. This will write additional debug messages to the pimatic log.

{
      "plugin": "probe",
      "debug": false
}

Then you need to add a device in the devices section. Currently, the following device types are supported:

  • HttpProbe: This type provides a probe for HTTP/HTTPS services by sending a HTTP GET request and checking the response.
  • TcpConnectProbe: This type provides a probe for TCP-based services by establishing a TCP connection and testing the connection status.

HttpProbe Configuration

As part of the device definition you need to provide the url for the Web Service to be probed. Note, the URL may also contain a port number and path if needed, for example: "http://fritz.box:88/details.html". If the property enableResponseTime is set to true (false by default) the device will additionally expose a responseTime attribute, which allows for monitoring the response times. You may also set the interval property to specify the probing interval in seconds (60 seconds by default). Warning Notice: Generally, it is not advised to ping external services at a high frequency as this may be regarded as a denial-of-service attack!

{
      "id": "probel",
      "class": "HttpProbe",
      "name": "Router Web Page",
      "url": "http://fritz.box",
      "enableResponseTime": false,
      "interval": 60
}

HttpProbe Advanced Configuration

This section is for advanced users with a good understanding of the HTTP protocol.

HTTP Response Status Codes

By default, HttpProbe accepts responses with any HTTP status code. This may not be satisfactory as this way you will not be able to detect HTTP-specific errors, such as 404 (Not Found) or 502 (Bad Gateway). If you require a specific accept pattern you can set the property acceptedStatusCodes which holds an array of accepted status codes. The value 0 is provided to allow all status codes by default.

{
    "id": "probe2",
    "class": "HttpProbe",
    "name": "Router Web Page with Basic Auth",
    "url": "http://fritz.box",
    "enableResponseTime": false,
    "interval": 60,
    "acceptedStatusCodes": [
        200
    ],
    "maxRedirects": 0
}

HTTP Basic Authentication

By default, HttpProbe accepts responses with any HTTP status code which includes code 401 (Unauthorized). However, you can perform proper authentication by setting the properties username and password. In this case you also need to remove status code 401 from the list of accepted status codes by setting the acceptedStatusCodes property. See example below. Warning Notice: Do not set username and password as part of the URL as this has been deprecated and it presents a security risk!

{
    "id": "probe3",
    "class": "HttpProbe",
    "name": "Router Web Page with Basic Auth",
    "url": "http://fritz.box",
    "enableResponseTime": false,
    "interval": 60
    "username": "foo",
    "password": "bar",
    "acceptedStatusCodes": [
        200
    ]
}

HTTPS Server Certificate Verification

By default, HttpProbe does not verify the server certificate if connected to a HTTPS server. The verification can be enabled by setting the verifyPeerCert property to true. In this case, HttpProbe will fail (absent state) if the server certificate cannot be verified.

{
    "id": "probe4",
    "class": "HttpProbe",
    "name": "Router Web Page with Basic Auth",
    "url": "https://fritz.box",
    "verifyPeerCert": true,
    "enableResponseTime": false,
    "interval": 60
    "username": "foo",
    "password": "bar",
    "acceptedStatusCodes": [
        200
    ]
}

HTTP Redirect

By default, HttpProbe will follow up to 5 redirects automatically. You can change the maximum number of redirects followed automatically by setting the property maxRedirects. If you set the maxRedirects to 0, redirects will not be followed automatically.

{
    "id": "probe5",
    "class": "HttpProbe",
    "name": "Router Web Page with Redirect",
    "url": "http://fritz.box",
    "enableResponseTime": false,
    "interval": 60,
    "maxRedirects": 0
}

xLink and xAttributeOptions properties

If you wish to hide the sparkline (the mini-graph) of responseTime attribute display this is possible with pimatic v0.8.68 and higher using the xAttributeOptions property as shown in the following example. Using the xLink property you can also add a hyperlink to the device display.

{
     "id": "probe6",
     "class": "HttpProbe",
     "name": "Router Web Page with Redirect",
     "url": "http://fritz.box",
     "enableResponseTime": true,
     "interval": 60,
     "maxRedirects": 0,
     "xLink": "http://fritz.box",
     "xAttributeOptions": [
         {
           "name": "responseTime",
           "displaySparkline": false
         }
     ]
 }

TcpConnectProbe Configuration

As part of the device definition you need to provide the host and portfor the TCP Service to be probed. If the property enableConnectTime is set to true (false by default) the device will additionally expose a connectTime attribute, which allows for monitoring the connection establishment times. You may also set the interval property to specify the probing interval in seconds (60 seconds by default). The timeout property may be set to specify the idle timeout on the TCP socket in seconds (10 seconds by default).

{
      "id": "probe7",
      "class": "TcpConnectProbe",
      "name": "Call Monitor",
      "host": "fritz.box",
      "port": 1012,
      "enableConnectTime": false,
      "interval": 10,
      "timeout": 10
}

TcpConnectProbe Advanced Configuration

xLink and xAttributeOptions properties

If you wish to hide the sparkline (the mini-graph) of connectTime attribute display this is possible with pimatic v0.8.68 and higher using the xAttributeOptions property as shown in the following example. Using the xLink property you can also add a hyperlink to the device display.

{
    "id": "probe8",
    "class": "TcpConnectProbe",
    "name": "Call Monitor",
    "host": "fritz.box",
    "port": 1012,
    "enableConnectTime": true,
    "interval": 10,
    "timeout": 10
    "xLink": "http://fritz.box",
    "xAttributeOptions": [
         {
           "name": "connectTime",
           "displaySparkline": false
         }
    ]
}

History

See Release History.

License

Copyright (c) 2015-2019, Marcus Wittig and contributors. All rights reserved.

License: GPL-2.0.

pimatic-probe's People

Contributors

greenkeeperio-bot avatar mwittig avatar sweetpi avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Forkers

sweetpi bstrebel

pimatic-probe's Issues

Deviceclass not listed

The device class HttpProbe is not listed in the #edit-device-page tab from mobile-frontend.

lastState faulty

I think

createCallback: (config, plugin, lastState)

should be

createCallback: (config, lastState)

in probe.coffee

Version 10 of node.js has been released

Version 10 of Node.js (code name Dubnium) has been released! 🎊

To see what happens to your code in Node.js 10, Greenkeeper has created a branch with the following changes:

  • Added the new Node.js version to your .travis.yml
  • The new Node.js version is in-range for the engines in 1 of your package.json files, so that was left alone

If you’re interested in upgrading this repo to Node.js 10, you can open a PR with these changes. Please note that this issue is just intended as a friendly reminder and the PR as a possible starting point for getting your code running on Node.js 10.

More information on this issue

Greenkeeper has checked the engines key in any package.json file, the .nvmrc file, and the .travis.yml file, if present.

  • engines was only updated if it defined a single version, not a range.
  • .nvmrc was updated to Node.js 10
  • .travis.yml was only changed if there was a root-level node_js that didn’t already include Node.js 10, such as node or lts/*. In this case, the new version was appended to the list. We didn’t touch job or matrix configurations because these tend to be quite specific and complex, and it’s difficult to infer what the intentions were.

For many simpler .travis.yml configurations, this PR should suffice as-is, but depending on what you’re doing it may require additional work or may not be applicable at all. We’re also aware that you may have good reasons to not update to Node.js 10, which is why this was sent as an issue and not a pull request. Feel free to delete it without comment, I’m a humble robot and won’t feel rejected 🤖


FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

option to choose logLevel

Hi, it would be nice, if you can choose how an error for a probe device is been logged. Options should be, info, warn and error. at the moment, if a probe fails, it's logged as an error, which sometimes is a bit anoying.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.