Code Monkey home page Code Monkey logo

cachet-url-monitor's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

cachet-url-monitor's Issues

The URL is unreachable

Why this page is unreachable when it's reachable on browser? I paste log from console. When i add site like google.com it's work.

cachet:
action:

  • CREATE_INCIDENT

  • UPDATE_STATUS
    api_url: ***
    component_id: 1
    public_incidents: true
    endpoint:
    allowed_fails: 0
    expectation:

  • status_range: 200-300
    type: HTTP_STATUS

  • threshold: 10
    type: LATENCY

  • regex: .(<body).
    type: REGEX
    method: GET
    timeout: 10
    url: http://wnuk.it
    frequency: 30
    latency_unit: ms

    INFO [2018-09-23 00:39:18,235] cachet_url_monitor.configuration.Configuration - Monitoring URL: GET http://wnuk.it
    INFO [2018-09-23 00:39:18,236] cachet_url_monitor.configuration.Configuration - Registered expectation: 'HTTP status range: (200, 300)'
    INFO [2018-09-23 00:39:18,237] cachet_url_monitor.configuration.Configuration - Registered expectation: 'Latency threshold: 10.0000 seconds'
    INFO [2018-09-23 00:39:18,237] cachet_url_monitor.configuration.Configuration - Registered expectation: 'Regex: .(<body).'
    INFO [2018-09-23 00:39:18,237] cachet_url_monitor.scheduler.Scheduler - Registering action CREATE_INCIDENT
    INFO [2018-09-23 00:39:18,238] cachet_url_monitor.scheduler.Scheduler - Registering action UPDATE_STATUS
    INFO [2018-09-23 00:39:18,238] cachet_url_monitor.scheduler.Scheduler - Starting monitor agent...
    WARNING [2018-09-23 00:39:51,269] cachet_url_monitor.configuration.Configuration - The URL is unreachable: GET http://wnuk.it
    INFO [2018-09-23 00:39:51,270] cachet_url_monitor.configuration.Configuration - Failure #1 with threshold set to 0
    INFO [2018-09-23 00:39:51,312] cachet_url_monitor.configuration.Configuration - Incident uploaded, API unhealthy: component status [3], message: "The URL is unreachable: GET http://wnuk.it"

No module named 'Schedule'

I followed the installation instructions.

Finished processing dependencies for cachet-url-monitor==0.6.7
(cachet-url-monitor) root@S1-Linux-VM:/home/servers/cachet-url-monitor# python3 cachet_url_monitor/scheduler.py config.yml
Traceback (most recent call last):
  File "cachet_url_monitor/scheduler.py", line 8, in <module>
    import schedule
ModuleNotFoundError: No module named 'schedule'

When i trying to install 'Schedule'

(cachet-url-monitor) root@S1-Linux-VM:/home/servers/cachet-url-monitor# pip install schedule
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
Requirement already satisfied: schedule in ./lib/python2.7/site-packages (0.6.0)

NameError: name 'file' is not defined

Hi,

I've installed the package via pip, when adding the config.yml file and starting it via : python3 scheduler.py config.yml I get the following error message :

Traceback (most recent call last):
File "scheduler.py", line 89, in
scheduler = Scheduler(sys.argv[1])
File "scheduler.py", line 55, in init
self.configuration = Configuration(config_file)
File "/usr/local/lib/python3.7/site-packages/cachet_url_monitor/configuration.py", line 83, in init
self.data = load(file(self.config_file, 'r'))
NameError: name 'file' is not defined

any idea how to solve this?

Jay

SSL Failed Certificate Verification Error

Trying to set up the url monitor with my status page and I'm getting this error:

(cachet_url_monitor) $ python cachet_url_monitor/scheduler.py config.yml

Traceback (most recent call last):
  File "cachet_url_monitor/scheduler.py", line 89, in 
    scheduler = Scheduler(sys.argv[1])
  File "cachet_url_monitor/scheduler.py", line 55, in __init__
    self.configuration = Configuration(config_file)
  File "/Users/username/Development/Web/Cachet/cachet-url-monitor/cachet_url_monitor/configuration.py", line 91, in __init__
    self.default_metric_value = self.get_default_metric_value()
  File "/Users/username/Development/Web/Cachet/cachet-url-monitor/cachet_url_monitor/configuration.py", line 106, in get_default_metric_value
    get_metric_request = requests.get('%s/metrics/%s' % (self.api_url, self.metric_id), headers=self.headers)
  File "/Users/username/Development/Web/Cachet/cachet-url-monitor/cachet_url_monitor/lib/python2.7/site-packages/requests/api.py", line 67, in get
    return request('get', url, params=params, **kwargs)
  File "/Users/username/Development/Web/Cachet/cachet-url-monitor/cachet_url_monitor/lib/python2.7/site-packages/requests/api.py", line 53, in request
    return session.request(method=method, url=url, **kwargs)


  File "/Users/username/Development/Web/Cachet/cachet-url-monitor/cachet_url_monitor/lib/python2.7/site-packages/requests/sessions.py", line 468, in request
    resp = self.send(prep, **send_kwargs)
  File "/Users/username/Development/Web/Cachet/cachet-url-monitor/cachet_url_monitor/lib/python2.7/site-packages/requests/sessions.py", line 576, in send
    r = adapter.send(request, **kwargs)
