2 * Unix SMB/CIFS implementation.
3 * Performance Counter Daemon
5 * Copyright (C) Marcin Krzysztof Porwit 2005
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, see <http://www.gnu.org/licenses/>.
30 #if !defined(HAVE_BOOL)
34 #error Need a real boolean type
55 #include "librpc/gen_ndr/perfcount.h"
56 #include <sys/statfs.h>
57 #include <sys/times.h>
58 #include <sys/sysinfo.h>
60 #define NUM_COUNTERS 10
66 #define PERF_INSTANCE 1
67 #define PERF_COUNTER 2
73 #define LARGE_BUF 16384
75 typedef struct perf_counter
80 char relationships
[NAME_LEN
];
81 unsigned int counter_type
;
85 typedef struct mem_data
87 unsigned int availPhysKb
;
88 unsigned int availSwapKb
;
89 unsigned int totalPhysKb
;
90 unsigned int totalSwapKb
;
93 typedef struct mem_info
95 PerfCounter memObjDesc
;
96 PerfCounter availPhysKb
;
97 PerfCounter availSwapKb
;
98 PerfCounter totalPhysKb
;
99 PerfCounter totalSwapKb
;
103 typedef struct cpu_data
105 unsigned long long user
;
106 unsigned long long nice
;
107 unsigned long long system
;
108 unsigned long long idle
;
111 typedef struct cpu_info
113 unsigned int numCPUs
;
114 PerfCounter cpuObjDesc
;
117 PerfCounter systemCPU
;
122 typedef struct disk_meta_data
125 char mountpoint
[NAME_LEN
];
128 typedef struct disk_data
130 unsigned long long freeMegs
;
131 unsigned int writesPerSec
;
132 unsigned int readsPerSec
;
135 typedef struct disk_info
137 unsigned int numDisks
;
139 PerfCounter diskObjDesc
;
140 PerfCounter freeMegs
;
141 PerfCounter writesPerSec
;
142 PerfCounter readsPerSec
;
146 typedef struct process_data
148 unsigned int runningProcessCount
;
151 typedef struct process_info
153 PerfCounter processObjDesc
;
154 PerfCounter runningProcessCount
;
158 typedef struct perf_data_block
160 unsigned int counter_id
;
161 unsigned int num_counters
;
162 unsigned int NumObjectTypes
;
163 unsigned long long PerfTime
;
164 unsigned long long PerfFreq
;
165 unsigned long long PerfTime100nSec
;
168 ProcessInfo processInfo
;
172 typedef struct runtime_settings
177 char dbDir
[PATH_MAX
];
178 char nameFile
[PATH_MAX
];
179 char counterFile
[PATH_MAX
];
185 /* perf_writer_ng_util.c function prototypes */
186 void fatal(char *msg
);
187 void add_key(TDB_CONTEXT
*db
, char *keystring
, char *datastring
, int flags
);
188 void add_key_raw(TDB_CONTEXT
*db
, char *keystring
, void *datastring
, size_t datasize
, int flags
);
189 void make_key(char *buf
, int buflen
, int key_part1
, char *key_part2
);
190 void parse_flags(RuntimeSettings
*rt
, int argc
, char **argv
);
191 void setup_file_paths(RuntimeSettings
*rt
);
192 void daemonize(RuntimeSettings
*rt
);
194 /* perf_writer_ng_mem.c function prototypes */
195 void get_meminfo(PERF_DATA_BLOCK
*data
);
196 void init_memdata_desc(PERF_DATA_BLOCK
*data
);
197 void init_memdata(PERF_DATA_BLOCK
*data
);
198 void output_mem_desc(PERF_DATA_BLOCK
*data
, RuntimeSettings rt
);
199 void output_meminfo(PERF_DATA_BLOCK
*data
, RuntimeSettings rt
, int tdb_flags
);
200 void init_perf_counter(PerfCounter
*counter
, PerfCounter
*parent
, unsigned int index
, char *name
, char *help
, int counter_type
, int record_type
);
202 /* perf_writer_ng_cpu.c function prototypes */
203 unsigned long long get_cpufreq();
204 void init_cpudata_desc(PERF_DATA_BLOCK
*data
);
205 void get_cpuinfo(PERF_DATA_BLOCK
*data
);
206 void init_cpu_data(PERF_DATA_BLOCK
*data
);
207 void output_cpu_desc(PERF_DATA_BLOCK
*data
, RuntimeSettings rt
);
208 void output_cpuinfo(PERF_DATA_BLOCK
*data
, RuntimeSettings rt
, int tdb_flags
);
210 #endif /* __PERF_H__ */