Skip to content

Commit

Permalink
ping/ping monitoring user/device no longer shows up on map nor in table
Browse files Browse the repository at this point in the history
	closes #195
  • Loading branch information
jpmens committed Jun 19, 2017
1 parent 390f761 commit 87a5839
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,8 @@ After sending a pingping, you can query the REST interface to determine the diff
OK ot-recorder pingping at http://127.0.0.1:8085: 0 seconds difference
```

Note that our Docker image has this monitoring built in with recorder-health.sh. What this basically does is it allows Docker to monitor the Recorder's availability in HEALTHCHECK. So, the `ping/ping` you may be seeing is being used between Docker and the container running the Recorder and has absolutely no impact on mobile data.

## Views

A view is a sort of sandboxed look at data provided by the Recorder. Assume you host several devices, be they your own or those of some of your friends, and assume you want to allow somebody else to see where you are or have been during a specific time frame: with the Recorder's default Web server you cannot limit a visitor to see specific data only; once they reach the Recorder's Web interface, they have access to all your data. (We warned you about that earlier.) Using a HTTP proxy, you can provide an insight into certain portions of your data only.
Expand Down
4 changes: 4 additions & 0 deletions docroot/table/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@
for (i in data) {
var d = data[i];

if (d.username == 'ping' && d.device == 'ping') {
continue;
}

if (!d.topic) {
console.log("SKIP " + JSON.stringify(d));
continue;
Expand Down
22 changes: 17 additions & 5 deletions http.c
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ static int send_reply(struct mg_connection *conn)
* Push a list of LAST users down the Websocket. We send individual
* JSON objects (not an array of them) because these are what the
* WS client gets when we the recorder sees a publish.
* Ignore the ping/ping user.
*/

static void send_last(struct mg_connection *conn)
Expand All @@ -297,6 +298,22 @@ static void send_last(struct mg_connection *conn)

o = json_mkobject();

if ((f = json_find_member(one, "username")) != NULL) {
JsonNode *d = json_find_member(one, "device");

/* check for pingping user (ping/ping) and skip */
if (f && d) {
if (!strcmp(f->string_, "ping") &&
!strcmp(d->string_, "ping")) {
json_delete(o);
continue;
}
}

/* Add CARD details */
append_card_to_object(o, f->string_, d->string_);
}

json_append_member(o, "_type", json_mkstring("location"));
if ((f = json_find_member(one, "lat")) != NULL)
json_copy_element_to_object(o, "lat", f);
Expand All @@ -312,11 +329,6 @@ static void send_last(struct mg_connection *conn)
if ((f = json_find_member(one, "topic")) != NULL)
json_copy_element_to_object(o, "topic", f);

if ((f = json_find_member(one, "username")) != NULL) {
JsonNode *d = json_find_member(one, "device");
/* Add CARD details */
append_card_to_object(o, f->string_, d->string_);
}

http_ws_push_json(ud->mgserver, o);
json_delete(o);
Expand Down

0 comments on commit 87a5839

Please sign in to comment.