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/>.
40 #include <rpc_perfcount_defs.h>
41 #include <sys/statfs.h>
42 #include <sys/times.h>
43 #include <sys/sysinfo.h>
45 #define NUM_COUNTERS 10
51 #define PERF_INSTANCE 1
52 #define PERF_COUNTER 2
58 #define LARGE_BUF 16384
60 typedef struct perf_counter
65 char relationships
[NAME_LEN
];
66 unsigned int counter_type
;
70 typedef struct mem_data
72 unsigned int availPhysKb
;
73 unsigned int availSwapKb
;
74 unsigned int totalPhysKb
;
75 unsigned int totalSwapKb
;
78 typedef struct mem_info
80 PerfCounter memObjDesc
;
81 PerfCounter availPhysKb
;
82 PerfCounter availSwapKb
;
83 PerfCounter totalPhysKb
;
84 PerfCounter totalSwapKb
;
88 typedef struct cpu_data
90 unsigned long long user
;
91 unsigned long long nice
;
92 unsigned long long system
;
93 unsigned long long idle
;
96 typedef struct cpu_info
99 PerfCounter cpuObjDesc
;
102 PerfCounter systemCPU
;
107 typedef struct disk_meta_data
110 char mountpoint
[NAME_LEN
];
113 typedef struct disk_data
115 unsigned long long freeMegs
;
116 unsigned int writesPerSec
;
117 unsigned int readsPerSec
;
120 typedef struct disk_info
122 unsigned int numDisks
;
124 PerfCounter diskObjDesc
;
125 PerfCounter freeMegs
;
126 PerfCounter writesPerSec
;
127 PerfCounter readsPerSec
;
131 typedef struct process_data
133 unsigned int runningProcessCount
;
136 typedef struct process_info
138 PerfCounter processObjDesc
;
139 PerfCounter runningProcessCount
;
143 typedef struct perf_data_block
145 unsigned int counter_id
;
146 unsigned int num_counters
;
147 unsigned int NumObjectTypes
;
148 unsigned long long PerfTime
;
149 unsigned long long PerfFreq
;
150 unsigned long long PerfTime100nSec
;
153 ProcessInfo processInfo
;
157 typedef struct runtime_settings
162 char dbDir
[PATH_MAX
];
163 char nameFile
[PATH_MAX
];
164 char counterFile
[PATH_MAX
];
170 /* perf_writer_ng_util.c function prototypes */
171 void fatal(char *msg
);
172 void add_key(TDB_CONTEXT
*db
, char *keystring
, char *datastring
, int flags
);
173 void add_key_raw(TDB_CONTEXT
*db
, char *keystring
, void *datastring
, size_t datasize
, int flags
);
174 void make_key(char *buf
, int buflen
, int key_part1
, char *key_part2
);
175 void parse_flags(RuntimeSettings
*rt
, int argc
, char **argv
);
176 void setup_file_paths(RuntimeSettings
*rt
);
177 void daemonize(RuntimeSettings
*rt
);
179 /* perf_writer_ng_mem.c function prototypes */
180 void get_meminfo(PERF_DATA_BLOCK
*data
);
181 void init_memdata_desc(PERF_DATA_BLOCK
*data
);
182 void init_memdata(PERF_DATA_BLOCK
*data
);
183 void output_mem_desc(PERF_DATA_BLOCK
*data
, RuntimeSettings rt
);
184 void output_meminfo(PERF_DATA_BLOCK
*data
, RuntimeSettings rt
, int tdb_flags
);
185 void init_perf_counter(PerfCounter
*counter
, PerfCounter
*parent
, unsigned int index
, char *name
, char *help
, int counter_type
, int record_type
);
187 /* perf_writer_ng_cpu.c function prototypes */
188 unsigned long long get_cpufreq();
189 void init_cpudata_desc(PERF_DATA_BLOCK
*data
);
190 void get_cpuinfo(PERF_DATA_BLOCK
*data
);
191 void init_cpu_data(PERF_DATA_BLOCK
*data
);
192 void output_cpu_desc(PERF_DATA_BLOCK
*data
, RuntimeSettings rt
);
193 void output_cpuinfo(PERF_DATA_BLOCK
*data
, RuntimeSettings rt
, int tdb_flags
);
195 #endif /* __PERF_H__ */