Changeset dd02c15 in nscp
- Timestamp:
- 03/20/08 17:13:36 (5 years ago)
- Branches:
- master, 0.4.0, 0.4.1, 0.4.2, stable
- Children:
- b7ed6ac
- Parents:
- 5aebda1
- Files:
-
- 7 edited
-
AutoBuild.h (modified) (1 diff)
-
changelog (modified) (2 diffs)
-
include/PDHCollectors.h (modified) (12 diffs)
-
include/config.h (modified) (1 diff)
-
modules/CheckSystem/CheckSystem.cpp (modified) (4 diffs)
-
modules/CheckSystem/PDHCollector.cpp (modified) (6 diffs)
-
modules/CheckSystem/PDHCollector.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
AutoBuild.h
r5aebda1 rdd02c15 3 3 // change the FALSE to TRUE for autoincrement of build number 4 4 #define INCREMENT_VERSION TRUE 5 #define FILEVER 0,3,1,1 56 #define PRODUCTVER 0,3,1,1 57 #define STRFILEVER _T("0.3.1.1 5")8 #define STRPRODUCTVER _T("0.3.1.1 5")9 #define STRPRODUCTDATE _T("2008-03- 18")5 #define FILEVER 0,3,1,18 6 #define PRODUCTVER 0,3,1,18 7 #define STRFILEVER _T("0.3.1.18") 8 #define STRPRODUCTVER _T("0.3.1.18") 9 #define STRPRODUCTDATE _T("2008-03-20") 10 10 #endif // AUTOBUILD_H -
changelog
r5aebda1 rdd02c15 2 2 * Process times and similar ? 3 3 * Fix configuration GUI (low priority) 4 * Fix installer (after configuration UI)5 4 * Add API for rehashing the daemon (or implement it the API is there but does nothing) 6 5 * Improved socket performance (would be nice if we could be used as a "hub") … … 8 7 9 8 2007-03-20 10 + Added host-lookupos for NSCA server 9 + Added host-lookupos for NSCA server (#149) 11 10 + Added option (cache_hostname=1|0) to cache the NSCA host name (Ie. only lookup once) 11 * Fixed service check: check_nt -v SERVICESTATE -l CheckAll so it works as advertised (#150) 12 * Fixed issue with check_nt MEMUSE/CPULOAD/UPTIME if something is "broken" they will now return an error instead of "0". (#134) 13 Added option debug_skip_data_collection to simulate this (just for kicks) 12 14 13 15 2007-03-18 -
include/PDHCollectors.h
r394f7a1 rdd02c15 116 116 TType value_; 117 117 TMutextHandler mutex_; 118 public: 119 StaticPDHCounterListener() : value_(0) {} 118 bool hasValue_; 119 std::wstring lastError_; 120 public: 121 StaticPDHCounterListener() : value_(0), hasValue_(false) {} 120 122 virtual void collect(const PDH::PDHCounter &counter) { 121 123 PDHCounterMutexHandler mutex(&mutex_); … … 123 125 return; 124 126 value_ = counter.getDoubleValue(); 127 hasValue_ = true; 125 128 } 126 129 void attach(const PDH::PDHCounter &counter){} … … 129 132 PDHCounterMutexHandler mutex(&mutex_); 130 133 if (!mutex.hasLock()) 131 return -1; 134 throw PDHException(_T("Could not get mutex")); 135 if (!hasValue_) 136 throw PDHException(_T("No value has been collected yet")); 132 137 return value_; 133 138 } … … 141 146 TType value_; 142 147 TMutextHandler mutex_; 143 public: 144 StaticPDHCounterListener() : value_(0) {} 148 bool hasValue_; 149 public: 150 StaticPDHCounterListener() : value_(0), hasValue_(false) {} 145 151 virtual void collect(const PDH::PDHCounter &counter) { 146 152 PDHCounterMutexHandler mutex(&mutex_); … … 148 154 return; 149 155 value_ = counter.getIntValue(); 156 hasValue_ = true; 150 157 } 151 158 void attach(const PDH::PDHCounter &counter){} … … 154 161 PDHCounterMutexHandler mutex(&mutex_); 155 162 if (!mutex.hasLock()) 156 return -1; 163 throw PDHException(_T("Could not get mutex")); 164 if (!hasValue_) 165 throw PDHException(_T("No value has been collected yet")); 157 166 return value_; 158 167 } … … 166 175 TMutextHandler mutex_; 167 176 TType value_; 168 public: 169 StaticPDHCounterListener() : value_(0) {} 177 bool hasValue_; 178 public: 179 StaticPDHCounterListener() : value_(0), hasValue_(false) {} 170 180 virtual void collect(const PDH::PDHCounter &counter) { 171 181 PDHCounterMutexHandler mutex(&mutex_); … … 173 183 return; 174 184 value_ = counter.getInt64Value(); 185 hasValue_ = true; 175 186 } 176 187 void attach(const PDH::PDHCounter &counter){} … … 179 190 PDHCounterMutexHandler mutex(&mutex_); 180 191 if (!mutex.hasLock()) 181 return -1; 192 throw PDHException(_T("Could not get mutex")); 193 if (!hasValue_) 194 throw PDHException(_T("No value has been collected yet")); 182 195 return value_; 183 196 } … … 194 207 TType *buffer; 195 208 unsigned int current; 196 public: 197 RoundINTPDHBufferListenerImpl() : buffer(NULL), length(0), current(0) {} 198 RoundINTPDHBufferListenerImpl(int length_) : length(length_), current(0) { 209 bool hasValue_; 210 public: 211 RoundINTPDHBufferListenerImpl() : buffer(NULL), length(0), current(0), hasValue_(false) {} 212 RoundINTPDHBufferListenerImpl(int length_) : length(length_), current(0), hasValue_(false) { 199 213 PDHCounterMutexHandler mutex(mutex_); 200 214 if (!mutex.hasLock()) … … 245 259 if (current >= length) 246 260 return; 261 hasValue_ = true; 247 262 buffer[current++] = value; 248 263 if (current >= length) … … 253 268 if (!mutex.hasLock(true)) 254 269 throw PDHException(_T("Failed to get mutex :(")); 270 if (!hasValue_) 271 throw PDHException(_T("No value has been collected yet")); 255 272 if ((backItems == 0) || (backItems >= length)) 256 return -1;273 throw PDHException(_T("Strange error buffer pointers are f*cked up")); 257 274 double ret = 0; 258 275 if (current >= backItems) { -
include/config.h
r5aebda1 rdd02c15 134 134 #define C_SYSTEM_NO_INDEX _T("dont_use_pdh_index") 135 135 #define C_SYSTEM_NO_INDEX_DEFAULT 0 136 #define C_SYSTEM_IGNORE_COLLECTION _T("debug_skip_data_collection") 137 #define C_SYSTEM_IGNORE_COLLECTION_DEFAULT 0 136 138 137 139 #define C_SYSTEM_MEM_PAGE_LIMIT _T("MemoryCommitLimit") -
modules/CheckSystem/CheckSystem.cpp
r394f7a1 rdd02c15 456 456 } 457 457 unsigned long long value = pObject->getUptime(); 458 if (value == -1) { 459 msg = _T("ERROR: Could not get value"); 460 return NSCAPI::returnUNKNOWN; 461 } 458 462 if (bNSClient) { 459 463 msg = strEx::itos(value); … … 474 478 475 479 480 inline int get_state(DWORD state) { 481 if (state == SERVICE_RUNNING) 482 return checkHolders::state_started; 483 else if (state == SERVICE_STOPPED) 484 return checkHolders::state_stopped; 485 return checkHolders::state_none; 486 } 476 487 477 488 /** … … 571 582 } catch (NTServiceException e) { 572 583 if (!msg.empty()) msg += _T(" - "); 573 msg += (*it).data + _T(": Unknown");584 msg += (*it).data + _T(": Error"); 574 585 NSCHelper::escalteReturnCodeToWARN(returnCode); 575 586 continue; 576 587 } 577 if ((info.m_dwCurrentState == SERVICE_RUNNING) && (*it).showAll()) { 578 if (!msg.empty()) msg += _T(" - "); 579 msg += (*it).data + _T(": Started"); 580 } else if (info.m_dwCurrentState == SERVICE_RUNNING) { 581 } else if (info.m_dwCurrentState == SERVICE_STOPPED) { 582 if (!msg.empty()) msg += _T(" - "); 583 msg += (*it).data + _T(": Stopped"); 584 NSCHelper::escalteReturnCodeToCRIT(returnCode); 585 } else { 586 if (!msg.empty()) msg += _T(" - "); 587 msg += (*it).data + _T(": Unknown"); 588 NSCHelper::escalteReturnCodeToWARN(returnCode); 588 if ((*it).crit.state.hasBounds()) { 589 bool ok = (*it).crit.state.check(get_state(info.m_dwCurrentState)); 590 if (!ok || (*it).showAll()) { 591 if (info.m_dwCurrentState == SERVICE_RUNNING) { 592 if (!msg.empty()) msg += _T(" - "); 593 msg += (*it).data + _T(": Started"); 594 } else if (info.m_dwCurrentState == SERVICE_STOPPED) { 595 if (!msg.empty()) msg += _T(" - "); 596 msg += (*it).data + _T(": Stopped"); 597 } else { 598 if (!msg.empty()) msg += _T(" - "); 599 msg += (*it).data + _T(": Unknown"); 600 } 601 if (!ok) 602 NSCHelper::escalteReturnCodeToCRIT(returnCode); 603 } 589 604 } 590 605 } else { … … 678 693 } 679 694 dataPaged.value = pObject->getMemCommit(); 695 if (dataPaged.value == -1) { 696 msg = _T("ERROR: Failed to get PDH value."); 697 return NSCAPI::returnUNKNOWN; 698 } 680 699 dataPaged.total = pObject->getMemCommitLimit(); 700 if (dataPaged.total == -1) { 701 msg = _T("ERROR: Failed to get PDH value."); 702 return NSCAPI::returnUNKNOWN; 703 } 681 704 } else if (firstMem) { 682 705 try { -
modules/CheckSystem/PDHCollector.cpp
r394f7a1 rdd02c15 25 25 26 26 PDHCollector::PDHCollector() : hStopEvent_(NULL) { 27 dontCollect_ = NSCModuleHelper::getSettingsInt(C_SYSTEM_SECTION_TITLE, C_SYSTEM_IGNORE_COLLECTION, C_SYSTEM_IGNORE_COLLECTION_DEFAULT)==1; 27 28 checkIntervall_ = NSCModuleHelper::getSettingsInt(C_SYSTEM_SECTION_TITLE, C_SYSTEM_CHECK_RESOLUTION, C_SYSTEM_CHECK_RESOLUTION_DEFAULT); 28 29 std::wstring s = NSCModuleHelper::getSettingsString(C_SYSTEM_SECTION_TITLE, C_SYSTEM_CPU_BUFFER_TIME, C_SYSTEM_CPU_BUFFER_TIME_DEFAULT); … … 192 193 else { 193 194 try { 194 pdh.gatherData(); 195 if (!dontCollect_) 196 pdh.gatherData(); 195 197 } catch (const PDH::PDHException &e) { 196 if (first) { // If this is the first run an error will be thrown since the data is not yet ava lible198 if (first) { // If this is the first run an error will be thrown since the data is not yet available 197 199 // This is "ok" but perhaps another solution would be better, but this works :) 198 200 first = false; … … 260 262 return static_cast<int>(cpu.getAvrage(mseconds / (checkIntervall_*100))); 261 263 } catch (PDHCollectors::PDHException &e) { 262 NSC_LOG_ERROR(_T("Failed to get (sub) Mutex!")); 264 NSC_LOG_ERROR(_T("Failed to get CPU value: ") + e.getError()); 265 return -1; 266 } catch (...) { 267 NSC_LOG_ERROR(_T("Failed to get CPU value")); 263 268 return -1; 264 269 } … … 276 281 return -1; 277 282 } 278 return upTime.getValue(); 283 try { 284 return upTime.getValue(); 285 } catch (PDHCollectors::PDHException &e) { 286 NSC_LOG_ERROR(_T("Failed to get UPTIME value: ") + e.getError()); 287 return -1; 288 } catch (...) { 289 NSC_LOG_ERROR(_T("Failed to get UPTIME value")); 290 return -1; 291 } 279 292 } 280 293 /** … … 288 301 return -1; 289 302 } 290 return memCmtLim.getValue(); 303 try { 304 return memCmtLim.getValue(); 305 } catch (PDHCollectors::PDHException &e) { 306 NSC_LOG_ERROR(_T("Failed to get MEM_CMT_LIMIT value: ") + e.getError()); 307 return -1; 308 } catch (...) { 309 NSC_LOG_ERROR(_T("Failed to get MEM_CMT_LIMIT value")); 310 return -1; 311 } 291 312 } 292 313 /** … … 301 322 return -1; 302 323 } 303 return memCmt.getValue(); 304 } 324 try { 325 return memCmt.getValue(); 326 } catch (PDHCollectors::PDHException &e) { 327 NSC_LOG_ERROR(_T("Failed to get MEM_CMT value: ") + e.getError()); 328 return -1; 329 } catch (...) { 330 NSC_LOG_ERROR(_T("Failed to get MEM_CMT value")); 331 return -1; 332 } 333 } -
modules/CheckSystem/PDHCollector.h
r394f7a1 rdd02c15 50 50 HANDLE hStopEvent_; 51 51 int checkIntervall_; 52 bool dontCollect_; 52 53 53 54 PDHCollectors::StaticPDHCounterListener<unsigned __int64, PDHCollectors::format_large, PDHCollectors::PDHCounterNormalMutex> memCmtLim;
Note: See TracChangeset
for help on using the changeset viewer.








