Changeset a87ce04 in nscp for service/NSClient++.cpp


Ignore:
Timestamp:
01/08/12 22:29:34 (18 months ago)
Author:
Michael Medin <michael@…>
Branches:
master, 0.4.0, 0.4.1, 0.4.2
Children:
7354aa1
Parents:
81a6048
Message:
  • Fixed some issues in the NRPE decoder
  • Added support for forwarding queries (ie. xxx_forward) mainly usefull for python(?) scripts where we can now handconstruct messages for delivery
  • Added NRPE unit tests (52 of them)
  • Fixed process enumeration API for 64/32 bit
File:
1 edited

Legend:

Unmodified
Added
Removed
  • service/NSClient++.cpp

    rf085f9b ra87ce04  
    12071207} 
    12081208int query_helper(NSClientT::plugin_type plugin, std::wstring command, std::vector<std::wstring> arguments, std::string request, std::list<std::string> *responses) { 
    1209   std::string response; 
    1210   if (!plugin->hasCommandHandler()) 
    1211     return NSCAPI::returnIgnored; 
    1212   int ret = plugin->handleCommand(command.c_str(), request, response); 
    1213   if (ret != NSCAPI::returnIgnored && !response.empty()) 
    1214     responses->push_back(response); 
    1215   return ret; 
     1209  return NSCAPI::returnIgnored; 
     1210//  std::string response; 
     1211//  if (!plugin->hasCommandHandler()) 
     1212//    return NSCAPI::returnIgnored; 
     1213//  int ret = plugin->handleCommand(command.c_str(), request, response); 
     1214//  if (ret != NSCAPI::returnIgnored && !response.empty()) 
     1215//    responses->push_back(response); 
     1216//  return ret; 
    12161217} 
    12171218 
     
    12231224  int ret = load_and_run(module, boost::bind(&query_helper, _1, command, arguments, request, &responses), errors); 
    12241225 
    1225   BOOST_FOREACH(std::string &r, responses) { 
    1226     try { 
    1227       std::wstring msg, perf; 
    1228       nscapi::functions::parse_simple_query_response(r, msg, perf); 
    1229       resp.push_back(msg + _T("|") + perf); 
    1230     } catch (std::exception &e) { 
    1231       resp.push_back(_T("Failed to extract return message: ") + utf8::cvt<std::wstring>(e.what())); 
    1232       LOG_ERROR_CORE_STD(resp.back()); 
    1233       return NSCAPI::returnUNKNOWN; 
    1234     } 
     1226  nsclient::commands::plugin_type plugin = commands_.get(command); 
     1227  if (!plugin) { 
     1228    LOG_ERROR_CORE(_T("No handler for command: ") + command + _T(" avalible commands: ") + commands_.to_wstring()); 
     1229    return NSCAPI::returnUNKNOWN; 
     1230  } 
     1231  std::string response; 
     1232  NSCAPI::nagiosReturn c = plugin->handleCommand(command.c_str(), request, response); 
     1233  try { 
     1234    std::wstring msg, perf; 
     1235    nscapi::functions::parse_simple_query_response(response, msg, perf); 
     1236    resp.push_back(msg + _T("|") + perf); 
     1237  } catch (std::exception &e) { 
     1238    resp.push_back(_T("Failed to extract return message: ") + utf8::cvt<std::wstring>(e.what())); 
     1239    LOG_ERROR_CORE_STD(resp.back()); 
     1240    return NSCAPI::returnUNKNOWN; 
    12351241  } 
    12361242  BOOST_FOREACH(const std::wstring &e, errors) { 
Note: See TracChangeset for help on using the changeset viewer.