Changeset 9853bc3 in nscp


Ignore:
Timestamp:
11/29/11 14:03:54 (18 months ago)
Author:
Michael Medin <michael@…>
Branches:
master, 0.4.0, 0.4.1, 0.4.2
Children:
f33c12f
Parents:
96c1461
Message:
  • Fixed some NSCA issues (reading from new conf)
  • Fixed some linux build issues (related to refactoring)
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • changelog

    r96c1461 r9853bc3  
    55 * Fixa dependonservice LanManWorkStation (old win) 
    66 * Fix RtlStringFromGUID problem on NT4 
     7 
     82011-11-27 MickeM 
     9 * Fixed some NSCA issues (reading from new conf) 
     10 * Fixed some linux build issues (related to refactoring) 
    711 
    8122011-11-27 MickeM 
  • modules/NRPEClient/NRPEClient.cpp

    r96c1461 r9853bc3  
    8282      ; 
    8383 
    84     settings.alias(_T("/targets/default")).add_key_to_settings() 
     84    settings.alias().add_key_to_settings(_T("targets/default")) 
    8585 
    8686      (_T("timeout"), sh::uint_key(&timeout, 30), 
     
    386386#else 
    387387      NSC_LOG_ERROR_STD(_T("SSL not avalible (compiled without USE_SSL)")); 
    388       return boost::tie(NSCAPI::returnUNKNOWN, _T("SSL support not available (compiled without USE_SSL)")); 
     388      return boost::make_tuple(NSCAPI::returnUNKNOWN, _T("SSL support not available (compiled without USE_SSL)")); 
    389389#endif 
    390390    } else 
     
    392392    return boost::make_tuple(static_cast<int>(packet.getResult()), packet.getPayload()); 
    393393  } catch (nrpe::nrpe_packet_exception &e) { 
    394     return boost::tie(NSCAPI::returnUNKNOWN, _T("NRPE Packet errro: ") + e.wwhat()); 
     394    return boost::make_tuple(NSCAPI::returnUNKNOWN, _T("NRPE Packet errro: ") + e.wwhat()); 
    395395  } catch (std::runtime_error &e) { 
    396396    NSC_LOG_ERROR_STD(_T("Socket error: ") + utf8::to_unicode(e.what())); 
    397     return boost::tie(NSCAPI::returnUNKNOWN, _T("Socket error: ") + utf8::to_unicode(e.what())); 
     397    return boost::make_tuple(NSCAPI::returnUNKNOWN, _T("Socket error: ") + utf8::to_unicode(e.what())); 
    398398  } catch (std::exception &e) { 
    399399    NSC_LOG_ERROR_STD(_T("Error: ") + utf8::to_unicode(e.what())); 
    400     return boost::tie(NSCAPI::returnUNKNOWN, _T("Error: ") + utf8::to_unicode(e.what())); 
     400    return boost::make_tuple(NSCAPI::returnUNKNOWN, _T("Error: ") + utf8::to_unicode(e.what())); 
    401401  } catch (...) { 
    402     return boost::tie(NSCAPI::returnUNKNOWN, _T("Unknown error -- REPORT THIS!")); 
     402    return boost::make_tuple(NSCAPI::returnUNKNOWN, _T("Unknown error -- REPORT THIS!")); 
    403403  } 
    404404} 
  • modules/NSCAClient/NSCAClient.cpp

    r96c1461 r9853bc3  
    9494      ; 
    9595 
    96     settings.alias(_T("/targets/default")).add_key_to_settings() 
     96    settings.alias().add_key_to_settings(_T("targets/default")) 
    9797 
    9898      (_T("timeout"), sh::uint_key(&timeout, 30), 
     
    441441  } catch (nsca::nsca_encrypt::encryption_exception &e) { 
    442442    NSC_LOG_ERROR_STD(_T("NSCA Error: ") + utf8::to_unicode(e.what())); 
    443     return boost::tie(NSCAPI::returnUNKNOWN, _T("NSCA error: ") + utf8::to_unicode(e.what())); 
     443    return boost::make_tuple(NSCAPI::returnUNKNOWN, _T("NSCA error: ") + utf8::to_unicode(e.what())); 
    444444  } catch (std::runtime_error &e) { 
    445445    NSC_LOG_ERROR_STD(_T("Socket error: ") + utf8::to_unicode(e.what())); 
    446     return boost::tie(NSCAPI::returnUNKNOWN, _T("Socket error: ") + utf8::to_unicode(e.what())); 
     446    return boost::make_tuple(NSCAPI::returnUNKNOWN, _T("Socket error: ") + utf8::to_unicode(e.what())); 
    447447  } catch (std::exception &e) { 
    448448    NSC_LOG_ERROR_STD(_T("Error: ") + utf8::to_unicode(e.what())); 
    449     return boost::tie(NSCAPI::returnUNKNOWN, _T("Error: ") + utf8::to_unicode(e.what())); 
     449    return boost::make_tuple(NSCAPI::returnUNKNOWN, _T("Error: ") + utf8::to_unicode(e.what())); 
    450450  } catch (...) { 
    451     return boost::tie(NSCAPI::returnUNKNOWN, _T("Unknown error -- REPORT THIS!")); 
     451    return boost::make_tuple(NSCAPI::returnUNKNOWN, _T("Unknown error -- REPORT THIS!")); 
    452452  } 
    453453} 
  • modules/NSCAClient/NSCAClient.h

    r96c1461 r9853bc3  
    5757    connection_data(nscapi::functions::destination_container recipient, nscapi::functions::destination_container sender) { 
    5858      timeout = recipient.get_int_data("timeout", 30); 
    59       buffer_length = recipient.get_int_data("payload length", 1024); 
     59      buffer_length = recipient.get_int_data("payload length", 512); 
    6060      password = recipient.get_string_data("password"); 
    6161      encryption = recipient.get_string_data("encryption"); 
  • modules/NSCPClient/NSCPClient.cpp

    r96c1461 r9853bc3  
    8787      ; 
    8888 
    89     settings.alias(_T("/targets/default")).add_key_to_settings() 
     89    settings.alias().add_key_to_settings(_T("targets/default")) 
    9090 
    9191      (_T("timeout"), sh::uint_key(&timeout, 30), 
  • modules/PythonScript/PythonScript.cpp

    rf7a074d r9853bc3  
    193193    if (!has_init) { 
    194194      has_init = true; 
     195      Py_Initialize(); 
    195196      PyEval_InitThreads(); 
    196       Py_Initialize(); 
     197 
     198        //PyThreadState *mainThreadState = PyThreadState_Get(); 
     199        //PyThreadState_Clear 
     200        //PyGILState_Release(mainThreadState); 
     201 
    197202      do_init = true; 
    198203    } 
    199204 
    200205    try { 
    201       script_wrapper::thread_locker locker; 
    202       try { 
    203  
    204         PyRun_SimpleString("import cStringIO"); 
    205         PyRun_SimpleString("import sys"); 
    206         PyRun_SimpleString("sys.stderr = cStringIO.StringIO()"); 
    207  
    208         if (do_init) 
    209           initNSCP(); 
    210  
    211         BOOST_FOREACH(script_container &script, scripts_) { 
    212           instances_.push_back(boost::shared_ptr<python_script>(new python_script(get_id(), utf8::cvt<std::string>(alias), script))); 
     206      { 
     207        script_wrapper::thread_locker locker; 
     208        try { 
     209 
     210          PyRun_SimpleString("import cStringIO"); 
     211          PyRun_SimpleString("import sys"); 
     212          PyRun_SimpleString("sys.stderr = cStringIO.StringIO()"); 
     213 
     214          if (do_init) 
     215            initNSCP(); 
     216 
     217        } catch( error_already_set e) { 
     218          script_wrapper::log_exception(); 
    213219        } 
    214220 
    215       } catch( error_already_set e) { 
    216         script_wrapper::log_exception(); 
    217221      } 
     222      BOOST_FOREACH(script_container &script, scripts_) { 
     223        instances_.push_back(boost::shared_ptr<python_script>(new python_script(get_id(), utf8::cvt<std::string>(alias), script))); 
     224      } 
     225      PyEval_ReleaseLock(); 
     226 
    218227    } catch (std::exception &e) { 
    219228      NSC_LOG_ERROR_STD(_T("Exception: Failed to load python scripts: ") + utf8::cvt<std::wstring>(e.what())); 
  • modules/Scheduler/Scheduler.cpp

    rf7a074d r9853bc3  
    158158    std::string response; 
    159159    NSCAPI::nagiosReturn code = GET_CORE()->simple_query(item.command.c_str(), item.arguments, response); 
    160     if (nscapi::report::matches(item.report, code)) { 
     160    if (code == NSCAPI::returnIgnored) { 
     161      NSC_LOG_ERROR_STD(_T("Command was not found: ") + item.command.c_str()); 
     162      nscapi::functions::create_simple_submit_request(item.channel, item.command, NSCAPI::returnUNKNOWN, _T("Command was not found: ") + item.command, _T(""), response); 
     163      std::string result; 
     164      GET_CORE()->submit_message(item.channel, response, result); 
     165    } else if (nscapi::report::matches(item.report, code)) { 
    161166      // @todo: allow renaming of commands here item.alias,  
    162167      // @todo this is broken, fix this (uses the wrong message) 
  • modules/SyslogClient/SyslogClient.cpp

    r96c1461 r9853bc3  
    115115      ; 
    116116 
    117     settings.alias(_T("/targets/default")).add_key_to_settings() 
     117    settings.alias().add_key_to_settings(_T("targets/default")) 
    118118 
    119119      (_T("severity"), sh::wpath_key(&severity, _T("error")), 
     
    430430  } catch (std::runtime_error &e) { 
    431431    NSC_LOG_ERROR_STD(_T("Socket error: ") + utf8::to_unicode(e.what())); 
    432     return boost::tie(NSCAPI::returnUNKNOWN, _T("Socket error: ") + utf8::to_unicode(e.what())); 
     432    return boost::make_tuple(NSCAPI::returnUNKNOWN, _T("Socket error: ") + utf8::to_unicode(e.what())); 
    433433  } catch (std::exception &e) { 
    434434    NSC_LOG_ERROR_STD(_T("Error: ") + utf8::to_unicode(e.what())); 
    435     return boost::tie(NSCAPI::returnUNKNOWN, _T("Error: ") + utf8::to_unicode(e.what())); 
     435    return boost::make_tuple(NSCAPI::returnUNKNOWN, _T("Error: ") + utf8::to_unicode(e.what())); 
    436436  } catch (...) { 
    437     return boost::tie(NSCAPI::returnUNKNOWN, _T("Unknown error -- REPORT THIS!")); 
     437    return boost::make_tuple(NSCAPI::returnUNKNOWN, _T("Unknown error -- REPORT THIS!")); 
    438438  } 
    439439} 
Note: See TracChangeset for help on using the changeset viewer.