定制 spatie/server-monitor-app 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

spatie/server-monitor-app

Composer 安装命令:

composer create-project spatie/server-monitor-app

包简介

A PHP application to monitor the health of your servers

README 文档

README

Latest Version on Packagist Software License Total Downloads

We all dream of servers that need no maintenance at all. But unfortunately in reality this is not the case. Disks can get full, processes can crash, the server can run out of memory...

This commandline app keeps an eye on the health of all your servers. There are a few checks that come out of the box.

When something goes wrong it can notify you via Slack or mail. This is what a Slack notification looks like:

Screenshot slack

Under the hood the server-monitor-app is a vanilla Laravel 5.4 application with the laravel-server-monitor installed into it. If you know your way around Laravel, it's recommended that you use laravel-server-monitor instead of this app.

Support us

We invest a lot of resources into creating best in class open source packages. You can support us by buying one of our paid products.

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on our contact page. We publish all received postcards on our virtual postcard wall.

Requirements

See the requirements in the docs of the underlying package.

Installation

You can install the application by issuing this command:

composer create-project spatie/server-monitor-app <name of install directory>

To complete your installation these steps must be performed:

First you should add the following command to your cron table. It should run every minute:

php <installation path>/artisan schedule:run

Secondly, specify a Slack webhook url in the SERVER_MONITOR_SLACK_WEBHOOK_URL key in the .env file found in the installation directory. You can create a new webhook url on the Slack website.

Optionally you can configure e-mail notifications by filling in the MAIL_ keys in the .env file located in the installation directory and adding mail to the notifications array in the configuration.php file.

Configuration

The configuration file configuration.php is located inside the installation directory.

Reading it is a good way to quickly get a feel of what server-monitor-app can do. Here's the content of the config file:

return [

    /*
     * These are the checks that can be performed on your servers. You can add your own
     * checks. The only requirement is that they should extend the
     * `Spatie\ServerMonitor\Checks\CheckDefinitions\CheckDefinition` class.
     */
    'checks' => [
        'diskspace' => Spatie\ServerMonitor\CheckDefinitions\Diskspace::class,
        'elasticsearch' => Spatie\ServerMonitor\CheckDefinitions\Elasticsearch::class,
        'memcached' => Spatie\ServerMonitor\CheckDefinitions\Memcached::class,
        'mysql' => Spatie\ServerMonitor\CheckDefinitions\MySql::class,
    ],

    /*
     * The performance of the package can be increased by allowing a high number
     * of concurrent ssh connections. Set this to a lower value if you're
     * getting weird errors running the check.
     */
    'concurrent_ssh_connections' => 5,

    /*
     * This string will be appended to the ssh command generated by the package.
     */
    'ssh_command_suffix' => '',

    'notifications' => [

        'notifications' => [
            Spatie\ServerMonitor\Notifications\Notifications\CheckSucceeded::class => [],
            Spatie\ServerMonitor\Notifications\Notifications\CheckRestored::class => ['slack'],
            Spatie\ServerMonitor\Notifications\Notifications\CheckWarning::class => ['slack'],
            Spatie\ServerMonitor\Notifications\Notifications\CheckFailed::class => ['slack'],
        ],

        /*
         * To avoid burying you in notifications, we'll only send one every given amount
         * of minutes when a check keeps emitting warning or keeps failing.
         */
        'throttle_failing_notifications_for_minutes' => 60,

        'mail' => [
            'to' => 'your@email.com',
        ],

        'slack' => [
            'webhook_url' => env('SERVER_MONITOR_SLACK_WEBHOOK_URL'),
        ],

        /*
         * Here you can specify the notifiable to which the notifications should be sent. The default
         * notifiable will use the variables specified in this config file.
         */
        'notifiable' => \Spatie\ServerMonitor\Notifications\Notifiable::class,

        /*
         * The date format used in notifications.
         */
        'date_format' => 'd/m/Y',
    ],

    /*
     * To add or modify behaviour to the `Check` model you can specify your
     * own model here. The only requirement is that they should
     * extend the `Check` model provided by this package.
     */
    'check_model' => Spatie\ServerMonitor\Models\Check::class,

    /*
     * Right before running a check it's process will be given to this class. Here you
     * can perform some last minute manipulations on it before it will
     * actually be run.
     *
     * This class should implement Spatie\ServerMonitor\Manipulators\Manipulator
     */
    'process_manipulator' => Spatie\ServerMonitor\Manipulators\Passthrough::class,
];

Basic usage

To start monitoring a server:

php artisan server-monitor:add-host

and answer the questions that are asked.`

To stop monitoring an url issue this command:

php artisan server-monitor:delete-host <name>

To list all monitors you can perform:

php artisan server-monitor:list-hosts

You can also list all active checks on all hosts:

php artisan server-monitor:list-checks

Finally, if you've got a large amount of servers to monitor you can import them from a JSON file:

php artisan server-monitor:sync-file <hosts.json>

Advanced usage

Under the hood the server-monitor-app is a vanilla Laravel 5.4 application with our laravel-server-monitor installed into it. Please refer to it's extensive documentation to know more how to configure and use this application.

By default the application will use a sqlite database located at <installation directory>/database.sqlite to store all monitors.

Documentation

You'll find the documentation of the underlying laravel-server-monitor package on https://docs.spatie.be/laravel-server-monitor/v1.

Find yourself stuck using this app or the underlying package? Found a bug? Do you have general questions or suggestions for improving the uptime monitor? Feel free to create an issue on GitHub, we'll try to address it as soon as possible.

Postcardware

You're free to use this package (it's MIT-licensed), but if it makes it to your production environment we highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using.

Our address is: Spatie, Kruikstraat 22, 2018 Antwerp, Belgium.

The best postcards will get published on the open source page on our website.

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you've found a bug regarding security please mail security@spatie.be instead of using the issue tracker.

Credits

About Spatie

Spatie is a webdesign agency based in Antwerp, Belgium. You'll find an overview of all our open source projects on our website.

License

The MIT License (MIT). Please see License File for more information.

spatie/server-monitor-app 适用场景与选型建议

spatie/server-monitor-app 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 347 次下载、GitHub Stars 达 174, 最近一次更新时间为 2017 年 03 月 04 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「server」 「elasticsearch」 「monitor」 「laravel」 「devops」 「spatie」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 spatie/server-monitor-app 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 spatie/server-monitor-app 我们能提供哪些服务?
定制开发 / 二次开发

基于 spatie/server-monitor-app 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 347
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 176
  • 点击次数: 7
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 174
  • Watchers: 5
  • Forks: 22
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-03-04