commit e998d99963933da7f5dc2f931951e37e43db7681
parent b65d62f36ef00868a1327c02244e2ded748e3b7e
Author: Remy Noulin <loader2x@gmail.com>
Date: Fri, 7 Jul 2023 15:56:57 +0200
change home path to absolute and enable heartbeat service for all agents
heartbeat.c | 25 +++++++++++++------------
1 file changed, 13 insertions(+), 12 deletions(-)
Diffstat:
1 file changed, 13 insertions(+), 12 deletions(-)
diff --git a/heartbeat.c b/heartbeat.c
@@ -24,13 +24,14 @@ monitor: display state
// it used in the config command to generate agentCfgFile for each machine
#define cfgFile "heartbeatConfig.yml"
+#define uHome "/root/"
#define home ".heartbeat"
// agentCfgFile is the default configuration file
-#define agentCfgPath ".heartbeat/config.yml"
-#define agentCfgFile "~/" agentCfgPath
+#define agentCfgPath home"/config.yml"
+#define agentCfgFile uHome agentCfgPath
#define binPath "bin/"
-#define bin "~/" binPath
+#define bin uHome binPath
#define defaultPeriod 1
// TODO #define defaultPeriod 120
@@ -79,7 +80,7 @@ int main(int ARGC, char** ARGV) {
ret 1;
}
elif (eqG(argv[1], "daemon")) {
- cleanCharP(h) = expandHome("~/" home "/heartbeat.log");
+ cleanCharP(h) = expandHome(uHome home "/heartbeat.log");
setLogFile(h);
setLogStdout(no);
#define KEEP_CWD 1
@@ -189,28 +190,28 @@ 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)));
pushNFreeG(copyScript,
formatS("scp heartbeat %s:" binPath, iK(cfg)));
+ pushNFreeG(copyScript,
+ formatS("scp heartbeat.service %s:/etc/systemd/system/", iK(cfg)));
}
elif (eqG($(d, "transfers"), "copy")) {
// cp same machine
pushG(copyScript,
- "mkdir ~/"home);
+ "mkdir "uHome home);
if (hasG(d, "logger")) {
pushG(copyScript,
- "cp "cfgFile" ~/" home "/" cfgFile);
- pushG(copyScript,
- "cp heartbeat.service /etc/systemd/system/");
+ "cp "cfgFile" "uHome home "/" cfgFile);
}
pushNFreeG(copyScript,
formatS("cp %s " agentCfgFile, thisCfgFile));
pushNFreeG(copyScript,
formatS("cp heartbeat " bin));
+ pushG(copyScript,
+ "cp heartbeat.service /etc/systemd/system/");
}
pushG(copyScript,
"systemctl daemon-reload ; systemctl enable heartbeat ; systemctl start heartbeat");
@@ -334,7 +335,7 @@ void probe(char *cfgfile) {
startTime = getCurrentUnixTime();
completeCfg = allocG(rtSmallJsont);
- cleanCharP(p) = expandHome("~/" home "/" cfgFile);
+ cleanCharP(p) = expandHome(uHome home "/" cfgFile);
smallJsont *r = readFileG(completeCfg, p);
if (!r) {
logE("Missing %s", p);
@@ -345,7 +346,7 @@ void probe(char *cfgfile) {
// create filename with path in ~/.heartbeat/
agents = keysG(completeCfg);
agentdbs = keysG(completeCfg);
- cleanCharP(h) = expandHome("~/" home "/");
+ cleanCharP(h) = expandHome(uHome home "/");
forEachCharP(agentdbs, ag) {
pErrorNULL(iPrependS(ag, h));
pErrorNULL(iAppendS(ag, ".bin"));