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 2 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, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
41 #include <rpc_perfcount_defs.h>
42 #include <sys/statfs.h>
43 #include <sys/times.h>
44 #include <sys/sysinfo.h>
46 #define NUM_COUNTERS 10
52 #define PERF_INSTANCE 1
53 #define PERF_COUNTER 2
59 #define LARGE_BUF 16384
61 typedef struct perf_counter
66 char relationships
[NAME_LEN
];
67 unsigned int counter_type
;
71 typedef struct mem_data
73 unsigned int availPhysKb
;
74 unsigned int availSwapKb
;
75 unsigned int totalPhysKb
;
76 unsigned int totalSwapKb
;
79 typedef struct mem_info
81 PerfCounter memObjDesc
;
82 PerfCounter availPhysKb
;
83 PerfCounter availSwapKb
;
84 PerfCounter totalPhysKb
;
85 PerfCounter totalSwapKb
;
89 typedef struct cpu_data
91 unsigned long long user
;
92 unsigned long long nice
;
93 unsigned long long system
;
94 unsigned long long idle
;
97 typedef struct cpu_info
100 PerfCounter cpuObjDesc
;
103 PerfCounter systemCPU
;
108 typedef struct disk_meta_data
111 char mountpoint
[NAME_LEN
];
114 typedef struct disk_data
116 unsigned long long freeMegs
;
117 unsigned int writesPerSec
;
118 unsigned int readsPerSec
;
121 typedef struct disk_info
123 unsigned int numDisks
;
125 PerfCounter diskObjDesc
;
126 PerfCounter freeMegs
;
127 PerfCounter writesPerSec
;
128 PerfCounter readsPerSec
;
132 typedef struct process_data
134 unsigned int runningProcessCount
;
137 typedef struct process_info
139 PerfCounter processObjDesc
;
140 PerfCounter runningProcessCount
;
144 typedef struct perf_data_block
146 unsigned int counter_id
;
147 unsigned int num_counters
;
148 unsigned int NumObjectTypes
;
149 unsigned long long PerfTime
;
150 unsigned long long PerfFreq
;
151 unsigned long long PerfTime100nSec
;
154 ProcessInfo processInfo
;
158 typedef struct runtime_settings
163 char dbDir
[PATH_MAX
];
164 char nameFile
[PATH_MAX
];
165 char counterFile
[PATH_MAX
];
171 /* perf_writer_ng_util.c function prototypes */
172 void fatal(char *msg
);
173 void add_key(TDB_CONTEXT
*db
, char *keystring
, char *datastring
, int flags
);
174 void add_key_raw(TDB_CONTEXT
*db
, char *keystring
, void *datastring
, size_t datasize
, int flags
);
175 void make_key(char *buf
, int buflen
, int key_part1
, char *key_part2
);
176 void parse_flags(RuntimeSettings
*rt
, int argc
, char **argv
);
177 void setup_file_paths(RuntimeSettings
*rt
);
178 void daemonize(RuntimeSettings
*rt
);
180 /* perf_writer_ng_mem.c function prototypes */
181 void get_meminfo(PERF_DATA_BLOCK
*data
);
182 void init_memdata_desc(PERF_DATA_BLOCK
*data
);
183 void init_memdata(PERF_DATA_BLOCK
*data
);
184 void output_mem_desc(PERF_DATA_BLOCK
*data
, RuntimeSettings rt
);
185 void output_meminfo(PERF_DATA_BLOCK
*data
, RuntimeSettings rt
, int tdb_flags
);
186 void init_perf_counter(PerfCounter
*counter
, PerfCounter
*parent
, unsigned int index
, char *name
, char *help
, int counter_type
, int record_type
);
188 /* perf_writer_ng_cpu.c function prototypes */
189 unsigned long long get_cpufreq();
190 void init_cpudata_desc(PERF_DATA_BLOCK
*data
);
191 void get_cpuinfo(PERF_DATA_BLOCK
*data
);
192 void init_cpu_data(PERF_DATA_BLOCK
*data
);
193 void output_cpu_desc(PERF_DATA_BLOCK
*data
, RuntimeSettings rt
);
194 void output_cpuinfo(PERF_DATA_BLOCK
*data
, RuntimeSettings rt
, int tdb_flags
);
196 #endif /* __PERF_H__ */