samples: add prometheus text file collector mustach template

Because prometheus needs timestamp information add that to mustach, and
update manual page what tags are available.

Reference: https://prometheus.io/docs/instrumenting/exposition_formats/
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This commit is contained in:
Sami Kerola 2017-11-13 14:16:35 +00:00
parent eabaa8adc2
commit e4f7259cf6
No known key found for this signature in database
GPG key ID: A9553245FDE9B739
6 changed files with 78 additions and 6 deletions

View file

@ -44,6 +44,7 @@
#include <error.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <unistd.h>
#include "close-stream.h"
@ -144,6 +145,20 @@ static int must_put_range(void *closure, const char *name, int escape
fprintf(file, "%d", e->oh.status);
return 0;
}
if (!strcmp(name, "gettimeofday")) {
struct timeval tp;
gettimeofday(&tp, NULL);
fprintf(file, "%ld", tp.tv_sec);
return 0;
}
if (!strcmp(name, "lease_file_mtime")) {
struct stat st;
stat(e->state->dhcpdlease_file, &st);
fprintf(file, "%ld", st.st_mtime);
return 0;
}
return 0;
}
@ -198,6 +213,20 @@ static int must_put_shnet(void *closure, const char *name, int escape
fprintf(file, "%d", e->oh.status);
return 0;
}
if (!strcmp(name, "gettimeofday")) {
struct timeval tp;
gettimeofday(&tp, NULL);
fprintf(file, "%ld", tp.tv_sec);
return 0;
}
if (!strcmp(name, "lease_file_mtime")) {
struct stat st;
stat(e->state->dhcpdlease_file, &st);
fprintf(file, "%ld", st.st_mtime);
return 0;
}
return 0;
}