source: nscp/modules/CheckSystem/PDHCollector.h @ b4110d8

0.4.00.4.10.4.2
Last change on this file since b4110d8 was b4110d8, checked in by Michael Medin <michael@…>, 3 years ago

Reintegrated stable branch and removed some project files (no longer needed) (part x of many)

  • Property mode set to 100644
File size: 3.2 KB
Line 
1/**************************************************************************
2*   Copyright (C) 2004-2007 by Michael Medin <michael@medin.name>         *
3*                                                                         *
4*   This code is part of NSClient++ - http://trac.nakednuns.org/nscp      *
5*                                                                         *
6*   This program is free software; you can redistribute it and/or modify  *
7*   it under the terms of the GNU General Public License as published by  *
8*   the Free Software Foundation; either version 2 of the License, or     *
9*   (at your option) any later version.                                   *
10*                                                                         *
11*   This program is distributed in the hope that it will be useful,       *
12*   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
13*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
14*   GNU General Public License for more details.                          *
15*                                                                         *
16*   You should have received a copy of the GNU General Public License     *
17*   along with this program; if not, write to the                         *
18*   Free Software Foundation, Inc.,                                       *
19*   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
20***************************************************************************/
21#pragma once
22
23#include <pdh.hpp>
24#include <thread.h>
25#include <MutexRW.h>
26
27/**
28 * @ingroup NSClientCompat
29 * PDH collector thread (gathers performance data and allows for clients to retrieve it)
30 *
31 * @version 1.0
32 * first version
33 *
34 * @date 02-13-2005
35 *
36 * @author mickem
37 *
38 * @par license
39 * This code is absolutely free to use and modify. The code is provided "as is" with
40 * no expressed or implied warranty. The author accepts no liability if it causes
41 * any damage to your computer, causes your pet to fall ill, increases baldness
42 * or makes your car start emitting strange noises when you start it up.
43 * This code has no bugs, just undocumented features!
44 *
45 */
46class PDHCollector {
47private:
48
49        MutexRW mutex_;
50        HANDLE hStopEvent_;
51        int checkIntervall_;
52        bool dontCollect_;
53
54        PDHCollectors::StaticPDHCounterListener<unsigned __int64, PDHCollectors::format_large, PDHCollectors::PDHCounterNormalMutex> memCmtLim;
55        PDHCollectors::StaticPDHCounterListener<unsigned __int64, PDHCollectors::format_large, PDHCollectors::PDHCounterNormalMutex> memCmt;
56        PDHCollectors::StaticPDHCounterListener<__int64, PDHCollectors::format_large, PDHCollectors::PDHCounterNormalMutex> upTime;
57        PDHCollectors::RoundINTPDHBufferListener<__int64, PDHCollectors::format_large, PDHCollectors::PDHCounterNormalMutex> cpu;
58
59public:
60        PDHCollector();
61        virtual ~PDHCollector();
62        DWORD threadProc(LPVOID lpParameter);
63        void exitThread(void);
64
65        // Retrieve values
66        int getCPUAvrage(std::wstring time);
67        long long getUptime();
68        unsigned long long getMemCommitLimit();
69        unsigned long long getMemCommit();
70        bool loadCounter(PDH::PDHQuery &pdh);
71
72
73private:
74//      bool isRunning(void);
75//      void startRunning(void);
76//      void stopRunning(void);
77
78};
79
80
81typedef Thread<PDHCollector> PDHCollectorThread;
Note: See TracBrowser for help on using the repository browser.