Compare commits
4 Commits
61dd64c0e6
...
81c9288e96
Author | SHA1 | Date |
---|---|---|
Joachim Desroches | 81c9288e96 | |
Joachim Desroches | dd8323939e | |
Joachim Desroches | b36749db03 | |
Joachim Desroches | d26b6b0b4a |
|
@ -0,0 +1 @@
|
||||||
|
exporter
|
|
@ -0,0 +1,32 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#define USER "odoo"
|
||||||
|
#define HTTP_PORT 9402
|
||||||
|
#define INTERVAL 10
|
||||||
|
|
||||||
|
int main(int argc, char **argv) {
|
||||||
|
if (argc != 2) {
|
||||||
|
fprintf(stdout, "Invalid number of arguments. Usage: %s [dbname]\n",
|
||||||
|
argv[0]);
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Setup database connection parameters */
|
||||||
|
char connstring[STRLEN];
|
||||||
|
sprintf(connstring, "database = %s, user = %s", argv[1], USER);
|
||||||
|
|
||||||
|
/* Connect to the database */
|
||||||
|
PGconn *conn = PQconnectdb(connstring);
|
||||||
|
|
||||||
|
if (conn == NULL) {
|
||||||
|
fprintf(stderr, "Out of memory connecting the PostgreSQL\n.");
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
} else if (PQstatus(conn) != CONNECTION_OK) {
|
||||||
|
fprintf(stderr, PQerrorMessage(conn));
|
||||||
|
PQfinish(conn);
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
|
@ -10,6 +10,7 @@ import sys
|
||||||
|
|
||||||
|
|
||||||
USER = "odoo"
|
USER = "odoo"
|
||||||
|
HTTP_HOST = "::"
|
||||||
HTTP_PORT = 9402
|
HTTP_PORT = 9402
|
||||||
INTERVAL = 10
|
INTERVAL = 10
|
||||||
|
|
||||||
|
@ -26,7 +27,7 @@ if __name__ == '__main__':
|
||||||
"Remaining days before Odoo license expiration")
|
"Remaining days before Odoo license expiration")
|
||||||
|
|
||||||
# Serve metrics over HTTP
|
# Serve metrics over HTTP
|
||||||
start_http_server(HTTP_PORT)
|
start_http_server(host=HTTP_HOST, port=HTTP_PORT)
|
||||||
|
|
||||||
# Open connection
|
# Open connection
|
||||||
with psycopg2.connect(database=DBNAME, user=USER) as conn:
|
with psycopg2.connect(database=DBNAME, user=USER) as conn:
|
||||||
|
|
Loading…
Reference in New Issue