{"id":13643069,"url":"https://github.com/yahoo/monitr","last_synced_at":"2025-05-15T18:02:20.245Z","repository":{"id":10776644,"uuid":"13042786","full_name":"yahoo/monitr","owner":"yahoo","description":"A Node.js process monitoring tool.","archived":false,"fork":false,"pushed_at":"2024-10-28T22:08:45.000Z","size":202,"stargazers_count":314,"open_issues_count":6,"forks_count":39,"subscribers_count":27,"default_branch":"master","last_synced_at":"2025-03-31T21:51:22.497Z","etag":null,"topics":["cpp","nodejs","process-monitoring","web"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yahoo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2013-09-23T17:54:25.000Z","updated_at":"2025-02-28T03:02:20.000Z","dependencies_parsed_at":"2024-01-14T09:15:28.848Z","dependency_job_id":"3e18b37a-ea31-414c-87fe-071bd49596d1","html_url":"https://github.com/yahoo/monitr","commit_stats":{"total_commits":69,"total_committers":10,"mean_commits":6.9,"dds":0.7681159420289855,"last_synced_commit":"31ae00094da0b53335e031822aa6a223ee362fee"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yahoo%2Fmonitr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yahoo%2Fmonitr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yahoo%2Fmonitr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yahoo%2Fmonitr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yahoo","download_url":"https://codeload.github.com/yahoo/monitr/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247737788,"owners_count":20987721,"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":["cpp","nodejs","process-monitoring","web"],"created_at":"2024-08-02T01:01:40.779Z","updated_at":"2025-04-07T22:11:29.407Z","avatar_url":"https://github.com/yahoo.png","language":"C++","readme":"# monitr\n\nNodejs process monitoring module\n\nThis package is tested only with Node.js LTS versions.\n\n_Note: This module currently works only on Linux operating systems_.\n\n## External statistics reporting\n\nThis module starts a separate thread within the Nodejs runtime that\nmonitors and collects statistics about the running nodejs process.\nThese statistics are then sent as JSON messages via UDP datagrams over\na local domain socket.\n\nHere is the list of data the module reports periodically:\n```\n { status:\n     { pid: \u003cpid of the node process\u003e,\n       ts: \u003ccurrent time stamp\u003e,\n       cluster: \u003cprocess group id\u003e,\n       reqstotal: \u003ctotal requests processed by this node process server\u003e,\n       utcstart: \u003cwhen the process was started\u003e,\n       events: \u003cnumber of new reports being processed since last stats reporting\u003e,,\n       cpu: \u003ccpu usage\u003e,\n       mem: \u003cmemory usage\u003e,\n       cpuperreq: \u003ccpu usage per request\u003e,\n       oreqs: \u003ccurrent open requests count\u003e,\n       sys_cpu: \u003csystem cpu load\u003e,\n       oconns: \u003ccurrent open connections count\u003e,\n       user_cpu: \u003cuser cpu load\u003e,\n       rps: \u003crequests per second\u003e,\n       kbs_out: \u003ckbs of data transferred since last stats reporting\u003e,\n       elapsed: \u003ctime elapsed since last event\u003e,\n       kb_trans: \u003ctotal kbs of data transferred\u003e,\n       jiffyperreq: \u003ccpu usage in terms of ticks per request\u003e,\n       gc: {\n           scavenge: { count: \u003cnumber\u003e, elapsed_ms: \u003cnumber\u003e, max_ms: \u003cnumber\u003e },\n           marksweep: { count: \u003cnumber\u003e, elapsed_ms: \u003cnumber\u003e, max_ms: \u003cnumber\u003e }\n       }\n    }\n }\n```\n\n## GC introspection\n\nIt provides the running nodejs application with the ability to\nintrospect garbage collection activity by creating read-only\nproperties at `process.monitor.gc` that reports:\n\n1.  `count`: number of times GC stop-the-world events occurred\n2.  `elapsed`: cumulative time (in milliseconds) spent in GC\n\n# Installation\n\nWith [npm](http://npmjs.org) do:\n\n```\nnpm install monitr\n```\n\n# Usage\n```js\nvar monitor = require('monitr');\n```\n\n## start()\n\n```js\nmonitor.start();\n```\nSpawns a thread and monitors the process. Writes process stats every second to the socket path.\n\n## stop()\n```js\nmonitor.stop();\n```\nTerminates the thread and closes the socket.\n\n## setIpcMonitorPath(socketPath)\n```js\nmonitor.setIpcMonitorPath('/tmp/my-process-stats.mon');\n```\nSets the datagram socket name to write the stats. Defaults to /tmp/nodejs.mon\n\n# Health Status\nMonitr supports custom health functionality whereby the app can report its own health.\nThe following methods are added to process.monitor to set and get the health information.\n```js\nsetHealthStatus(isDown, statusCode)\nisDown()\ngetStatusCode()\ngetStatusTimestamp() - Return seconds when setHealthStatus was last called\ngetStatusDate() - Return Date object\n```\nOnce setHealthStatus is invoked, the status json, described above, will have following additional fields.\n```js\nhealth_status_timestamp: \u003ctimestamp when the setHealthStatus was invoked, in sec\u003e,\nhealth_is_down: \u003capp is down or up, boolean\u003e,\nhealth_status_code: \u003chealth status code\u003e\n```\n\n# Handling HUP events\n\n`Monitr` installs a custom `SIGHUP` handler which will optionally\nprint out a NodeJS stack backtrace of the Javascript currently being\nexecuted.  This can be useful for debugging where a NodeJS process may\nbe _stuck_.\n\n# Implementation\n\nIt looks up /proc/* files on the system to report CPU Usage.  It looks\nup /proc/pid/* files on the system to report its own stats.\n`process.monitor.*` methods are set by `lib/monitor.js`.\n\nIt calls the process.monitor.* methods to report total requests since\nmonitoring started (`reqstotal`), current requests in flight\n(`oreqs`), current open connections (`oconns`) and total data returned\nsince monitoring started (`kb_trans`).  _Note: `oreqs` may be greater\nthan `oconns` when keepalive is enabled_.\n\nIt attaches to the v8 garbage collection hooks to instrument (for each\nGC type) the following stats for each reporting interval.\n\n1.  `count` : number of times GC type invoked\n2.  `elapsed_ms`: total elapsed time nodejs thread is blocked\n3.  `max_ms`:  maximum time spent blocked by any one GC event\n\n# Example\n\nPlease refer to examples/README.md for examples showing the use of these functions.\n\n# Build Status\n\n[![Build Status](https://secure.travis-ci.org/yahoo/monitr.png?branch=master)](http://travis-ci.org/yahoo/monitr)\n\n# Node Badge\n\n[![NPM](https://nodei.co/npm/monitr.png)](https://nodei.co/npm/monitr/)\n\n","funding_links":[],"categories":["C++"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyahoo%2Fmonitr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyahoo%2Fmonitr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyahoo%2Fmonitr/lists"}