mirror of
https://github.com/owntracks/recorder.git
synced 2026-08-27 16:57:21 +00:00
@@ -38,6 +38,7 @@ void ghash_store_redis(redisContext **redis, char *ghash, char *addr, char *cc)
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void last_storeredis(redisContext **redis, char *username, char *device, char *jsonstring)
|
||||
{
|
||||
redisReply *r;
|
||||
@@ -89,6 +90,19 @@ int ghash_get_redis_cache(redisContext **redis, char *ghash, UT_string *addr, UT
|
||||
|
||||
return (found);
|
||||
}
|
||||
|
||||
void monitor_update(struct udata *ud, time_t now, char *topic)
|
||||
{
|
||||
redisReply *r;
|
||||
|
||||
redis_ping(&ud->redis);
|
||||
|
||||
r = redisCommand(ud->redis, "HMSET ot-recorder-monitor time %ld topic %s", now, topic);
|
||||
if (r) /* FIXME */
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
#endif /* !HAVE_REDIS */
|
||||
|
||||
int ghash_readcache(struct udata *ud, char *ghash, UT_string *addr, UT_string *cc)
|
||||
|
||||
@@ -26,7 +26,7 @@ char *bindump(char *buf, long buflen)
|
||||
/*
|
||||
* At each received message, the recorder invokes this function with the
|
||||
* current epoch time and the topic being handled. Use this to update
|
||||
* a monitoring hoook.
|
||||
* a monitoring hoook. If we have Redis, use that exclusively.
|
||||
*/
|
||||
|
||||
void monitorhook(struct udata *userdata, time_t now, char *topic)
|
||||
@@ -35,8 +35,19 @@ void monitorhook(struct udata *userdata, time_t now, char *topic)
|
||||
|
||||
#ifdef HAVE_REDIS
|
||||
if (ud->useredis) {
|
||||
monitor_update(ud, now, topic);
|
||||
return;
|
||||
}
|
||||
#else
|
||||
if (ud->usefiles) {
|
||||
char mpath[BUFSIZ];
|
||||
FILE *fp;
|
||||
|
||||
sprintf(mpath, "%s/monitor", JSONDIR);
|
||||
if ((fp = fopen(mpath, "w")) != NULL) {
|
||||
fprintf(fp, "%ld %s\n", now, topic);
|
||||
fclose(fp);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (ud->usefiles) {
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user