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.

225 lines
7.4 KiB

  1. //***************************************************************************
  2. //
  3. // THRESHLD.H
  4. //
  5. // Module: HEALTHMON SERVER AGENT
  6. //
  7. // Purpose: CThreshold class to do thresholding on a CDatapoint class.
  8. // The CDatapoint class contains the WMI instance, and the CThreshold
  9. // class says what ptoperty to threshold against, and how.
  10. //
  11. // Copyright (c)1999 Microsoft Corporation, All Rights Reserved
  12. //
  13. //***************************************************************************
  14. #if !defined( __THRESHLD_H )
  15. #define __THRESHLD_H
  16. #include <wbemcli.h>
  17. #include <vector>
  18. #include "global.h"
  19. #include "base.h"
  20. // Add support for UINT64 and other similar datatypes.
  21. // Need to use a union for the values collecting.
  22. union hm_datatypes {
  23. long lValue;
  24. unsigned long ulValue;
  25. float fValue;
  26. double dValue;
  27. __int64 i64Value;
  28. unsigned __int64 ui64Value;
  29. // LPTSTR lpstr_value;
  30. // LPTSTR date_value;
  31. // unsigned char bool_value;
  32. // short int int_value;
  33. };
  34. //XXXTake out the kludge in the Threshold::CrossTest and RearmTest that was converting all numeric
  35. //XXXstrings to numbers to do arithemetic compare instead of lexical.
  36. //XXXIn the StoreValues code use the CIMTYPE that get from the Get call directly, as
  37. //XXXwe do now in the ppn property.
  38. typedef struct _tag_VALStruct
  39. {
  40. union hm_datatypes value;
  41. } VALSTRUCT, *PVALSTRUCT;
  42. typedef std::vector<VALSTRUCT, std::allocator<VALSTRUCT> > VALLIST;
  43. typedef struct _tag_INSTStruct
  44. {
  45. LPTSTR szInstanceID; // Name of instance
  46. LPTSTR szCurrValue;
  47. union hm_datatypes currValue;
  48. union hm_datatypes minValue;
  49. union hm_datatypes maxValue;
  50. union hm_datatypes avgValue;
  51. BOOL bNull;
  52. BOOL bNeeded;
  53. VALLIST valList;
  54. } INSTSTRUCT, *PINSTSTRUCT;
  55. typedef std::vector<INSTSTRUCT, std::allocator<INSTSTRUCT> > INSTLIST;
  56. typedef struct _tag_PNStruct
  57. {
  58. LPTSTR szPropertyName;
  59. CIMTYPE type;
  60. // BOOL bNull;
  61. // BOOL bNeeded;
  62. INSTLIST instList;
  63. int iRefCount;
  64. } PNSTRUCT;
  65. typedef std::vector<PNSTRUCT, std::allocator<PNSTRUCT> > PNLIST;
  66. typedef struct _tag_IRSStruct
  67. {
  68. LPTSTR szStatusGUID;
  69. TCHAR szDTTime[512];
  70. TCHAR szTime[512];
  71. LPTSTR szInstanceID; // Name of instance
  72. long lPrevState;
  73. long lCurrState;
  74. long lCrossCountTry;
  75. // union hm_datatypes prevValue;
  76. // union hm_datatypes prevPrevValue;
  77. long lPrevValue;
  78. unsigned long ulPrevValue;
  79. float fPrevValue;
  80. double dPrevValue;
  81. __int64 i64PrevValue;
  82. unsigned __int64 ui64PrevValue;
  83. long lPrevPrevValue;
  84. unsigned long ulPrevPrevValue;
  85. float fPrevPrevValue;
  86. double dPrevPrevValue;
  87. __int64 i64PrevPrevValue;
  88. unsigned __int64 ui64PrevPrevValue;
  89. BOOL bNeeded;
  90. int unknownReason;
  91. } IRSSTRUCT, *PIRSSTRUCT;
  92. typedef std::vector<IRSSTRUCT, std::allocator<IRSSTRUCT> > IRSLIST;
  93. typedef struct _tag_ACTUALINSTStruct
  94. {
  95. LPTSTR szInstanceID; // Name of instance
  96. IWbemClassObject* pInst;
  97. BOOL bNeeded;
  98. TCHAR szDTTime[512];
  99. TCHAR szTime[512];
  100. } ACTUALINSTSTRUCT, *PACTUALINSTSTRUCT;
  101. typedef std::vector<ACTUALINSTSTRUCT, std::allocator<ACTUALINSTSTRUCT> > ACTUALINSTLIST;
  102. class CDataCollector; // Forward declaration
  103. class CThreshold : public CBase
  104. {
  105. public:
  106. CThreshold();
  107. ~CThreshold();
  108. CDataCollector *m_pParentDC;
  109. long m_lPrevState;
  110. // long m_lCurrState;
  111. // long m_lViolationValue;
  112. // IWbemServices* m_pIWbemServices;
  113. LPTSTR m_szParentObjPath;
  114. // long m_lNameRID;
  115. LPTSTR m_szDescription;
  116. // long m_lDescriptionRID;
  117. // LPTSTR m_szResourceDLL;
  118. long m_lID;
  119. LPTSTR m_szPropertyName;
  120. BOOL m_bUseAverage;
  121. BOOL m_bUseDifference;
  122. BOOL m_bUseSum;
  123. // HM_CONDITION m_lTestCondition;
  124. long m_lTestCondition;
  125. LPTSTR m_szCompareValue;
  126. long m_lCompareValue;
  127. unsigned long m_ulCompareValue;
  128. float m_fCompareValue;
  129. double m_dCompareValue;
  130. __int64 m_i64CompareValue;
  131. unsigned __int64 m_ui64CompareValue;
  132. // union hm_datatypes m_compareValue;
  133. long m_lThresholdDuration;
  134. long m_lViolationToState;
  135. LPTSTR m_szCreationDate;
  136. LPTSTR m_szLastUpdate;
  137. // LPTSTR m_szMessage;
  138. // long m_lMessageRID;
  139. // LPTSTR m_szResetMessage;
  140. // long m_lResetMessageRID;
  141. long m_lStartupDelay;
  142. //XXX int m_iActiveDays;
  143. //XXX long m_lBeginHourTime;
  144. //XXX long m_lBeginMinuteTime;
  145. //XXX long m_lEndHourTime;
  146. //XXX long m_lEndMinuteTime;
  147. BOOL m_bEnabled;
  148. BOOL m_bParentEnabled; // So we can transfer down the hierarchy the state.
  149. BOOL m_bParentScheduledOut;
  150. TCHAR m_szDTTime[512];
  151. TCHAR m_szTime[512];
  152. IRSLIST m_irsList;
  153. long m_lNumberNormals;
  154. long m_lNumberWarnings;
  155. long m_lNumberCriticals;
  156. long m_lNumberChanges;
  157. BOOL m_bValidLoad;
  158. //
  159. // STATIC STATIC STATIC STATIC STATIC STATIC STATIC STATIC STATIC STATIC STATIC
  160. //
  161. static void ThresholdTerminationCleanup(void);
  162. static void GetLocal(void);
  163. static BOOL mg_bEnglishCompare;
  164. HRESULT LoadInstanceFromMOF(IWbemClassObject* pObj, CDataCollector *pParentDC, LPTSTR pszParentObjPath, BOOL bModifyPass=FALSE);
  165. // return polling interval in milliseconds
  166. BOOL OnAgentInterval(ACTUALINSTLIST *actualInstList, PNSTRUCT *ppn, BOOL bRequireReset);
  167. BOOL FireEvent(BOOL bForce);
  168. BOOL FireInstanceEvents(ACTUALINSTLIST *actualInstList, PNSTRUCT *ppn);
  169. LPTSTR GetPropertyName(void);
  170. BOOL CrossTest(PNSTRUCT *ppn, IRSSTRUCT *pirs, LPTSTR szTestValue, union hm_datatypes testValue, INSTSTRUCT *pinst);
  171. BOOL RearmTest(PNSTRUCT *ppn, IRSSTRUCT *pirs, LPTSTR szTestValue, union hm_datatypes testValue, INSTSTRUCT *pinst);
  172. HRESULT GetHMThresholdStatusInstance(IWbemClassObject** pInstance, BOOL bEventBased);
  173. // BOOL GetHMThresholdStatusInstanceInstance(ACTUALINSTSTRUCT *pActualInst, PNSTRUCT *ppn, INSTSTRUCT *pinst, IRSSTRUCT *pirs, IWbemClassObject** ppIRSInstance, BOOL bChangesOnly, BOOL bEventBased);
  174. HRESULT SendHMThresholdStatusInstances(IWbemObjectSink* pSink);
  175. HRESULT SendHMThresholdStatusInstance(IWbemObjectSink* pSink, LPTSTR pszGUID);
  176. // HRESULT SendHMThresholdStatusInstanceInstances(ACTUALINSTLIST *actualInstList, PNSTRUCT *ppn, IWbemObjectSink* pSink);
  177. // HRESULT SendHMThresholdStatusInstanceInstance(ACTUALINSTLIST *actualInstList, PNSTRUCT *ppn, IWbemObjectSink* pSink, LPTSTR pszGUID);
  178. long GetCurrState(void);
  179. HRESULT FindAndModThreshold(BSTR szGUID, IWbemClassObject* pObj);
  180. LPTSTR GetGUID(void);
  181. BOOL SetCurrState(HM_STATE state, BOOL bForce = FALSE, int reason = 0);
  182. BOOL SetPrevState(HM_STATE state);
  183. BOOL SetParentEnabledFlag(BOOL bEnabled);
  184. BOOL SetParentScheduledOutFlag(BOOL bScheduledOut);
  185. BOOL SetBackPrev(PNSTRUCT *ppn);
  186. BOOL ClearInstList(void);
  187. BOOL ResetResetThreshold(void);
  188. BOOL GetChange(void);
  189. BOOL GetEnabledChange(void);
  190. HRESULT AddInstance(LPTSTR pszID);
  191. // BOOL FormatMessages(IWbemClassObject* pObj);
  192. BOOL FormatMessage(IWbemClassObject* pIRSInstance, IWbemClassObject *pEmbeddedInstance);
  193. //XXX BOOL Enable(BOOL bEnable);
  194. BOOL Cleanup(BOOL bSavePrevSettings);
  195. BOOL Init(void);
  196. BOOL DeleteThresholdConfig(BOOL bDeleteAssocOnly=FALSE);
  197. HRESULT Copy(ILIST* pConfigList, LPTSTR pszOldParentGUID, LPTSTR pszNewParentGUID);
  198. CBase *FindImediateChildByName(LPTSTR pszChildName);
  199. BOOL GetNextChildName(LPTSTR pszChildName, LPTSTR pszOutName);
  200. CBase *FindPointerFromName(LPTSTR pszChildName);
  201. // BOOL ModifyAssocForMove(CBase *pNewParentBase);
  202. BOOL ReceiveNewChildForMove(CBase *pBase);
  203. BOOL DeleteChildFromList(LPTSTR pszGUID);
  204. long PassBackStateIfChangedPerInstance(LPTSTR pszInstName);
  205. long PassBackWorstStatePerInstance(LPTSTR pszInstName);
  206. BOOL SendReminderActionIfStateIsSame(IWbemObjectSink* pActionEventSink, IWbemObjectSink* pActionTriggerEventSink, IWbemClassObject* pActionInstance, IWbemClassObject* pActionTriggerInstance, unsigned long ulTriggerStates);
  207. BOOL SkipClean(void);
  208. HRESULT CheckForBadLoad(void);
  209. };
  210. #endif // __THRESHLD_H