MXS-1220: Fix date formatting
Some of the dates were printed with a trailing newline. This was added by asctime_r. Fixed `/services` resource returning an empty array.
This commit is contained in:

committed by
Markus Mäkelä

parent
75b44198ba
commit
aa16980cec
@ -38,6 +38,7 @@
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include <maxscale/service.h>
|
||||
#include <maxscale/session.h>
|
||||
#include <maxscale/server.h>
|
||||
@ -48,6 +49,7 @@
|
||||
#include <maxscale/ssl.h>
|
||||
#include <maxscale/alloc.h>
|
||||
#include <maxscale/paths.h>
|
||||
#include <maxscale/utils.h>
|
||||
#include <maxscale/semaphore.hh>
|
||||
|
||||
#include "maxscale/monitor.h"
|
||||
@ -1438,7 +1440,13 @@ json_t* server_to_json(const SERVER* server)
|
||||
|
||||
if (server->node_ts > 0)
|
||||
{
|
||||
json_object_set_new(rval, "last_heartbeat", json_integer(server->node_ts));
|
||||
struct tm result;
|
||||
char timebuf[30];
|
||||
time_t tim = server->node_ts;
|
||||
asctime_r(localtime_r(&tim, &result), timebuf);
|
||||
trim(timebuf);
|
||||
|
||||
json_object_set_new(rval, "last_heartbeat", json_string(timebuf));
|
||||
}
|
||||
|
||||
json_t* stats = json_object();
|
||||
|
Reference in New Issue
Block a user