Changeset e26cfe0 in nscp for NSClient++.cpp
- Timestamp:
- 07/11/05 21:55:28 (8 years ago)
- Branches:
- master, 0.4.0, 0.4.1, 0.4.2, stable
- Children:
- 75d5e70
- Parents:
- 6654022
- File:
-
- 1 edited
-
NSClient++.cpp (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
NSClient++.cpp
r1d9338a re26cfe0 20 20 #include <Socket.h> 21 21 #include <b64/b64.h> 22 22 #include <PDHCounter.h> 23 23 24 24 NSClient mainClient; // Global core instance. … … 82 82 g_bConsoleLog = true; 83 83 LOG_MESSAGE(SZAPPNAME " Version: " SZVERSION); 84 85 86 } else if ( _stricmp( "listpdh", argv[1]+1 ) == 0 ) { 87 PDH::Enumerations::str_lst lst = PDH::Enumerations::EnumObjects(); 88 for (PDH::Enumerations::str_lst::iterator it = lst.begin();it!=lst.end();++it) { 89 PDH::Enumerations::str_lst lst = PDH::Enumerations::EnumObjectItems(*it); 90 for (PDH::Enumerations::str_lst::iterator it2 = lst.begin();it2!=lst.end();++it2) { 91 std::cout << "\\" << *it <<"\\" << *it2 << std::endl;; 92 } 93 } 84 94 } else if ( _stricmp( "test", argv[1]+1 ) == 0 ) { 85 95 #ifdef _DEBUG … … 96 106 LOG_MESSAGE("Enter command to inject or exit to terminate..."); 97 107 std::string s = ""; 108 std::string buff = ""; 98 109 std::cin >> s; 99 110 while (s != "exit") { 100 strEx::token t = strEx::getToken(s, ','); 101 std::string msg, perf; 102 NSCAPI::nagiosReturn ret = mainClient.inject(t.first, t.second, ',', msg, perf); 103 if (perf.empty()) 104 std::cout << NSCHelper::translateReturn(ret) << ":" << msg << std::endl; 105 else 106 std::cout << NSCHelper::translateReturn(ret) << ":" << msg << "|" << perf << std::endl; 111 if (std::cin.peek() < 15) { 112 buff += s; 113 strEx::token t = strEx::getToken(buff, ' '); 114 std::string msg, perf; 115 NSCAPI::nagiosReturn ret = mainClient.inject(t.first, t.second, ' ', msg, perf); 116 if (perf.empty()) 117 std::cout << NSCHelper::translateReturn(ret) << ":" << msg << std::endl; 118 else 119 std::cout << NSCHelper::translateReturn(ret) << ":" << msg << "|" << perf << std::endl; 120 buff = ""; 121 } else { 122 buff += s + " "; 123 } 107 124 std::cin >> s; 108 125 } … … 137 154 for (SettingsT::sectionList::iterator it = list.begin(); it != list.end(); it++) { 138 155 try { 139 LOG_DEBUG_STD("Loading: " + getBasePath() + "modules\\" + (*it));140 156 loadPlugin(getBasePath() + "modules\\" + (*it)); 141 157 } catch(const NSPluginException& e) { … … 143 159 } 144 160 } 161 loadPlugins(); 145 162 } 146 163 /** … … 186 203 * @param plugins A list with plug-ins (DLL files) to load 187 204 */ 188 void NSClientT:: loadPlugins(const std::list<std::string> plugins) {205 void NSClientT::addPlugins(const std::list<std::string> plugins) { 189 206 ReadLock readLock(&m_mutexRW, true, 10000); 190 207 if (!readLock.IsLocked()) { … … 236 253 } 237 254 } 255 256 void NSClientT::loadPlugins() { 257 ReadLock readLock(&m_mutexRW, true, 10000); 258 if (!readLock.IsLocked()) { 259 LOG_ERROR("FATAL ERROR: Could not get read-mutex."); 260 return; 261 } 262 for (pluginList::iterator it=plugins_.begin(); it != plugins_.end(); ++it) { 263 LOG_DEBUG_STD("Loading plugin: " + (*it)->getName() + "..."); 264 (*it)->load_plugin(); 265 } 266 } 238 267 /** 239 268 * Load a single plug-in using a DLL filename … … 241 270 */ 242 271 void NSClientT::loadPlugin(const std::string file) { 243 LOG_DEBUG_STD("Loading: " + file);244 272 addPlugin(new NSCPlugin(file)); 245 273 } … … 249 277 */ 250 278 void NSClientT::addPlugin(plugin_type plugin) { 251 plugin->load ();279 plugin->load_dll(); 252 280 { 253 281 WriteLock writeLock(&m_mutexRW, true, 10000); … … 256 284 return; 257 285 } 258 // @todo Catch here and unload if we fail perhaps ?259 286 plugins_.insert(plugins_.end(), plugin); 260 287 if (plugin->hasCommandHandler()) … … 331 358 } 332 359 } 333 LOG_MESSAGE_STD("No handler for command: " + command);360 LOG_MESSAGE_STD("No handler for command: '" + command + "'"); 334 361 return NSCAPI::returnIgnored; 335 362 } … … 495 522 char *c = new char[inBufLen+1]; 496 523 strncpy(c, inBuffer, inBufLen); 497 for ( int i=0,j=0;i<inBufLen;i++,j++) {524 for (unsigned int i=0,j=0;i<inBufLen;i++,j++) { 498 525 if (j > key.size()) 499 526 j = 0; … … 527 554 } 528 555 std::string key = Settings::getInstance()->getString(MAIN_SECTION_TITLE, MAIN_MASTERKEY, MAIN_MASTERKEY_DEFAULT); 529 for ( int i=0,j=0;i<len;i++,j++) {556 for (unsigned int i=0,j=0;i<len;i++,j++) { 530 557 if (j > key.size()) 531 558 j = 0;
Note: See TracChangeset
for help on using the changeset viewer.