File "/Users/username/Development/Web/Cachet/cachet-url-monitor/cachet_url_monitor/lib/python2.7/site-packages/requests/adapters.py", line 447, in send
    raise SSLError(e, request=request)
requests.exceptions.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:661)

The URL is unreachable

Doesn't work to me. Got always "The URL is unreachable" no matter what URL I use - even with google.com. Any ideas?

Pushing latency as milliseconds

Usually status pages show the latency in ms.

Cachet can't convert the seconds to milliseconds, so url-monitor should be able to do that.

I'm suggesting a config param to switch to ms.

Trailing slash in api_url causes 404

Removing the trailing slash from the config file fixes this.

Ubuntu Linux 16
Python: 2.7

<Response [404]>
Traceback (most recent call last):
  File "cachet_url_monitor/scheduler.py", line 77, in <module>
    scheduler = Scheduler(sys.argv[1])
  File "cachet_url_monitor/scheduler.py", line 50, in __init__
    self.configuration = Configuration(config_file)
  File "/home/gardner/cachet-url-monitor/cachet_url_monitor/configuration.py", line 84, in __init__
    self.status = get_current_status(self.api_url, self.component_id, self.headers)
  File "/home/gardner/cachet-url-monitor/cachet_url_monitor/configuration.py", line 56, in get_current_status
    raise ComponentNonexistentError(component_id)
configuration.ComponentNonexistentError: 'Component with id [1] does not exist.'

Monitoring executed several times

I have configured monitor to monitor 11 services and I've noticed that some of them are triggered several times. Looking at the scheduler module, it doesn't seem to be designed with multiple threads in mind. When triggering it from thread, it can easily happen that more threads get the same pending tasks.

Possible solutions:

  • Use just one scheduler thread, let it execute the tasks in separate threads.
  • Use per thread scheduler instance.

Receiving "Unexpected HTTP status (200)" when status_range: 200

Except from config.yml

    expectation:
      - type: HTTP_STATUS
        status_range: 200
        incident: MAJOR

Except from logs:

cachet-url-monitor    |      INFO [2020-02-05 22:38:41,228] cachet_url_monitor.configuration.Configuration.example backend - Component current status: ComponentStatus.MAJOR_OUTAGE
cachet-url-monitor    |      INFO [2020-02-05 22:38:41,228] cachet_url_monitor.configuration.Configuration.example backend - Monitoring URL: GET https://example.com
cachet-url-monitor    |      INFO [2020-02-05 22:38:41,228] cachet_url_monitor.configuration.Configuration.example backend - Registered expectation: 'HTTP status range: [200, 201['
cachet-url-monitor    |      INFO [2020-02-05 22:38:41,228] cachet_url_monitor.scheduler - Registering action CREATE_INCIDENT
cachet-url-monitor    |      INFO [2020-02-05 22:38:41,228] cachet_url_monitor.scheduler - Registering action UPDATE_STATUS
cachet-url-monitor    |      INFO [2020-02-05 22:38:41,228] cachet_url_monitor.scheduler.Scheduler - Starting monitor agent...
...
cachet-url-monitor    |      INFO [2020-02-05 22:39:11,396] cachet_url_monitor.configuration.Configuration.example backend - Unexpected HTTP status (200)
cachet-url-monitor    |      INFO [2020-02-05 22:39:11,537] cachet_url_monitor.configuration.Configuration.example backend - Component update: status [ComponentStatus.MAJOR_OUTAGE]
cachet-url-monitor    |      INFO [2020-02-05 22:39:41,708] cachet_url_monitor.configuration.Configuration.example backend - Unexpected HTTP status (200)
cachet-url-monitor    |      INFO [2020-02-05 22:39:41,708] cachet_url_monitor.configuration.Configuration.example backend - No changes to component status.

