Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

199 lines
7.7 KiB

  1. //***************************************************************************
  2. //
  3. // DATACLTR.H
  4. //
  5. // Module: HEALTHMON SERVER AGENT
  6. //
  7. // Purpose: CDataCollector class to do WMI instance collection.
  8. //
  9. // Copyright (c)1999 Microsoft Corporation, All Rights Reserved
  10. //
  11. //***************************************************************************
  12. #if !defined( __DATACLTR_H )
  13. #define __DATACLTR_H
  14. #include <wbemcli.h>
  15. #include <vector>
  16. #include "global.h"
  17. #include "base.h"
  18. #include "threshld.h"
  19. typedef struct _tag_NSStruct
  20. {
  21. LPTSTR szTargetNamespace; // Namespace class exists in
  22. LPTSTR szLocal;
  23. IWbemServices* pIWbemServices; // pointer to the namespace
  24. } NSSTRUCT, *PNSSTRUCT;
  25. typedef struct _tag_InstIDStruct
  26. {
  27. LPTSTR szInstanceIDPropertyName;
  28. } InstIDSTRUCT, *PInstIDSTRUCT;
  29. typedef std::vector<NSSTRUCT, std::allocator<NSSTRUCT> > NSLIST;
  30. typedef std::vector<CThreshold*, std::allocator<CThreshold*> > RLIST;
  31. typedef std::vector<InstIDSTRUCT, std::allocator<InstIDSTRUCT> > InstIDLIST;
  32. class CDataGroup; // Forward declaration
  33. class CDataCollector : public CBase
  34. {
  35. public:
  36. CDataCollector();
  37. virtual ~CDataCollector();
  38. CDataGroup *m_pParentDG;
  39. long m_lNumberNormals;
  40. long m_lNumberWarnings;
  41. long m_lNumberCriticals;
  42. IWbemServices* m_pIWbemServices;
  43. RLIST m_thresholdList;
  44. LPTSTR m_szParentObjPath;
  45. LPTSTR m_szDescription;
  46. LPTSTR m_szUserName;
  47. LPTSTR m_szPassword;
  48. LPTSTR m_szTargetNamespace;
  49. LPTSTR m_szLocal;
  50. InstIDLIST m_instIDList; // List of the key properties of the class we are collecting
  51. ACTUALINSTLIST m_actualInstList; // List of actual instances being collected (most recent)
  52. LPTSTR m_szTypeGUID;
  53. long m_lCollectionIntervalMultiple;
  54. long m_lCollectionTimeOut;
  55. long m_lStatisticsWindowSize;
  56. int m_iActiveDays;
  57. long m_lBeginHourTime;
  58. long m_lBeginMinuteTime;
  59. long m_lEndHourTime;
  60. long m_lEndMinuteTime;
  61. long m_lTypeGUID;
  62. BOOL m_bRequireReset;
  63. BOOL m_bReplicate;
  64. BOOL m_bEnabled;
  65. BOOL m_bParentEnabled; // So we can transfer down the hierarchy the state.
  66. long m_lId;
  67. long m_lNumberChanges;
  68. IWbemContext *m_pContext;
  69. HM_DE_TYPE m_deType;
  70. IWbemCallResult *m_pCallResult;
  71. BOOL m_bKeepCollectingSemiSync;
  72. TCHAR m_szTime[512];
  73. TCHAR m_szCollectTime[512];
  74. TCHAR m_szCICTime[512];
  75. TCHAR m_szCECTime[512];
  76. TCHAR m_szDTTime[512];
  77. TCHAR m_szDTCollectTime[512];
  78. TCHAR m_szDTCICTime[512];
  79. TCHAR m_szDTCECTime[512];
  80. TCHAR m_szStatusGUID[100];
  81. unsigned long m_ulErrorCode;
  82. TCHAR m_szErrorDescription[4096];
  83. LPTSTR m_szMessage;
  84. LPTSTR m_szResetMessage;
  85. HRESULT FormatMessage(IWbemClassObject* pIRSInstance, IWbemClassObject *pEmbeddedInstance);
  86. // HM_UNKNOWN_REASON m_unknownReason;
  87. // HRESULT m_unknownhRes;
  88. // TCHAR m_szWmiError[1024];
  89. long m_lPrevChildCount;
  90. BOOL m_ulErrorCodePrev;
  91. BOOL m_bValidLoad;
  92. long m_lIntervalCount;
  93. long m_lCollectionTimeOutCount;
  94. long m_lNumInstancesCollected;
  95. long m_lPrevState;
  96. // long m_lCurrState;
  97. BOOL Cleanup(BOOL bSavePrevSettings);
  98. BOOL Init(void);
  99. BOOL OnAgentInterval(void);
  100. BOOL SendEvents(void);
  101. HRESULT FireEvent(BOOL bForce);
  102. BOOL FireStatisticsEvent(void);
  103. virtual BOOL CollectInstance(void) = 0;
  104. virtual BOOL CollectInstanceSemiSync(void) = 0;
  105. virtual BOOL CleanupSemiSync(void) = 0;
  106. virtual BOOL EnumDone(void) = 0;
  107. BOOL StoreValues(IWbemClassObject* pObj, LPTSTR pszInstID);
  108. BOOL StoreStandardProperties(void);
  109. long GetCollectionIntervalMultiple();
  110. virtual HRESULT LoadInstanceFromMOF(IWbemClassObject* pObj, CDataGroup *pParentDG, LPTSTR pszParentObjPath, BOOL bModifyPass=FALSE);
  111. //
  112. // STATIC STATIC STATIC STATIC STATIC STATIC STATIC STATIC STATIC STATIC STATIC
  113. //
  114. static void DETerminationCleanup(void);
  115. //private:
  116. static NSLIST mg_nsList;
  117. PNLIST m_pnList;
  118. // static BOOL fillInNamespacePointer(void);
  119. HRESULT fillInNamespacePointer(void);
  120. HRESULT InternalizeThresholds(void);
  121. BOOL InitContext(IWbemClassObject* pObj);
  122. HRESULT InitPropertyStatus(IWbemClassObject* pObj);
  123. virtual BOOL EvaluateThresholds(BOOL bIgnoreReset, BOOL bSkipStandard=FALSE, BOOL bSkipOthers=FALSE, BOOL bDoThresholdSkipClean=TRUE);
  124. HRESULT SendHMDataCollectorStatusInstances(IWbemObjectSink* pSink);
  125. HRESULT SendHMDataCollectorStatusInstance(IWbemObjectSink* pSink, LPTSTR pszGUID);
  126. HRESULT SendHMDataCollectorPerInstanceStatusInstances(IWbemObjectSink* pSink);
  127. HRESULT SendHMDataCollectorPerInstanceStatusInstance(IWbemObjectSink* pSink, LPTSTR pszGUID);
  128. HRESULT SendHMDataCollectorStatisticsInstances(IWbemObjectSink* pSink);
  129. HRESULT SendHMDataCollectorStatisticsInstance(IWbemObjectSink* pSink, LPTSTR pszGUID);
  130. HRESULT SendHMThresholdStatusInstances(IWbemObjectSink* pSink);
  131. HRESULT SendHMThresholdStatusInstance(IWbemObjectSink* pSink, LPTSTR pszGUID);
  132. // HRESULT SendHMThresholdStatusInstanceInstances(IWbemObjectSink* pSink);
  133. // HRESULT SendHMThresholdStatusInstanceInstance(IWbemObjectSink* pSink, LPTSTR pszGUID);
  134. HRESULT GetHMDataCollectorStatusInstance(IWbemClassObject** ppInstance, BOOL bEventBased);
  135. // HRESULT GetHMDataCollectorStatisticsInstancePrev(IWbemClassObject** ppInstance);
  136. HRESULT GetHMDataCollectorStatisticsInstances(LPTSTR szDTTime, LPTSTR szTime);
  137. long GetCurrState(void);
  138. BOOL ConsolodateStatistics(IWbemClassObject** ppInstance);
  139. HRESULT FindAndModDataCollector(BSTR szGUID, IWbemClassObject* pObj);
  140. HRESULT FindAndModThreshold(BSTR szGUID, IWbemClassObject* pObj);
  141. LPTSTR GetGUID(void);
  142. HRESULT AddThreshold(BSTR szParentGUID, BSTR szChildGUID);
  143. BOOL CalcStatistics(INSTSTRUCT *ppn, CIMTYPE type);
  144. BOOL ResetResetThresholdStates(void);
  145. BOOL GetChange(void);
  146. BOOL fillInPropertyStatus(LPTSTR szDTTime, LPTSTR szTime);
  147. // BOOL GetHMPropertyStatusInstance(PNSTRUCT *ppn, LPTSTR szTime);
  148. // BOOL GetHMPropertyStatusInstanceInstance(PNSTRUCT *ppn, INSTSTRUCT *pinst, LPTSTR szTime);
  149. HRESULT FindAndDeleteByGUID(LPTSTR pszGUID);
  150. HRESULT FindAndEnableByGUID(LPTSTR pszGUID, BOOL bEnable);
  151. HRESULT ResetState(BOOL bPreserveThresholdStates, BOOL bDoImmediate);
  152. HRESULT ResetStatistics(void);
  153. HRESULT EvaluateNow(BOOL bDoImmediate);
  154. virtual BOOL SetParentEnabledFlag(BOOL bEnabled);
  155. BOOL DeleteDEConfig(BOOL bDeleteAssocOnly=FALSE);
  156. BOOL DeleteDEInternal(void);
  157. //XXX BOOL Enable(BOOL bEnable);
  158. HRESULT FindAndCopyByGUID(LPTSTR pszGUID, ILIST* pConfigList, LPTSTR *pszParentGUID);
  159. HRESULT Copy(ILIST* pConfigList, LPTSTR pszOldParentGUID, LPTSTR pszNewParentGUID);
  160. CBase *GetParentPointerFromGUID(LPTSTR pszGUID);
  161. CBase *FindImediateChildByName(LPTSTR pszChildName);
  162. BOOL GetNextChildName(LPTSTR pszChildName, LPTSTR pszOutName);
  163. CBase *FindPointerFromName(LPTSTR pszChildName);
  164. HRESULT GetInstanceID(IWbemClassObject *pObj, LPTSTR *pszID);
  165. HRESULT CheckInstanceExistance(IWbemClassObject *pObj, LPTSTR pszInstanceID);
  166. HRESULT CheckActualInstanceExistance(IWbemClassObject *pObj, LPTSTR pszInstanceID);
  167. BOOL GetEnabledChange(void);
  168. BOOL SetCurrState(HM_STATE state, BOOL bCheckChanges=FALSE);
  169. BOOL checkTime(void);
  170. // BOOL ModifyAssocForMove(CBase *pNewParentBase);
  171. BOOL ReceiveNewChildForMove(CBase *pBase);
  172. BOOL DeleteChildFromList(LPTSTR pszGUID);
  173. BOOL FirePerInstanceEvents(void);
  174. long PassBackStateIfChangedPerInstance(LPTSTR pszInstName, BOOL bCombineWithStandardProperties);
  175. HRESULT GetHMDataCollectorPerInstanceStatusEvent(LPTSTR pszInstanceID, ACTUALINSTSTRUCT *pActualInst, long state, IWbemClassObject** ppInstance, BOOL bEventBased);
  176. long PassBackWorstStatePerInstance(LPTSTR pszInstName, BOOL bCombineWithStandardProperties);
  177. BOOL SendReminderActionIfStateIsSame(IWbemObjectSink* pActionEventSink, IWbemObjectSink* pActionTriggerEventSink, IWbemClassObject* pActionInstance, IWbemClassObject* pActionTriggerInstance, unsigned long ulTriggerStates);
  178. HRESULT insertNewProperty(LPTSTR pszPropertyName);
  179. BOOL propertyNotNeeded(LPTSTR pszPropertyName);
  180. BOOL ResetInst(INSTSTRUCT *pinst, CIMTYPE type);
  181. BOOL CheckForReset(void);
  182. HRESULT CheckForBadLoad(void);
  183. };
  184. #endif // __DATACLTR_H