build: fix types/headers for mingw windows builds
[pcp.git] / src / pmdas / root / root.h
blob4e1d744c7ca93d91c10d6d8e494ce8e75f066445
1 /*
2 * Copyright (c) 2014-2016 Red Hat.
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * for more details.
14 #ifndef _ROOT_H
15 #define _ROOT_H
17 #include <sys/stat.h>
19 enum {
20 CONTAINERS_INDOM,
21 NUM_INDOMS
24 enum {
25 CONTAINERS_ENGINE,
26 CONTAINERS_NAME,
27 CONTAINERS_PID,
28 CONTAINERS_RUNNING,
29 CONTAINERS_PAUSED,
30 CONTAINERS_RESTARTING,
31 CONTAINERS_CGROUP,
32 NUM_METRICS
35 enum {
36 CONTAINERS_UPTODATE_NAME,
37 CONTAINERS_UPTODATE_STATE,
38 NUM_UPTODATE
42 * General container services, abstracting individual implementations into
43 * "engines" which are then instantiated one-per-container-technology.
46 struct container;
47 struct container_engine;
49 typedef void (*container_setup_t)(struct container_engine *);
50 typedef int (*container_changed_t)(struct container_engine *);
51 typedef void (*container_insts_t)(struct container_engine *, pmInDom);
52 typedef int (*container_values_t)(struct container_engine *,
53 const char *, struct container *);
54 typedef int (*container_match_t)(struct container_engine *,
55 const char *, const char *, const char *);
57 typedef struct container_engine {
58 char *name; /* docker, lxc, rkt, etc. */
59 int state; /* external driver states */
60 char path[60]; /* suffix for cgroup path */
61 container_setup_t setup;
62 container_changed_t indom_changed;
63 container_insts_t insts_refresh;
64 container_values_t value_refresh;
65 container_match_t name_matching;
66 } container_engine_t;
68 enum {
69 CONTAINER_STATE_SYSTEMD = (1<<0),
72 typedef struct container {
73 int pid;
74 int flags : 8; /* CONTAINER_FLAG bitwise */
75 int state : 8; /* internal driver states */
76 int uptodate : 8; /* refreshed values count */
77 int padding : 8;
78 char *name; /* human-presentable name */
79 char cgroup[128];
80 struct stat stat;
81 container_engine_t *engine;
82 } container_t;
84 enum {
85 CONTAINER_FLAG_RUNNING = (1<<0),
86 CONTAINER_FLAG_PAUSED = (1<<1),
87 CONTAINER_FLAG_RESTARTING = (1<<2),
90 extern int root_stat_time_differs(struct stat *, struct stat *);
92 enum {
93 ROOT_AGENT_SOCKET = 1,
94 ROOT_AGENT_PIPE = 2,
97 extern int root_create_agent(int, char *, char *, int *, int *);
98 extern int root_agent_wait(int *);
99 extern int root_maximum_fd;
101 #endif