diff --git a/Makefile b/Makefile index ce91d46..c8aecb2 100644 --- a/Makefile +++ b/Makefile @@ -16,8 +16,8 @@ OTR_OBJS = json.o \ CFLAGS += -DGHASHPREC=$(GHASHPREC) -ifeq ($(HAVE_PING),yes) - CFLAGS += -DHAVE_PING=1 +ifeq ($(WITH_PING),yes) + CFLAGS += -DWITH_PING=1 endif ifeq ($(WITH_LUA),yes) @@ -26,19 +26,19 @@ ifeq ($(WITH_LUA),yes) OTR_OBJS += hooks.o endif -ifeq ($(HAVE_KILL),yes) - CFLAGS += -DHAVE_KILL=1 +ifeq ($(WITH_KILL),yes) + CFLAGS += -DWITH_KILL=1 endif -ifeq ($(HAVE_LMDB),yes) - CFLAGS += -DHAVE_LMDB=1 -Imdb/ +ifeq ($(WITH_LMDB),yes) + CFLAGS += -DWITH_LMDB=1 -Imdb/ OTR_OBJS += gcache.o LIBS += mdb/liblmdb.a -lpthread TARGETS += mdb/liblmdb.a endif -ifeq ($(HAVE_HTTP),yes) - CFLAGS += -DHAVE_HTTP=1 +ifeq ($(WITH_HTTP),yes) + CFLAGS += -DWITH_HTTP=1 OTR_OBJS += mongoose.o http.o endif diff --git a/README.md b/README.md index 5d260d2..491d835 100644 --- a/README.md +++ b/README.md @@ -328,7 +328,7 @@ In order to monitor the _recorder_, whenever an MQTT message is received, a `mon ``` -If _recorder_ is built with `HAVE_PING` (default), a location publish to `owntracks/ping/ping` (i.e. username is `ping` and device is `ping`) can be used to round-trip-test the recorder. For this particular username/device combination, _recorder_ will store LAST position, but it will not keep a `.REC` file for it. This can be used to verify, say, via your favorite monitoring system, that the _recorder_ is still operational. +If _recorder_ is built with `WITH_PING` (default), a location publish to `owntracks/ping/ping` (i.e. username is `ping` and device is `ping`) can be used to round-trip-test the recorder. For this particular username/device combination, _recorder_ will store LAST position, but it will not keep a `.REC` file for it. This can be used to verify, say, via your favorite monitoring system, that the _recorder_ is still operational. After sending a _pingping_, you can query the REST interface to determine the difference in time. The `contrib/` directory has an example Python program (`ot-ping.py`) which you can adapt as needed for use by Icinga or Nagios. diff --git a/config.mk.in b/config.mk.in index dea210b..fe35f76 100644 --- a/config.mk.in +++ b/config.mk.in @@ -3,19 +3,19 @@ INSTALLDIR = /usr/local # Do you want recorder's built-in HTTP REST API? -HAVE_HTTP ?= yes +WITH_HTTP ?= yes # Do you want to use reverse-geo caching? (Highly recommended) -HAVE_LMDB ?= yes +WITH_LMDB ?= yes # Do you have Lua libraries installed and want the Lua hook integration? WITH_LUA ?= no # Do you want support for the `pingping' monitoring feature? -HAVE_PING ?= yes +WITH_PING ?= yes # Do you want support for removing data via the API? (Dangerous) -HAVE_KILL ?= no +WITH_KILL ?= no # Where should the recorder store its data? This directory must # exist and be writeable by recorder (and readable by ocat) diff --git a/gcache.h b/gcache.h index 273b3c0..a1dba6a 100644 --- a/gcache.h +++ b/gcache.h @@ -1,7 +1,7 @@ #ifndef _GCACHE_H_INCLUDED_ # define _GCACHE_H_INCLUDED_ -#ifdef HAVE_LMDB +#ifdef WITH_LMDB #include "json.h" #include "lmdb.h" diff --git a/hooks.c b/hooks.c index 93f00e1..e6dd90d 100644 --- a/hooks.c +++ b/hooks.c @@ -83,7 +83,7 @@ struct luadata *hooks_init(struct udata *ud, char *script) lua_setglobal(ld->L, "otr"); -#ifdef HAVE_LMDB +#ifdef WITH_LMDB LuaDB = ud->luadb; #endif diff --git a/http.c b/http.c index 22e5eda..a10ffb5 100644 --- a/http.c +++ b/http.c @@ -31,11 +31,11 @@ #include "storage.h" #include "geohash.h" #include "udata.h" -#ifdef HAVE_HTTP +#ifdef WITH_HTTP # include "http.h" #endif -#ifdef HAVE_HTTP +#ifdef WITH_HTTP /* * Return a lowercased copy of a GET/POST parameter or NULL. The parameter @@ -291,7 +291,7 @@ static int dispatch(struct mg_connection *conn, const char *uri) time_from = field(conn, "from"); time_to = field(conn, "to"); -#if HAVE_KILL +#if WITH_KILL if (nparts == 1 && !strcmp(uparts[0], "kill")) { JsonNode *deleted; @@ -311,7 +311,7 @@ static int dispatch(struct mg_connection *conn, const char *uri) CLEANUP; return (json_response(conn, deleted)); } -#endif /* HAVE_KILL */ +#endif /* WITH_KILL */ if (nparts == 1 && !strcmp(uparts[0], "last")) { JsonNode *user_array; @@ -520,5 +520,5 @@ int ev_handler(struct mg_connection *conn, enum mg_event ev) } } -#endif /* HAVE_HTTP */ +#endif /* WITH_HTTP */ diff --git a/ocat.c b/ocat.c index 1eba353..c913cf6 100644 --- a/ocat.c +++ b/ocat.c @@ -148,7 +148,7 @@ void usage(char *prog) printf(" payload Like RAW but JSON payload only\n"); printf(" --fields tst,lat,lon,... Choose fields for CSV. (dflt: ALL)\n"); printf(" --last -L JSON object with last users\n"); -#if HAVE_KILL +#if WITH_KILL printf(" --killdata requires -u and -d\n"); #endif printf(" --storage -S storage dir (%s)\n", STORAGEDEFAULT); @@ -170,20 +170,20 @@ void print_versioninfo() { printf("This is OwnTracks Recorder, version %s\n", VERSION); printf("built with:\n"); -#ifdef HAVE_LMDB - printf("\tHAVE_LMDB = yes\n"); +#ifdef WITH_LMDB + printf("\tWITH_LMDB = yes\n"); #endif #ifdef WITH_LUA printf("\tWITH_LUA = yes\n"); #endif -#ifdef HAVE_HTTP - printf("\tHAVE_HTTP = yes\n"); +#ifdef WITH_HTTP + printf("\tWITH_HTTP = yes\n"); #endif -#ifdef HAVE_PING - printf("\tHAVE_PING = yes\n"); +#ifdef WITH_PING + printf("\tWITH_PING = yes\n"); #endif -#ifdef HAVE_KILL - printf("\tHAVE_KILL = yes\n"); +#ifdef WITH_KILL + printf("\tWITH_KILL = yes\n"); #endif printf("\tSTORAGEDEFAULT = \"%s\"\n", STORAGEDEFAULT); printf("\tDOCROOT = \"%s\"\n", DOCROOT); @@ -199,7 +199,7 @@ int main(int argc, char **argv) char *progname = *argv, *p, *lmdbname = NULL; int c; int list = 0, last = 0, limit = 0, dumpghash = FALSE, loadghash = FALSE; -#if HAVE_KILL +#if WITH_KILL int killdata = FALSE; #endif int revgeo = TRUE; @@ -251,7 +251,7 @@ int main(int argc, char **argv) { "precision", required_argument, 0, 2}, { "dump", optional_argument, 0, 3}, { "load", optional_argument, 0, 4}, -#if HAVE_KILL +#if WITH_KILL { "killdata", no_argument, 0, 'K'}, #endif { "norevgeo", no_argument, 0, 'G'}, @@ -330,7 +330,7 @@ int main(int argc, char **argv) exit(2); } break; -#if HAVE_KILL +#if WITH_KILL case 'K': killdata = 1; break; @@ -367,7 +367,7 @@ int main(int argc, char **argv) storage_init(revgeo); -#if HAVE_KILL +#if WITH_KILL if (killdata) { JsonNode *obj; //, *killed, *f; diff --git a/ot-recorder.c b/ot-recorder.c index fb35ca3..bbabdb6 100644 --- a/ot-recorder.c +++ b/ot-recorder.c @@ -40,10 +40,10 @@ #include "misc.h" #include "util.h" #include "storage.h" -#ifdef HAVE_LMDB +#ifdef WITH_LMDB # include "gcache.h" #endif -#ifdef HAVE_HTTP +#ifdef WITH_HTTP # include "http.h" #endif #ifdef WITH_LUA @@ -371,7 +371,7 @@ void on_message(struct mosquitto *mosq, void *userdata, const struct mosquitto_m mosquitto_sub_topic_tokens_free(&topics, count); -#ifdef HAVE_PING +#ifdef WITH_PING if (!strcmp(UB(username), "ping") && !strcmp(UB(device), "ping")) { pingping = TRUE; } @@ -473,7 +473,7 @@ void on_message(struct mosquitto *mosq, void *userdata, const struct mosquitto_m } } -#ifdef HAVE_LMDB +#ifdef WITH_LMDB /* * If the topic we are handling is in topic2tid, replace the TID * in this payload with that from the database. @@ -614,7 +614,7 @@ void on_message(struct mosquitto *mosq, void *userdata, const struct mosquitto_m json_copy_to_object(json, geo, FALSE); } -#ifdef HAVE_HTTP +#ifdef WITH_HTTP if (ud->mgserver && !pingping) { http_ws_push_json(ud->mgserver, json); } @@ -702,12 +702,12 @@ static char *mosquitto_reason(int rc) void on_disconnect(struct mosquitto *mosq, void *userdata, int reason) { -#ifdef HAVE_LMDB +#ifdef WITH_LMDB struct udata *ud = (struct udata *)userdata; #endif if (reason == 0) { // client wish -#ifdef HAVE_LMDB +#ifdef WITH_LMDB gcache_close(ud->gc); #endif } else { @@ -736,7 +736,7 @@ void usage(char *prog) printf(" --port -p MQTT port (1883)\n"); printf(" --logfacility syslog facility (local0)\n"); printf(" --quiet disable printing of messages to stdout\n"); -#ifdef HAVE_HTTP +#ifdef WITH_HTTP printf(" --http-host HTTP addr to bind to (localhost)\n"); printf(" --http-port -A HTTP port (8083); 0 to disable HTTP\n"); printf(" --doc-root document root (%s)\n", DOCROOT); @@ -776,7 +776,7 @@ int main(int argc, char **argv) static struct udata udata, *ud = &udata; struct utsname uts; UT_string *clientid; -#ifdef HAVE_HTTP +#ifdef WITH_HTTP int http_port = 8083; char *doc_root = DOCROOT; char *http_host = "localhost"; @@ -789,16 +789,16 @@ int main(int argc, char **argv) udata.skipdemo = TRUE; udata.revgeo = TRUE; udata.verbose = TRUE; -#ifdef HAVE_LMDB +#ifdef WITH_LMDB udata.gc = NULL; udata.t2t = NULL; /* Topic to TID */ #endif -#ifdef HAVE_HTTP +#ifdef WITH_HTTP udata.mgserver = NULL; #endif #ifdef WITH_LUA udata.luadata = NULL; -# ifdef HAVE_LMDB +# ifdef WITH_LMDB udata.luadb = NULL; # endif #endif @@ -841,7 +841,7 @@ int main(int argc, char **argv) #ifdef WITH_LUA { "lua-script", required_argument, 0, 7}, #endif -#ifdef HAVE_HTTP +#ifdef WITH_HTTP { "http-host", required_argument, 0, 3}, { "http-port", required_argument, 0, 'A'}, { "doc-root", required_argument, 0, 2}, @@ -873,7 +873,7 @@ int main(int argc, char **argv) case 4: logfacility = strdup(optarg); break; -#ifdef HAVE_HTTP +#ifdef WITH_HTTP case 'A': /* API */ http_port = atoi(optarg); break; @@ -971,7 +971,7 @@ int main(int argc, char **argv) openlog("ot-recorder", LOG_PID | LOG_PERROR, syslog_facility_code(logfacility)); -#ifdef HAVE_HTTP +#ifdef WITH_HTTP if (http_port) { if (!is_directory(doc_root)) { olog(LOG_ERR, "%s is not a directory", doc_root); @@ -984,7 +984,7 @@ int main(int argc, char **argv) olog(LOG_DEBUG, "starting"); if (ud->revgeo == TRUE) { -#ifdef HAVE_LMDB +#ifdef WITH_LMDB char db_filename[BUFSIZ], *pa; snprintf(db_filename, BUFSIZ, "%s/ghash", STORAGEDIR); @@ -1001,7 +1001,7 @@ int main(int argc, char **argv) revgeo_init(); } -#ifdef HAVE_LMDB +#ifdef WITH_LMDB snprintf(err, sizeof(err), "%s/ghash", STORAGEDIR); ud->t2t = gcache_open(err, "topic2tid", TRUE); # ifdef WITH_LUA @@ -1103,7 +1103,7 @@ int main(int argc, char **argv) return rc; } -#ifdef HAVE_HTTP +#ifdef WITH_HTTP if (http_port) { char address[BUFSIZ]; const char *addressinfo; @@ -1139,7 +1139,7 @@ int main(int argc, char **argv) sleep(10); mosquitto_reconnect(mosq); } -#ifdef HAVE_HTTP +#ifdef WITH_HTTP if (udata.mgserver) { mg_poll_server(udata.mgserver, 200); } @@ -1148,7 +1148,7 @@ int main(int argc, char **argv) json_delete(ud->topics); -#ifdef HAVE_LMDB +#ifdef WITH_LMDB if (ud->t2t) gcache_close(ud->t2t); # ifdef WITH_LUA @@ -1157,7 +1157,7 @@ int main(int argc, char **argv) # endif #endif -#ifdef HAVE_HTTP +#ifdef WITH_HTTP mg_destroy_server(&udata.mgserver); #endif diff --git a/storage.c b/storage.c index c773843..f961225 100644 --- a/storage.c +++ b/storage.c @@ -856,7 +856,7 @@ char *gpx_string(JsonNode *location_array) return (UB(xml)); } -#if HAVE_KILL +#if WITH_KILL /* * Remove all data for a user's device. Return a JSON object with a status @@ -1018,7 +1018,7 @@ JsonNode *kill_datastore(char *user, char *device) json_append_member(obj, "killed", killed); return (obj); } -#endif /* HAVE_KILL */ +#endif /* WITH_KILL */ /* * Print the value in a single JSON node as XML by invoking func(). If string, diff --git a/udata.h b/udata.h index 86c54a1..99fb442 100644 --- a/udata.h +++ b/udata.h @@ -3,10 +3,10 @@ #include "json.h" -#ifdef HAVE_HTTP +#ifdef WITH_HTTP # include "mongoose.h" #endif -#ifdef HAVE_LMDB +#ifdef WITH_LMDB # include "gcache.h" #endif @@ -19,15 +19,15 @@ struct udata { int revgeo; /* True (default) if we should do reverse Geo lookups */ int qos; /* Subscribe QoS */ int verbose; /* TRUE if print verbose messages to stdout */ -#ifdef HAVE_LMDB +#ifdef WITH_LMDB struct gcache *gc; struct gcache *t2t; /* topic to tid */ #endif -#ifdef HAVE_HTTP +#ifdef WITH_HTTP struct mg_server *mgserver; /* Mongoose */ #endif #ifdef WITH_LUA -# ifdef HAVE_LMDB +# ifdef WITH_LMDB struct luadata *luadata; /* Lua stuff */ struct gcache *luadb; /* lmdb named database 'luadb' */ # endif