At first I thought it may be a parsing issue, looking at this line of the log
cachet_url_monitor.configuration.Configuration.example backend - Registered expectation: 'HTTP status range: [200, 201['
But from the code that seems to be expected.

docker-compose file

Hello!

I'm attempting to set up an instance using Docker, and the README suggests that there is a docker-compose file ready for use, however, I can't seem to locate it. Is it meant to be in the repo?

Error :(

(cachet-url-monitor)root@244637a1:/opt/cachet-url-monitor# python cachet_url_monitor/scheduler.py config.yml
     INFO [2017-03-14 18:03:29,590] cachet_url_monitor.configuration.Configuration - Current configuration:
cachet:
  action:
  - CREATE_INCIDENT
  - UPDATE_STATUS
  api_url: https://status.PAGE.eu/api/v1
  component_id: 3
  public_incidents: true
endpoint:
  expectation:
  - status: 200
    type: HTTP_STATUS
  - threshold: 1
    type: LATENCY
  - regex: .*(<body).*
    type: REGEX
  method: GET
  timeout: 1
  url: https://PAGE.eu
frequency: 30

Traceback (most recent call last):
  File "cachet_url_monitor/scheduler.py", line 89, in <module>
    scheduler = Scheduler(sys.argv[1])
  File "cachet_url_monitor/scheduler.py", line 55, in __init__
    self.configuration = Configuration(config_file)
  File "/opt/cachet-url-monitor/cachet_url_monitor/configuration.py", line 91, in __init__
    self.default_metric_value = self.get_default_metric_value()
  File "/opt/cachet-url-monitor/cachet_url_monitor/configuration.py", line 107, in get_default_metric_value
    return get_metric_request.json()['data']['default_value']
KeyError: 'data'
(cachet-url-monitor)root@244637a1:/opt/cachet-url-monitor# 

Metrics not pushed

Hi @mtakaki,

First of all, thanks for this great piece of code.

I'm a pretty new user of cachet and cachet-url-monitor. So far, I have managed to configure the different components and the status is updated correctly. My problem is that I cannot see any metrics pushed but I cannot see what I am doing wrong.

I am running cachet-url-monitor in the provided Docker Container.

Here is my config:

endpoints:
  - name: _NAME_
    url: https://_URL_TO_MONITOR_/
    method: GET
    timeout: 1 # seconds
    expectation:
      - type: HTTP_STATUS
        status_range: 200
      - type: LATENCY
        threshold: 1 # seconds
      - type: REGEX
        regex: ".*<body>.*"
    allowed_fails: 0
    component_id: 25
    metric_id: 25
    action:
      - UPDATE_STATUS
      - PUSH_METRICS
    public_incidents: true
    latency_unit: ms
    frequency: 60 # seconds
cachet:
  api_url: https://_MY_CACHET_INSTANCE_/api/v1
  token: _TOKEN_

An extract of the log (seems to me that I should have some "Metric uploaded" logs between the "No changes")

     INFO [2020-03-22 13:46:03,296] cachet_url_monitor.configuration.Configuration._NAME_ - Current configuration:
cachet:
  api_url: https://_MY_CACHET_INSTANCE_/api/v1
endpoints:
  action:
  - UPDATE_STATUS
  - PUSH_METRICS
  allowed_fails: 0
  component_id: 25
  expectation:
  - status_range: 200
    type: HTTP_STATUS
  - threshold: 1
    type: LATENCY
  - regex: .*<body>.*
    type: REGEX
  frequency: 60
  latency_unit: ms
  method: GET
  metric_id: 25
  name: _NAME_
  public_incidents: true
  timeout: 1
  url: https://_URL_TO_MONITOR_/

     INFO [2020-03-22 13:46:03,491] cachet_url_monitor.configuration.Configuration._NAME_ - Component current status: ComponentStatus.OPERATIONAL
     INFO [2020-03-22 13:46:03,491] cachet_url_monitor.configuration.Configuration._NAME_ - Monitoring URL: GET https://_URL_TO_MONITOR_/
     INFO [2020-03-22 13:46:03,491] cachet_url_monitor.configuration.Configuration._NAME_ - Registered expectation: 'HTTP status range: [200, 201['
     INFO [2020-03-22 13:46:03,492] cachet_url_monitor.configuration.Configuration._NAME_ - Registered expectation: 'Latency threshold: 1.0000 seconds'
     INFO [2020-03-22 13:46:03,492] cachet_url_monitor.configuration.Configuration._NAME_ - Registered expectation: 'Regex: .*<body>.*'
     INFO [2020-03-22 13:46:03,492] cachet_url_monitor.scheduler - Registering action UPDATE_STATUS
     INFO [2020-03-22 13:46:03,492] cachet_url_monitor.scheduler - Registering action PUSH_METRICS
     INFO [2020-03-22 13:46:03,492] cachet_url_monitor.scheduler.Scheduler - Starting monitor agent...
     INFO [2020-03-22 13:47:03,666] cachet_url_monitor.configuration.Configuration._NAME_ - No changes to component status.
     INFO [2020-03-22 13:48:03,795] cachet_url_monitor.configuration.Configuration._NAME_ - No changes to component status.
     INFO [2020-03-22 13:49:03,936] cachet_url_monitor.configuration.Configuration._NAME_ - No changes to component status.
     INFO [2020-03-22 13:50:04,058] cachet_url_monitor.configuration.Configuration._NAME_ - No changes to component status.

I configured the metric in Cachet like so:

  • Suffix: ms
  • Calculation of metrics: Average
  • Default value: 0
  • Decimal Places: 0
  • How many minutes of threshold between metric points: 1
  • Display chart on status page: Yes

And nothing is visible on the dashbord and there is no metrics_points in cachet database (not access logs on metrics endpoints in cachet).

I have tried to tweak the monitored url and managed to get a status change by HTTP_STATUS and LATENCY, neither seems to trigger a metric push.

Any insight will be greatly appreciated.

Thanks,

Monitor Multple URLs

Is it currently possible to monitor multiple URL's? I've tried entering multiple URL's into the config.yml file using the same format as the single URL example, making sure that each has the correct component ID, but only 1 seems to be checked and updated.

Increase code coverage

We don't have a good code coverage and the Scheduler is not well tested. It's essential to have a proper coverage and test all the different edge cases.

InsecurePlatformWarning

InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings

Running this from a shared hosting site, what is the minimum version requirement for this script? We are on python 2.6 atm.

Running as python daemon

I'm currently utilising screen to keep scheduler.py running in the background, but what would be great is to run as python daemon.

Has anyone managed to do this? There is some information on this here.

threshold = ?

Is threshold a value in seconds? Or is threshold the number of times before check is marked as a failed?

Example threshold = 5 ...would this prevent changes to cachet until 5 failed checks?

thanks

api_url is incorrect when CachetHQ send a email in button "manage subscriptions"

with the following docker-compose (I'm behind a reverse proxy: traefik)

version: "3"

services:
  postgres:
    image: postgres:10-alpine
    volumes:
      - ./db_data:/var/lib/postgresql/data
    environment:
      - POSTGRES_USER=postgress
      - POSTGRES_PASSWORD=postgress
      - POSTGRES_DB=postgress
    networks:
      - cachethq_internal
    restart: always

  cachet:
    image: cachethq/docker:2.3-latest
    networks:
      - ak_cachethq_outside
      - ak_cachethq_internal
#    environment:
#...
    depends_on:
      - postgres
    restart: always
  cachet_url_monitor:
    image: mtakaki/cachet-url-monitor
    networks:
      - ak_cachethq_internal
    depends_on:
      - cachet
    volumes:
      - ${PWD}/.config.yml:/usr/src/app/config/config.yml:ro
    restart: always

networks:
  cachethq_outside:
    external:
      name: traefik_proxy
  cachethq_internal:
    driver: bridge

And the following configuration:

endpoint:
  url: https://myworpresspage.com
  method: GET
  timeout: 1 # seconds
  expectation:
    - type: HTTP_STATUS
      status_range: 200-300
    - type: LATENCY
      threshold: 1
    - type: REGEX
      regex: ".*WORDPRESS FOOTER HOOK.*"
  allowed_fails: 0
cachet:
  api_url: http://cachet:8000/api/v1
  token: xxxxxxxxxxxxxxxxxxx
  component_id: 1
  metric_id: 1
  action:
    - CREATE_INCIDENT
    - UPDATE_STATUS
  public_incidents: true
frequency: 30
latency_unit: ms

It works perfectly, but when cachetHQ sends an email, in the URL inside the email, redirects me to http://cachet:8000/subscribe/manage/xxxxxxx instead of https://status.myworpresspage.com/subscribe/manage/xxxxxxx in button "manage subscriptions"

I do not understand the API very well, but you could place an API URL and a LINK (A hyperlink to the component)???

config.yml file seg fault when passing value rapped in " "

I am using your contianer image in a Kubernetes / OpenShift 3.3 deployment. I gotten to work really well and wanted to rap it up as a PaaS offering. One item that is odd about k8s is that you can not just mount a config file but use configmap. This worked great and was able to get your container to work.

I then figured i make this in to a template. I setup the template but in the parameter section boolean and numbers base values have to ramped in " " or it fails validation. Well when these params are passed to the container as a configmap all the values are still ramped in " " and your app seg faults. Was not sure if there was a way to say " " rapped value is still valid.

How to run this in the background?

Hello,

How to run this in the background? I want to update often http websites?

"python cachet_url_monitor/scheduler.py config.yml"

I have server with Debian 9.5 Stretch.

is there any way to integrate with AWS Secret server

API keys we provide in config.yaml need to integrate with AWS secret server . for any cloudified environment where the central secret server is the only option to store keys, the current version has the limitation. I appreciate it if anyone takes up this feature to develop.

Problem with config.yml

Hi! I have some problem. When me made

[root@bessmertni-poni bin]# docker run -it --rm -v /usr/local/bin/config.yml:/usr/src/app/config/config.yml:ro mtakaki/cachet-url-monitor
Traceback (most recent call last):
  File "cachet_url_monitor/scheduler.py", line 89, in <module>
    scheduler = Scheduler(sys.argv[1])
  File "cachet_url_monitor/scheduler.py", line 55, in __init__
    self.configuration = Configuration(config_file)
  File "/usr/src/app/cachet_url_monitor/configuration.py", line 83, in __init__
    self.data = load(file(self.config_file, 'r'))
  File "/usr/local/lib/python2.7/site-packages/yaml/__init__.py", line 71, in load
    return loader.get_single_data()
  File "/usr/local/lib/python2.7/site-packages/yaml/constructor.py", line 37, in get_single_data
    node = self.get_single_node()
  File "/usr/local/lib/python2.7/site-packages/yaml/composer.py", line 36, in get_single_node
    document = self.compose_document()
  File "/usr/local/lib/python2.7/site-packages/yaml/composer.py", line 55, in compose_document
    node = self.compose_node(None, None)
  File "/usr/local/lib/python2.7/site-packages/yaml/composer.py", line 84, in compose_node
    node = self.compose_mapping_node(anchor)
  File "/usr/local/lib/python2.7/site-packages/yaml/composer.py", line 127, in compose_mapping_node
    while not self.check_event(MappingEndEvent):
  File "/usr/local/lib/python2.7/site-packages/yaml/parser.py", line 98, in check_event
    self.current_event = self.state()
  **File "/usr/local/lib/python2.7/site-packages/yaml/parser.py", line 439, in parse_block_mapping_key
    "expected <block end>, but found %r" % token.id, token.start_mark)**
**yaml.parser.ParserError: while parsing a block mapping
  in "config/config.yml", line 1, column 1
expected <block end>, but found '<block mapping start>'
  in "config/config.yml", line 3, column 3**

it's my config.yml

endpoint:
      url: http://google.com
  method: GET
  timeout: 1 # seconds
  expectation:
    - type: HTTP_STATUS
      status_range: 200-300
    - type: LATENCY
      threshold: 1
    - type: REGEX
      regex: ".*<body>.*"
  allowed_fails: 0
cachet:
  api_url: http://localhost/api/v1
  token: example_my_toker_from_cachet
  component_id: 1
  metric_id: 1
  action:
    - CREATE_INCIDENT
    - UPDATE_STATUS
  public_incidents: true
frequency: 30
latency_unit: ms

What i do wrong?
Thank you!

Expectation validation is not working properly

When creating a config, if the expectation is not a valid option is just fail with a non-descriptive exception:

Traceback (most recent call last):
  File "cachet_url_monitor/scheduler.py", line 54, in <module>
    scheduler = Scheduler(sys.argv[1])
  File "cachet_url_monitor/scheduler.py", line 32, in __init__
    self.configuration = Configuration(config_file)
  File "/usr/src/app/cachet_url_monitor/configuration.py", line 43, in __init__
    in self.data['endpoint']['expectation']]
  File "/usr/src/app/cachet_url_monitor/configuration.py", line 152, in create
    return expectations.get(configuration['type'])(configuration)
