Changeset 682ccd2 in nscp


Ignore:
Timestamp:
04/11/12 18:34:18 (13 months ago)
Author:
Michael Medin <michael@…>
Branches:
master, 0.4.0, 0.4.1, 0.4.2
Children:
6533c1a
Parents:
440c0cb
Message:
  • Fixed crash in new logger
  • Fixed a few command line parsing issues (most notably test and --log-to-file)
  • Changed default location for process dumps to be a non-elevated location (under common-appdata).
  • Fixed (ish) check_nt issue (check_nt really really is broken... this will probably cause problems with people sending large payloads though)
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • changelog

    r440c0cb r682ccd2  
    44 * Fixa dependonservice LanManWorkStation (old win) 
    55 * Fix RtlStringFromGUID problem on NT4 
     6 
     72012-04-10 MickeM 
     8 * Fixed crash in new logger 
     9 * Fixed a few command line parsing issues (most notably test and --log-to-file) 
     10 * Changed default location for process dumps to be a non-elevated location (under common-appdata). 
     11 * Fixed (ish) check_nt issue (check_nt really really is broken... this will probably cause problems with people sending large payloads though) 
     12  
     132012-04-06 MickeM 
     14 * Easter break! 
    615 
    7162012-04-04 MickeM 
     
    23322012-03-27 MickeM 
    2433 * Removed some annoying "error" messages 
    25  * Tweaked FGileLogger a bit to be more "modern" 
     34 * Tweaked FileLogger a bit to be more "modern" 
    2635 * Changed so file-name expansion is more efficient 
    2736 * Changed so modules are defaulted to 0 in config. 
    28  * Log levels are case sensetive 
     37 * Log levels are case sensitive 
    2938 * Fixed so log level is not read from ini file 
    3039 * improved plugin processing from ini files 
     
    32412012-03-26 MickeM 
    3342 * Fixed perfoamcen data parsing issue 
    34  * Fixed external scripts perfoamcen data issue 
     43 * Fixed external scripts performance data issue 
    3544 * Fixed boolen flag handling in settings (default generated as false regardless of actual state) 
    3645 * Fixed so "advanced properties" are not generated with --update-defalts 
  • files/old-settings.map

    r8d89d7a r682ccd2  
    5353NRPE/allow_arguments=/settings/NRPE/server/allow arguments 
    5454NRPE/allow_nasty_meta_chars=/settings/NRPE/server/allow nasty characters 
    55 NRPE/use_ssl=/settings/NRPE/server/ssl 
     55NRPE/use_ssl=/settings/NRPE/server/use ssl 
    5656# NRPE/script_dir 
    5757 
  • include/check_nt/server/parser.hpp

    re1d9a58 r682ccd2  
    2121          buffer_.push_back(*begin); 
    2222          if (*begin == '\n') { 
    23             found = true; 
    2423            break; 
    2524          } 
    2625        } 
    27         return boost::make_tuple(found, begin); 
     26        return boost::make_tuple(true, begin); 
    2827      } 
    2928 
  • include/concurrent_queue.hpp

    r8d89d7a r682ccd2  
    4242    } 
    4343 
    44     popped_value=queue_.front(); 
    45     queue_.pop(); 
     44    if (!queue_.empty()) { 
     45      popped_value=queue_.front(); 
     46      queue_.pop(); 
     47    } 
    4648  } 
    4749 
  • include/settings/settings_old.hpp

    r8d89d7a r682ccd2  
    120120        key_map::iterator it1 = keys_.find(new_key); 
    121121        if (it1 != keys_.end()) { 
    122           get_logger()->debug(__FILE__, __LINE__, new_key.first + _T(".") + new_key.second + _T(" found in alias list")); 
     122          //get_logger()->debug(__FILE__, __LINE__, new_key.first + _T(".") + new_key.second + _T(" found in alias list")); 
    123123          return (*it1).second; 
    124124        } 
  • modules/CheckSystem/CheckSystem.cpp

    r523576e r682ccd2  
    9090      , _T("PDH COUNTERS"), _T("")) 
    9191 
    92  
    9392      ; 
    94  
    9593 
    9694    settings.alias().add_key_to_settings() 
     
    9896      _T("DEFAULT COUNTERS"), _T("Load the default counters: ") PDH_SYSTEM_KEY_CPU _T(", ") PDH_SYSTEM_KEY_MCB _T(", ") PDH_SYSTEM_KEY_MCL _T(" and ") PDH_SYSTEM_KEY_UPT _T(" If not you need to specify these manually. ") ) 
    9997 
    100       (_T("default"), sh::bool_key(&default_counters, true), 
    101       _T("DEFAULT COUNTERS"), _T("Load the default counters: ") PDH_SYSTEM_KEY_CPU _T(", ") PDH_SYSTEM_KEY_MCB _T(", ") PDH_SYSTEM_KEY_MCL _T(" and ") PDH_SYSTEM_KEY_UPT _T(" If not you need to specify these manually. ") ) 
    102  
    10398      (_T("default buffer length"), sh::wstring_key(&data->buffer_length, _T("1h")), 
    10499      _T("DEFAULT INTERVALL"), _T("Used to define the default intervall for range buffer checks (ie. CPU).")) 
    105 //  
    106 //      (_T("hostname cache"), sh::bool_key(&cacheNscaHost_), 
    107 //      _T("CACHE HOSTNAME"), _T("")) 
    108 //  
    109 //      (_T("delay"), sh::string_fun_key<std::wstring>(boost::bind(&NSCAAgent::set_delay, this, _1), 0), 
    110 //      _T("DELAY"), _T("")) 
    111 //  
    112 //      (_T("payload length"), sh::uint_key(&payload_length_, 512), 
    113 //      _T("PAYLOAD LENGTH"), _T("The password to use. Again has to be the same as the server or it wont work at all.")) 
    114100 
    115101      ; 
    116102 
    117     //std::map<DWORD,std::wstring>::key_type 
    118  
    119     settings.alias().add_key_to_settings() 
     103    settings.alias().add_key_to_settings(_T("service mapping")) 
    120104 
    121105      (_T("BOOT_START"), sh::wstring_vector_key(&lookups_, SERVICE_BOOT_START, _T("ignored")), 
    122       _T("SERVICE_BOOT_START"), _T("TODO")) 
     106      _T("SERVICE_BOOT_START"), _T("TODO"), true) 
    123107 
    124108      (_T("SYSTEM_START"), sh::wstring_vector_key(&lookups_, SERVICE_SYSTEM_START, _T("ignored")), 
    125       _T("SERVICE_SYSTEM_START"), _T("TODO")) 
     109      _T("SERVICE_SYSTEM_START"), _T("TODO"), true) 
    126110 
    127111      (_T("AUTO_START"), sh::wstring_vector_key(&lookups_, SERVICE_AUTO_START, _T("started")), 
    128       _T("SERVICE_AUTO_START"), _T("TODO")) 
     112      _T("SERVICE_AUTO_START"), _T("TODO"), true) 
    129113 
    130114      (_T("DEMAND_START"), sh::wstring_vector_key(&lookups_, SERVICE_DEMAND_START, _T("ignored")), 
    131       _T("SERVICE_DEMAND_START"), _T("TODO")) 
     115      _T("SERVICE_DEMAND_START"), _T("TODO"), true) 
    132116 
    133117      (_T("DISABLED"), sh::wstring_vector_key(&lookups_, SERVICE_DISABLED, _T("stopped")), 
    134       _T("SERVICE_DISABLED"), _T("TODO")) 
     118      _T("SERVICE_DISABLED"), _T("TODO"), true) 
    135119 
    136120      (_T("DELAYED"), sh::wstring_vector_key(&lookups_, NSCP_SERVICE_DELAYED, _T("ignored")), 
    137       _T("SERVICE_DELAYED"), _T("TODO")) 
     121      _T("SERVICE_DELAYED"), _T("TODO"), true) 
    138122 
    139123      ; 
  • modules/NSClientServer/NSClientServer.cpp

    r440c0cb r682ccd2  
    5858      ; 
    5959 
     60 
     61    settings.alias().add_key_to_settings() 
     62      (_T("thread pool"), sh::uint_key(&info_.thread_pool_size, 10), 
     63      _T("THREAD POOL"), _T(""), true) 
     64 
     65      (_T("socket queue size"), sh::int_key(&info_.back_log, 0), 
     66      _T("LISTEN QUEUE"), _T("Number of sockets to queue before starting to refuse new incoming connections. This can be used to tweak the amount of simultaneous sockets that the server accepts."), true) 
     67 
     68      (_T("use ssl"), sh::bool_key(&info_.use_ssl, false), 
     69      _T("ENABLE SSL ENCRYPTION"), _T("This option controls if SSL should be enabled."), true) 
     70 
     71      (_T("certificate"), sh::wpath_key(&info_.certificate, _T("${certificate-path}/nrpe_dh_512.pem")), 
     72      _T("SSL CERTIFICATE"), _T(""), true) 
     73 
     74      ; 
     75 
     76 
     77 
    6078    settings.alias().add_parent(_T("/settings/default/socket")).add_key_to_settings() 
    61  
    62       (_T("thread pool"), sh::uint_key(&info_.thread_pool_size, 10), 
    63       _T("THREAD POOL"), _T("")) 
    6479 
    6580      (_T("bind to"), sh::string_key(&info_.address), 
    6681      _T("BIND TO ADDRESS"), _T("Allows you to bind server to a specific local address. This has to be a dotted ip address not a host name. Leaving this blank will bind to all available IP addresses.")) 
    67  
    68       (_T("socket queue size"), sh::int_key(&info_.back_log, 0), 
    69       _T("LISTEN QUEUE"), _T("Number of sockets to queue before starting to refuse new incoming connections. This can be used to tweak the amount of simultaneous sockets that the server accepts.")) 
    7082 
    7183      (_T("allowed hosts"), sh::string_fun_key<std::wstring>(boost::bind(&socket_helpers::allowed_hosts_manager::set_source, &info_.allowed_hosts, _1), _T("127.0.0.1")), 
     
    7890      _T("TIMEOUT"), _T("Timeout when reading packets on incoming sockets. If the data has not arrived within this time we will bail out.")) 
    7991 
    80       (_T("use ssl"), sh::bool_key(&info_.use_ssl, false), 
    81       _T("ENABLE SSL ENCRYPTION"), _T("This option controls if SSL should be enabled.")) 
    82  
    83       (_T("certificate"), sh::wpath_key(&info_.certificate, _T("${certificate-path}/nrpe_dh_512.pem")), 
    84       _T("SSL CERTIFICATE"), _T("")) 
    85  
    8692      ; 
    8793 
     
    9096      (_T("password"), sh::string_fun_key<std::wstring>(boost::bind(&check_nt::server::handler::set_password, info_.request_handler, _1), _T("")), 
    9197      _T("PASSWORD"), _T("Password used to authenticate againast server")) 
     98 
    9299      ; 
    93100 
  • service/NSClient++.cpp

    r440c0cb r682ccd2  
    431431 
    432432      (_T("archive folder"), sh::wpath_key(&crash_folder, CRASH_ARCHIVE_FOLDER), 
    433       CRASH_ARCHIVE_FOLDER_KEY, _T("The folder to archive crash dumps in")) 
     433      _T("CRASH ARCHIVE LOCATION"), _T("The folder to archive crash dumps in")) 
    434434      ; 
    435435 
     
    538538      std::wstring file = NSCPlugin::get_plugin_file(v.second); 
    539539      std::wstring alias = v.first; 
    540       if (!alias.empty()) { 
    541         LOG_DEBUG_CORE_STD(_T("Processing plugin: ") + file + _T(" as ") + alias); 
    542       } else { 
    543         LOG_DEBUG_CORE_STD(_T("Processing plugin: ") + file); 
    544       } 
     540//      if (!alias.empty()) { 
     541//        LOG_DEBUG_CORE_STD(_T("Processing plugin: ") + file + _T(" as ") + alias); 
     542//      } else { 
     543//        LOG_DEBUG_CORE_STD(_T("Processing plugin: ") + file); 
     544//      } 
    545545      try { 
    546546        addPlugin(pluginPath / boost::filesystem::wpath(file), alias); 
     
    14101410    std::wstring::size_type pend = file.find('}', pstart); 
    14111411    std::wstring key = file.substr(pstart+1, pend-2); 
    1412     LOG_DEBUG_CORE(_T("Found key: ") + key); 
     1412    //LOG_DEBUG_CORE(_T("Found key: ") + key); 
    14131413 
    14141414    std::wstring tmp = file; 
  • service/cli_parser.hpp

    r440c0cb r682ccd2  
    178178 
    179179      po::options_description all("Allowed options"); 
    180       all.add(root).add(common).add(service).add(settings).add(client); 
     180      all.add(root).add(common).add(service).add(settings).add(client).add(test).add(unittest); 
    181181      std::cout << all << std::endl; 
    182182 
     
    204204 
    205205  int parse_test(int argc, wchar_t* argv[]) { 
    206  
    207     po::options_description all("Allowed options (test)"); 
    208     all.add(common).add(test); 
    209  
    210     po::variables_map vm; 
    211     po::store(po::parse_command_line(argc, argv, all), vm); 
    212     po::notify(vm); 
    213  
    214     if (log_level.empty()) 
    215       log_level  = _T("debug"); 
    216  
    217     if (process_common_options("test", all)) 
    218       return 1; 
    219  
    220     if (vm.count("log-to-file") == 0) { 
    221       nsclient::logging::logger::set_backend("console"); 
    222     } 
    223  
    224     try { 
    225       po::options_description all("Allowed options (settings)"); 
    226       all.add(common).add(settings); 
     206    try { 
     207 
     208      po::options_description all("Allowed options (test)"); 
     209      all.add(common).add(test); 
    227210 
    228211      po::variables_map vm; 
     
    230213      po::notify(vm); 
    231214 
    232       if (process_common_options("settings", all)) 
     215      if (log_level.empty()) 
     216        log_level  = _T("debug"); 
     217 
     218      if (process_common_options("test", all)) 
    233219        return 1; 
     220 
     221      if (vm.count("log-to-file") == 0) { 
     222        nsclient::logging::logger::set_backend("console"); 
     223      } 
    234224 
    235225      nsclient::simple_client client(core_); 
  • service/logger_impl.cpp

    r440c0cb r682ccd2  
    269269 
    270270  log_impl_type background_logger_; 
     271  bool running_; 
    271272 
    272273public: 
    273274 
    274   threaded_logger(log_impl_type background_logger) : background_logger_(background_logger) {} 
     275  threaded_logger(log_impl_type background_logger) : background_logger_(background_logger), running_(false) {} 
     276  ~threaded_logger() { 
     277    shutdown(); 
     278  } 
    275279 
    276280  void do_log(const std::string &data) { 
     
    287291    std::string data; 
    288292    while (true) { 
    289       log_queue_.wait_and_pop(data); 
    290       if (data == QUIT_MESSAGE) { 
    291         break; 
    292       } else if (data == CONFIGURE_MESSAGE) { 
    293         if (background_logger_) 
    294           background_logger_->configure(); 
    295       } else { 
    296         if (background_logger_) 
    297           background_logger_->do_log(data); 
    298         subscribers_.notify(data); 
     293      try { 
     294        log_queue_.wait_and_pop(data); 
     295        if (data == QUIT_MESSAGE) { 
     296          break; 
     297        } else if (data == CONFIGURE_MESSAGE) { 
     298          if (background_logger_) 
     299            background_logger_->configure(); 
     300        } else { 
     301          if (background_logger_) 
     302            background_logger_->do_log(data); 
     303          subscribers_.notify(data); 
     304        } 
     305      } catch (const std::exception &e) { 
     306        log_fatal(std::string("Failed to process log message: ") + e.what()); 
     307      } catch (...) { 
     308        log_fatal("Failed to process log message"); 
    299309      } 
    300310    } 
     
    306316  bool startup() { 
    307317    thread_ = boost::thread(boost::bind(&threaded_logger::thread_proc, this)); 
     318    running_ = true; 
    308319    return true; 
    309320  } 
    310321  bool shutdown() { 
     322    if (!running_) 
     323      return true; 
    311324    push(QUIT_MESSAGE); 
    312325    if (!thread_.timed_join(boost::posix_time::seconds(5))) { 
     
    314327      return false; 
    315328    } 
     329    running_ = false; 
    316330    return true; 
    317331  } 
     
    346360  } 
    347361  nsclient::logging::logging_interface_impl *old = logger_impl_ ; 
    348   logger_impl_  = tmp; 
     362  if (old != NULL && tmp != NULL) { 
     363    tmp->set_console_log(old->get_console_log()); 
     364    tmp->set_log_level(old->get_log_level()); 
     365  } 
     366  logger_impl_ = tmp; 
    349367  delete old; 
    350368  old = NULL; 
  • version.hpp

    r440c0cb r682ccd2  
    11#ifndef VERSION_HPP 
    22#define VERSION_HPP 
    3 #define PRODUCTVER     0,4,0,156 
    4 #define STRPRODUCTVER  "0,4,0,156" 
    5 #define STRPRODUCTDATE "2012-04-05" 
     3#define PRODUCTVER     0,4,0,159 
     4#define STRPRODUCTVER  "0,4,0,159" 
     5#define STRPRODUCTDATE "2012-04-11" 
    66#endif // VERSION_HPP 
  • version.txt

    r440c0cb r682ccd2  
    11version=0.4.0 
    2 build=156 
    3 date=2012-04-05 
     2build=159 
     3date=2012-04-11 
Note: See TracChangeset for help on using the changeset viewer.