Changeset 441a022 in nscp
- Timestamp:
- 01/18/12 22:47:06 (16 months ago)
- Branches:
- master, 0.4.0, 0.4.1, 0.4.2
- Children:
- 2ec2eb6
- Parents:
- ffa6a59
- Files:
-
- 16 edited
-
CMakeLists.txt (modified) (1 diff)
-
build/cmake/functions.cmake (modified) (1 diff)
-
changelog (modified) (1 diff)
-
helpers/installer-dlls/main_dll/main_dll.cpp (modified) (2 diffs)
-
modules/PythonScript/PythonScript.cpp (modified) (5 diffs)
-
modules/PythonScript/PythonScript.h (modified) (1 diff)
-
scripts/CMakeLists.txt (modified) (1 diff)
-
scripts/python/lib/test_helper.py (modified) (1 diff)
-
scripts/python/test_all.py (modified) (1 diff)
-
scripts/python/test_nrpe.py (modified) (1 diff)
-
scripts/python/test_nsca.py (modified) (2 diffs)
-
scripts/python/test_python.py (modified) (4 diffs)
-
service/NSClient++.cpp (modified) (2 diffs)
-
service/cli_parser.hpp (modified) (1 diff)
-
version.hpp (modified) (1 diff)
-
version.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
CMakeLists.txt
r2b2e9b8 r441a022 476 476 ${BUILD_TARGET_EXE_PATH}/config.py 477 477 ) 478 479 ENABLE_TESTING() 480 481 add_nscp_py_test(nsca test_nsca) 482 add_nscp_py_test(nrpe test_nrpe) 483 add_nscp_py_test(python test_python) 484 IF(WIN32) 485 add_nscp_py_test(eventlog test_eventlog) 486 add_nscp_py_test(w32_system test_w32_system) 487 ENDIF(WIN32) -
build/cmake/functions.cmake
r7ec3dd1 r441a022 41 41 ENDMACRO(copy_single_file) 42 42 43 MACRO(add_nscp_py_test name script) 44 ADD_TEST("${name}" 45 nscp 46 py 47 --settings dummy 48 --exec run 49 --script ${script} 50 --query py_unittest 51 ) 52 ENDMACRO(add_nscp_py_test) 53 -
changelog
rffa6a59 r441a022 11 11 * Improved the syntax and output of running unit tests 12 12 * Refactored unit tests to be slightly nicer 13 * Fixed error state propagation 14 * Added unit tests to cmake (ie make test will now run unit tests) 13 15 14 16 2012-01-16 MickeM -
helpers/installer-dlls/main_dll/main_dll.cpp
r16198e3 r441a022 228 228 h.setPropertyAndOld(_T("CONF_NRPE"), has_key(modpath, _T("NRPEServer"))); 229 229 h.setPropertyAndOld(_T("CONF_SCHEDULER"), has_key(modpath, _T("Scheduler"))); 230 h.setPropertyAndOld(_T("CONF_NSCA"), has_key(modpath, _T("NSCA Agent")));230 h.setPropertyAndOld(_T("CONF_NSCA"), has_key(modpath, _T("NSCAClient"))); 231 231 h.setPropertyAndOld(_T("CONF_NSCLIENT"), has_key(modpath, _T("NSClientServer"))); 232 232 h.setPropertyAndOld(_T("CONF_WMI"), has_key(modpath, _T("CheckWMI"))); … … 300 300 write_changed_key(h, data, _T("CONF_NRPE"), modpath, _T("NRPEServer"), modval); 301 301 write_changed_key(h, data, _T("CONF_SCHEDULER"), modpath, _T("Scheduler"), modval); 302 write_changed_key(h, data, _T("CONF_NSCA"), modpath, _T("NSCA Agent"), modval);302 write_changed_key(h, data, _T("CONF_NSCA"), modpath, _T("NSCAClient"), modval); 303 303 write_changed_key(h, data, _T("CONF_NSCLIENT"), modpath, _T("NSClientServer"), modval); 304 304 write_changed_key(h, data, _T("CONF_WMI"), modpath, _T("CheckWMI"), modval); -
modules/PythonScript/PythonScript.cpp
rba63b95 r441a022 120 120 callFunction("shutdown"); 121 121 } 122 voidpython_script::callFunction(const std::string& functionName) {122 bool python_script::callFunction(const std::string& functionName) { 123 123 try { 124 124 script_wrapper::thread_locker locker; … … 127 127 if( scriptFunction ) 128 128 scriptFunction(); 129 return true; 129 130 } catch( error_already_set e) { 130 131 script_wrapper::log_exception(); 132 return false; 131 133 } 132 134 } catch (...) { 133 135 NSC_LOG_ERROR(_T("Unknown exception")); 134 } 135 } 136 void python_script::callFunction(const std::string& functionName, unsigned int i1, const std::string &s1, const std::string &s2){ 136 return false; 137 } 138 } 139 bool python_script::callFunction(const std::string& functionName, unsigned int i1, const std::string &s1, const std::string &s2){ 137 140 try { 138 141 script_wrapper::thread_locker locker; … … 141 144 if(scriptFunction) 142 145 scriptFunction(i1, s1, s2); 146 return true; 143 147 } catch(error_already_set e) { 144 148 script_wrapper::log_exception(); 149 return false; 145 150 } 146 151 } catch (...) { 147 152 NSC_LOG_ERROR(_T("Unknown exception")); 153 return false; 148 154 } 149 155 } … … 165 171 path /= _T("python"); 166 172 path /= _T("lib"); 173 NSC_DEBUG_MSG(_T("Lib path: ") + path.string()); 167 174 PyRun_SimpleString(("sys.path.append('" + utf8::cvt<std::string>(path.string()) + "')").c_str()); 168 175 … … 293 300 script_container sc(*ofile); 294 301 python_script script(get_id(), "", sc); 295 script.callFunction("__main__"); 302 if (!script.callFunction("__main__")) { 303 message = _T("Failed to execute script: __main__"); 304 return NSCAPI::returnUNKNOWN; 305 } 296 306 message = _T("Script execute successfully..."); 297 307 return NSCAPI::returnOK; -
modules/PythonScript/PythonScript.h
r9c06054 r441a022 39 39 python_script(unsigned int plugin_id, const std::string alias, const script_container& script); 40 40 ~python_script(); 41 voidcallFunction(const std::string& functionName);42 voidcallFunction(const std::string& functionName, unsigned int i1, const std::string &s1, const std::string &s2);41 bool callFunction(const std::string& functionName); 42 bool callFunction(const std::string& functionName, unsigned int i1, const std::string &s1, const std::string &s2); 43 43 void _exec(const std::string &scriptfile); 44 44 }; -
scripts/CMakeLists.txt
r4b1e6fe r441a022 5 5 FILE (GLOB scripts_PS1 "*.ps1") 6 6 FILE (GLOB scripts_LIB "lib/*.vbs") 7 IF(WIN32)7 #IF(WIN32) 8 8 FILE (GLOB_RECURSE scripts_PYT "python/*.py") 9 ELSE(WIN32)10 FILE (GLOB scripts_PYT "python/*.py" "python/lib/*.py")11 ENDIF(WIN32)9 #ELSE(WIN32) 10 #FILE (GLOB scripts_PYT "python/*.py" "python/lib/*.py") 11 #ENDIF(WIN32) 12 12 FILE (GLOB scripts_LUA "lua/*.lua") 13 13 -
scripts/python/lib/test_helper.py
rffa6a59 r441a022 221 221 return 'OK: %s'%self.title 222 222 else: 223 (total, ok) = c.count()223 (total, ok) = self.count() 224 224 return 'ERROR: %s (%d/%d)'%(self.title, ok, total) 225 225 -
scripts/python/test_all.py
rffa6a59 r441a022 3 3 4 4 from sys import path 5 from os import getcwd 6 path.append( getcwd() + '/scripts/python')5 import os 6 path.append(os.getcwd() + '/scripts/python') 7 7 8 8 from test_nsca import NSCAServerTest 9 9 from test_nrpe import NRPEServerTest 10 10 #from test_pb import NSCAServerTest 11 from test_eventlog import EventLogTest12 11 from test_python import PythonTest 13 from test_w32_system import Win32SystemTest14 12 15 all_tests = [NSCAServerTest, NRPEServerTest, EventLogTest, PythonTest, Win32SystemTest] 13 # 14 all_tests = [NSCAServerTest, PythonTest, NRPEServerTest] 15 if os.name == 'nt': 16 from test_eventlog import EventLogTest 17 from test_w32_system import Win32SystemTest 18 all_tests.extend([EventLogTest, Win32SystemTest]) 16 19 17 20 def __main__(): -
scripts/python/test_nrpe.py
r89838be r441a022 1 1 from NSCP import Settings, Registry, Core, log, status, log_error, sleep 2 import sys 3 log('==>%s'%sys.path) 4 2 5 from test_helper import BasicTest, TestResult, Callable, setup_singleton, install_testcases, init_testcases, shutdown_testcases 3 6 import plugin_pb2 -
scripts/python/test_nsca.py
rba63b95 r441a022 165 165 (result_code, err) = core.submit('nsca_test_outbox', message.SerializeToString()) 166 166 167 result = TestResult( )167 result = TestResult('Testing payload: %s'%tag) 168 168 result.add_message(len(err) == 0, 'Testing to send message using %s/sbp'%tag, err) 169 169 found = self.wait_and_validate(uid, result, msg, perf, '%s/spb'%tag) … … 192 192 found = self.wait_and_validate(uid, result, msg, perf, '%s/exec'%tag) 193 193 if retry and not found: 194 return self.submit_via_exec(encryption, source, status, msg, perf, tag, False)194 return self.submit_via_exec(encryption, source, status, msg, perf, '%s (retry)'%tag, False) 195 195 return result 196 196 -
scripts/python/test_python.py
r89838be r441a022 4 4 from time import time 5 5 6 install_checks = 1000 6 install_checks = 100 7 time_to_run = 30 8 9 core = Core.get() 7 10 8 11 class PythonTest(BasicTest): … … 36 39 self.reg.simple_function('py_stress_noop', PythonTest.noop_handler, 'This is a simple noop command') 37 40 self.reg.simple_subscription('py_stress_test', PythonTest.stress_handler) 41 conf = Settings.get() 42 conf.set_string('/settings/test_scheduler', 'threads', '50') 43 core.reload('test_scheduler') 44 38 45 39 46 def teardown(self): 47 conf = Settings.get() 48 conf.set_string('/settings/test_scheduler', 'threads', '0') 49 core.reload('test_scheduler') 40 50 None 41 51 … … 43 53 result = TestResult() 44 54 start = time() 45 while self.stress_count < install_checks*10: 46 log('Waiting for %d: %d/%d'%(install_checks*10, self.stress_count, self.noop_count)) 55 total_count = install_checks*time_to_run/5 56 while self.stress_count < total_count: 57 log('Waiting for %d: %d/%d'%(total_count, self.stress_count, self.noop_count)) 47 58 old_stress_count = self.stress_count 48 59 old_noop_count = self.noop_count … … 63 74 64 75 base_path = '/settings/test_scheduler' 65 conf.set_string(base_path, 'threads', ' 50')76 conf.set_string(base_path, 'threads', '0') 66 77 67 78 default_path = '%s/default'%base_path -
service/NSClient++.cpp
r89838be r441a022 254 254 } 255 255 delete [] wargv; 256 return ret; 256 257 } 257 258 #endif … … 1257 1258 } 1258 1259 std::string response; 1259 NSCAPI::nagiosReturn c= plugin->handleCommand(command.c_str(), request, response);1260 ret = plugin->handleCommand(command.c_str(), request, response); 1260 1261 try { 1261 1262 std::wstring msg, perf; -
service/cli_parser.hpp
r89838be r441a022 432 432 mainClient.simple_exec(module, _T("help"), arguments, resp); 433 433 } else if (mode == combined) { 434 mainClient.reload(_T("service")); 435 ret = mainClient.simple_query(module, combined_query, arguments, resp); 434 if (ret == NSCAPI::returnOK) { 435 mainClient.reload(_T("service")); 436 ret = mainClient.simple_query(module, combined_query, arguments, resp); 437 } else { 438 std::wcerr << _T("Failed to execute command, will not attempt query") << std::endl; 439 } 436 440 } 437 441 } else if (mode == submit) { -
version.hpp
r89838be r441a022 1 1 #ifndef VERSION_HPP 2 2 #define VERSION_HPP 3 #define PRODUCTVER 0,4,0,12 34 #define STRPRODUCTVER "0,4,0,12 3"5 #define STRPRODUCTDATE "2012-01-1 6"3 #define PRODUCTVER 0,4,0,125 4 #define STRPRODUCTVER "0,4,0,125" 5 #define STRPRODUCTDATE "2012-01-18" 6 6 #endif // VERSION_HPP -
version.txt
r89838be r441a022 1 1 version=0.4.0 2 build=12 33 date=2012-01-1 62 build=125 3 date=2012-01-18
Note: See TracChangeset
for help on using the changeset viewer.