TypeError: 'NoneType' object is not callable

It should also list the available options.

'Metric with id [x] does not exist.' but it in Cachet DB

I'm unable to run the script and get the following errors stating that the Metric ID does not exist but for sure it is in the DB.

[email protected]:/var/www/html/cachet-url-monitor# python cachet_url_monitor/scheduler.py config.yml

INFO [2019-05-31 16:06:01,831] cachet_url_monitor.configuration.Configuration - Current configuration:
cachet:
  action: null
  api_url: http://10.0.70.14:80/api/v1
  component_id: 1
  metric_id: 1
  public_incidents: false
endpoint:
  allowed_fails: 1
  expectation:
  - status_range: 200-300
    type: HTTP_STATUS
  - threshold: 1
    type: LATENCY
  - regex: .*<body>.*
    type: REGEX
  method: GET
  timeout: 1
  url: http://www.google.co.uk
frequency: 10
latency_unit: ms

Traceback (most recent call last):
  File "cachet_url_monitor/scheduler.py", line 90, in <module>
    scheduler = Scheduler(sys.argv[1])
  File "cachet_url_monitor/scheduler.py", line 56, in __init__
    self.configuration = Configuration(config_file)
  File "build/bdist.linux-x86_64/egg/cachet_url_monitor/configuration.py", line 108, in __init__
    self.default_metric_value = self.get_default_metric_value(self.metric_id)
  File "build/bdist.linux-x86_64/egg/cachet_url_monitor/configuration.py", line 133, in get_default_metric_value
    raise MetricNonexistentError(metric_id)
