mirror of
git://git.code.sf.net/p/dhcpd-pools/code
synced 2025-12-17 16:26:59 +00:00
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:
parent
eabaa8adc2
commit
e4f7259cf6
6 changed files with 78 additions and 6 deletions
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue