heartbeat

Simple server monitor system using encrypted messages over udp
git clone https://noulin.net/git/heartbeat.git
Log | Files | Refs | README

commit b65d62f36ef00868a1327c02244e2ded748e3b7e
parent d48387a5fa2549e598a873891eac82a5c9da79f6
Author: Remy Noulin <loader2x@gmail.com>
Date:   Fri,  7 Jul 2023 15:43:15 +0200

add start heartbeat at startup with systemd

heartbeat.c       |  8 +++++++-
heartbeat.service | 15 +++++++++++++++
2 files changed, 22 insertions(+), 1 deletion(-)

Diffstat:
Mheartbeat.c | 8+++++++-
Aheartbeat.service | 15+++++++++++++++
2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/heartbeat.c b/heartbeat.c @@ -189,6 +189,8 @@ void config(smallJsont *cfg) { if (hasG(d, "logger")) { pushNFreeG(copyScript, formatS("scp "cfgFile" %s:" home "/" cfgFile, iK(cfg))); + pushNFreeG(copyScript, + formatS("scp heartbeat.service %s:/etc/systemd/system/", iK(cfg))); } pushNFreeG(copyScript, formatS("scp %s %s:" agentCfgPath, thisCfgFile, iK(cfg))); @@ -196,18 +198,22 @@ void config(smallJsont *cfg) { formatS("scp heartbeat %s:" binPath, iK(cfg))); } elif (eqG($(d, "transfers"), "copy")) { + // cp same machine pushG(copyScript, "mkdir ~/"home); if (hasG(d, "logger")) { pushG(copyScript, "cp "cfgFile" ~/" home "/" cfgFile); + pushG(copyScript, + "cp heartbeat.service /etc/systemd/system/"); } pushNFreeG(copyScript, formatS("cp %s " agentCfgFile, thisCfgFile)); pushNFreeG(copyScript, formatS("cp heartbeat " bin)); } - + pushG(copyScript, + "systemctl daemon-reload ; systemctl enable heartbeat ; systemctl start heartbeat"); inc id; } diff --git a/heartbeat.service b/heartbeat.service @@ -0,0 +1,15 @@ +[Unit] +Description=Heartbeat + +Wants=network.target +After=syslog.target network-online.target + +[Service] +Type=simple +ExecStart=/root/bin/heartbeat +Restart=on-failure +RestartSec=10 +KillMode=process + +[Install] +WantedBy=multi-user.target