prometheus-odoo-license-exp.../exporter.c

33 lines
773 B
C

#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;
}