| 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 2 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, write to the Free Software
|
|---|
| 19 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|---|
| 20 | */
|
|---|
| 21 |
|
|---|
| 22 | #include "perf.h"
|
|---|
| 23 |
|
|---|
| 24 | void get_processinfo(PERF_DATA_BLOCK *data)
|
|---|
| 25 | {
|
|---|
| 26 | int status;
|
|---|
| 27 | struct sysinfo info;
|
|---|
| 28 | status = sysinfo(&info);
|
|---|
| 29 |
|
|---|
| 30 | data->processInfo.data->runningProcessCount = (unsigned int)info.procs;
|
|---|
| 31 |
|
|---|
| 32 | return;
|
|---|
| 33 | }
|
|---|
| 34 |
|
|---|
| 35 | void init_processdata_desc(PERF_DATA_BLOCK *data)
|
|---|
| 36 | {
|
|---|
| 37 | init_perf_counter(&(data->processInfo.processObjDesc),
|
|---|
| 38 | &(data->processInfo.processObjDesc),
|
|---|
| 39 | get_counter_id(data),
|
|---|
| 40 | "Processes",
|
|---|
| 41 | "%The Processes performance object displays aggregate information about processes on the machine.",
|
|---|
| 42 | 0,
|
|---|
| 43 | PERF_OBJECT);
|
|---|
| 44 | init_perf_counter(&(data->processInfo.runningProcessCount),
|
|---|
| 45 | &(data->processInfo.processObjDesc),
|
|---|
| 46 | get_counter_id(data),
|
|---|
| 47 | "Process Count",
|
|---|
| 48 | "Process Count is the number of processes currently on the machine.",
|
|---|
| 49 | PERF_SIZE_DWORD | PERF_TYPE_NUMBER | PERF_NUMBER_DECIMAL | PERF_DISPLAY_NO_SUFFIX,
|
|---|
| 50 | PERF_COUNTER);
|
|---|
| 51 |
|
|---|
| 52 | return;
|
|---|
| 53 | }
|
|---|
| 54 |
|
|---|
| 55 | void init_process_data(PERF_DATA_BLOCK *data)
|
|---|
| 56 | {
|
|---|
| 57 | data->processInfo.data = calloc(1, sizeof(*data->processInfo.data));
|
|---|
| 58 | if(!(data->processInfo.data))
|
|---|
| 59 | {
|
|---|
| 60 | perror("init_process_data: out of memory");
|
|---|
| 61 | exit(1);
|
|---|
| 62 | }
|
|---|
| 63 |
|
|---|
| 64 | init_processdata_desc(data);
|
|---|
| 65 |
|
|---|
| 66 | get_processinfo(data);
|
|---|
| 67 |
|
|---|
| 68 | return;
|
|---|
| 69 | }
|
|---|
| 70 |
|
|---|
| 71 | void output_processinfo(PERF_DATA_BLOCK *data, RuntimeSettings rt, int tdb_flags)
|
|---|
| 72 | {
|
|---|
| 73 | output_perf_counter(data->processInfo.runningProcessCount,
|
|---|
| 74 | (unsigned long long)data->processInfo.data->runningProcessCount,
|
|---|
| 75 | rt, tdb_flags);
|
|---|
| 76 |
|
|---|
| 77 | return;
|
|---|
| 78 | }
|
|---|
| 79 |
|
|---|
| 80 | void output_process_desc(PERF_DATA_BLOCK *data, RuntimeSettings rt)
|
|---|
| 81 | {
|
|---|
| 82 | output_perf_desc(data->processInfo.processObjDesc, rt);
|
|---|
| 83 | output_perf_desc(data->processInfo.runningProcessCount, rt);
|
|---|
| 84 |
|
|---|
| 85 | return;
|
|---|
| 86 | }
|
|---|