summaryrefslogtreecommitdiff
path: root/customquery.h
blob: d9ce46131402a7c734ba44f9834cdb32aa490700 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#ifndef CUSTHANDLER_H
#define CUSTHANDLER_H

#include "pgsnmpd.h"

void init_custom_queries(void);

typedef struct pgsnmpd_query pgsnmpd_query;

extern char *custom_query_config_file;

struct pgsnmpd_query {
    char  *table_name;
    char  *query_text;
    oid   *table_oid;
    size_t oid_len;

    int      num_indexes;
    int      min_colnum;
    u_char  *types;
    int      typeslen;

    /* Number of rows and columns returned by the query */
    int rowcount;
    int colcount;

    PGresult *result;

    /* How long (sec) before I need to refresh this result */
    int cache_timeout;
    /* When the result was last refreshed */
    time_t last_refresh;

    netsnmp_table_array_callbacks cb;
    netsnmp_handler_registration *my_handler;

    pgsnmpd_query *next;
};

pgsnmpd_query *alloc_custom_query(char *table_name, char *query_text,
                                    oid *table_oid, int oid_len);

void init_types_array(u_char *types, int start, int end);

oid *parse_oid(const char *oid_str_orig, int *oid_len);

#endif /* CUSTHANDLER_H */