/* [<][>][^][v][top][bottom][index][help] */
DEFINITIONS
This source file includes following definitions.
- get_processinfo
- init_processdata_desc
- init_process_data
- output_processinfo
- output_process_desc
1 /*
2 * Unix SMB/CIFS implementation.
3 * Performance Counter Daemon
4 *
5 * Copyright (C) Marcin Krzysztof Porwit 2005
6 *
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.
11 *
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.
16 *
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/>.
19 */
20
21 #include "perf.h"
22
23 void get_processinfo(PERF_DATA_BLOCK *data)
/* [<][>][^][v][top][bottom][index][help] */
24 {
25 int status;
26 struct sysinfo info;
27 status = sysinfo(&info);
28
29 data->processInfo.data->runningProcessCount = (unsigned int)info.procs;
30
31 return;
32 }
33
34 void init_processdata_desc(PERF_DATA_BLOCK *data)
/* [<][>][^][v][top][bottom][index][help] */
35 {
36 init_perf_counter(&(data->processInfo.processObjDesc),
37 &(data->processInfo.processObjDesc),
38 get_counter_id(data),
39 "Processes",
40 "%The Processes performance object displays aggregate information about processes on the machine.",
41 0,
42 PERF_OBJECT);
43 init_perf_counter(&(data->processInfo.runningProcessCount),
44 &(data->processInfo.processObjDesc),
45 get_counter_id(data),
46 "Process Count",
47 "Process Count is the number of processes currently on the machine.",
48 PERF_SIZE_DWORD | PERF_TYPE_NUMBER | PERF_NUMBER_DECIMAL | PERF_DISPLAY_NO_SUFFIX,
49 PERF_COUNTER);
50
51 return;
52 }
53
54 void init_process_data(PERF_DATA_BLOCK *data)
/* [<][>][^][v][top][bottom][index][help] */
55 {
56 data->processInfo.data = calloc(1, sizeof(*data->processInfo.data));
57 if(!(data->processInfo.data))
58 {
59 perror("init_process_data: out of memory");
60 exit(1);
61 }
62
63 init_processdata_desc(data);
64
65 get_processinfo(data);
66
67 return;
68 }
69
70 void output_processinfo(PERF_DATA_BLOCK *data, RuntimeSettings rt, int tdb_flags)
/* [<][>][^][v][top][bottom][index][help] */
71 {
72 output_perf_counter(data->processInfo.runningProcessCount,
73 (unsigned long long)data->processInfo.data->runningProcessCount,
74 rt, tdb_flags);
75
76 return;
77 }
78
79 void output_process_desc(PERF_DATA_BLOCK *data, RuntimeSettings rt)
/* [<][>][^][v][top][bottom][index][help] */
80 {
81 output_perf_desc(data->processInfo.processObjDesc, rt);
82 output_perf_desc(data->processInfo.runningProcessCount, rt);
83
84 return;
85 }