Changeset f7a074d in nscp


Ignore:
Timestamp:
11/06/11 22:04:48 (19 months ago)
Author:
Michael Medin <michael@…>
Branches:
master, 0.4.0, 0.4.1, 0.4.2
Children:
0d9eed6
Parents:
58f0e80
Message:
  • Had some "vacation" so no updates for a while
  • A lot of fixes to the NSCA parts (now 100% compatible with old settings file)
  • Added option to read sections (to plugin API)
  • Fixed issues in settings wrapper so child paths are also mapped (not just keys)
  • Many fixes related to NRPE/NSCA/*
  • "RC quality" expect RC within the week (only need to fix default config file somehow)
  • Upgraded all unit test to use the simplified API
  • Fixed a some unicode issues in PythonScript module
  • Improved threading a bit
  • Fixed CheckSystem (service check)
  • Fixed duplicate keys (when replacing) in old settings client
Files:
1 added
34 edited

Legend:

Unmodified
Added
Removed
  • files/old-settings.map

    rfb7e36a rf7a074d  
    1212modules/CheckNSCP.dll=/modules/CheckNSCP 
    1313modules/CheckExternalScripts.dll=/modules/CheckExternalScripts 
    14 modules/NSCAAgent.dll=/modules/NSCAAgent 
     14modules/NSCAAgent.dll=/modules/NSCAClient 
    1515modules/NSCAAgent.dll=/modules/Scheduler 
    1616modules/LUAScript.dll=/modules/LUAScript 
  • helpers/installers/installer/Product.wxs

    ra78a985 rf7a074d  
    118118            </Component> 
    119119            <Component Id="NSCA" Guid="8820A304-C596-4393-A72F-$(var.Postfix.GUID)" Win64="$(var.Win64)"> 
    120               <File Id="NSCAAgentDLL" Name="NSCAAgent.dll" DiskId="1" Source="$(var.Source)/modules/NSCAAgent.dll" Vital="no" /> 
     120              <File Id="NSCAClientDLL" Name="NSCAClient.dll" DiskId="1" Source="$(var.Source)/modules/NSCAClient.dll" Vital="no" /> 
     121              <File Id="NSCAServerDLL" Name="NSCAServer.dll" DiskId="1" Source="$(var.Source)/modules/NSCAServer.dll" Vital="no" /> 
    121122              <File Id="SchedulerDLL" Name="Scheduler.dll" DiskId="1" Source="$(var.Source)/modules/Scheduler.dll" Vital="no" /> 
     123            </Component> 
     124            <Component Id="NSCP" Guid="B185B8F1-3718-4e8e-ADA4-38049A0721EA" Win64="$(var.Win64)"> 
     125              <File Id="NSCPClientDLL" Name="NSCPClient.dll" DiskId="1" Source="$(var.Source)/modules/NSCPClient.dll" Vital="no" /> 
     126              <File Id="NSCPServerDLL" Name="NSCPServer.dll" DiskId="1" Source="$(var.Source)/modules/NSCPServer.dll" Vital="no" /> 
    122127            </Component> 
    123128            <Component Id="PythonScript" Guid="8820A304-C696-4393-A72F-$(var.Postfix.GUID)" Win64="$(var.Win64)"> 
     
    125130            </Component> 
    126131            <Component Id="Plugins" Guid="9B490E67-5472-4266-96DC-$(var.Postfix.GUID)" Win64="$(var.Win64)"> 
    127               <!-- NOT PORTED MODULES ! 
    128                 <File Id="ModRemoteConfiguration.dll" Name="RmtCfg.dll" LongName="RemoteConfiguration.dll" DiskId="1" Source="$(var.Source)/modules/RemoteConfiguration.dll" Vital="no" /> 
    129                 <File Id="ModSysTray.dll" Name="SysTray.dll" LongName="SysTray.dll" DiskId="1" Source="$(var.Source)/modules/SysTray.dll" Vital="no" /> 
    130                 <File Id="A_DebugLogMetrics.dll" Name="ADebug.dll" LongName="A_DebugLogMetrics.dll" DiskId="1" Source="$(var.Source)/modules/A_DebugLogMetrics.dll" Vital="no" /> 
    131               --> 
    132132              <File Id="ModCheckEventLog.dll" Name="CheckEventLog.dll" DiskId="1" Source="$(var.Source)/modules/CheckEventLog.dll" Vital="no" /> 
    133133              <File Id="ModCheckExternalScripts.dll" Name="CheckExternalScripts.dll" DiskId="1" Source="$(var.Source)/modules/CheckExternalScripts.dll" Vital="no" /> 
     
    147147              <File Id="script001" Name="check_60s.bat" DiskId="1" Source="$(var.Source)/scripts/check_60s.bat" Vital="no" /> 
    148148              <File Id="script002" Name="check_battery.vbs" DiskId="1" Source="$(var.Source)/scripts/check_battery.vbs" Vital="no" /> 
    149               <File Id="script003" Name="check_no_rdp.bat" DiskId="1" Source="$(var.Source)/scripts/check_no_rdp.bat" Vital="no" /> 
    150               <File Id="script004" Name="check_printer.vbs" DiskId="1" Source="$(var.Source)/scripts/check_printer.vbs" Vital="no" /> 
    151               <File Id="script005" Name="check_ok.bat" DiskId="1" Source="$(var.Source)/scripts/check_ok.bat" Vital="no" /> 
    152               <File Id="script006" Name="check_files.vbs" DiskId="1" Source="$(var.Source)/scripts/check_files.vbs" Vital="no" /> 
     149              <File Id="script003" Name="check_files.vbs" DiskId="1" Source="$(var.Source)/scripts/check_files.vbs" Vital="no" /> 
     150              <File Id="script004" Name="check_no_rdp.bat" DiskId="1" Source="$(var.Source)/scripts/check_no_rdp.bat" Vital="no" /> 
     151              <File Id="script005" Name="check_printer.vbs" DiskId="1" Source="$(var.Source)/scripts/check_printer.vbs" Vital="no" /> 
     152              <File Id="script006" Name="check_ok.bat" DiskId="1" Source="$(var.Source)/scripts/check_ok.bat" Vital="no" /> 
    153153              <File Id="script007" Name="check_ping.bat" DiskId="1" Source="$(var.Source)/scripts/check_ping.bat" Vital="no" /> 
    154154              <File Id="script008" Name="check_updates.vbs" DiskId="1" Source="$(var.Source)/scripts/check_updates.vbs" Vital="no" /> 
    155               <File Id="sample002" Name="check_test.ps1" DiskId="1" Source="$(var.Source)/scripts/check_test.ps1" Vital="no" /> 
    156               <File Id="sample003" Name="check_test.vbs" DiskId="1" Source="$(var.Source)/scripts/check_test.vbs" Vital="no" /> 
     155              <File Id="sample001" Name="check_test.ps1" DiskId="1" Source="$(var.Source)/scripts/check_test.ps1" Vital="no" /> 
     156              <File Id="sample002" Name="check_test.vbs" DiskId="1" Source="$(var.Source)/scripts/check_test.vbs" Vital="no" /> 
    157157              <!-- 
    158158                Scripts missing 
     159              <File Id="sample003" Name="check_test.bat" DiskId="1" Source="$(var.Source)/scripts/check_test.bat" Vital="no" /> 
    159160              <File Id="lua001" Name="test.lua" LongName="test.lua" DiskId="1" Source="$(var.Source)/scripts/test.lua" Vital="no" /> 
    160161              --> 
     
    168169            <Directory Id="INSTALLLOCATION_SCRIPTS_PYTHON" Name="python"> 
    169170              <Component Id="PythonScripts" Guid="8820A304-C697-4393-A72F-$(var.Postfix.GUID)" Win64="$(var.Win64)"> 
    170                 <File Id="P_script_001" Name="test.py" DiskId="1" Source="$(var.Source)/scripts/python/test.py" Vital="no" /> 
    171                 <File Id="P_script_002" Name="test_pb.py" DiskId="1" Source="$(var.Source)/scripts/python/test_pb.py" Vital="no" /> 
     171                <File Id="P_script_001" Name="test_eventlog.py" DiskId="1" Source="$(var.Source)/scripts/python/test_eventlog.py" Vital="no" /> 
     172                <File Id="P_script_002" Name="test_nsca.py" DiskId="1" Source="$(var.Source)/scripts/python/test_nsca.py" Vital="no" /> 
     173                <File Id="P_script_003" Name="test_pb.py" DiskId="1" Source="$(var.Source)/scripts/python/test_pb.py" Vital="no" /> 
     174                <File Id="P_script_004" Name="test_sample.py" DiskId="1" Source="$(var.Source)/scripts/python/test_sample.py" Vital="no" /> 
    172175              </Component> 
    173176            </Directory> 
     
    253256          <ComponentRef Id="NSCA" /> 
    254257        </Feature> 
     258        <Feature Id="NSCPPlugin" Title="NSCP plugin (experimental)" Description="Plugin to submit passive results to an NSCP server" Level="1" Absent="disallow"> 
     259          <ComponentRef Id="NSCP" /> 
     260        </Feature> 
    255261        <Feature Id="PythonScript" Title="Python Scripting" Description="Python scripting requires python to be installed)" Level="1" Absent="disallow"> 
    256262          <ComponentRef Id="PythonScript" /> 
  • include/NSCAPI.h

    r98113da rf7a074d  
    144144    typedef NSCAPI::errorReturn (*lpNSAPIGetSettingsBool)(const wchar_t*, const wchar_t*, int); 
    145145    typedef NSCAPI::errorReturn (*lpNSAPIGetSettingsSection)(const wchar_t*, wchar_t***, unsigned int *); 
     146    typedef NSCAPI::errorReturn (*lpNSAPIGetSettingsSections)(const wchar_t*, wchar_t***, unsigned int *); 
    146147    typedef NSCAPI::errorReturn (*lpNSAPIReleaseSettingsSectionBuffer)(wchar_t***, unsigned int *); 
    147148    typedef void (*lpNSAPIMessage)(const char*, unsigned int); 
  • include/client/command_line_parser.cpp

    r98113da rf7a074d  
    246246  nscapi::functions::destination_container myself = config.data->host_self; 
    247247  if (!header->has_recipient_id()) { 
     248    if (recipient.id.empty()) 
     249      recipient.id = "TODO missing id"; 
    248250    nscapi::functions::add_host(header, recipient); 
    249251    header->set_recipient_id(recipient.id); 
  • include/nrpe/packet.hpp

    r294b37b rf7a074d  
    7373  }; 
    7474 
    75   class nrpe_exception { 
    76     std::wstring error_; 
    77   public: 
    78     nrpe_exception(std::wstring error) : error_(error) {} 
    79     std::wstring getMessage() { 
    80       return error_; 
     75  class nrpe_exception : public std::exception { 
     76    std::string error_; 
     77  public: 
     78    nrpe_exception(std::wstring error) : error_(utf8::cvt<std::string>(error)) {} 
     79    nrpe_exception(std::string error) : error_(utf8::cvt<std::string>(error)) {} 
     80    ~nrpe_exception() throw() {} 
     81    const char* what() const throw() { 
     82      return error_.c_str(); 
     83    } 
     84    const std::wstring wwhat() const throw() { 
     85      return utf8::cvt<std::wstring>(error_); 
    8186    } 
    8287  }; 
  • include/nrpe/server/connection.cpp

    rc391984 rf7a074d  
    7575              nrpe::packet request = parser_.parse(); 
    7676              response = handler_->handle(request); 
    77             } catch (nrpe::nrpe_packet_exception &e) { 
    78               response = handler_->create_error(e.getMessage()); 
     77            } catch (const nrpe::nrpe_packet_exception &e) { 
     78              response = handler_->create_error(e.wwhat()); 
     79            } catch (const nrpe::nrpe_exception &e) { 
     80              response = handler_->create_error(e.wwhat()); 
     81            } catch (const std::exception &e) { 
     82              response = handler_->create_error(_T("Error handling NRPE packet: ") + utf8::cvt<std::wstring>(e.what())); 
    7983            } catch (...) { 
    80               response = handler_->create_error(_T("Unknown error handling packet")); 
     84              response = handler_->create_error(_T("Unknown error handling NRPE packet")); 
    8185            } 
    8286 
  • include/nsca/nsca_packet.hpp

    ra629015 rf7a074d  
    140140 
    141141    void parse_data(const char* buffer, unsigned int buffer_len) { 
    142       const nsca::data::data_packet *data = reinterpret_cast<const nsca::data::data_packet*>(buffer); 
     142      char *tmp = new char[buffer_len]; 
     143      memcpy(tmp, buffer, buffer_len); 
     144      nsca::data::data_packet *data = reinterpret_cast<nsca::data::data_packet*>(tmp); 
    143145      //packet_version=swap_bytes::ntoh<int16_t>(data->packet_version); 
    144146      time=swap_bytes::ntoh<u_int32_t>(data->timestamp); 
     
    150152      result= data->get_result_ptr(nsca::length::host_length, nsca::length::desc_length); 
    151153 
     154      unsigned int crc32 = swap_bytes::ntoh<u_int32_t>(data->crc32_value); 
     155      data->crc32_value = 0; 
     156      unsigned int calculated_crc32=calculate_crc32(tmp, buffer_len); 
     157      delete [] tmp; 
     158      if (crc32 != calculated_crc32) 
     159        throw nsca::nsca_exception(_T("Invalid crc: ") + strEx::itos(crc32) + _T(" != ") + strEx::itos(calculated_crc32)); 
    152160    } 
    153161 
  • include/nsca/nsca_socket.hpp

    r9b9be81 rf7a074d  
    7474      std::vector<char> buf(len); 
    7575      if (!read_with_timeout(buf, timeout)) { 
    76         NSC_LOG_ERROR_STD(_T("Failed to read IV from server.")); 
     76        NSC_LOG_ERROR_STD(_T("Failed to read IV from server (using ") + strEx::itos(encryption_method) + _T(", ") + strEx::itos(len) + _T(").")); 
    7777        return false; 
    7878      } 
  • include/nscapi/functions.hpp

    r98113da rf7a074d  
    180180      if (!dst.host.empty()) 
    181181        host->set_host(dst.host); 
     182      if (!dst.address.empty()) 
     183        host->set_address(dst.address); 
    182184      if (!dst.protocol.empty()) 
    183185        host->set_protocol(dst.protocol); 
     
    199201        if (host.id() == tag) { 
    200202          data.id = tag; 
    201           data.host = host.host(); 
    202           data.address = host.address(); 
    203           data.protocol = host.protocol(); 
    204           data.comment = host.comment(); 
     203          if (!host.host().empty()) 
     204            data.host = host.host(); 
     205          if (!host.address().empty()) 
     206            data.address = host.address(); 
     207          if (!host.protocol().empty()) 
     208            data.protocol = host.protocol(); 
     209          if (!host.comment().empty()) 
     210            data.comment = host.comment(); 
    205211          if (expand_meta) { 
    206212            for(int j=0;j<host.tags_size(); ++j) { 
     
    219225    ////////////////////////////////////////////////////////////////////////// 
    220226 
     227    static void make_submit_from_query(std::string &message, const std::wstring channel, const std::wstring alias = _T("")) { 
     228      Plugin::QueryResponseMessage response; 
     229      response.ParseFromString(message); 
     230      Plugin::SubmitRequestMessage request; 
     231      request.mutable_header()->CopyFrom(response.header()); 
     232      request.set_channel(to_string(channel)); 
     233      for (int i=0;i<response.payload_size();++i) { 
     234        request.add_payload()->CopyFrom(response.payload(i)); 
     235        if (!alias.empty()) 
     236          request.mutable_payload(i)->set_alias(to_string(alias)); 
     237      } 
     238      message = request.SerializeAsString(); 
     239    } 
     240 
    221241    static void create_simple_query_request(std::wstring command, std::vector<std::wstring> arguments, std::string &buffer) { 
    222242      Plugin::QueryRequestMessage message; 
     
    271291      return gbp_to_nagios_status(payload.result()); 
    272292    } 
    273     static NSCAPI::errorReturn parse_simple_submit_request_payload(const Plugin::QueryResponseMessage::Response &payload, std::wstring &command, std::wstring &msg, std::wstring &perf) { 
     293    static NSCAPI::errorReturn parse_simple_submit_request_payload(const Plugin::QueryResponseMessage::Response &payload, std::wstring &alias, std::wstring &command, std::wstring &msg, std::wstring &perf) { 
     294      alias = utf8::cvt<std::wstring>(payload.alias()); 
    274295      command = utf8::cvt<std::wstring>(payload.command()); 
    275296      msg = utf8::cvt<std::wstring>(payload.message()); 
     
    361382    } 
    362383 
    363     static int parse_simple_query_response(std::string &response, std::wstring &msg, std::wstring &perf) { 
     384    static int parse_simple_query_response(const std::string &response, std::wstring &msg, std::wstring &perf) { 
    364385      Plugin::QueryResponseMessage message; 
    365386      message.ParseFromString(response); 
  • include/nscapi/nscapi_core_wrapper.cpp

    r98113da rf7a074d  
    370370  return ret; 
    371371} 
     372std::list<std::wstring> nscapi::core_wrapper::getSettingsSections(std::wstring section) { 
     373  if (!fNSAPIGetSettingsSections) 
     374    throw nscapi::nscapi_exception(_T("NSCore has not been initiated...")); 
     375  array_buffer::arrayBuffer aBuffer = NULL; 
     376  unsigned int argLen = 0; 
     377  if (fNSAPIGetSettingsSections(section.c_str(), &aBuffer, &argLen) != NSCAPI::isSuccess) { 
     378    throw nscapi::nscapi_exception(_T("Settings could not be retrieved.")); 
     379  } 
     380  std::list<std::wstring> ret = array_buffer::arrayBuffer2list(argLen, aBuffer); 
     381  if (fNSAPIReleaseSettingsSectionBuffer(&aBuffer, &argLen) != NSCAPI::isSuccess) { 
     382    throw nscapi::nscapi_exception(_T("Settings could not be destroyed.")); 
     383  } 
     384  if (aBuffer != NULL) 
     385    throw nscapi::nscapi_exception(_T("buffer is not null?.")); 
     386  return ret; 
     387} 
    372388/** 
    373389 * Retrieve an int from the settings subsystem (INI-file) 
     
    639655  fNSAPIGetSettingsString = (nscapi::core_api::lpNSAPIGetSettingsString)f(_T("NSAPIGetSettingsString")); 
    640656  fNSAPIGetSettingsSection = (nscapi::core_api::lpNSAPIGetSettingsSection)f(_T("NSAPIGetSettingsSection")); 
     657  fNSAPIGetSettingsSections = (nscapi::core_api::lpNSAPIGetSettingsSections)f(_T("NSAPIGetSettingsSections")); 
    641658  fNSAPIReleaseSettingsSectionBuffer = (nscapi::core_api::lpNSAPIReleaseSettingsSectionBuffer)f(_T("NSAPIReleaseSettingsSectionBuffer")); 
    642659  fNSAPIMessage = (nscapi::core_api::lpNSAPIMessage)f(_T("NSAPIMessage")); 
  • include/nscapi/nscapi_core_wrapper.hpp

    r98113da rf7a074d  
    4040    nscapi::core_api::lpNSAPIGetApplicationVersionStr fNSAPIGetApplicationVersionStr; 
    4141    nscapi::core_api::lpNSAPIGetSettingsSection fNSAPIGetSettingsSection; 
     42    nscapi::core_api::lpNSAPIGetSettingsSections fNSAPIGetSettingsSections; 
    4243    nscapi::core_api::lpNSAPIReleaseSettingsSectionBuffer fNSAPIReleaseSettingsSectionBuffer; 
    4344    nscapi::core_api::lpNSAPIGetSettingsString fNSAPIGetSettingsString; 
     
    8889      , fNSAPIGetApplicationVersionStr(NULL) 
    8990      , fNSAPIGetSettingsSection(NULL) 
     91      , fNSAPIGetSettingsSections(NULL) 
    9092      , fNSAPIReleaseSettingsSectionBuffer(NULL) 
    9193      , fNSAPIGetSettingsString(NULL) 
     
    122124    std::wstring getApplicationVersionString(void); 
    123125    std::list<std::wstring> getSettingsSection(std::wstring section); 
     126    std::list<std::wstring> getSettingsSections(std::wstring section); 
    124127    std::wstring getSettingsString(std::wstring section, std::wstring key, std::wstring defaultValue); 
    125128    std::wstring expand_path(std::wstring value); 
  • include/nscapi/settings_proxy.hpp

    rd66ccee rf7a074d  
    4242 
    4343    virtual string_list get_sections(std::wstring path) { 
    44       return core_->getSettingsSection(path); 
     44      return core_->getSettingsSections(path); 
    4545    } 
    4646    virtual string_list get_keys(std::wstring path) { 
  • include/settings/client/settings_client.cpp

    r3bdaf18 rf7a074d  
    44namespace nscapi { 
    55  namespace settings_helper { 
    6  
    7  
     6/* 
     7    template<typename T> 
     8    typed_key_entry_in_vector<std::wstring, T, typed_string_value<std::wstring> >* wstring_vector_key(T *val, typename T::key_type key, std::wstring def) { 
     9      typed_key_entry_in_vector<std::wstring, T, typed_string_value<std::wstring> >* r = new typed_key_entry_in_vector<std::wstring, T, typed_string_value<std::wstring> >(val, key, def); 
     10      return r; 
     11    } 
     12*/ 
    813    wstring_key_type* wstring_key(std::wstring *val, std::wstring def) { 
    914      wstring_key_type* r = new wstring_key_type(val, def); 
  • include/settings/client/settings_client.hpp

    r9b9be81 rf7a074d  
    140140    }; 
    141141 
     142    template<class T, class V, class TBase> 
     143    class typed_key_entry_in_vector : public TBase { 
     144    public: 
     145      typed_key_entry_in_vector(V* store_to, typename V::key_type key, const T& v) : TBase(v), store_to_(store_to), key_(key) {} 
     146 
     147      virtual void update_target(T *value) const { 
     148        if (store_to_) 
     149          (*store_to_)[key_] = *value; 
     150      } 
     151    protected: 
     152      V* store_to_; 
     153      typename V::key_type key_; 
     154    }; 
     155 
    142156    template<class T, class TBase> 
    143157    class typed_key_fun : public TBase { 
     
    152166    }; 
    153167 
     168    template<typename T> 
     169    typed_key_entry_in_vector<std::wstring, T, typed_string_value<std::wstring> >* wstring_vector_key(T *val, typename T::key_type key, std::wstring def) { 
     170      typed_key_entry_in_vector<std::wstring, T, typed_string_value<std::wstring> >* r = new typed_key_entry_in_vector<std::wstring, T, typed_string_value<std::wstring> >(val, key, def); 
     171      return r; 
     172    } 
    154173 
    155174    typedef typed_key_value<std::wstring, typed_string_value<std::wstring> > wstring_key_type; 
     
    160179    typedef typed_key_value<bool, typed_bool_value<bool> > bool_key_type; 
    161180 
     181    /* 
     182    template<typename T> 
     183    typed_key_entry_in_vector<std::wstring, T, typed_string_value<std::wstring> >* wstring_vector_key(T *val, typename T::key_type key, std::wstring def); 
     184    */ 
    162185    wstring_key_type* wstring_key(std::wstring *val, std::wstring def = _T("")); 
    163186    string_key_type* string_key(std::string *val, std::string def = ""); 
     
    232255            std::wstring val = core_->get_string(path, key, _T("")); 
    233256            callback_(key, val); 
     257          } 
     258          list = core_->get_sections(path); 
     259          BOOST_FOREACH(std::wstring key, list) { 
     260            callback_(key, _T("")); 
    234261          } 
    235262        } 
  • include/settings/settings_old.hpp

    r65a2940 rf7a074d  
    386386      } 
    387387      // @todo: this will NOT work for "nodes in paths" 
     388      std::set<std::wstring> ignore_list; 
    388389      BOOST_FOREACH(settings_map::keys_key_type key, map.keys_) { 
    389390        if (key.first.first == path) { 
    390391          if (has_key_int(key.second.first, key.second.second)) { 
    391392            list.push_back(key.first.second); 
     393            ignore_list.insert(key.second.first + _T("/") + key.second.second); 
    392394          } 
    393395        } 
     
    402404            it = section_cache_.find(path); 
    403405          } 
    404           list.insert(list.end(), (*it).second.begin(), (*it).second.end()); 
     406          BOOST_FOREACH(std::wstring k, (*it).second) { 
     407            std::set<std::wstring>::const_iterator cit = ignore_list.find(key.second + _T("/") + k); 
     408            if (cit == ignore_list.end()) 
     409              list.push_back(k); 
     410          } 
     411          //list.insert(list.end(), (*it).second.begin(), (*it).second.end()); 
    405412        } 
    406413      } 
  • modules/CheckSystem/CheckSystem.cpp

    ra78a985 rf7a074d  
    7474  try { 
    7575    typedef std::map<std::wstring,std::wstring> counter_map_type; 
    76     std::map<std::wstring,std::wstring> service_mappings; 
    7776    std::map<std::wstring,std::wstring> counters; 
    7877    bool default_counters = true; 
     
    8483      (_T("WINDOWS CHECK SYSTEM"), _T("Section for system checks and system settings")) 
    8584 
    86       (_T("service mapping"), sh::wstring_map_path(&service_mappings) 
    87       , _T("SERVICE MAPPING SECTION"), _T("")) 
     85      (_T("service mapping"), _T("SERVICE MAPPING SECTION"), _T("Confiure which services has to be in which state")) 
    8886 
    8987      (_T("pdh"), _T("PDH COUNTER INFORMATION"), _T("")) 
     
    9189      (_T("pdh/counters"), sh::wstring_map_path(&counters) 
    9290      , _T("PDH COUNTERS"), _T("")) 
     91 
    9392 
    9493      ; 
     
    116115      ; 
    117116 
     117    //std::map<DWORD,std::wstring>::key_type 
     118 
     119    settings.alias().add_key_to_settings() 
     120 
     121      (_T("BOOT_START"), sh::wstring_vector_key(&lookups_, SERVICE_BOOT_START, _T("ignored")), 
     122      _T("SERVICE_BOOT_START"), _T("TODO")) 
     123 
     124      (_T("SYSTEM_START"), sh::wstring_vector_key(&lookups_, SERVICE_SYSTEM_START, _T("ignored")), 
     125      _T("SERVICE_SYSTEM_START"), _T("TODO")) 
     126 
     127      (_T("AUTO_START"), sh::wstring_vector_key(&lookups_, SERVICE_AUTO_START, _T("started")), 
     128      _T("SERVICE_AUTO_START"), _T("TODO")) 
     129 
     130      (_T("DEMAND_START"), sh::wstring_vector_key(&lookups_, SERVICE_DEMAND_START, _T("ignored")), 
     131      _T("SERVICE_DEMAND_START"), _T("TODO")) 
     132 
     133      (_T("DISABLED"), sh::wstring_vector_key(&lookups_, SERVICE_DISABLED, _T("stopped")), 
     134      _T("SERVICE_DISABLED"), _T("TODO")) 
     135 
     136      (_T("DELAYED"), sh::wstring_vector_key(&lookups_, NSCP_SERVICE_DELAYED, _T("ignored")), 
     137      _T("SERVICE_DELAYED"), _T("TODO")) 
     138 
     139      ; 
    118140 
    119141    settings.register_all(); 
    120142    settings.notify(); 
    121  
    122     lookups_[SERVICE_BOOT_START] = service_mappings[_T("BOOT_START")]; 
    123     lookups_[SERVICE_SYSTEM_START] = service_mappings[_T("SYSTEM_START")]; 
    124     lookups_[SERVICE_AUTO_START] = service_mappings[_T("AUTO_START")]; 
    125     lookups_[SERVICE_DEMAND_START] = service_mappings[_T("DEMAND_START")]; 
    126     lookups_[SERVICE_DISABLED] = service_mappings[_T("DISABLED")]; 
    127     lookups_[NSCP_SERVICE_DELAYED] = service_mappings[_T("DELAYED")]; 
    128143 
    129144    typedef PDHCollector::system_counter_data::counter cnt; 
  • modules/NRPEClient/NRPEClient.cpp

    ra78a985 rf7a074d  
    284284    return nrpe_result_data(packet.getResult(), packet.getPayload()); 
    285285  } catch (nrpe::nrpe_packet_exception &e) { 
    286     return nrpe_result_data(NSCAPI::returnUNKNOWN, _T("NRPE Packet errro: ") + e.getMessage()); 
     286    return nrpe_result_data(NSCAPI::returnUNKNOWN, _T("NRPE Packet errro: ") + e.wwhat()); 
    287287  } catch (std::runtime_error &e) { 
    288288    NSC_LOG_ERROR_STD(_T("Socket error: ") + utf8::cvt<std::wstring>(e.what())); 
  • modules/NRPEServer/handler_impl.hpp

    rc391984 rf7a074d  
    2323 
    2424  nrpe::packet create_error(std::wstring msg) { 
    25     return nrpe::packet::create_response(4, msg, payload_length_); 
     25    return nrpe::packet::create_response(3, msg, payload_length_); 
    2626  } 
    2727 
  • modules/NSCAClient/NSCAClient.cpp

    r58f0e80 rf7a074d  
    6767    sh::settings_registry settings(get_settings_proxy()); 
    6868    settings.set_alias(_T("NSCA"), alias, _T("client")); 
     69    target_path = settings.alias().get_settings_path(_T("targets")); 
    6970 
    7071    settings.alias().add_path_to_settings() 
    7172      (_T("NSCA AGENT SECTION"), _T("Section for NSCA passive check module.")) 
     73 
     74      (_T("targets"), sh::fun_values_path(boost::bind(&NSCAAgent::add_target, this, _1, _2)),  
     75      _T("REMOTE TARGET DEFINITIONS"), _T("")) 
     76 
    7277      ; 
    7378 
     
    95100 
    96101    settings.alias().add_key_to_settings(_T("server")) 
     102      /* 
    97103      (_T("host"), sh::wstring_key(&nscahost_), 
    98104      _T("NSCA HOST"), _T("The NSCA server to report results to.")) 
     
    101107      _T("NSCA PORT"), _T("The NSCA server port")) 
    102108 
    103       (_T("encryption method"), sh::int_key(&encryption_method_), 
     109      (_T("encryption method"), sh::string_key(&encryption_method_), 
    104110      _T("ENCRYPTION METHOD"), _T("Number corresponding to the various encryption algorithms (see the wiki). Has to be the same as the server or it wont work at all.")) 
    105111 
    106112      (_T("password"), sh::string_key(&password_), 
    107113      _T("PASSWORD"), _T("The password to use. Again has to be the same as the server or it wont work at all.")) 
     114      */ 
    108115 
    109116      (_T("timeout"), sh::uint_key(&timeout_, 30), 
     
    158165} 
    159166 
     167void NSCAAgent::add_target(std::wstring key, std::wstring arg) { 
     168  try { 
     169    targets.add(get_settings_proxy(), target_path , key, arg); 
     170  } catch (...) { 
     171    NSC_LOG_ERROR_STD(_T("Failed to add target: ") + key); 
     172  } 
     173} 
    160174void NSCAAgent::add_local_options(po::options_description &desc, nscp_connection_data &command_data) { 
    161175  desc.add_options() 
     
    203217NSCAPI::nagiosReturn NSCAAgent::handleRAWNotification(const wchar_t* channel, std::string request, std::string &response) { 
    204218  try { 
     219 
    205220    client::configuration config; 
     221    net::wurl url; 
     222    url.protocol = _T("nsca"); 
     223 
     224    nscapi::target_handler::optarget target = targets.find_target(_T("default")); 
     225    if (target) { 
     226      url.host = target->host; 
     227      url.port = strEx::stoi(target->options[_T("port")]); 
     228      config.data->recipient.data["encryption"] = utf8::cvt<std::string>(target->options[_T("encryption")]); 
     229      config.data->recipient.data["password"] = utf8::cvt<std::string>(target->options[_T("password")]); 
     230    } 
     231    config.data->recipient.id = "default"; 
     232    config.data->recipient.address = utf8::cvt<std::string>(url.to_string()); 
     233    config.data->host_self.id = "self"; 
     234    config.data->host_self.host = hostname_; 
     235 
    206236    setup(config, _T("")); 
    207237    if (!client::command_line_parser::relay_submit(config, request, response)) { 
     
    230260      return NSCAPI::hasFailed; 
    231261    } 
    232     NSC_LOG_ERROR_STD(_T("Got IV sending data: ") + strEx::itos(packets.size())); 
     262    NSC_DEBUG_MSG_STD(_T("Got IV sending data: ") + strEx::itos(packets.size())); 
    233263    BOOST_FOREACH(const nsca::packet &packet, packets) { 
    234264      socket.send_nsca(packet, boost::posix_time::seconds(data.timeout)); 
     
    256286int NSCAAgent::clp_handler_impl::submit(client::configuration::data_type data, ::Plugin::Common_Header* header, const std::string &request, std::string &response) { 
    257287  try { 
     288 
    258289    Plugin::SubmitRequestMessage message; 
    259290    message.ParseFromString(request); 
    260291    std::list<nsca::packet> list; 
    261  
    262     std::wstring command, msg, perf; 
     292    int iii = message.payload_size(); 
     293 
     294    std::wstring alias, command, msg, perf; 
    263295    nscapi::functions::destination_container recipient; // = data->host_default_recipient; 
    264296    nscapi::functions::parse_destination(*header, header->recipient_id(), recipient, true); 
     
    268300    for (int i=0;i < message.payload_size(); ++i) { 
    269301      nsca::packet packet(source.host, local_data.payload_length, local_data.time_delta); 
    270       packet.code = nscapi::functions::parse_simple_submit_request_payload(message.payload(i), command, msg, perf); 
    271       packet.service = utf8::cvt<std::string>(command); 
     302      packet.code = nscapi::functions::parse_simple_submit_request_payload(message.payload(i), alias, command, msg, perf); 
     303      if (alias != _T("host_check")) 
     304        packet.service = utf8::cvt<std::string>(alias); 
     305      packet.host = source.host; 
    272306      packet.result = utf8::cvt<std::string>(msg) + "|" + utf8::cvt<std::string>(perf); 
    273307      list.push_back(packet); 
  • modules/NSCAClient/NSCAClient.h

    r58f0e80 rf7a074d  
    2626 
    2727#include <nsca/nsca_packet.hpp> 
     28#include <nscapi/targets.hpp> 
    2829 
    2930NSC_WRAPPERS_MAIN(); 
     
    3435 
    3536  std::string hostname_; 
    36   std::wstring nscahost_; 
    37   unsigned int nscaport_; 
    3837  unsigned int payload_length_; 
    3938  bool cacheNscaHost_; 
    40   std::string password_; 
    41   int encryption_method_; 
    4239  unsigned int timeout_; 
    4340  std::wstring channel_; 
    4441  int time_delta_; 
     42  nscapi::target_handler targets; 
     43  std::wstring target_path; 
    4544 
    4645 
     
    146145  std::wstring setup(client::configuration &config, const std::wstring &command); 
    147146  void add_local_options(boost::program_options::options_description &desc, nscp_connection_data &command_data); 
     147  void add_target(std::wstring key, std::wstring args); 
    148148 
    149149  void set_delay(std::wstring key) { 
  • modules/PythonScript/PythonScript.cpp

    r58f0e80 rf7a074d  
    114114} 
    115115python_script::~python_script(){ 
    116   script_wrapper::thread_locker locker; 
    117116  callFunction("shutdown"); 
    118117} 
     
    194193    if (!has_init) { 
    195194      has_init = true; 
     195      PyEval_InitThreads(); 
    196196      Py_Initialize(); 
    197       PyEval_InitThreads(); 
    198197      do_init = true; 
    199198    } 
     
    390389    std::wstring src, cmd, msg, perf; 
    391390    int code = nscapi::functions::parse_simple_submit_request(request, src, cmd, msg, perf); 
     391    NSC_LOG_ERROR_STD(_T(" --- command: ") + cmd); 
    392392    int ret = inst->handle_simple_message(chnl, to_string(src), to_string(cmd), code, msg, perf); 
    393393    nscapi::functions::create_simple_submit_response(channel, cmd, ret, _T(""), response); 
  • modules/PythonScript/script_wrapper.cpp

    r58f0e80 rf7a074d  
    129129} 
    130130void script_wrapper::sleep(unsigned int seconds) { 
    131   thread_unlocker unlocker; 
    132   boost::this_thread::sleep(boost::posix_time::milliseconds(seconds*1000)); 
     131  { 
     132    thread_unlocker unlocker; 
     133    { 
     134      boost::this_thread::sleep(boost::posix_time::milliseconds(1000)); 
     135 
     136    } 
     137  } 
    133138} 
    134139/* 
     
    252257      return NSCAPI::returnIgnored; 
    253258    } 
    254  
    255     py::list l; 
    256     BOOST_FOREACH(std::wstring a, arguments) { 
    257       l.append(utf8::cvt<std::string>(a)); 
    258     } 
    259259    { 
    260260      thread_locker locker; 
     261 
    261262      try { 
     263        py::list l; 
     264        BOOST_FOREACH(std::wstring a, arguments) { 
     265          l.append(utf8::cvt<std::string>(a)); 
     266        } 
    262267        tuple ret = boost::python::call<tuple>(boost::python::object(it->second).ptr(), l); 
    263268        if (ret.ptr() == Py_None) { 
  • modules/PythonScript/script_wrapper.hpp

    r58f0e80 rf7a074d  
    22 
    33#include <boost/python.hpp> 
     4#include <boost/thread.hpp> 
    45 
    56namespace script_wrapper { 
     
    910  namespace thread_support { 
    1011    static bool enabled = true; 
     12    static boost::shared_mutex mutex; 
     13 
     14    struct log_lock { 
     15      boost::unique_lock<boost::shared_mutex> lock; 
     16      log_lock() : lock(thread_support::mutex, boost::get_system_time() + boost::posix_time::seconds(2)) { 
     17        if (!lock.owns_lock()) 
     18          NSC_LOG_ERROR(_T("Failed to get mutex: thread_locker")); 
     19      } 
     20    }; 
     21 
    1122  } 
    1223 
     
    2839    PyThreadState *state; 
    2940    thread_unlocker() { 
    30       state = PyEval_SaveThread(); 
     41      if (thread_support::enabled) 
     42        state = PyEval_SaveThread(); 
    3143    } 
    3244    ~thread_unlocker() { 
    33       PyEval_RestoreThread(state); 
    34     } 
    35  
    36  
     45      if (thread_support::enabled) 
     46        PyEval_RestoreThread(state); 
     47    } 
    3748  }; 
    3849   
  • modules/Scheduler/Scheduler.cpp

    ra629015 rf7a074d  
    153153  NSC_LOG_ERROR_STD(error); 
    154154} 
    155  
     155#include <nscapi/functions.hpp> 
    156156void Scheduler::handle_schedule(scheduler::target item) { 
    157157  try { 
     
    161161      // @todo: allow renaming of commands here item.alias,  
    162162      // @todo this is broken, fix this (uses the wrong message) 
     163      nscapi::functions::make_submit_from_query(response, item.channel, item.alias); 
    163164      std::string result; 
    164165      GET_CORE()->submit_message(item.channel, response, result); 
  • scripts/python/lib/test_helper.py

    r58f0e80 rf7a074d  
    11from NSCP import Settings, Registry, Core, log, log_error, status 
     2import os 
     3import inspect 
    24 
    35test_manager = None 
     6 
     7def install_testcases(tests): 
     8  test_manager = create_test_manager() 
     9  test_manager.add(tests) 
     10  test_manager.install() 
     11 
     12def init_testcases(plugin_id, plugin_alias, script_alias, tests): 
     13  test_manager = create_test_manager(plugin_id, plugin_alias, script_alias) 
     14  test_manager.add(tests) 
     15  test_manager.init() 
     16 
     17def shutdown_testcases(): 
     18  get_test_manager().shutdown() 
    419 
    520def get_test_manager(): 
     
    4055def display_help(arguments = []): 
    4156  return (status.OK, 'TODO') 
    42    
     57 
    4358class Callable: 
    4459  def __init__(self, anycallable): 
    4560    self.__call__ = anycallable 
    4661 
     62class SingletonHelper: 
     63  klass = None 
     64  def __init__(self, klass): 
     65    self.klass = klass 
     66  def __call__(self, *args, **kw): 
     67    if not self.klass._instance: 
     68      self.klass._instance = self.klass() 
     69    return self.klass._instance 
     70 
     71def setup_singleton(klass, src = None): 
     72  klass.getInstance = SingletonHelper(klass) 
     73  log('Setting path: %s'%src) 
     74  if not src: 
     75    cf = inspect.currentframe() 
     76    if cf: 
     77      bf = cf.f_back 
     78      if bf: 
     79        src = bf.f_code.co_filename 
     80  klass.__source__ = src 
     81  log('==>%s'%src) 
     82 
     83class BasicTest(object): 
     84 
     85  _instance = None 
     86  getInstance = None 
     87  __source__ = '' 
     88 
     89  def desc(self): 
     90    return 'TODO: Describe: %s'%self.title() 
     91 
     92  def title(self): 
     93    return self._instance.__class__.__name__ 
     94 
     95  def setup(self, plugin_id, prefix): 
     96    None 
     97 
     98  def teardown(self): 
     99    None 
     100 
     101  def run_test(self): 
     102    result = TestResult() 
     103    result.add_message(False, 'TODO add implementation') 
     104    return result 
     105 
     106  def install(self, arguments): 
     107    conf = Settings.get() 
     108    conf.set_string('/modules', 'pytest', 'PythonScript') 
     109    log('==> %s'%self.__source__) 
     110    fn = os.path.basename(self.__source__) 
     111    (sn, ext) = os.path.splitext(fn) 
     112    conf.register_key('/settings/pytest/scripts', sn, 'string', 'UNIT TEST SCRIPT: %s'%self.title(), 'A script for running unittests for: %s'%self.desc(), fn) 
     113    conf.set_string('/settings/pytest/scripts', sn, fn) 
     114     
     115    conf.save() 
     116   
     117  def uninstall(self): 
     118    None 
     119 
     120  def help(self): 
     121    None 
     122 
     123  def init(self, plugin_id): 
     124    None 
     125 
     126  def shutdown(self): 
     127    None 
     128     
     129     
    47130class TestResult: 
    48131  class Entry: 
  • scripts/python/test_eventlog.py

    r58f0e80 rf7a074d  
    11from NSCP import Settings, Registry, Core, log, status, sleep 
    2 from test_helper import Callable, TestResult, get_test_manager, create_test_manager 
     2from test_helper import BasicTest, TestResult, Callable, setup_singleton, install_testcases, init_testcases, shutdown_testcases 
    33import plugin_pb2 
    44from types import * 
     
    66import unicodedata 
    77 
    8 class EventLogTest: 
     8class EventLogTest(BasicTest): 
    99  instance = None 
    1010  key = '' 
     
    107107    None 
    108108 
     109setup_singleton(EventLogTest) 
     110 
    109111all_tests = [EventLogTest] 
    110112 
    111113def __main__(): 
    112   test_manager = create_test_manager() 
    113   test_manager.add(all_tests) 
    114   test_manager.install() 
     114  install_testcases(all_tests) 
    115115   
    116116def init(plugin_id, plugin_alias, script_alias): 
    117   test_manager = create_test_manager(plugin_id, plugin_alias, script_alias) 
    118   test_manager.add(all_tests) 
    119  
    120   test_manager.init() 
     117  init_testcases(plugin_id, plugin_alias, script_alias, all_tests) 
    121118 
    122119def shutdown(): 
    123   test_manager = get_test_manager() 
    124   test_manager.shutdown() 
     120  shutdown_testcases() 
  • scripts/python/test_nsca.py

    r58f0e80 rf7a074d  
    11from NSCP import Settings, Registry, Core, log, status, log_error, sleep 
    2 from test_helper import Callable, TestResult, get_test_manager, create_test_manager 
     2from test_helper import BasicTest, TestResult, Callable, setup_singleton, install_testcases, init_testcases, shutdown_testcases 
    33import plugin_pb2 
    44from types import * 
     
    66import uuid 
    77import unicodedata 
     8#import _thread 
     9#sync = _thread.allocate_lock() 
     10 
     11import threading 
     12sync = threading.RLock() 
    813 
    914core = Core.get() 
    10  
    11 prefix = 'py_' 
    12 plugin_id = 0 
    13  
    14 def get_help(arguments): 
    15   return (status.OK, 'help: Get help') 
    16  
    1715 
    1816def isOpen(ip, port): 
     
    3533 
    3634  def __init__(self, command): 
    37     try: 
    38       self.uuid = command.decode('ascii') 
    39     except UnicodeDecodeError: 
     35    if type(command) == 'unicode': 
     36      try: 
     37        self.uuid = command.decode('ascii', 'replace') 
     38      except UnicodeDecodeError: 
     39        self.uuid = command 
     40    else: 
    4041      self.uuid = command 
    4142    #self.uuid = unicodedata.normalize('NFKD', command).encode('ascii','ignore') 
     
    4445    return 'Message: %s (%s, %s, %s)'%(self.uuid, self.source, self.command, self.status) 
    4546 
    46 class NSCAServerTest: 
     47class NSCAServerTest(BasicTest): 
    4748  instance = None 
    4849  key = '' 
    4950  reg = None 
    50   responses = {} 
    51    
    52   class SingletonHelper: 
    53     def __call__( self, *args, **kw ) : 
    54       if NSCAServerTest.instance is None : 
    55         object = NSCAServerTest() 
    56         NSCAServerTest.instance = object 
    57       return NSCAServerTest.instance 
    58  
    59   getInstance = SingletonHelper() 
    60  
     51  _responses = {} 
     52   
     53  def has_response(self, id): 
     54    with sync: 
     55      return id in self._responses 
     56   
     57  def get_response(self, id): 
     58    with sync: 
     59      if id in self._responses: 
     60        return self._responses[id] 
     61      msg = NSCAMessage(id) 
     62      self._responses[id] = msg 
     63      return msg 
     64 
     65  def set_response(self, msg): 
     66    with sync: 
     67      self._responses[msg.uuid] = msg 
     68 
     69  def del_response(self, id): 
     70    with sync: 
     71      del self._responses[id] 
     72       
     73   
    6174  def desc(self): 
    6275    return 'Testcase for NSCA protocol' 
     
    8295   
    8396  def simple_inbox_handler_wrapped(self, channel, source, command, status, message, perf): 
    84     log('Got simple message %s on %s'%(command, channel)) 
    85     msg = NSCAMessage(command) 
    86     if msg.uuid in self.responses: 
    87       msg = self.responses[msg.uuid] 
     97    log('Got simple message %s'%command) 
     98    msg = self.get_response(command) 
    8899    msg.source = source 
    89100    msg.status = status 
     
    91102    msg.perfdata = perf 
    92103    msg.got_simple_response = True 
    93     self.responses[msg.uuid] = msg 
     104    self.set_response(msg) 
    94105    return True 
    95106 
     
    100111    message.ParseFromString(request) 
    101112    command = message.payload[0].command 
    102     log('Got simple message %s on %s'%(command, channel)) 
    103      
    104     msg = NSCAMessage(command) 
    105     if msg.uuid in self.responses: 
    106       msg = self.responses[msg.uuid] 
     113    #log('Got message %s on %s'%(command, channel)) 
     114     
     115    msg = self.get_response(command) 
    107116    msg.got_response = True 
    108     self.responses[msg.uuid] = msg 
     117    self.set_response(msg) 
    109118    return (False, '') 
    110119     
     
    139148    found = False 
    140149    for i in range(0,10): 
    141       if uid in self.responses: 
    142         rmsg = self.responses[uid] 
     150      if self.has_response(uid): 
     151        rmsg = self.get_response(uid) 
    143152        result.add_message(rmsg.got_response, 'Testing to recieve message using %s'%encryption) 
    144153        result.add_message(rmsg.got_simple_response, 'Testing to recieve simple message using %s'%encryption) 
     
    148157        result.assert_contains(rmsg.message, msg, 'Verify that message is sent through') 
    149158        result.assert_equals(rmsg.perfdata, perf, 'Verify that performance data is sent through') 
    150         del self.responses[uid] 
     159        self.del_response(uid) 
    151160        found = True 
    152161        break 
    153162      else: 
    154         log('Waiting for %s (%s)'%(uid, self.responses.keys())) 
     163        log('Waiting for %s'%uid) 
    155164        sleep(1) 
    156165    if not found: 
     
    178187    # Currently broken: "xor" 
    179188    cryptos = ["des", "3des", "cast128", "xtea", "blowfish", "twofish", "rc2", "aes", "serpent", "gost", "none", "3way"] 
     189    #cryptos = ["none"] 
    180190    for c in cryptos: 
    181191      result.add_message(True, 'Testing crypto: %s'%c) 
     
    213223    None 
    214224 
     225setup_singleton(NSCAServerTest) 
     226 
    215227all_tests = [NSCAServerTest] 
    216228 
    217229def __main__(): 
    218   test_manager = create_test_manager() 
    219   test_manager.add(all_tests) 
    220   test_manager.install() 
     230  install_testcases(all_tests) 
    221231   
    222232def init(plugin_id, plugin_alias, script_alias): 
    223   test_manager = create_test_manager(plugin_id, plugin_alias, script_alias) 
    224   test_manager.add(all_tests) 
    225  
    226   test_manager.init() 
     233  init_testcases(plugin_id, plugin_alias, script_alias, all_tests) 
    227234 
    228235def shutdown(): 
    229   test_manager = get_test_manager() 
    230   test_manager.shutdown() 
     236  shutdown_testcases() 
  • service/NSCPlugin.h

    r9b9be81 rf7a074d  
    157157  bool route_message(const wchar_t *channel, const char* buffer, unsigned int buffer_len, wchar_t **new_channel_buffer, char **new_buffer, unsigned int *new_buffer_len); 
    158158 
     159  std::wstring get_description() { 
     160    if (alias_.empty()) 
     161      return getName(); 
     162    return getName() + _T(" (") + alias_ + _T(")"); 
     163  } 
    159164  std::wstring get_alias() { 
    160165    return alias_; 
  • service/NSClient++.cpp

    r98113da rf7a074d  
    371371  BOOST_FOREACH(std::wstring plugin, list) { 
    372372    std::wstring alias = settings_manager::get_settings()->get_string(MAIN_MODULES_SECTION, plugin); 
    373     if (plugin == _T("enabled")) { 
     373    if (plugin == _T("enabled") || plugin == _T("1")) { 
    374374      plugin = alias; 
    375375      alias = _T(""); 
     376    } else if (alias == _T("enabled") || alias == _T("1")) { 
     377        alias = _T(""); 
    376378    } else if ((active && plugin == _T("disabled")) || (active && alias == _T("disabled"))) 
    377379      continue; 
     
    387389      alias = tmp; 
    388390    } 
    389     LOG_DEBUG_CORE_STD(_T("Found: ") + plugin + _T(" as ") + alias); 
     391    if (alias.empty()) { 
     392      LOG_DEBUG_CORE_STD(_T("Found: ") + plugin); 
     393    } else { 
     394      LOG_DEBUG_CORE_STD(_T("Found: ") + plugin + _T(" as ") + alias); 
     395    } 
    390396    if (plugin.length() > 4 && plugin.substr(plugin.length()-4) == _T(".dll")) 
    391397      plugin = plugin.substr(0, plugin.length()-4); 
     
    687693      std::wstring file = NSCPlugin::get_plugin_file(v.second); 
    688694      std::wstring alias = v.first; 
    689       LOG_DEBUG_CORE_STD(_T("Processing plugin: ") + file + _T(" as ") + alias); 
     695      if (!alias.empty()) { 
     696        LOG_DEBUG_CORE_STD(_T("Processing plugin: ") + file + _T(" as ") + alias); 
     697      } else { 
     698        LOG_DEBUG_CORE_STD(_T("Processing plugin: ") + file); 
     699      } 
    690700      try { 
    691701        addPlugin(pluginPath / boost::filesystem::wpath(file), alias); 
     
    921931    } 
    922932    for (pluginList::iterator it=plugins_.begin(); it != plugins_.end();) { 
    923       LOG_DEBUG_CORE_STD(_T("Loading plugin: ") + (*it)->getName() + _T(" as ") + (*it)->get_alias()); 
     933      LOG_DEBUG_CORE_STD(_T("Loading plugin: ") + (*it)->get_description()); 
    924934      try { 
    925935        if (!(*it)->load_plugin(mode)) { 
  • service/core_api.cpp

    r98113da rf7a074d  
    148148  return NSCAPI::hasFailed; 
    149149} 
     150NSCAPI::errorReturn NSAPIGetSettingsSections(const wchar_t* section, wchar_t*** aBuffer, unsigned int * bufLen) { 
     151  try { 
     152    unsigned int len = 0; 
     153    *aBuffer = array_buffer::list2arrayBuffer(settings_manager::get_settings()->get_sections(section), len); 
     154    *bufLen = len; 
     155    return NSCAPI::isSuccess; 
     156  } catch (settings::settings_exception e) { 
     157    LOG_ERROR_STD(_T("Failed to get section: ") + e.getMessage()); 
     158  } catch (...) { 
     159    LOG_ERROR_STD(_T("Failed to getSection: ") + section); 
     160  } 
     161  return NSCAPI::hasFailed; 
     162} 
    150163NSCAPI::errorReturn NSAPIReleaseSettingsSectionBuffer(wchar_t*** aBuffer, unsigned int * bufLen) { 
    151164  array_buffer::destroyArrayBuffer(*aBuffer, *bufLen); 
     
    436449  if (wcscasecmp(buffer, _T("NSAPIGetSettingsSection")) == 0) 
    437450    return reinterpret_cast<LPVOID>(&NSAPIGetSettingsSection); 
     451  if (wcscasecmp(buffer, _T("NSAPIGetSettingsSections")) == 0) 
     452    return reinterpret_cast<LPVOID>(&NSAPIGetSettingsSections); 
    438453  if (wcscasecmp(buffer, _T("NSAPIReleaseSettingsSectionBuffer")) == 0) 
    439454    return reinterpret_cast<LPVOID>(&NSAPIReleaseSettingsSectionBuffer); 
  • service/core_api.h

    r98113da rf7a074d  
    4141NSCAPI::nagiosReturn NSAPIExecCommand(const wchar_t* target, const wchar_t* command, const char *request_buffer, const unsigned int request_buffer_len, char **response_buffer, unsigned int *response_buffer_len); 
    4242NSCAPI::errorReturn NSAPIGetSettingsSection(const wchar_t*, wchar_t***, unsigned int *); 
     43NSCAPI::errorReturn NSAPIGetSettingsSections(const wchar_t*, wchar_t***, unsigned int *); 
    4344NSCAPI::errorReturn NSAPIReleaseSettingsSectionBuffer(wchar_t*** aBuffer, unsigned int * bufLen); 
    4445NSCAPI::boolReturn NSAPICheckLogMessages(int messageType); 
  • service/logger.hpp

    ra14aa07 rf7a074d  
    6666 
    6767    namespace ip = boost::interprocess; 
    68     const int max_message_size = 4096; 
     68    const int max_message_size = 40960; 
    6969    const std::string queue_name = "logging_queue"; 
    7070 
  • version.hpp

    r98113da rf7a074d  
    11#ifndef VERSION_HPP 
    22#define VERSION_HPP 
    3 #define PRODUCTVER     0,4,0,98 
    4 #define STRPRODUCTVER  "0,4,0,98" 
    5 #define STRPRODUCTDATE "2011-09-06" 
     3#define PRODUCTVER     0,4,0,107 
     4#define STRPRODUCTVER  "0,4,0,107" 
     5#define STRPRODUCTDATE "2011-11-06" 
    66#endif // VERSION_HPP 
  • version.txt

    r7515d00 rf7a074d  
    11version=0.4.0 
    2 build=98 
    3 date=2011-09-06 
     2build=107 
     3date=2011-11-06 
Note: See TracChangeset for help on using the changeset viewer.