cachet_url_monitor.configuration.MetricNonexistentError: 'Metric with id [1] does not exist.'
[email protected]:/var/www/html/cachet-url-monitor#
MariaDB [cachet_data]> select * from metrics;
+----+----------------------+--------+---------------------------------+---------------+-----------+---------------+--------+--------------+-----------+-------+---------------------+---------------------+
| id | name                 | suffix | description                     | default_value | calc_type | display_chart | places | default_view | threshold | order | created_at          | updated_at          |
+----+----------------------+--------+---------------------------------+---------------+-----------+---------------+--------+--------------+-----------+-------+---------------------+---------------------+
|  1 | Website Availability | ms     | Latency for www.google.co.uk |       100.000 |         1 |             0 |      2 |            1 |         5 |     0 | 2019-05-31 14:05:30 | 2019-05-31 14:43:06 |
|  2 | Website Availability | ms     | Latency for www.yahoo.co.uk |       100.000 |         1 |             0 |      2 |            2 |        60 |     0 | 2019-05-31 14:05:30 | 2019-05-31 14:43:10 |
+----+----------------------+--------+---------------------------------+---------------+-----------+---------------+--------+--------------+-----------+-------+---------------------+---------------------+
2 rows in set (0.00 sec)

MariaDB [cachet_data]> 

