GithubHelp home page GithubHelp logo

cakephp-server-monitor's Introduction

CakeServerMonitor

CakePHP 3 Plugin for Monitoring Server Stats

Installation

  • To install the CakeServerMonitor plugin, you can use composer. From your application's ROOT directory (where composer.json file is located) run the following:

    composer require jeffersonsimaogoncalves/cakephp-server-monitor

  • You will need to add the following line to your application's config/bootstrap.php file:

    Plugin::load('JeffersonSimaoGoncalves/CakeServerMonitor',['bootstrap' => true]);

Notification

CakeServerMonitor currently supports notification via email. You can configure recipients' email addresses in your applications 'config/bootstrap.php' file using overwriting the CakeServerMonitor.email.recipients key:

Configure::write(
    'CakeServerMonitor.email.recipients',
    ['[email protected]','[email protected]']
);

Scheduling task

The last step to make this work is to add a cron job. You can do so by adding a similar line as shown below to your system's crontab file. Do remember to update the path to your own project. The following cron job runs at 1 am every day, you can change it to your own preference.

* 1 * * * cd path && bin/cake monitor run

Customisation

CakeServerMonitor does provide some customisation options.

  • Changing email profile

by default CakeServerMonitor uses the default profile to send an email. You can change it to your own preference using the CakeServerMonitor.email.profile key:

Configure::write(
    'CakeServerMonitor.email.profile',
    'debug'
);
  • Changing checking stats

by default CakeServerMonitor checks following stats:

  • Disk Space
  • MySql Process
  • Nginx Process

Under the hood, each checker is actually a class under JeffersonSimaoGoncalves namespace. You can overwrite what checkers to run via the CakeServerMonitor.commands key:

Configure::write(
    'CakeServerMonitor.commands',
    [
        'disk_space' => 'JeffersonSimaoGoncalves\CakeServerMonitor\CommandDefinition\DiskSpace',
        'mysql' => 'JeffersonSimaoGoncalves\CakeServerMonitor\CommandDefinition\MySql',
        'nginx' => 'JeffersonSimaoGoncalves\CakeServerMonitor\CommandDefinition\Nginx',
    ]
);

You can remove any checkers above so it won't run.

  • Creating your own checker

As you might have already guessed, you can create your own checker to extend CakeServerMonitor's abilities. To do so, creates a class extends from JeffersonSimaoGoncalves\CakeServerMonitor\CommandDefinition\CommandDefinition abstract class and implement its defined abstract methods.

After that, add your own checker to the CakeServerMonitor.commands key as shown in previous section.

Helper methods

To view current server stats:

bin/cake monitor view

Credits

This work is fork on the code by watchowl.

cakephp-server-monitor's People

Contributors

curtisgibby avatar jeffersonsimaogoncalves avatar watchowl avatar

Stargazers

 avatar

Watchers

 avatar  avatar

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.