{"id":15007487,"url":"https://github.com/patrikx3/systemd-manager","last_synced_at":"2025-10-30T12:31:42.029Z","repository":{"id":49823395,"uuid":"82687890","full_name":"patrikx3/systemd-manager","owner":"patrikx3","description":"⌚ SystemD Manager, watchdog, notifier and service","archived":false,"fork":false,"pushed_at":"2025-02-01T18:12:18.000Z","size":698,"stargazers_count":11,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-14T13:33:37.169Z","etag":null,"topics":["bsd","corifeus","dbus","linux","linux-kernel","manager","nodejs","notifier","notify","polling","service","systemd","systemd-dbus-notifier","systemd-manager","systemd-service","trigger","unix","watchdog"],"latest_commit_sha":null,"homepage":"https://www.corifeus.com/systemd-manager","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/patrikx3.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":"2017-02-21T14:17:37.000Z","updated_at":"2025-02-08T01:23:22.000Z","dependencies_parsed_at":"2025-01-27T17:11:31.105Z","dependency_job_id":"4e65e61a-38d7-43fa-b540-5d9252392895","html_url":"https://github.com/patrikx3/systemd-manager","commit_stats":{"total_commits":300,"total_committers":1,"mean_commits":300.0,"dds":0.0,"last_synced_commit":"ecb32138f5b1c4513c988d40a34e0bd16e71137d"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patrikx3%2Fsystemd-manager","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patrikx3%2Fsystemd-manager/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patrikx3%2Fsystemd-manager/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patrikx3%2Fsystemd-manager/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/patrikx3","download_url":"https://codeload.github.com/patrikx3/systemd-manager/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238968409,"owners_count":19560586,"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":["bsd","corifeus","dbus","linux","linux-kernel","manager","nodejs","notifier","notify","polling","service","systemd","systemd-dbus-notifier","systemd-manager","systemd-service","trigger","unix","watchdog"],"created_at":"2024-09-24T19:10:17.330Z","updated_at":"2025-10-30T12:31:36.661Z","avatar_url":"https://github.com/patrikx3.png","language":"JavaScript","funding_links":["https://paypal.me/patrikx3","https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick\u0026hosted_button_id=QZVM4V6HVZJW6"],"categories":[],"sub_categories":[],"readme":"[//]: #@corifeus-header\n\n  [![NPM](https://img.shields.io/npm/v/p3x-systemd-manager.svg)](https://www.npmjs.com/package/p3x-systemd-manager)  [![Donate for PatrikX3 / P3X](https://img.shields.io/badge/Donate-PatrikX3-003087.svg)](https://paypal.me/patrikx3) [![Contact Corifeus / P3X](https://img.shields.io/badge/Contact-P3X-ff9900.svg)](https://www.patrikx3.com/en/front/contact) [![Corifeus @ Facebook](https://img.shields.io/badge/Facebook-Corifeus-3b5998.svg)](https://www.facebook.com/corifeus.software)  [![Uptime ratio (90 days)](https://network.corifeus.com/public/api/uptime-shield/31ad7a5c194347c33e5445dbaf8.svg)](https://network.corifeus.com/status/31ad7a5c194347c33e5445dbaf8)\n\n\n\n\n\n# ⌚ SystemD Manager, watchdog, notifier and service v2025.4.123\n\n\n  \n🌌 **Bugs are evident™ - MATRIX️**  \n🚧 **This project is under active development!**  \n📢 **We welcome your feedback and contributions.**  \n    \n\n\n\n### NodeJS LTS is supported\n\n### 🛠️ Built on NodeJs version\n\n```txt\nv22.13.1\n```\n\n\n\n\n\n# 📝 Description\n\n                        \n[//]: #@corifeus-header:end\n\n\n\nStay informed about the status of your SystemD services with this notification tool. Designed for flexibility, this tool sends notifications (e.g., via email) when specific service states are detected, making it easier to manage and maintain clean and efficient SystemD configurations.\n\n---\n\n## Use Case\n\nReceive email notifications when a SystemD service enters a **failed** state. By enabling boot-time monitoring, the tool can report all failed or \"not found\" services on startup, allowing you to clean up or remove them from your SystemD configuration effortlessly.\n\nAdditionally, you can expand its functionality to track other service states such as **running**, **stopped**, or even monitor **all SystemD changes**. The tool leverages `LoadState` and other properties to trigger actions, enabling notifications or integrations with platforms like Twitter, Facebook, or custom alert systems.\n\n---\n\n## Extensibility\n\nThis notifier was initially developed to monitor and alert for failed services on my server via email. However, it is designed for easy customization:\n\n- **Fork \u0026 Pull:** Add new features or modify existing ones to suit your needs.\n- **Trigger Flexibility:** Configure it to monitor additional service states or actions.\n- **Integration:** Expand notifications beyond email (e.g., social platforms or messaging apps).\n\nWith its **DBus-based architecture** and **async/await wrappers**, evolving and adapting the tool is straightforward.\n\n---\n\n## Features and Details\n\nThis is a lightweight yet robust solution for Linux/Unix/BSD environments (tested on Debian Testing and Ubuntu). Key features include:\n\n- **Email Notifications:** Powered by NodeMailer, receive instant alerts for monitored services.\n- **Polling and Event-Based Monitoring:**\n  - Default interval-based polling acts as a watchdog.\n  - Optional event-based DBus wrappers for real-time service management (ideal for reducing overhead).\n- **SystemD Management:** Handle services through DBus, enabling actions triggered by state changes.\n- **Clean Startup:** On boot, automatically report failed or missing services for easy maintenance.\n\nThis tool is perfect for maintaining server reliability and cleanliness, with the potential to replace traditional watchdogs entirely.\n\n---\n\nContributions are welcome! Fork the repository, add features, or improve functionality as needed.\n\n\n## SystemD DBus Manager\n\nReferences:\n[DBus](https://www.freedesktop.org/wiki/Software/systemd/dbus/),\n[Node Dbus](https://github.com/Shouqun/node-dbus)\n\n### Prerequisites\n\n```bash\n#you probably might need a c++11 if it is old, \n#for additional requirements check out .travis.yml\nsudo apt-get install libdbus-1-dev libglib2.0-dev\n```\n\n### Using from code\n\nPlease do not use ```yarn```, because it asks for ```sudo``` and prompt (unless you are ```root```).\n\n```bash\nnpm install p3x-systemd-manager --save\n```\n\n#### SystemD DBus Notifier\n\n```js\n#!/usr/bin/env node\nconst systemd = require('p3x-systemd-manager');\nconst settings = systemd.lib.getSettings();\nif (settings === false) {\n    return;\n}\nsystemd.boot(settings);\nsystemd.notifier(settings);\n```\n\n#### SystemD Watchdog Notify\n\nThis notifies changes in the SystemD via e-mail. Right now it polls, so that it gets all changes. It task about 30-50\nmilliseconds per run on my 3.3 GHz Pentium 2 cores, not too much. All automatic, requires email and a few tweaks as you\nwant.\n\n```js\nconst Watchdog = require('p3x-systemd-manager').watchdog;\nconst settings = require('./settings.json');\nconst watchdog = Watchdog(settings);\nwatchdog.run();\n```\n\n##### Looks like this\n\n```text\nFeb 22 11:41:31 server systemd[1]: Started p3x-watchdog.\nFeb 22 11:41:32 server watchdog[2196]: started\nFeb 22 11:41:32 server watchdog[2196]: watchdog type(s): service\nFeb 22 11:41:32 server watchdog[2196]: ping: 2 hours\nFeb 22 11:41:32 server watchdog[2196]: interval: 10 seconds\nFeb 22 11:41:32 server watchdog[2196]: command: systemctl --plain --no-pager --no-legend  --type=service\nFeb 22 11:41:32 server watchdog[2196]: ping - 51 items - every 2 hours\nFeb 22 11:41:32 server watchdog[2196]: Mail is working.\n```\n\n### Using terminal\n\n```bash\ngit clone https://github.com/patrikx3/systemd-manager.git\ncd systemd-manager\nsudo apt-get install libdbus-1-dev libglib2.0-dev\nnpm install\n./notifier settings.json\n#it is used to be a watchdog, polling\n./watchdog settings.json\n```\n\n### Settings\n\nCheckout [```artifacts/setttings.json```](artifacts/settings.json)\n\n```filter.type```: Array, can be empty, actual ```man systemctl``` type. Service is the safest. Not always working when\nyou fine tune, some are weird.\n\n```nodemailer.config```: Exact nodemailer config, any of that.\n\n```interval, ping```: Uses npm ```milliseconds``` framework for turn into actual milliseconds from a string. This is\nfor ```Watchdog```, not needed anymore.\n\n```sudo```: for the watchdog either you need to use root, or via sudo (```true|false```). For SystemD needs root, but\nyou can use another user, and it will use sudo then when polling.\n\nFor SystemD DBus notifier you need to use root anyway. I think it cannot do anything else so it's safe to take over the\nsystem, also it's internal, no web interface for now.\n\n```json\n{\n{\n    \"debug\": false,\n    \"filter\": {\n        \"type\": [\n            \"service\"\n        ],\n        \"exclude\": [\n            \"fwupd-refresh\",\n            \"sysstat-collect\",\n            \"systemd-tmpfiles-clean\",\n            \"ua-timer\",\n            \"phpsessionclean\",\n            \"display-manager\",\n            \"motd-news\",\n            \"sysstat-summary\",\n            \"logrotate\",\n            \"dpkg-db-backup\",\n            \"mdcheck_continue\",\n            \"mdmonitor-oneshot\",\n            \"apt-daily\",\n            \"man-db\",\n            \"packagekit\",\n            \"certbot\",\n            \"user-runtime-dir\",\n            \"user\",\n            \"update-notifier-download\"\n        ],\n        \"include\": [],\n        \"trigger\": {\n            \"SubState\": [\n                \"dead\",\n                \"failed\"\n            ]\n        }\n    },\n    \"boot\": {\n        \"enabled\": true,\n        \"trigger\": {\n            \"SubState\": [\n                \"dead\",\n                \"failed\"\n            ]\n        }\n    },\n    \"moment\": \"LLL\",\n    \"prefix\": \"P3X-SYSTEMD-NOTIFIER\",\n    \"dbus\": {\n        \"address\": \"unix:path=/run/dbus/system_bus_socket\",\n        \"display\": \":0\"\n    },\n    \"interval\": \"watchdog only\",\n    \"interval\": \"10 seconds\",\n    \"ping\": \"watchdog only\",\n    \"ping\": \"2 hours\",\n    \"sudo\": \"watchdog only\",\n    \"sudo\": false,\n    \"email\": {\n        \"to\": \"system@localhost\",\n        \"from\": \"system@localhost\"\n    },\n    \"nodemailer\": {\n        \"singleton\": true,\n        \"config\": {\n            \"host\": \"mail.localhost\",\n            \"port\": 465,\n            \"secure\": true,\n            \"auth\": {\n                \"user\": \"system@localhost\",\n                \"pass\": \"unknown\"\n            }\n        }\n    },\n    \"ignoreErrors\": [\n        \"The maximum number of pending replies per connection has been reached\",\n        \"No introspectable\"\n    ]\n}\n```\n\n### Weird errors\n\nThere are 2 errors that I could not catch or why it happens, so I created a hack:\n```js\nconst settings = {\n    \"ignoreErrors\": [\n        \"The maximum number of pending replies per connection has been reached\",\n        \"No introspectable\"\n    ]\n}\nprocess.on(\"unhandledRejection\", function (err) {\n    if (err \u0026\u0026 err.message \u0026\u0026 settings.ignoreErrors.includes(err.message)) {\n        console.warn('ignoring error', err)\n    } else {\n        // user your own logic\n        console.error(err)\n        process.exit(-1)\n    }\n});\n```\n\nThe two error messages:\n```txt\n\"The maximum number of pending replies per connection has been reached\"\n\"No introspectable\"\n```\n\n[//]: #@corifeus-footer\n\n---\n\n## 🚀 Quick and Affordable Web Development Services\n\nIf you want to quickly and affordably develop your next digital project, visit [corifeus.eu](https://corifeus.eu) for expert solutions tailored to your needs.\n\n---\n\n## 🌐 Powerful Online Networking Tool  \n\nDiscover the powerful and free online networking tool at [network.corifeus.com](https://network.corifeus.com).  \n\n**🆓 Free**  \nDesigned for professionals and enthusiasts, this tool provides essential features for network analysis, troubleshooting, and management.  \nAdditionally, it offers tools for:  \n- 📡 Monitoring TCP, HTTP, and Ping to ensure optimal network performance and reliability.  \n- 📊 Status page management to track uptime, performance, and incidents in real time with customizable dashboards.  \n\nAll these features are completely free to use.  \n\n---\n\n## ❤️ Support Our Open-Source Project  \nIf you appreciate our work, consider ⭐ starring this repository or 💰 making a donation to support server maintenance and ongoing development. Your support means the world to us—thank you!  \n\n---\n\n### 🌍 About My Domains  \nAll my domains, including [patrikx3.com](https://patrikx3.com), [corifeus.eu](https://corifeus.eu), and [corifeus.com](https://corifeus.com), are developed in my spare time. While you may encounter minor errors, the sites are generally stable and fully functional.  \n\n---\n\n### 📈 Versioning Policy  \n**Version Structure:** We follow a **Major.Minor.Patch** versioning scheme:  \n- **Major:** 📅 Corresponds to the current year.  \n- **Minor:** 🌓 Set as 4 for releases from January to June, and 10 for July to December.  \n- **Patch:** 🔧 Incremental, updated with each build.  \n\n**🚨 Important Changes:** Any breaking changes are prominently noted in the readme to keep you informed.\n\n---\n\n\n[**P3X-SYSTEMD-MANAGER**](https://corifeus.com/systemd-manager) Build v2025.4.123\n\n [![NPM](https://img.shields.io/npm/v/p3x-systemd-manager.svg)](https://www.npmjs.com/package/p3x-systemd-manager)  [![Donate for PatrikX3 / P3X](https://img.shields.io/badge/Donate-PatrikX3-003087.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick\u0026hosted_button_id=QZVM4V6HVZJW6)  [![Contact Corifeus / P3X](https://img.shields.io/badge/Contact-P3X-ff9900.svg)](https://www.patrikx3.com/en/front/contact) [![Like Corifeus @ Facebook](https://img.shields.io/badge/LIKE-Corifeus-3b5998.svg)](https://www.facebook.com/corifeus.software)\n\n\n\n\n\n[//]: #@corifeus-footer:end\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpatrikx3%2Fsystemd-manager","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpatrikx3%2Fsystemd-manager","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpatrikx3%2Fsystemd-manager/lists"}