Release-0.6.4 doesn't load config file anymore

cachet-monitor_1  | Traceback (most recent call last):
cachet-monitor_1  |   File "./cachet_url_monitor/scheduler.py", line 144, in <module>
cachet-monitor_1  |     token = os.environ.get('CACHET_TOKEN') or config_data['cachet']['token']
cachet-monitor_1  | NameError: name 'os' is not defined
cachet-monitor:
    # https://github.com/mtakaki/cachet-url-monitor/blob/master/config.yml
    image: mtakaki/cachet-url-monitor:release-0.6.4
    volumes: 
      - "${PWD}/config.yml:/usr/src/app/config/config.yml:ro"

It works with release-0.6.3

Monitor Appliance

Hello

I use "cachet" with "cachet-url-monitor" just perfect :)

I would like to know if it is possible to ping a server or appilance (switch, firewall ...)

Is there a free solution or module;)

Thank you

latency_unit is read from cachet section

The code behaves differently than documented, the docs says, that latency_unit should be placed in endpoint configuration, but it is read from cachet section:

# The latency_unit configuration is not mandatory and we fallback to seconds, by default.
self.latency_unit = self.data['cachet'].get('latency_unit') or 's'

I can submit a PR once it's clear whether code or docs is the one to follow :-).

Monitoring multiple servers

Excuse my ignorance a little, is the idea here to run a virtualenv and a copy of this codebase/config for every server/component, or am i missing something?

passing environment variable in the header.

Hi all,

I would like to know the flow for configuration.py with respect to scheduler.py as in how the configuration.py gets loaded. I would also like to know as to where the configuration is stored? How can I make DD-API-KEY' and 'DD-APPLICATION-KEY' as environment variables that can be called into monitor.yaml under header section for URL monitoring? PS : DD-API-KEY' and 'DD-APPLICATION-KEY' are the environment variables I am trying to create and call in the YAML file.

URL unavailable

Hey,i always become this error:

