agent icon indicating copy to clipboard operation
agent copied to clipboard

Support for systemd timers alongside cron

Open jnaskali opened this issue 5 years ago • 1 comments
trafficstars

I'm running the agent on Arch Linux with systemd and no cron. For this, I need to manually comment out the checks and setup processes for cron, as the default install script fails when cron is not available.

After installing with the modified script, I manually create the following systemd files:

/etc/systemd/system/hetrixtools-agent.service

[Unit]
Description=Service for running HetrixTools Server Monitoring Agent

[Service]
Type=oneshot
ExecStart=/etc/hetrixtools/hetrixtools_agent.sh >> /etc/hetrixtools/hetrixtools_cron.log 2>&1

[Install]
WantedBy=multi-user.target

/etc/systemd/system/hetrixtools-agent.timer

[Unit]
Description=HetrixTools Server Monitoring Agent Timer

[Timer]
OnBootSec=20
OnUnitActiveSec=1min
AccuracySec=1s

[Install]
WantedBy=timers.target

Then I enable and run the agent with:

# systemctl enable hetrixtools-agent.timer # systemctl start hetrixtools-agent.timer

It would be nice to include this behaviour in the official install script in order to support a wider range of servers.

Perhaps the install script could detect which init environment is used with ps --no-headers -o comm 1 (which returns either 'systemd' or 'init') and continue with the correct installation procedure. Or perhaps if crontab is not found, the script could check for systemd and use that when available.

jnaskali avatar Sep 23 '20 12:09 jnaskali

Thank you for the feedback, we'll test it out and try to implement such a scenario in future versions of our agent.

hetrixtools avatar Sep 23 '20 19:09 hetrixtools