Changeset e26cfe0 in nscp for NSClient++.cpp


Ignore:
Timestamp:
07/11/05 21:55:28 (8 years ago)
Author:
Michael Medin <michael@…>
Branches:
master, 0.4.0, 0.4.1, 0.4.2, stable
Children:
75d5e70
Parents:
6654022
Message:

changes all over manily in the checking code

File:
1 edited

Legend:

Unmodified
Added
Removed
  • NSClient++.cpp

    r1d9338a re26cfe0  
    2020#include <Socket.h> 
    2121#include <b64/b64.h> 
    22  
     22#include <PDHCounter.h> 
    2323 
    2424NSClient mainClient;  // Global core instance. 
     
    8282      g_bConsoleLog = true; 
    8383      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      } 
    8494    } else if ( _stricmp( "test", argv[1]+1 ) == 0 ) { 
    8595#ifdef _DEBUG 
     
    96106      LOG_MESSAGE("Enter command to inject or exit to terminate..."); 
    97107      std::string s = ""; 
     108      std::string buff = ""; 
    98109      std::cin >> s; 
    99110      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        } 
    107124        std::cin >> s; 
    108125      } 
     
    137154  for (SettingsT::sectionList::iterator it = list.begin(); it != list.end(); it++) { 
    138155    try { 
    139       LOG_DEBUG_STD("Loading: " + getBasePath() + "modules\\" + (*it)); 
    140156      loadPlugin(getBasePath() + "modules\\" + (*it)); 
    141157    } catch(const NSPluginException& e) { 
     
    143159    } 
    144160  } 
     161  loadPlugins(); 
    145162} 
    146163/** 
     
    186203 * @param plugins A list with plug-ins (DLL files) to load 
    187204 */ 
    188 void NSClientT::loadPlugins(const std::list<std::string> plugins) { 
     205void NSClientT::addPlugins(const std::list<std::string> plugins) { 
    189206  ReadLock readLock(&m_mutexRW, true, 10000); 
    190207  if (!readLock.IsLocked()) { 
     
    236253  } 
    237254} 
     255 
     256void 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} 
    238267/** 
    239268 * Load a single plug-in using a DLL filename 
     
    241270 */ 
    242271void NSClientT::loadPlugin(const std::string file) { 
    243   LOG_DEBUG_STD("Loading: " + file); 
    244272  addPlugin(new NSCPlugin(file)); 
    245273} 
     
    249277 */ 
    250278void NSClientT::addPlugin(plugin_type plugin) { 
    251   plugin->load(); 
     279  plugin->load_dll(); 
    252280  { 
    253281    WriteLock writeLock(&m_mutexRW, true, 10000); 
     
    256284      return; 
    257285    } 
    258     // @todo Catch here and unload if we fail perhaps ? 
    259286    plugins_.insert(plugins_.end(), plugin); 
    260287    if (plugin->hasCommandHandler()) 
     
    331358    } 
    332359  } 
    333   LOG_MESSAGE_STD("No handler for command: " + command); 
     360  LOG_MESSAGE_STD("No handler for command: '" + command + "'"); 
    334361  return NSCAPI::returnIgnored; 
    335362} 
     
    495522  char *c = new char[inBufLen+1]; 
    496523  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++) { 
    498525    if (j > key.size()) 
    499526      j = 0; 
     
    527554    } 
    528555    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++) { 
    530557      if (j > key.size()) 
    531558        j = 0; 
Note: See TracChangeset for help on using the changeset viewer.