URL unavailable
INFO [2019-07-11 17:04:03,217] cachet_url_monitor.configuration.Configuration - Monitoring URL: GET https://example.de/ INFO [2019-07-11 17:04:03,217] cachet_url_monitor.configuration.Configuration - Registered expectation: 'HTTP status range: (200, 300)' INFO [2019-07-11 17:04:03,217] cachet_url_monitor.scheduler.Scheduler - Registering action CREATE_INCIDENT INFO [2019-07-11 17:04:03,217] cachet_url_monitor.scheduler.Scheduler - Registering action UPDATE_STATUS INFO [2019-07-11 17:04:03,217] cachet_url_monitor.scheduler.Scheduler - Starting monitor agent... WARNING [2019-07-11 17:04:33,245] cachet_url_monitor.configuration.Configuration - Request timed out INFO [2019-07-11 17:04:33,245] cachet_url_monitor.configuration.Configuration - Failure #1 with threshold set to 0 INFO [2019-07-11 17:04:33,380] cachet_url_monitor.configuration.Configuration - Incident uploaded, API unhealthy: component status [2], message: "Request timed out"

My config is:

endpoint: url: https://example.de/ method: GET #header: #SOME-HEADER: SOME-VALUE timeout: 0.01 expectation: - type: HTTP_STATUS status_range: 200-300 #- type: LATENCY # threshold: 15 #- type: REGEX # regex: '.*(<body).*' allowed_fails: 0 cachet: api_url: https://status.example.de/api/v1 token: my_token component_id: 1 metric_id: 1 action: - CREATE_INCIDENT - UPDATE_STATUS public_incidents: true latency_unit: s frequency: 30

Edited url to example.de, dont post my real url here, also my token ;)

So what i am do wrong?

SSLError

getting this error when trying to start url monitor, any ideas?

Traceback (most recent call last):
File "cachet_url_monitor/scheduler.py", line 90, in
scheduler = Scheduler(sys.argv[1])
File "cachet_url_monitor/scheduler.py", line 56, in init
self.configuration = Configuration(config_file)
File "/root/cachet-url-monitor/cachet_url_monitor/configuration.py", line 113, in init
self.status = get_current_status(self.api_url, self.component_id, self.headers)
File "/root/cachet-url-monitor/cachet_url_monitor/configuration.py", line 59, in get_current_status
get_status_request = requests.get('%s/components/%s' % (endpoint_url, component_id), headers=headers)
File "/root/cachet-url-monitor/lib/python2.7/site-packages/requests/api.py", line 72, in get
return request('get', url, params=params, **kwargs)
File "/root/cachet-url-monitor/lib/python2.7/site-packages/requests/api.py", line 58, in request
return session.request(method=method, url=url, **kwargs)
File "/root/cachet-url-monitor/lib/python2.7/site-packages/requests/sessions.py", line 508, in request
resp = self.send(prep, **send_kwargs)
File "/root/cachet-url-monitor/lib/python2.7/site-packages/requests/sessions.py", line 640, in send
history = [resp for resp in gen] if allow_redirects else []
File "/root/cachet-url-monitor/lib/python2.7/site-packages/requests/sessions.py", line 218, in resolve_redirects
**adapter_kwargs
File "/root/cachet-url-monitor/lib/python2.7/site-packages/requests/sessions.py", line 618, in send
r = adapter.send(request, **kwargs)
File "/root/cachet-url-monitor/lib/python2.7/site-packages/requests/adapters.py", line 506, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='itstatus.redacted.com', port=443): Max retries exceeded with url: /api/v1/components/19 (Caused by SSLError(SSLError(1, u'[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:579)'),))

The cert is fine, it's our wildcard.

Thanks

Check multiple URLs?

Hi there, I really like this plugin! How could I go and check multiple URLs?
By using multiple config files? How could I load multiple config files?
Thanks
David

Timeout with valid url

Hi

I am getting "request timed out" message even though the URL works fine when accessed directly. Even if I up the threshold to 15 seconds (much longer than the page response time) it still fails. Also the log (below) says "Failure #1 with threshold set to 0" even with the threshold set to 15 seconds.

Any advice?

     INFO [2018-05-22 13:05:58,896] cachet_url_monitor.configuration.Configuration - Current configuration:
cachet:
  action:
  - CREATE_INCIDENT
  - UPDATE_STATUS
  api_url: https://status.workinconfidence.com/api/v1
  component_id: 1
  metric_id: 1
  public_incidents: true
endpoint:
  allowed_fails: 0
  expectation:
  - status_range: 200-300
    type: HTTP_STATUS
  - threshold: 15
    type: LATENCY
  - regex: .*(<body).*
    type: REGEX
  method: GET
  timeout: 0.01
  url: https://secure.speakinconfidence.com/company/en
