Skip to content

hogosha/monitor

Repository files navigation

Hogosha Monitor

Monitoring tool for Hogosha Service that can be used as a standalone tool as a simple ping program.

Currently in development but ready to use in production

Build Status Code Quality Code Coverage SensioLabsInsight Latest Unstable Version Latest Stable Version

Installation

Composer

Globally

composer global require hogosha/monitor

If it is the first time you globally install a dependency then make sure you include ~/.composer/vendor/bin in $PATH as shown here.

Keep Hogosha Monitor up-to-date

composer global update hogosha/monitor

In your project

composer require hogosha/monitor

.phar

Download the last PHAR file from the release panel

VERSION=master; curl -LO "https://raw.githubusercontent.com/hogosha/monitor/$VERSION/build/monitor.phar"
chmod u+x monitor.phar
mv monitor.phar /usr/local/bin/hogosha-monitor

Or build it manually

git clone https://github.com/hogosha/monitor.git
composer install
bin/compile
mv monitor.phar /usr/local/bin/hogosha-monitor

Usage

Create the configuration file:

hogosha-monitor init

or change the directory

hogosha-monitor init -c $HOME

This will create an yml file with this configuration:

urls:
    google: #this has to be unique
        url: 'https://www.google.fr'
        method: GET
        headers: { Accept: text/html }
        timeout: 1
        validator: { }
        status_code: 200 #status expected

Then run the tool

hogosha-monitor run -c $HOME

Output - List

[OK][200] google - 0.267724

Output - Table

+---------------+-------------+---------+---------------+----------------+---------------------+
| Global Status | Status Code | Name    | Response Time | Http Error Log | Validator Error Log |
+---------------+-------------+---------+---------------+----------------+---------------------+
| OK            | 200         | thefork | 0.274106      |                |                     |
+---------------+-------------+---------+---------------+----------------+---------------------+

Output - Csv

"Global Status","Status Code",Name,"Reponse Time","Http Error Log","Validator Error Log"
OK,200,thefork,0.307092,,

Validator

Sometimes we need more than just status codes. So we introduced a validator system for html, xml and json so you can test a existing string.

Html Validator

urls:
    google:
        url: 'https://www.google.fr'
        method: GET
        headers: { Accept: text/html }
        timeout: 1
        validator:
        	type: html
        	match: /images/ #regex will be 
        status_code: 200 #status expected

Json Validator

Json example:

{"name": "Chuck Norris"}
urls:
    google:
        url: 'https://www.example.org/names.json'
        method: GET
        headers: { Accept: text/json }
        timeout: 1
        validator:
        	type: json
        	match: name #we use property accessor
        status_code: 200 #status expected

Xml Validator

Xml example:

<?xml version="1.0"?>
<root>
    <name>chuck</name>
</root>
urls:
    google:
        url: 'https://www.example.org/test.xml'
        method: GET
        headers: { Accept: text/xml }
        timeout: 1
        validator:
        	type: xml
        	match: //name #use xpath selector
        status_code: 200 #status expected

Connect to hogosha portal

Once you have configured the hogosha portal, you need to add this configuration in your yaml

urls:
    google:
        url: 'https://www.google.fr'
        method: GET
        headers: { Accept: text/html }
        timeout: 1
        status_code: 200 #status expected
        metric_uuid: ec9e5ba7-9136-4b67-b049-a969e8e6dcde # Metric uuid you can find in the hogosha portal
        service_uuid: 9e231852-5343-4653-81c8-f52ee223d3d2 # Service monitored by the hogosha portal

hogosha_portal:
  username: admin
  password: admin
  base_uri: http://localhost:8000/api/
  metric_update: true # Update metric graph
  incident_update: true #create an incident when there is a problem and update it when there is one to resolve
  default_failed_incident_message: "An error as occured, we are investigating %service_name%",
  default_resolved_incident_message: "The service %service_name% is back to normal"

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

TODO

  • Connnect to the hogosha portal
  • Collect metric to the hogosha portal metric system
  • Automatic incident update when failing
  • Automatic service resolver
  • Refacto

Credits

Thanks to Silex project for the compiler file.

License

Hogosha Monitor is licensed under the MIT License - see the LICENSE file for details

About

Monitoring tool in php with multiple output

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages