Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
sd_notify and sd_watchdog_enabled functionality for writing Python daemons under systemd
sd_notify(3) and sd_watchdog_enabled(3) client functionality implemented in Python 3 for writing Python daemons
$ pip install systemd-watchdog
or
$ git clone ...
$ make install
import systemd_watchdog
wd = systemd_watchdog.watchdog()
if not wd.enabled():
# Then it's probably not running is systemd with watchdog enabled
raise Exception("Watchdog not enabled")
# Report a status message
wd.status("Starting my service...")
time.sleep(3)
# Report that the program init is complete
wd.ready()
wd.status("Waiting for web requests...")
wd.notify()
time.sleep(3)
# Compute time between notifications
timeout_half_sec = int(float(wd.timeout) / 2e6) # Convert us->s and half that
time.sleep(timeout_half_sec)
wd.notify()
# Report an error to the service manager
wd.notify_error("An irrecoverable error occured!")
# The service manager will probably kill the program here
time.sleep(3)
systemd_watchdog.watchdog
- commonly used properties and methodsping
The only method required for the simplest implementation; combines notify_due
with notify()
to only send "alive" notifications at reasonable intervals.
Returns boolean indicating if a message was sent or not.
beat
Alias for ping()
if you prefer heartbeat terminology.
ready()
Report ready service state, i.e. completed init (only needed with Type=notify
).
status(msg)
Send a service status message.
systemd_watchdog.watchdog
- less-used properties and methodsis_enabled
Boolean property stating whether watchdog capability is enabled.
timeout
Property reporting the number of microseconds (int) before process will be killed.
It is recommended that you call notify()
once roughly half of this interval has passed (see notify_due
).
timeout_td
Property that is the same as timeout
but presented as datetime.timedelta
for easier manipulation.
notify_due
Boolean property indicating more than half of the watchdog interval has passed since last update.
notify()
Report a healthy service state. Other calls, e.g. status()
do not reset the watchdog.
notify_error(msg=None)
Report an error to the watchdog manager. This program will likely be killed upon receipt.
If msg
is provided, it will be reported as a status message prior to the error.
Aaron D. Marasco May 2020
See LICENSE
file
FAQs
sd_notify and sd_watchdog_enabled functionality for writing Python daemons under systemd
We found that systemd-watchdog demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.