add hostname in influx request
This commit is contained in:
parent
95f938e0b5
commit
562ee0d16c
@ -13,9 +13,13 @@ const char INFLUXURL[] = "http://172.16.3.15:8086/write?db=smarthome2&precision=
|
||||
char influxBuffer[BUFSIZE];
|
||||
char *bufferNextEntry;
|
||||
|
||||
#define HOSTNAMESIZE 128
|
||||
char hostname[HOSTNAMESIZE];
|
||||
|
||||
void influxInit() {
|
||||
memset(influxBuffer, 0, BUFSIZE);
|
||||
bufferNextEntry = influxBuffer;
|
||||
gethostname(hostname, HOSTNAMESIZE);
|
||||
}
|
||||
|
||||
static void influxSendRequest() {
|
||||
@ -36,12 +40,12 @@ static void influxSendRequest() {
|
||||
void influxAddFrequency(double f) {
|
||||
static uint32_t entries = 0;
|
||||
static uint32_t totalEntries = 0;
|
||||
char tmpBuf[128];
|
||||
char tmpBuf[256];
|
||||
struct timespec t;
|
||||
|
||||
clock_gettime(CLOCK_REALTIME, &t);
|
||||
uint64_t tt = (((uint64_t)t.tv_sec) * 1000) + (((uint64_t)t.tv_nsec) / 1000000);
|
||||
int c = sprintf(tmpBuf, "mainsfrequency freq=%f %llu\n", f, tt);
|
||||
int c = sprintf(tmpBuf, "mainsfrequency,host=%s freq=%f %llu\n", hostname, f, tt);
|
||||
|
||||
if ((bufferNextEntry + c + 10) > (influxBuffer + BUFSIZE)) {
|
||||
influxSendRequest();
|
||||
|
Loading…
x
Reference in New Issue
Block a user