{"id":27019250,"url":"https://github.com/jameslavin/monitor","last_synced_at":"2025-04-04T17:20:01.958Z","repository":{"id":62429901,"uuid":"203086273","full_name":"JamesLavin/monitor","owner":"JamesLavin","description":"Rudimentary (but hopefully -- eventually -- simple \u0026 powerful) API for querying and monitoring the status of servers, server processes, Elixir nodes, and Elixir processes","archived":false,"fork":false,"pushed_at":"2019-08-19T03:05:34.000Z","size":15,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-08T03:06:03.050Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Elixir","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/JamesLavin.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}},"created_at":"2019-08-19T02:45:16.000Z","updated_at":"2020-12-12T12:56:53.000Z","dependencies_parsed_at":"2022-11-01T20:07:47.546Z","dependency_job_id":null,"html_url":"https://github.com/JamesLavin/monitor","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JamesLavin%2Fmonitor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JamesLavin%2Fmonitor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JamesLavin%2Fmonitor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JamesLavin%2Fmonitor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JamesLavin","download_url":"https://codeload.github.com/JamesLavin/monitor/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247217203,"owners_count":20903009,"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":"2025-04-04T17:20:01.490Z","updated_at":"2025-04-04T17:20:01.952Z","avatar_url":"https://github.com/JamesLavin.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Monitor\n\nMonitor provides a rudimentary (but hopefully -- eventually -- simple yet powerful) API\nfor querying and monitoring the status of servers, server processes,\nElixir nodes, and Elixir processes.\n\nThe Monitor runs as a supervised GenServer, so if it crashes, it should\nget automatically restarted and its new PID associated with its `:global`\nname, which looks something like `{Monitor.Server, :\"node@server\"}`.\n\n## Usage\n\nTo start up one or more Elixir nodes running `Monitor`:\n\n```elixir\niex --name \"m1@127.0.0.1\" -S mix\n```\n\nWhen the node starts up, it will start a `Monitor.Server` instance on the node and output a message like:\n\n```elixir\n\"Starting a Monitor.Server on node :\\\"m1@127.0.0.1\\\" with PID #PID\u003c0.182.0\u003e and name {:global, {Monitor.Server, :\\\"m1@127.0.0.1\\\"}}\"\n\n```\n\n### Finding the server's :global name \u0026 PID\n\nTo find the PID of the `Monitor.Server` on the local node:\n\n```elixir\n{Monitor.Server, node()} |\u003e :global.whereis_name()\n```\n\nor\n\n```elixir\nMonitor.Server.monitor_pid()\n```\n\nTo find the PID of the `Monitor.Server` on a named node:\n\n```elixir\n{Monitor.Server, :\"m2@127.0.0.1\"} |\u003e :global.whereis_name()\n```\n\nor\n\n```elixir\n:\"m2@127.0.0.1\" |\u003e Monitor.Server.monitor_pid()\n```\n\n### Memory usage\n\nTo look up the current node's memory usage:\n\n```elixir\nMonitor.Server.mem\n```\n\nTo look up a specific node's memory usage:\n\n```elixir\nnode() |\u003e Monitor.Server.monitor_pid |\u003e Monitor.Server.mem\n```\n\nThis should return output like:\n\n```\n%{\n  allocated: 22520721408,\n  pct_used: 67.07508261746172,\n  total: 33575391232,\n  worst_pid: {#PID\u003c0.195.0\u003e, 372624}\n}\n```\n\n### System memory usage\n\nTo look up the current node's system memory usage:\n\n```elixir\nMonitor.Server.sys_mem\n```\n\nTo look up a specific node's system memory usage:\n\n```elixir\nnode() |\u003e Monitor.Server.monitor_pid |\u003e Monitor.Server.sys_mem\n```\n\nThis should return output like:\n\n```\n%{\n  buffered_memory: 1577607168,\n  cached_memory: 9958359040,\n  free_memory: 11125661696,\n  free_swap: 0,\n  pct_free: 33.1363575754744,\n  pct_used: 66.86364242452561,\n  system_pct_free: 33.1363575754744,\n  system_total_memory: 33575391232,\n  total_memory: 33575391232,\n  total_swap: 0\n}\n```\n\n### Disk usage\n\nTo look up the current node's disk usage:\n\n```elixir\nMonitor.Server.disk\n```\n\nTo look up a specific node's disk usage:\n\n```elixir\nnode() |\u003e Monitor.Server.monitor_pid |\u003e Monitor.Server.disk\n```\n\nThis should return output like:\n\n```\n[\n  %{disk_id: \"/dev\", pct_used: 0.0, total_kbytes: 16363208},\n  %{disk_id: \"/run\", pct_used: 1.0, total_kbytes: 3278848},\n  %{disk_id: \"/\", pct_used: 88.0, total_kbytes: 980675660},\n  ...\n]\n```\n\n### CPU usage\n\nTo look up the current node's CPU usage:\n\n```elixir\nMonitor.Server.cpu\n```\n\nTo look up a specific node's CPU usage:\n\n```elixir\nnode() |\u003e Monitor.Server.monitor_pid |\u003e Monitor.Server.cpu\n```\n\nThis should return output like:\n\n```\n%{\n  cpu_rup_load_15_mins: 0.890625,\n  cpu_rup_load_1_min: 1.0390625,\n  cpu_rup_load_5_mins: 0.7890625,\n  cpu_usage_pct: 27.03737166435444\n}\n```\n\n### Unix processes\n\nTo look up the current node's number of Unix processes:\n\n```elixir\nMonitor.Server.unix_procs\n```\n\nTo look up a specific node's number of Unix processes:\n\n```elixir\nnode() |\u003e Monitor.Server.monitor_pid |\u003e Monitor.Server.unix_procs\n```\n\nThis should return output like:\n\n```\n%{num_unix_procs: 2399}\n```\n\n## Installation\n\nIf [available in Hex](https://hex.pm/docs/publish), the package can be installed\nby adding `monitor` to your list of dependencies in `mix.exs`:\n\n```elixir\ndef deps do\n  [\n    {:monitor, \"~\u003e 0.1.1\"}\n  ]\nend\n```\n\nDocumentation can be generated with [ExDoc](https://github.com/elixir-lang/ex_doc)\nand published on [HexDocs](https://hexdocs.pm). Once published, the docs can\nbe found at [https://hexdocs.pm/monitor](https://hexdocs.pm/monitor).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjameslavin%2Fmonitor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjameslavin%2Fmonitor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjameslavin%2Fmonitor/lists"}