From db85308aa8339e8ba3f3b5b68fb7fc321f0c63fb Mon Sep 17 00:00:00 2001 From: onefang Date: Wed, 18 Mar 2020 11:32:43 +1000 Subject: Now that ROBUST is saving it's PID, check for it on the stats web page. --- src/sledjchisl/sledjchisl.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'src/sledjchisl') diff --git a/src/sledjchisl/sledjchisl.c b/src/sledjchisl/sledjchisl.c index 393376e..b4e20f7 100644 --- a/src/sledjchisl/sledjchisl.c +++ b/src/sledjchisl/sledjchisl.c @@ -756,7 +756,6 @@ char *getSimName(char *sim) // Expects either "simXX" or "ROBUST". -// TODO - ROBUST isn't creating it's pid file, bug in ROBUST, it has config for it. int checkSimIsRunning(char *sim) { int ret = 0; @@ -795,6 +794,8 @@ int checkSimIsRunning(char *sim) d("%s", path); i = system(path); } + else + d("checkSimIsRunning(%s) has PID %s, which is actually running.", sim, pid); } } } @@ -804,7 +805,12 @@ int checkSimIsRunning(char *sim) free(path); path = xmprintf("%s/caches/%s.pid", scRoot, sim); if (0 == stat(path, &st)) + { + D("checkSimIsRunning(%s) -> %s is really really running.", sim, path); ret = 1; + } + else + D("checkSimIsRunning(%s) -> %s is not running.", sim, path); free(path); return ret; @@ -1836,9 +1842,10 @@ gridStats *getStats(MYSQL *db, gridStats *stats) stats->stats->putstr(stats->stats, "version", "SledjChisl FCGI Dev 0.1"); stats->stats->putstr(stats->stats, "grid", "my grid"); stats->stats->putstr(stats->stats, "uri", "http://localhost:8002/"); -// TODO - figure out how to do this. Do this once ROBUST is fixed to actually store it's PID - -// if (checkSimIsRunning("ROBUST")) - stats->stats->putstr(stats->stats, "gridOnline", "??"); + if (checkSimIsRunning("ROBUST")) + stats->stats->putstr(stats->stats, "gridOnline", "online"); + else + stats->stats->putstr(stats->stats, "gridOnline", "offline"); } else { @@ -1847,9 +1854,13 @@ gridStats *getStats(MYSQL *db, gridStats *stats) return stats; } + I("Getting fresh grid stats."); + if (checkSimIsRunning("ROBUST")) + replaceStr(stats->stats, "gridOnline", "online"); + else + replaceStr(stats->stats, "gridOnline", "offline"); if (db) { - I("Getting fresh grid stats."); char *tmp; my_ulonglong locIn = dbCount(db, "Presence", "RegionID != '00000000-0000-0000-0000-000000000000'"); // Locals online but not HGing, and HGers in world. my_ulonglong HGin = dbCount(db, "Presence", "UserID NOT IN (SELECT PrincipalID FROM UserAccounts)"); // HGers in world. -- cgit v1.1