承接 staabm/sysmonitor 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

staabm/sysmonitor

最新稳定版本:1.1.0

Composer 安装命令:

composer require staabm/sysmonitor

包简介

无描述信息

README 文档

README

Monitors a php app and sends notifications on certain error/exception/resource-exhausting/custom/etc. events.

The monitor checks the data you provide and decides with a naive default implementation (see SystemMonitor#rateAndStore) when things get urgent/severe. SystemEvents are compared using a hash so times of occurence can also be based on similarity. Notifications are beeing send in such cases, depending on your used Notifier.

The default implementation of SystemEventStorage stores your data in a mix of APC and Memcached. Therefore it requires both php extensions.

Usage

init all the things. All classes prefixed with My need to be provided by the application/framework beeing monitored.

// sends notificaitons on urgent events
$notifier = new SeverityNotifier(new MyCustomNotifier(), SystemEvent::SEVERITY_URGENT);
// main class which collects all the data
$monitor = new SystemMonitor(new SystemEventStorage(), new MyRequestEnvImpl(), $notifier);

report performance-data from somewhere in your app (e.g. on request shutdown)

register_shutdown_function(function() {
    $requestStats = new RequestStatsEvent();
    // data from your db class
    $requestStats->usedQueries = DB::$num_of_queries;
    $requestStats->usedConnections = DB::$num_of_connections;
    // data from your runtime
    $requestStats->peakMemory = number_format(memory_get_peak_usage(true) / 1024 / 1024);
    
    // retrieve the monitor instance, e.g. via a DIC/a registry/singleton/whatever
    // $monitor = .. 
    $monitor->collectStats($requestStats);
});

let the Monitor collect data about exceptions occured

set_exception_handler(function() {
    $event = new RequestExceptionEvent();
    $event->exception = $exception;
    
    // retrieve the monitor instance, e.g. via a DIC/a registry/singleton/whatever
    // $monitor = .. 
    $monitor->collectException($event);
});

you could do the same for errors. To collect data of fatal errors there are some known workarounds which can be used (checking for error_get_last() in a shutdown function)

Sidenote

This library was extracted out of a framework and contains some "strange" things which are kept for BC reasons. This will be changed in version 2.0.

统计信息

  • 总下载量: 1.34M
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 6
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 6
  • Watchers: 1
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固