Changeset c88cf98 in nscp
- Timestamp:
- 03/12/12 07:40:24 (15 months ago)
- Branches:
- master, 0.4.0, 0.4.1, 0.4.2
- Children:
- 74e060a
- Parents:
- fb8241a
- Files:
-
- 2 added
- 11 edited
-
changelog (modified) (2 diffs)
-
helpers/installer-dlls/main_dll/main_dll.cpp (modified) (1 diff)
-
helpers/installers/installer/Product.wxs (modified) (6 diffs)
-
helpers/installers/installer/properties.wxs (modified) (2 diffs)
-
helpers/installers/ui/SelectConfigurationDlg.wxs (modified) (1 diff)
-
modules/CheckWMI/CheckWMI.cpp (modified) (10 diffs)
-
modules/CheckWMI/WMIQuery.cpp (modified) (1 diff)
-
modules/PythonScript/PythonScript.cpp (modified) (2 diffs)
-
scripts/python/lib/test_helper.py (modified) (1 diff)
-
scripts/python/sample/list_all_wmi_objects.py (added)
-
scripts/python/test_all.py (modified) (1 diff)
-
scripts/python/test_w32_file.py (modified) (1 diff)
-
scripts/python/test_w32_wmi.py (added)
Legend:
- Unmodified
- Added
- Removed
-
changelog
rfb8241a rc88cf98 5 5 * Fix RtlStringFromGUID problem on NT4 6 6 7 2012-03-11 MickeM 8 * Fixed a lot of issues with the installer 9 * Added so the installer can generate a config file for you 10 * Fixed so installer uses the correct path for password and allowed hosts 11 7 12 2012-03-08 MickeM 8 13 * Major improvments to the WMI command line syntax. … … 10 15 Means you can use NSCLient++ as a almost full featured WMI command line client. 11 16 For details use: nscp wmi --help 17 * Added sample python WMI script to list all classes in all namespaces 18 * Fixed so if python scripts does not expose init and shutdown they will not be called 19 * Added new option --simple to CheckWMI wmi commands to return a simple list without formatting. 12 20 13 21 2012-03-06 MickeM -
helpers/installer-dlls/main_dll/main_dll.cpp
r441a022 rc88cf98 313 313 } 314 314 315 std::wstring defpath = _T("/settings/default /");315 std::wstring defpath = _T("/settings/default"); 316 316 write_changed_key(h, data, _T("ALLOWED_HOSTS"), defpath, _T("allowed hosts")); 317 317 write_changed_key(h, data, _T("NSCLIENT_PWD"), defpath, _T("password")); -
helpers/installers/installer/Product.wxs
r523576e rc88cf98 30 30 31 31 <?if "$(var.arch)" = "x64"?> 32 <Condition Message="x64 bit version not supported (by installer) on Win32 bit platform (get Win32 bit version instead)">NOTVersionNT64</Condition>32 <Condition Message="x64 bit version not supported on Win32 bit platform (get Win32 instead)">VersionNT64</Condition> 33 33 <?endif?> 34 34 <Media Id="1" Cabinet="Product.cab" EmbedCab="yes" CompressionLevel="high" /> … … 44 44 <fire:FirewallException Id="FWX1" Name="NSClient++ Monitoring Agent" Scope="any" IgnoreFailure="yes" /> 45 45 </File> 46 <RemoveFile Id="PurgeLogFiles" Name="*.log" On="uninstall" /> 46 47 <ServiceInstall Id="SWCNSCP" 47 48 Name="[SERVICE_NAME]" DisplayName="$(var.App.Title) ($(var.arch))" … … 49 50 Description="Monitoring agent for nagios (and others) used to respond to status queries" 50 51 Arguments="service --run --name [SERVICE_NAME]"> 51 <ServiceDependency Id="Tcpip" />52 </ServiceInstall>52 <ServiceDependency Id="Tcpip" /> 53 </ServiceInstall> 53 54 <ServiceControl Id="StartSWCNSCP" Name="[SERVICE_NAME]" Start="install" Stop="both" Wait="yes" Remove="uninstall" /> 54 55 <RemoveFolder Id="RemoveMenuShortcuts" Directory="ProgramMenuDir" On="uninstall" /> … … 77 78 --> 78 79 <File Id="ErrorReporter" Name="reporter.exe" DiskId="1" Source="$(var.Source)/reporter.exe" Vital="yes" /> 79 <!-- 80 <File Id="NSClientINI" Name="NSC.ini" LongName="NSC.ini" DiskId="1" Source="$(var.Path.ini)/NSC.ini" Vital="yes"/> 81 --> 80 </Component> 81 <Component Id="SampleConfigUser" Guid="AA636DB0-A0B9-4dd2-B74C-$(var.Postfix.GUID)" Win64="$(var.Win64)"> 82 <File Id="NSClientINIUser" Name="nsclient.ini" DiskId="1" Source="$(var.Path.ini)/nsclient.dist" Vital="no" PatchIgnore="yes"> 83 <Permission User="Everyone" GenericRead="yes" Read="yes" GenericWrite="yes" Write="yes"/> 84 </File> 85 <RemoveFile Id="PurgeConfigFilesUser" Name="*.ini" On="uninstall" /> 86 <Condition>INSTALL_SAMPLE_CONFIG AND USER_WRITABLE_CONFIG</Condition> 87 </Component> 88 <Component Id="SampleConfig" Guid="AAA36DB0-A0B9-4dd2-B74C-$(var.Postfix.GUID)" Win64="$(var.Win64)"> 89 <File Id="NSClientINI" Name="nsclient.ini" DiskId="1" Source="$(var.Path.ini)/nsclient.dist" Vital="no" PatchIgnore="yes" /> 90 <RemoveFile Id="PurgeConfigFiles" Name="*.ini" On="uninstall" /> 91 <Condition>INSTALL_SAMPLE_CONFIG AND NOT USER_WRITABLE_CONFIG</Condition> 82 92 </Component> 83 93 <Component Id="RandomFiles" Guid="B4636DB0-A0B9-4dd2-B74C-$(var.Postfix.GUID)" Win64="$(var.Win64)"> … … 236 246 <ComponentRef Id="Shortcuts" /> 237 247 <ComponentRef Id="Helpers" /> 238 <ComponentRef Id="RandomFiles" /> 239 </Feature> 248 <ComponentRef Id="RandomFiles" /> 249 <ComponentRef Id="SampleConfigUser" /> 250 <ComponentRef Id="SampleConfig" /> 251 </Feature> 240 252 <Feature Id="Documentation" Title="Documentation (pdf)" Description="Documentation for NSClient++ and how to use it from Nagios" Level="1"> 241 253 <ComponentRef Id="NagiosDocumentation" /> … … 279 291 <CustomAction Id='ImportConfig' BinaryKey='InstallerHelper' DllEntry='ImportConfig' Impersonate='yes' Execute="immediate" Return="check" /> 280 292 <CustomAction Id='ScheduleWriteConfig' BinaryKey='InstallerHelper' DllEntry='ScheduleWriteConfig' Impersonate='yes' Execute="immediate" Return="check" /> 281 <CustomAction Id="ExecWriteConfig" BinaryKey="InstallerHelper" DllEntry="ExecWriteConfig" Impersonate="no" Execute="deferred" Return="check" />282 283 <CustomAction Id='NeedUninstall' BinaryKey='InstallerHelper' DllEntry='NeedUninstall' Impersonate='yes' Execute="immediate" Return="check" />293 <CustomAction Id="ExecWriteConfig" BinaryKey="InstallerHelper" DllEntry="ExecWriteConfig" Impersonate="no" Execute="deferred" Return="check" /> 294 295 <CustomAction Id='NeedUninstall' BinaryKey='InstallerHelper' DllEntry='NeedUninstall' Impersonate='yes' Execute="immediate" Return="check" /> 284 296 <CustomAction Id="PreventDowngrading" Error="Newer version already installed." /> 285 297 298 299 <CustomAction Id="GenConfig.Command" Property="GenConfig" Value=""[#NSClientEXE]" settings --generate ini"/> 300 <CustomAction Id="GenConfig" BinaryKey="WixCA" DllEntry="CAQuietExec" Impersonate="no" Return="ignore" Execute="deferred"/> 301 286 302 <Binary Id='InstallerHelper' SourceFile='$(var.Helpers)/main_dll.dll' /> 287 303 288 <InstallExecuteSequence>304 <InstallExecuteSequence> 289 305 <RemoveExistingProducts After='InstallInitialize'/> 290 306 <Custom Action="PreventDowngrading" After="FindRelatedProducts">NEWAPPFOUND</Custom> 291 <Custom Action="ScheduleWriteConfig" After='InstallFiles' /> 307 <Custom Action="ScheduleWriteConfig" After="InstallFiles">NOT REMOVE</Custom> 308 <Custom Action="GenConfig.Command" After="ScheduleWriteConfig">NOT REMOVE AND INSTALL_SAMPLE_CONFIG = 1</Custom> 309 <Custom Action="GenConfig" After="GenConfig.Command">NOT REMOVE AND INSTALL_SAMPLE_CONFIG = 1</Custom> 292 310 </InstallExecuteSequence> 293 311 294 312 <InstallUISequence> 295 313 <Custom Action="PreventDowngrading" After="FindRelatedProducts">NEWAPPFOUND</Custom> 296 <Custom Action="NeedUninstall" After="FindRelatedProducts" >1</Custom>297 <Custom Action="ImportConfig" After="CostFinalize" >1</Custom>314 <Custom Action="NeedUninstall" After="FindRelatedProducts">1</Custom> 315 <Custom Action="ImportConfig" After="CostFinalize">NOT REMOVE</Custom> 298 316 </InstallUISequence> 299 317 -
helpers/installers/installer/properties.wxs
rb7d17f8 rc88cf98 19 19 <Property Id="NSCLIENT_PWD_DEFAULT"></Property> 20 20 --> 21 <Property Id="CONFIGURATION_TYPE_DEFAULT">ini://${ shared-path}/nsclient.ini</Property>21 <Property Id="CONFIGURATION_TYPE_DEFAULT">ini://${exe-path}/nsclient.ini</Property> 22 22 23 23 <!-- CONFIGURE INITAL VALUES IN CONFIG UI --> … … 30 30 <Property Id="ALLOWED_HOSTS"></Property> 31 31 <Property Id="NSCLIENT_PWD"></Property> 32 <Property Id="CONFIGURATION_TYPE">ini://${shared-path}/nsclient.ini</Property> 32 33 --> 33 <Property Id="CONFIGURATION_TYPE">ini://${shared-path}/nsclient.ini</Property> 34 <Property Id="CONFIGURATION_TYPE">ini://${exe-path}/nsclient.ini</Property> 35 <Property Id="INSTALL_SAMPLE_CONFIG">1</Property> 34 36 35 37 <!-- CONFIGURE THE INSTALLER --> -
helpers/installers/ui/SelectConfigurationDlg.wxs
re11d494 rc88cf98 15 15 </Control> 16 16 17 <Control Id="Back" Type="PushButton" X="180" Y="243" Width="56" Height="17" Text="&Back"> 17 <Control Id="generateConfig" Type="CheckBox" X="45" Y="73" Width="260" Height="20" Property="INSTALL_SAMPLE_CONFIG" Text="Install sample configuration" CheckBoxValue="1"> 18 <Condition Action="enable">CONFIGURATION_TYPE = "ini://${exe-path}/nsclient.ini"</Condition> 19 <Condition Action="disable"><![CDATA[CONFIGURATION_TYPE <> "ini://${exe-path}/nsclient.ini"]]></Condition> 20 </Control> 21 <Control Id="userWriteConfig" Type="CheckBox" X="60" Y="88" Width="260" Height="20" Property="USER_WRITABLE_CONFIG" Text="Allow Everyone to write config file" CheckBoxValue="1"> 22 <Condition Action="enable">CONFIGURATION_TYPE = "ini://${exe-path}/nsclient.ini" AND INSTALL_SAMPLE_CONFIG</Condition> 23 <Condition Action="disable"><![CDATA[CONFIGURATION_TYPE <> "ini://${exe-path}/nsclient.ini" OR NOT INSTALL_SAMPLE_CONFIG]]></Condition> 24 </Control> 25 26 <Control Id="Back" Type="PushButton" X="180" Y="243" Width="56" Height="17" Text="&Back"> 18 27 </Control> 19 28 <Control Id="Next" Type="PushButton" X="236" Y="243" Width="56" Height="17" Default="yes" Text="&Next"> -
modules/CheckWMI/CheckWMI.cpp
rfb8241a rc88cf98 405 405 406 406 }; 407 void print_ results(WMIQuery::result_type &rows, int limit, std::wstring & result)407 void print_pretty_results(WMIQuery::result_type &rows, int limit, std::wstring & result) 408 408 { 409 409 pad_handler padder; 410 410 NSC_DEBUG_MSG_STD(_T("Query returned: ") + strEx::itos(rows.size()) + _T(" rows.")); 411 std::vector<std::wstring::size_type> widths;412 411 int rownum=0; 413 412 BOOST_FOREACH(const WMIQuery::wmi_row &row, rows) { … … 441 440 if (limit != -1 && rownum > limit) 442 441 break; 443 int i=0;444 442 std::wstring row1 = _T("|"); 445 443 padder.reset_index(); … … 450 448 } 451 449 } 450 451 void print_simple_results(WMIQuery::result_type &rows, int limit, std::wstring & result) 452 { 453 int rownum=0; 454 BOOST_FOREACH(const WMIQuery::wmi_row &row, rows) { 455 if (limit != -1 && rownum > limit) 456 break; 457 bool first = true; 458 BOOST_FOREACH(const WMIQuery::wmi_row::list_type::value_type &val, row.results) { 459 if (first) 460 first = false; 461 else 462 result += _T(","); 463 result += val.second.string; 464 } 465 result += _T("\n"); 466 } 467 } 468 void print_results(WMIQuery::result_type &rows, int limit, std::wstring & result, bool simple) { 469 if (simple) 470 print_simple_results(rows, limit, result); 471 else 472 print_pretty_results(rows, limit, result); 473 } 474 452 475 453 476 NSCAPI::nagiosReturn CheckWMI::handleCommand(const std::wstring &target, const std::wstring &command, std::list<std::wstring> &arguments, std::wstring &message, std::wstring &perf) { … … 485 508 486 509 std::wstring query, ns, computer, user, password, list_cls, list_inst; 510 bool simple; 487 511 int limit = -1; 488 512 po::options_description desc("Allowed options"); … … 490 514 ("help,h", "Show help screen") 491 515 ("select,s", po::wvalue<std::wstring>(&query), "Execute a query") 516 ("simple", "Use simple format") 492 517 ("list-classes", po::wvalue<std::wstring>(&list_cls)->implicit_value(_T("")), "list all classes of a given type") 493 518 ("list-instances", po::wvalue<std::wstring>(&list_inst)->implicit_value(_T("")), "list all instances of a given type") … … 523 548 return NSCAPI::isSuccess; 524 549 } 550 simple = vm.count("simple") > 0; 525 551 526 552 ns = build_namespace(ns, computer); … … 541 567 return NSCAPI::isSuccess; 542 568 } else { 543 print_results(rows, limit, result );569 print_results(rows, limit, result, simple); 544 570 } 545 571 } else if (vm.count("list-classes")) { … … 547 573 WMIQuery wmiQuery; 548 574 rows = wmiQuery.get_classes(ns, list_cls, user, password); 549 print_results(rows, limit, result );575 print_results(rows, limit, result, simple); 550 576 } catch (WMIException e) { 551 577 NSC_LOG_ERROR_STD(_T("WMIQuery failed: ") + e.getMessage()); … … 557 583 WMIQuery wmiQuery; 558 584 rows = wmiQuery.get_instances(ns, list_inst, user, password); 559 print_results(rows, limit, result );585 print_results(rows, limit, result, simple); 560 586 } catch (WMIException e) { 561 587 NSC_LOG_ERROR_STD(_T("WMIQuery failed: ") + e.getMessage()); … … 567 593 WMIQuery wmiQuery; 568 594 rows = wmiQuery.get_instances(ns, _T("__Namespace"), user, password); 569 print_results(rows, limit, result );595 print_results(rows, limit, result, simple); 570 596 } catch (WMIException e) { 571 597 NSC_LOG_ERROR_STD(_T("WMIQuery failed: ") + e.getMessage()); -
modules/CheckWMI/WMIQuery.cpp
rfb8241a rc88cf98 120 120 set_proxy_blanket(service, user, password); 121 121 122 // if (! (user.empty() && password.empty())) {123 // std::wstring error;124 // boost::optional<identidy_container> auth = get_identity(user, password, error);125 // if (auth) {126 // //hr = CoSetProxyBlanket(service, RPC_C_AUTHN_DEFAULT, RPC_C_AUTHZ_DEFAULT, COLE_DEFAULT_PRINCIPAL, RPC_C_AUTHN_LEVEL_DEFAULT,127 // // RPC_C_IMP_LEVEL_IMPERSONATE, NULL, EOAC_NONE );128 // hr = CoSetProxyBlanket(service, RPC_C_AUTHN_DEFAULT, RPC_C_AUTHZ_DEFAULT, COLE_DEFAULT_PRINCIPAL, RPC_C_AUTHN_LEVEL_DEFAULT,129 // RPC_C_IMP_LEVEL_IMPERSONATE, &(*auth).auth_identity, EOAC_NONE );130 // //hr = CoSetProxyBlanket(service, RPC_C_AUTHN_WINNT, RPC_C_AUTHZ_NONE, NULL, RPC_C_AUTHN_LEVEL_CALL,131 // // RPC_C_IMP_LEVEL_IMPERSONATE, NULL, EOAC_NONE );132 // if (FAILED(hr))133 // throw WMIException(_T("CoSetProxyBlanket failed: ") + ComError::getComError(ComError::getWMIError(hr)));134 // }135 // }136 122 return service; 137 123 } -
modules/PythonScript/PythonScript.cpp
r836e9cd rc88cf98 125 125 script_wrapper::thread_locker locker; 126 126 try { 127 if (!localDict.has_key(functionName)) 128 return true; 127 129 object scriptFunction = extract<object>(localDict[functionName]); 128 130 if( scriptFunction ) … … 142 144 script_wrapper::thread_locker locker; 143 145 try { 146 if (!localDict.has_key(functionName)) 147 return true; 144 148 object scriptFunction = extract<object>(localDict[functionName]); 145 149 if(scriptFunction) -
scripts/python/lib/test_helper.py
r8013c0c rc88cf98 263 263 else: 264 264 self.add_message(s1 in s2 or s2 in s1, msg, '"%s" (contains) "%s"'%(s1, s2)) 265 266 def assert_not_contains(self, s1, s2, msg): 267 if s1 == s2: 268 self.add_message(False, msg, '"%s" (equals) "%s"'%(s1, s2)) 269 elif s1 == None or s2 == None: 270 self.add_message(True, msg, '"%s" (is null?) "%s"'%(s1, s2)) 271 else: 272 self.add_message(not (s1 in s2 or s2 in s1), msg, '"%s" (does not contains) "%s"'%(s1, s2)) 265 273 266 274 def add_entry(self, e): -
scripts/python/test_all.py
r836e9cd rc88cf98 16 16 from test_w32_system import Win32SystemTest 17 17 from test_w32_file import Win32FileTest 18 all_tests.extend([EventLogTest, Win32SystemTest, Win32FileTest]) 18 from test_w32_wmi import Win32WMITest 19 all_tests.extend([EventLogTest, Win32SystemTest, Win32FileTest, Win32WMITest]) 19 20 20 21 def __main__(): -
scripts/python/test_w32_file.py
r836e9cd rc88cf98 157 157 def install(self, arguments): 158 158 conf = Settings.get() 159 conf.set_string('/modules', 'test_ system', 'CheckDisk')159 conf.set_string('/modules', 'test_disk', 'CheckDisk') 160 160 conf.set_string('/modules', 'pytest', 'PythonScript') 161 161 conf.set_string('/settings/pytest/scripts', 'test_w32sys', 'test_w32_file.py')
Note: See TracChangeset
for help on using the changeset viewer.








