{"id":15525064,"url":"https://github.com/staabm/sysmonitor","last_synced_at":"2025-04-23T07:52:07.018Z","repository":{"id":22913612,"uuid":"26262419","full_name":"staabm/SysMonitor","owner":"staabm","description":"Monitors a php app and send notifications on certain error/exception/resource-exhausting/custom events","archived":false,"fork":false,"pushed_at":"2025-01-20T15:16:31.000Z","size":54,"stargazers_count":6,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-13T09:17:37.164Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/staabm.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-11-06T09:15:13.000Z","updated_at":"2025-01-20T17:21:17.000Z","dependencies_parsed_at":"2025-01-20T16:51:13.674Z","dependency_job_id":null,"html_url":"https://github.com/staabm/SysMonitor","commit_stats":null,"previous_names":[],"tags_count":25,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/staabm%2FSysMonitor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/staabm%2FSysMonitor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/staabm%2FSysMonitor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/staabm%2FSysMonitor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/staabm","download_url":"https://codeload.github.com/staabm/SysMonitor/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250395107,"owners_count":21423375,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-02T10:54:28.823Z","updated_at":"2025-04-23T07:52:06.996Z","avatar_url":"https://github.com/staabm.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"SysMonitor\n==========\n\nMonitors a php app and sends notifications on certain error/exception/resource-exhausting/custom/etc. events.\n\nThe monitor checks the data you provide and decides with a naive default implementation (see `SystemMonitor#rateAndStore`) when things get urgent/severe. `SystemEvent`s are compared using a hash so times of occurence can also be based on similarity.\nNotifications are beeing send in such cases, depending on your used Notifier.\n\nThe default implementation of `SystemEventStorage` stores your data in a mix of APC and Memcached. Therefore it requires both php extensions.\n\nUsage\n=====\n\ninit all the things. All classes prefixed with `My` need to be provided by the application/framework beeing monitored.\n\n```php\n// sends notificaitons on urgent events\n$notifier = new SeverityNotifier(new MyCustomNotifier(), SystemEvent::SEVERITY_URGENT);\n// main class which collects all the data\n$monitor = new SystemMonitor(new SystemEventStorage(), new MyRequestEnvImpl(), $notifier);\n```\n\nreport performance-data from somewhere in your app (e.g. on request shutdown)\n\n```php\nregister_shutdown_function(function() {\n    $requestStats = new RequestStatsEvent();\n    // data from your db class\n    $requestStats-\u003eusedQueries = DB::$num_of_queries;\n    $requestStats-\u003eusedConnections = DB::$num_of_connections;\n    // data from your runtime\n    $requestStats-\u003epeakMemory = number_format(memory_get_peak_usage(true) / 1024 / 1024);\n    \n    // retrieve the monitor instance, e.g. via a DIC/a registry/singleton/whatever\n    // $monitor = .. \n    $monitor-\u003ecollectStats($requestStats);\n});\n```\n\nlet the `Monitor` collect data about exceptions occured\n\n```php\nset_exception_handler(function() {\n    $event = new RequestExceptionEvent();\n    $event-\u003eexception = $exception;\n    \n    // retrieve the monitor instance, e.g. via a DIC/a registry/singleton/whatever\n    // $monitor = .. \n    $monitor-\u003ecollectException($event);\n});\n```\n\nyou 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)\n\n\nSidenote\n========\n\nThis library was extracted out of a framework and contains some \"strange\" things which are kept for BC reasons.\nThis will be changed in version 2.0.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstaabm%2Fsysmonitor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstaabm%2Fsysmonitor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstaabm%2Fsysmonitor/lists"}