frequency: 30
latency_unit: ms

     INFO [2018-05-22 13:05:59,243] cachet_url_monitor.configuration.Configuration - Monitoring URL: GET https://secure.speakinconfidence.com/company/en
     INFO [2018-05-22 13:05:59,244] cachet_url_monitor.configuration.Configuration - Registered expectation: 'HTTP status range: (200, 300)'
     INFO [2018-05-22 13:05:59,244] cachet_url_monitor.configuration.Configuration - Registered expectation: 'Latency threshold: 15.0000 seconds'
     INFO [2018-05-22 13:05:59,244] cachet_url_monitor.configuration.Configuration - Registered expectation: 'Regex: .*(<body).*'
     INFO [2018-05-22 13:05:59,244] cachet_url_monitor.scheduler.Scheduler - Registering action CREATE_INCIDENT
     INFO [2018-05-22 13:05:59,244] cachet_url_monitor.scheduler.Scheduler - Registering action UPDATE_STATUS
     INFO [2018-05-22 13:05:59,244] cachet_url_monitor.scheduler.Scheduler - Starting monitor agent...
  WARNING [2018-05-22 13:06:29,421] cachet_url_monitor.configuration.Configuration - Request timed out
     INFO [2018-05-22 13:06:29,421] cachet_url_monitor.configuration.Configuration - Failure #1 with threshold set to 0
     INFO [2018-05-22 13:06:29,601] cachet_url_monitor.configuration.Configuration - Incident uploaded, API unhealthy: component status [2], message: "Request timed out"

This is the relevant bit from the config file:

endpoint:
  url: https://secure.speakinconfidence.com/company/en
  method: GET
  timeout: 0.01
  expectation:
    - type: HTTP_STATUS
      status_range: 200-300
    - type: LATENCY
      threshold: 15
    - type: REGEX
      regex: '.*(<body).*'
  allowed_fails: 0

IsADirectoryError: [Errno 21] Is a directory: 'config/config.yml'

Hello,

Sorry but i may sounds weird because i am bit confused on how to run with docker.
I first pull the image from the docker hub and then i get an erroor with this command:

docker run --rm -it -v "$PWD":/usr/src/app/config/ mtakaki/cachet-url-monitor

and i get this :

Traceback (most recent call last):
File "./cachet_url_monitor/scheduler.py", line 90, in
scheduler = Scheduler(sys.argv[1])
File "./cachet_url_monitor/scheduler.py", line 56, in init
self.configuration = Configuration(config_file)
File "/usr/local/lib/python3.7/site-packages/cachet_url_monitor-0.5-py3.7.egg/cachet_url_monitor/configuration.py", line 84, in init
self.data = load(open(self.config_file, 'r'), Loader=FullLoader)
IsADirectoryError: [Errno 21] Is a directory: 'config/config.yml'

I am a bit confused if i need to clone the repository or i just need to add a yml on my current directory . Also i was wondering if i need to get the repository to the yml file (/usr/src/app/config/) in my current directory.
Thank you in advance for the answers

Component with id does not exist

Hello,

I'm getting the error 'Component with id does not exist.', are my settings wrong? Can the api read groups using your monitor? Or can't it be in groups?
error

Create incidents whenever the checks fail

We should be creating incidents whenever a check fails. At the moment we're only updating the component status and we're not creating incidents, which are more descriptive of what happens and adds a timeline to it.

No module named 'cachet_url_monitor'

Hi, I've followed instructions from the readme.md but got stuck and failed to launch it due to the following error.

Traceback (most recent call last):
  File "cachet_url_monitor/scheduler.py", line 8, in <module>
    from cachet_url_monitor.configuration import Configuration
ImportError: No module named 'cachet_url_monitor'

From my understanding it looks like it's not able to import itself. All pip requirements are already installed so I have no idea why this is occuring. I am running on a Fedora 27 CE server (no docker) if that helps.

Add support to status range

We currently only support a single HTTP status code value, but it would be handy to support a range of values.

Self-Signed certificate

Hi getting this error
requests.exceptions.SSLError: HTTPSConnectionPool(host='cachetdocker_cachet_1', port=8000): Max retries exceeded with url: /api/v1/components/1 (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate (_ssl.c:1056)')))

Could it be avoided by doing the REQUEST variable?
Thanks
Math

Monitor uses UTC

Hi!

I've setup the monitor so it measures latency and everything works as a charm, however! I've tried setting the timezone on my ubuntu server with sudo dpkg-reconfigure tzdata

But Cachet still reports the latency reports an hour earlier than it should be.

I am currently using the Docker image, when running the monitor.

Push latency metrics

We should push the latency metrics, if the metrics id is set, so we can monitor the API responsiveness and lag.

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.