Changeset 8840f09 in nscp


Ignore:
Timestamp:
08/26/11 13:40:23 (21 months ago)
Author:
Michael Medin <michael@…>
Branches:
master, 0.4.0, 0.4.1, 0.4.2
Children:
60e6c18
Parents:
d7e265d
Message:
  • Fixed some issues in the NSCPClient
  • Fixed debug log issue in core
  • Added support for "pushing" passive checks via NSCP
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • changelog

    rd7e265d r8840f09  
    66 * Fix RtlStringFromGUID problem on NT4 
    77 
     82011-08-25 MickeM 
     9 * Fixed some issues in the NSCPClient 
     10 * Fixed debug log issue in core 
     11 * Added support for "pushing" passive checks via NSCP 
     12 
    8132011-08-24 MickeM 
    914 * Sever refactoring of the new API (there is now two pb files ipc for NSCP protocol and plugin for plugin communication) 
     
    1116 * Fixed client argument for "client mode" to allow arbitrary arguments 
    1217 * Cleaned up the argument processor code now requires "mode" to be first argument 
    13  * Fixed some issues in the NSCPClient 
    1418 
    15192011-08-23 MickeM 
  • include/nscapi/macros.hpp

    r65a2940 r8840f09  
    216216    NSCAPI::nagiosReturn retCode = (&toObject)->commandRAWLineExec(command, request, response); \ 
    217217    return GET_PLUGIN()->wrapCommandLineExec(retCode, response, response_buffer, response_len); \ 
     218    } catch (const std::exception &e) { \ 
     219    NSC_LOG_CRITICAL(_T("Exception in: commandLineExec(...)") + utf8::cvt<std::wstring>(e.what())); \ 
     220      std::wcerr << _T("Exception in: commandLineExec(...)") << utf8::cvt<std::wstring>(e.what()) << std::endl; \ 
     221      return NSCAPI::hasFailed; \ 
    218222    } catch (...) { \ 
    219223      NSC_LOG_CRITICAL(_T("Unknown exception in: commandLineExec(...)")); \ 
  • include/nscp/client/socket.hpp

    rd7e265d r8840f09  
    6262      writer->start_timer(timeout); 
    6363      BOOST_FOREACH(const nscp::packet &chunk, chunks) { 
     64        std::wcout << _T(">>>") << chunk.signature.to_wstring() << std::endl; 
    6465        if (!writer->write_and_wait(*socket_, get_socket(), boost::asio::buffer(chunk.to_buffer()))) { 
    6566          std::cout << "FaILED TO SEND DATA..." << std::endl; 
     
    8485        } 
    8586        chunk.read_signature(buf); 
    86         std::wcout << chunk.signature.to_wstring() << std::endl; 
     87        std::wcout << _T("<<<") << chunk.signature.to_wstring() << std::endl; 
    8788        buf.resize(chunk.signature.payload_length); 
    8889 
     
    138139      writer->start_timer(timeout); 
    139140      BOOST_FOREACH(const nscp::packet &chunk, chunks) { 
     141        std::wcout << _T(">>>") << chunk.signature.to_wstring() << std::endl; 
    140142        if (!writer->write_and_wait(*ssl_socket_, get_socket(), boost::asio::buffer(chunk.to_buffer()))) { 
    141143          std::cout << "FaILED TO SEND DATA..." << std::endl; 
     
    161163        } 
    162164        chunk.read_signature(buf); 
    163         std::wcout << chunk.signature.to_wstring() << std::endl; 
     165        std::wcout << _T("<<<") <<  chunk.signature.to_wstring() << std::endl; 
    164166        buf.resize(chunk.signature.payload_length); 
    165167 
  • include/nscp/packet.hpp

    rd7e265d r8840f09  
    8181      } 
    8282 
    83       std::wstring to_wstring() { 
     83      std::wstring to_wstring() const { 
    8484        std::wstringstream ss; 
    8585        ss << _T("version: ") << version  
     
    179179    } 
    180180 
     181    static packet build_envelope_response(unsigned long additionl_packets) { 
     182      nscp::data::signature_packet signature; 
     183      signature.header_length = 0; 
     184      signature.header_type = 0; 
     185 
     186      signature.additional_packet_count = additionl_packets; 
     187      signature.version = nscp::data::version_1; 
     188 
     189      std::string buffer; 
     190      NSCPIPC::RequestEnvelope request_envelope; 
     191      request_envelope.set_version(NSCPIPC::Common_Version_VERSION_1); 
     192      request_envelope.set_max_supported_version(NSCPIPC::Common_Version_VERSION_1); 
     193      request_envelope.SerializeToString(&buffer); 
     194 
     195      signature.payload_length = buffer.size(); 
     196      signature.payload_type = nscp::data::envelope_response; 
     197 
     198      return packet(signature, "", buffer); 
     199    } 
     200 
    181201    static nscp::data::signature_packet create_simple_sig(int payload_type, std::string::size_type size) { 
    182202      nscp::data::signature_packet signature; 
     
    228248      return packet(signature, "", buffer); 
    229249    } 
    230     bool is_command_request() { 
     250    bool is_envelope_request() { 
     251      return signature.payload_type == nscp::data::envelope_request; 
     252    } 
     253    bool is_envelope_response() { 
     254      return signature.payload_type == nscp::data::envelope_response; 
     255    } 
     256    bool is_query_request() { 
    231257      return signature.payload_type == nscp::data::command_request; 
    232258    } 
    233     bool is_command_response() { 
     259    bool is_query_response() { 
     260      return signature.payload_type == nscp::data::command_response; 
     261    } 
     262    bool is_submit_message() { 
    234263      return signature.payload_type == nscp::data::command_response; 
    235264    } 
  • include/nscp/server/connection.cpp

    rb38e845 r8840f09  
    8787          start_read_request(buffer_, 30, helper); 
    8888        } else { 
    89           if (outbound_queue_.size() > 0) 
    90             outbound_queue_.push_front(nscp::packet::build_envelope_request(1)); 
    91  
    9289          unsigned int count = outbound_queue_.size(); 
    93           handler_->log_debug(__FILE__, __LINE__, _T("Sending responses: ") + strEx::itos(count)); 
     90          outbound_queue_.push_front(nscp::packet::build_envelope_response(count)); 
    9491          BOOST_FOREACH(nscp::packet &chunk, outbound_queue_) { 
    95             chunk.signature.additional_packet_count = --count; 
     92            chunk.signature.additional_packet_count = count--; 
    9693            std::string s = chunk.to_buffer(); 
    97             handler_->log_debug(__FILE__, __LINE__, _T("Sending: ") + chunk.signature.to_wstring()); 
    98             handler_->log_debug(__FILE__, __LINE__, _T("Sending: ") + utf8::cvt<std::wstring>(strEx::format_buffer(s.c_str(), s.size()))); 
    99 /* 
    100             std::vector<boost::asio::const_buffer> buffers; 
    101             response_buffers_.push_back(buf(s)); 
    102             start_write_request(buffers); 
    103  
    104 */ 
     94            handler_->log_debug(__FILE__, __LINE__, _T(">>>") + chunk.signature.to_wstring()); 
    10595            response_buffers_.push_back(buf(s)); 
    10696          } 
     
    116106      sig = parser_.parse_signature(); 
    117107 
    118       handler_->log_debug(__FILE__, __LINE__, _T("Got signature with: ") + strEx::itos(sig.payload_length)); 
     108      handler_->log_debug(__FILE__, __LINE__, _T("<<<") + sig.to_wstring()); 
    119109      if (sig.header_length > 0) { 
    120110        // @todo read header 
     
    125115 
    126116    boost::tuple<bool, connection::process_helper> connection::process_payload() { 
    127       nscp::packet chunk(sig); 
    128       parser_.parse_payload(chunk); 
    129       handler_->log_debug(__FILE__, __LINE__, _T("Processing: ") + chunk.to_wstring()); 
    130       std::list<nscp::packet> result = handler_->process(chunk); 
    131       outbound_queue_.insert(outbound_queue_.end(), result.begin(), result.end()); 
    132       /* 
     117      nscp::packet packet(sig); 
     118      parser_.parse_payload(packet); 
    133119      if (sig.payload_type == nscp::data::envelope_request) { 
    134         NSCPEnvelope::Request envelope; 
    135         envelope.ParseFromString(result); 
    136         handler_->log_debug(__FILE__, __LINE__, _T("Got envelope: ") + strEx::itos(envelope.version())); 
    137       } else if (sig.payload_type == nscp::data::command_request) { 
    138         PluginCommand::RequestMessage msg; 
    139         msg.ParseFromString(result); 
    140         handler_->log_debug(__FILE__, __LINE__, _T("Proessing command: ") + utf8::cvt<std::wstring>(msg.payload(0).command())); 
    141         outbound_queue_.push_back(nscp::packet::build_payload(nscp::data::command_response, handler_->process(result), 0)); 
     120        NSCPIPC::RequestEnvelope envelope; 
     121        envelope.ParseFromString(packet.payload); 
    142122      } else { 
    143         handler_->log_error(__FILE__, __LINE__, _T("Unhandled packet: ") + strEx::itos(sig.payload_type)); 
     123        std::list<nscp::packet> result = handler_->process(packet); 
     124        outbound_queue_.insert(outbound_queue_.end(), result.begin(), result.end()); 
    144125      } 
    145       */ 
    146126      return boost::make_tuple(sig.additional_packet_count > 0, process_helper(&nscp::server::parser::digest_signature, &connection::process_signature)); 
    147127    } 
  • modules/NSCPClient/NSCPClient.cpp

    rd7e265d r8840f09  
    5454 
    5555    get_core()->registerCommand(_T("query_nscp"), _T("Submit a query to a remote host via NSCP")); 
     56    get_core()->registerCommand(_T("submit_nscp"), _T("Submit a query to a remote host via NSCP")); 
    5657    //"/settings/NSCP/client/handlers" 
    5758    sh::settings_registry settings(get_settings_proxy()); 
     
    9596} 
    9697 
    97 void NSCPClient::add_options(po::options_description &desc, nscp_connection_data &command_data) { 
     98void NSCPClient::add_common_options(po::options_description &desc, nscp_connection_data &command_data) { 
    9899  desc.add_options() 
    99100    ("host,H", po::wvalue<std::wstring>(&command_data.host), "The address of the host running the NSCP daemon") 
    100101    ("port,p", po::value<int>(&command_data.port), "The port on which the daemon is running (default=5668)") 
     102    ("timeout,t", po::value<int>(&command_data.timeout), "Number of seconds before connection times out (default=10)") 
     103    ("no-ssl,n", po::value<bool>(&command_data.no_ssl)->zero_tokens()->default_value(false), "Do not initial an ssl handshake with the server, talk in plain text.") 
     104    ("query,q", po::bool_switch(&command_data.query), "Force query mode (only useful when this is not obvious)") 
     105    ("submit,s", po::bool_switch(&command_data.submit), "Force submit mode (only useful when this is not obvious)") 
     106    ; 
     107} 
     108void NSCPClient::add_query_options(po::options_description &desc, nscp_connection_data &command_data) { 
     109  desc.add_options() 
    101110    ("command,c", po::wvalue<std::wstring>(&command_data.command), "The name of the command that the remote daemon should run") 
    102     ("timeout,t", po::value<int>(&command_data.timeout), "Number of seconds before connection times out (default=10)") 
    103     ("no-ssl,n", po::value<bool>(&command_data.no_ssl)->zero_tokens()->default_value(false), "Do not initial an ssl handshake with the server, talk in plaintext.") 
    104111    ("arguments,a", po::wvalue<std::vector<std::wstring> >(&command_data.arguments), "list of arguments") 
    105112    ; 
    106113} 
     114void NSCPClient::add_submit_options(po::options_description &desc, nscp_connection_data &command_data) { 
     115  desc.add_options() 
     116    ("command,c", po::wvalue<std::wstring>(&command_data.command), "The name of the command that the remote daemon should run") 
     117    ("message,m", po::wvalue<std::wstring>(&command_data.message), "Message") 
     118    ("result,r", po::value<unsigned int>(&command_data.result), "Result code") 
     119    ; 
     120} 
    107121 
    108122void NSCPClient::add_server(std::wstring key, std::wstring args) { 
     
    115129    boost::program_options::variables_map vm; 
    116130 
    117     po::options_description desc("Allowed options"); 
    118     add_options(desc, command_data); 
     131    po::options_description common("Common options"); 
     132    add_common_options(common, command_data); 
     133    po::options_description query("Query options"); 
     134    add_query_options(query, command_data); 
     135    po::options_description submit("Submit options"); 
     136    add_submit_options(submit, command_data); 
    119137 
    120138    po::positional_options_description p; 
     
    130148    } 
    131149 
     150    po::options_description desc("Availible options"); 
     151    desc.add(common).add(query).add(submit); 
    132152    po::wparsed_options parsed = po::basic_command_line_parser<wchar_t>(list).options(desc).positional(p).run(); 
    133153    po::store(parsed, vm); 
     
    169189      std::string line = payload.message(); 
    170190 
    171       // @todo: Add performance data parsin here! 
     191      // @todo: Add performance data parsing here! 
    172192      //nscapi::functions::parse_performance_data(payload, perf); 
    173193      //if (!payload.perf().empty()) 
     
    182202NSCAPI::nagiosReturn NSCPClient::handleCommand(const std::wstring &target, const std::wstring &command, std::list<std::wstring> &arguments, std::wstring &message, std::wstring &perf) { 
    183203  if (command == _T("query_nscp")) { 
     204    return query_nscp(arguments, message, perf); 
     205  } 
     206  if (command == _T("submit_nscp")) { 
    184207    return query_nscp(arguments, message, perf); 
    185208  } 
     
    205228    boost::program_options::variables_map vm; 
    206229 
     230    po::options_description common("Common options"); 
     231    add_common_options(common, command_data); 
     232    po::options_description query("Query options"); 
     233    add_query_options(query, command_data); 
     234 
    207235    po::options_description desc("Allowed options"); 
    208     add_options(desc, command_data); 
     236    desc.add(common).add(query); 
    209237 
    210238    std::vector<std::wstring> vargs(arguments.begin(), arguments.end()); 
     
    235263} 
    236264 
    237 int NSCPClient::commandLineExec(const std::wstring &command, std::list<std::wstring> &arguments, std::wstring &result) { 
    238   if (command != _T("query_nscp") && command != _T("help")) 
    239     return NSCAPI::returnIgnored; 
     265bool NSCPClient::submit_nscp(std::list<std::wstring> &arguments, std::wstring &result) { 
    240266  try { 
    241267    NSCPClient::nscp_connection_data command_data; 
    242268    boost::program_options::variables_map vm; 
    243269 
     270    po::options_description common("Common options"); 
     271    add_common_options(common, command_data); 
     272    po::options_description submit("Submit options"); 
     273    add_submit_options(submit, command_data); 
     274 
    244275    po::options_description desc("Allowed options"); 
    245     add_options(desc, command_data); 
     276    desc.add(common).add(submit); 
    246277 
    247278    std::vector<std::wstring> vargs(arguments.begin(), arguments.end()); 
     
    252283    po::notify(vm); 
    253284 
    254     if (command == _T("help")) { 
    255       std::stringstream ss; 
    256       ss << "NSCPClient Command line syntax for command: query" << std::endl;; 
    257       ss << desc; 
    258       result = utf8::cvt<std::wstring>(ss.str()); 
    259       return NSCAPI::returnOK; 
    260     } 
     285 
     286    std::string buffer; 
     287    nscapi::functions::create_simple_query_response(command_data.command, command_data.result, command_data.message, _T(""), buffer); 
     288    std::list<std::string> errors = submit_nscp_command(command_data, buffer); 
     289     
     290    BOOST_FOREACH(std::string e, errors) { 
     291      result += utf8::cvt<std::wstring>(e) + _T("\n"); 
     292    } 
     293  } catch (boost::program_options::validation_error &e) { 
     294    result = _T("Error: ") + utf8::cvt<std::wstring>(e.what()); 
     295    return false; 
     296  } catch (...) { 
     297    result = _T("Unknown exception parsing command line"); 
     298    return false; 
     299  } 
     300  return true; 
     301} 
     302 
     303 
     304int NSCPClient::commandLineExec(const std::wstring &command, std::list<std::wstring> &arguments, std::wstring &result) { 
     305  NSCPClient::nscp_connection_data command_data; 
     306  if (command == _T("help")) { 
     307    po::options_description common("Common options"); 
     308    add_common_options(common, command_data); 
     309    po::options_description query("Query NSCP options"); 
     310    add_query_options(query, command_data); 
     311    po::options_description submit("Submit NSCP options"); 
     312    add_submit_options(submit, command_data); 
     313    po::options_description desc("Allowed options"); 
     314    desc.add(common).add(query).add(submit); 
     315 
     316    std::stringstream ss; 
     317    ss << "NSCPClient Command line syntax for command: query_nscp and submit_nscp" << std::endl;; 
     318    ss << desc; 
     319    result = utf8::cvt<std::wstring>(ss.str()); 
     320    return NSCAPI::returnOK; 
     321  } else if (command == _T("query_nscp")) { 
     322    boost::program_options::variables_map vm; 
     323 
     324    po::options_description common("Common options"); 
     325    add_common_options(common, command_data); 
     326    po::options_description query("Query NSCP options"); 
     327    add_query_options(query, command_data); 
     328    po::options_description desc("Allowed options"); 
     329    desc.add(common).add(query); 
     330 
     331    std::vector<std::wstring> vargs(arguments.begin(), arguments.end()); 
     332    po::positional_options_description p; 
     333    p.add("arguments", -1); 
     334    po::wparsed_options parsed = po::basic_command_line_parser<wchar_t>(vargs).options(desc).positional(p).run(); 
     335    po::store(parsed, vm); 
     336    po::notify(vm); 
    261337 
    262338    std::string buffer; 
     
    264340    std::list<std::string> payloads = execute_nscp_command(command_data, buffer); 
    265341    int ret = NSCAPI::returnUNKNOWN; 
    266     BOOST_FOREACH(std::string p, collect_result(payloads, ret)) { 
     342    std::list<std::string> strings = collect_result(payloads, ret); 
     343    BOOST_FOREACH(std::string p, strings) { 
    267344      result += utf8::cvt<std::wstring>(p) + _T("\n"); 
    268345    } 
    269346    return ret; 
    270   } catch (std::exception &e) { 
    271     result = _T("Error: ") + utf8::cvt<std::wstring>(e.what()); 
    272     return NSCAPI::returnUNKNOWN; 
    273   } catch (...) { 
    274     result = _T("Unknown exception processing request"); 
    275     return NSCAPI::returnUNKNOWN; 
    276   } 
    277   return NSCAPI::returnUNKNOWN; 
     347  } else if (command == _T("submit_nscp")) { 
     348    boost::program_options::variables_map vm; 
     349 
     350    po::options_description common("Common options"); 
     351    add_common_options(common, command_data); 
     352    po::options_description submit("Submit  NSCP options"); 
     353    add_submit_options(submit, command_data); 
     354    po::options_description desc("Allowed options"); 
     355    desc.add(common).add(submit); 
     356 
     357    std::vector<std::wstring> vargs(arguments.begin(), arguments.end()); 
     358    po::positional_options_description p; 
     359    p.add("arguments", -1); 
     360    po::wparsed_options parsed = po::basic_command_line_parser<wchar_t>(vargs).options(desc).positional(p).run(); 
     361    po::store(parsed, vm); 
     362    po::notify(vm); 
     363 
     364    std::string buffer; 
     365    nscapi::functions::create_simple_query_response(command_data.command, command_data.result, command_data.message, _T(""), buffer); 
     366    std::list<std::string> errors = submit_nscp_command(command_data, buffer); 
     367    BOOST_FOREACH(std::string p, errors) { 
     368      result += utf8::cvt<std::wstring>(p) + _T("\n"); 
     369    } 
     370    return NSCAPI::returnOK; 
     371  } 
     372  return NSCAPI::returnIgnored; 
    278373} 
    279374std::list<std::string> NSCPClient::execute_nscp_command(nscp_connection_data con, std::string buffer) { 
     
    285380    chunks = send(con, chunks); 
    286381    BOOST_FOREACH(nscp::packet &chunk, chunks) { 
    287       if (chunk.is_command_response()) { 
     382      if (chunk.is_query_response()) { 
    288383        result.push_back(chunk.payload); 
    289384      } else if (chunk.is_error()) { 
     
    305400} 
    306401 
    307 std::list<nscp::packet> NSCPClient::send(nscp_connection_data &con, const std::list<nscp::packet> &chunks) { 
    308   std::list<nscp::packet> result; 
     402std::list<std::string> NSCPClient::submit_nscp_command(nscp_connection_data con, std::string buffer) { 
     403  std::list<std::string> result; 
     404  try { 
     405    std::list<nscp::packet> chunks; 
     406    chunks.push_back(nscp::packet::create_payload(nscp::data::command_response, buffer, 0)); 
     407    chunks = send(con, chunks); 
     408    BOOST_FOREACH(nscp::packet &chunk, chunks) { 
     409      if (chunk.is_query_response()) { 
     410        result.push_back(chunk.payload); 
     411      } else if (chunk.is_error()) { 
     412        NSCPIPC::ErrorMessage message; 
     413        message.ParseFromString(chunk.payload); 
     414        for (int i=0;i<message.error_size();i++) { 
     415          result.push_back("Error: " + message.error(i).message()); 
     416        } 
     417      } else { 
     418        NSC_LOG_ERROR_STD(_T("Unsupported message type: ") + strEx::itos(chunk.signature.payload_type)); 
     419      } 
     420      //NSC_DEBUG_MSG_STD(_T("Found chunk: ") + utf8::cvt<std::wstring>(strEx::format_buffer(chunk.payload.c_str(), chunk.payload.size()))); 
     421    } 
     422    return result; 
     423  } catch (std::exception &e) { 
     424    NSC_LOG_ERROR_STD(_T("Exception: ") + utf8::cvt<std::wstring>(e.what())); 
     425    return result; 
     426  } 
     427} 
     428 
     429std::list<nscp::packet> NSCPClient::send(nscp_connection_data &con, std::list<nscp::packet> &chunks) { 
     430  chunks.push_front(nscp::packet::build_envelope_request(1)); 
     431  std::list<nscp::packet> tmp, result; 
    309432  if (!con.no_ssl) { 
    310433#ifdef USE_SSL 
    311     result = send_ssl(con.host, con.port, con.timeout, chunks); 
     434    tmp = send_ssl(con.host, con.port, con.timeout, chunks); 
    312435#else 
    313436    NSC_LOG_ERROR_STD(_T("SSL not avalible (not compiled with USE_SSL)")); 
     
    315438#endif 
    316439  } else { 
    317     result = send_nossl(con.host, con.port, con.timeout, chunks); 
     440    tmp = send_nossl(con.host, con.port, con.timeout, chunks); 
     441  } 
     442  BOOST_FOREACH(nscp::packet &p, tmp) { 
     443    if (p.is_envelope_response()) { 
     444      std::cout << "Got envelope" << std::endl; 
     445    } else { 
     446      result.push_back(p); 
     447    } 
    318448  } 
    319449  return result; 
  • modules/NSCPClient/NSCPClient.h

    rd7e265d r8840f09  
    3434    std::wstring command; 
    3535    std::wstring command_line; 
     36    std::wstring message; 
     37    unsigned int result; 
     38    bool submit; 
     39    bool query; 
    3640    std::vector<std::wstring> arguments; 
    3741    int port; 
     
    4246      port(5668),  
    4347      timeout(10),  
    44       no_ssl(false) 
     48      no_ssl(false), 
     49      submit(false), 
     50      query(false) 
    4551    {} 
    4652    std::wstring toString() { 
     
    5157      ss << _T(", no_ssl: ") << no_ssl; 
    5258      ss << _T(", command: ") << command; 
     59      ss << _T(", message: ") << message; 
     60      ss << _T(", result: ") << result; 
    5361      int i=0; 
    5462      BOOST_FOREACH(std::wstring a, arguments) { 
     
    98106 
    99107private: 
     108  std::list<std::string> submit_nscp_command(nscp_connection_data con, std::string buffer); 
    100109  std::list<std::string> execute_nscp_command(nscp_connection_data con, std::string buffer); 
    101   std::list<nscp::packet> send(nscp_connection_data &con, const std::list<nscp::packet> &chunks); 
     110  std::list<nscp::packet> send(nscp_connection_data &con, std::list<nscp::packet> &chunks); 
    102111  std::list<nscp::packet> send_nossl(std::wstring host, int port, int timeout, const std::list<nscp::packet> &chunks); 
    103112  std::list<nscp::packet> send_ssl(std::wstring host, int port, int timeout, const std::list<nscp::packet> &chunks); 
    104   void add_options(po::options_description &desc, nscp_connection_data &command_data); 
     113  void add_common_options(po::options_description &desc, nscp_connection_data &command_data); 
     114  void add_query_options(po::options_description &desc, nscp_connection_data &command_data); 
     115  void add_submit_options(po::options_description &desc, nscp_connection_data &command_data); 
    105116 
    106117  NSCAPI::nagiosReturn query_nscp(std::list<std::wstring> &arguments, std::wstring &message, std::wstring perf); 
     118  bool submit_nscp(std::list<std::wstring> &arguments, std::wstring &result); 
    107119 
    108120private: 
  • modules/NSCPServer/handler_impl.cpp

    rd7e265d r8840f09  
    1212  Plugin::Common::Header hdr; 
    1313 
    14   if (packet.is_command_request()) { 
     14  if (packet.is_query_request()) { 
    1515    Plugin::QueryRequestMessage msg; 
    1616    msg.ParseFromString(packet.payload); 
     
    5555      result.push_back(nscp::packet::create_query_response(outBuffer)); 
    5656    } 
     57  } else if (packet.is_query_response()) { 
     58 
     59    // @todo handle submission here 
     60 
    5761  } else { 
    5862    NSC_LOG_ERROR(_T("Unknown packet: ") + packet.to_wstring()); 
  • service/NSClient++.cpp

    rb38e845 r8840f09  
    7979#define LOG_INFO_CORE(msg) { std::string s = nsclient::logger_helper::create_info(__FILE__, __LINE__, msg); mainClient.reportMessage(s); } 
    8080#define LOG_INFO_CORE_STD(msg) LOG_INFO_CORE(std::wstring(msg)) 
    81 #define LOG_DEBUG_CORE(msg) { std::string s = nsclient::logger_helper::create_debug(__FILE__, __LINE__, msg); mainClient.reportMessage(s); } 
     81#define LOG_DEBUG_CORE(msg) { if (mainClient.logDebug()) { std::string s = nsclient::logger_helper::create_debug(__FILE__, __LINE__, msg); mainClient.reportMessage(s); } } 
    8282#define LOG_DEBUG_CORE_STD(msg) LOG_DEBUG_CORE(std::wstring(msg)) 
    8383 
Note: See TracChangeset for help on using the changeset viewer.