Posts in category linux

Looking for distributed monitorers (not necessarily using NSClient++)

I am looking for people interested in distributed monitoring!

As some of you might know I am building some features do manage distributed and incoherent monitoring (ie. more then one monitoring tool) so I am interested in getting some real world insight into this area. So if you or anyone you know are interested in this area and want to come with feedback on some ideas I have please don't hesitate to contact me (michael <AT> medin <DOT> name).

Also on a bit more sad note, lack of updates on the wiki/forums is due to ion part preparing for NWC but also on me trying to complete some new cool(?) features which hopefully shall be out this week.

Michael Medin

0.4.0 build 93 out and how to play with Python: NSClient++ style!

Hello again dearest Google bot!

Today I have a pretty big announcement for all you 0.4.0 waiters out there. I have release another nightly build which is the result of a lot of work put in during august. The main new features is of course the new protocol as well as a very extended PythonScript? module.

Since there is so much new it is a bit difficult to create s short blog post to summarize the new features. But I hope that the new test.py and test_pb.py scripts will eventually cover most of the features if nothing else as a test script.

Installing Scripts

The best way to get start with these scripts are to "install them". Something which is now supported from the command line lik so:

nscp --client --module PythonScript --command execute-and-load-python --script test.py

This is a pretty complicated command actually. The first thing we do is add --client which runs command line queries as well as commands on modules without launching NSClient++ in server mode. IN essence this is the "offline mode".

Then we have --module PythonScript? which tells the "client" to load the PythonScript? module (regardless of what your configuration says) this also prevents any configured modules from being loaded.

The next step is the --command execute-and-load-python which actually just sends a command down the pipeline to see if any plugin want to run it. In this case the PythonScript? module will run it and do so by executing the ---script test.py script.

This script is then the magic, if we look at the main function of this script we can see the following:

def install_test(arguments):
	log('-+---==(TEST INSTALLER)==---------------------------------------------------+-')
	log(' | Setup nessecary configuration for running test                           |')
	log(' | This includes: Loading the PythonScript module at startup                |')
#...
	log('-+--------------------------------------------------------==(DAS ENDE!)==---+-')
	conf = Settings.get()
	conf.set_string('/modules', 'pytest', 'PythonScript')
	conf.set_string('/settings/pytest/scripts', 'pytest', 'test.py')
	conf.save()

def __main__():
	install_test([])

The interesting thing here is that we have a python script which is modifying our configuration by first enabling the PythonScript? module (using an alias: pytest) and then adds the relevant script (again with an alias pytest). The reason for using the alias is so we can easily "uninstall" this without messing up your configuration. This is thanks to the new fully supported multiple module support. Now unfortunately NSClient++ does not (yet) support uninstalling but that will come.

The next step is (as the install command above will tell you) to reun the test script from the "test mode".

Test mode

Test mode is nothing new since as far as I can remember it has been possible to run NSClient++ is "test mode" previously we used -test and for 0.4.0 we use

nscp --test

This will start NSClient++ like a service with three main exceptions:

  1. The program will run with YOUR privileges and in YOUR session (not system)
  2. The program will run with console log and debug log enabled
  3. You will be able to interact with NSClient++ directly

So lets try it out.

D:\source\nscp\build\x64>nscp --test
l    ..\..\..\trunk\service\NSClient++.cpp:536  NSClient++ 0,4,0,93 2011-09-04 x64 booting...
d ttings_manager\settings_manager_impl.cpp:148  Boot.ini found in: D:/source/nscp/build/x64//boot.ini
d ttings_manager\settings_manager_impl.cpp:165  Boot order: ini://${shared-path}/nsclient.ini, old://${exe-path}/nsc.ini
d ttings_manager\settings_manager_impl.cpp:168  Activating: ini://${shared-path}/nsclient.ini
d ttings_manager\settings_manager_impl.cpp:68   Creating instance for: ini://${shared-path}//nsclient.ini
d \trunk\include\settings/settings_ini.hpp:256  Reading INI settings from: D:/source/nscp/build/x64//nsclient.ini
d \trunk\include\settings/settings_ini.hpp:230  Loading: D:/source/nscp/build/x64//nsclient.ini from ini://${shared-path}/nsclient.ini
l    ..\..\..\trunk\service\NSClient++.cpp:541  Booted settings subsystem...
d    ..\..\..\trunk\service\NSClient++.cpp:602  On crash: restart: NSClientpp
d    ..\..\..\trunk\service\NSClient++.cpp:614  Archiving crash dumps in: D:/source/nscp/build/x64//crash-dumps
d    ..\..\..\trunk\service\NSClient++.cpp:681  booting::loading plugins
d    ..\..\..\trunk\service\NSClient++.cpp:389  Found: PythonScript as pytest
d    ..\..\..\trunk\service\NSClient++.cpp:689  Processing plugin: PythonScript.dll as pytest
d    ..\..\..\trunk\service\NSClient++.cpp:926  addPlugin(D:/source/nscp/build/x64//modules/PythonScript.dll as pytest)
d    ..\..\..\trunk\service\NSClient++.cpp:902  Loading plugin: PythonScript as pytest
d nk\modules\PythonScript\PythoDn:S/csroiuprtc.ec/pnps:c1p5/6b u iLloda/dxE6x4 /isnc rPiyptthso/npSyctrhiopnt/ taess tp.yptye
st
d nk\modules\PythonScript\PythonScript.cpp:213  Looking for: test.py
d nk\modules\PythonScript\PythonScript.cpp:213  Looking for: D:/source/nscp/build/x64/scripts/python/test.py
d nk\modules\PythonScript\PythonScript.cpp:259  Adding script: pytest (D:/source/nscp/build/x64/scripts/python/test.py)
d nk\modules\PythonScript\PythonScript.cpp:106  Loading python script: D:/source/nscp/build/x64/scripts/python/test.py
e \modules\PythonScript\script_wrapper.cpp:15   Testing to register a function
d    ..\..\..\trunk\service\NSClient++.cpp:714  NSClient++ - 0,4,0,93 2011-09-04 Started!
l rce\nscp\trunk\service\simple_client.hpp:30   Enter command to inject or exit to terminate...

So now we are all set. The next step is to run the commands command which will list all available commands:

commands
l rce\nscp\trunk\service\simple_client.hpp:12   Commands:
l rce\nscp\trunk\service\simple_client.hpp:12   | pytest_test: Run python unittest

Now this is a pretty slim set of commands as I am only loading my script and my module. Normally you will have a lot more commands here. But lets run the command and see what happens:

pytest_test
d    ..\..\..\trunk\service\NSClient++.cpp:1021 Injecting: pytest_test...
d    ..\..\..\trunk\service\NSClient++.cpp:1021 Injecting: _pytest_test_channel_001...
d    ..\..\..\trunk\service\NSClient++.cpp:1051 Result _pytest_test_channel_001: OK
e \modules\PythonScript\script_wrapper.cpp:15   OK - Test successfull: simple ok
d    ..\..\..\trunk\service\NSClient++.cpp:1021 Injecting: _pytest_test_channel_001...
d    ..\..\..\trunk\service\NSClient++.cpp:1051 Result _pytest_test_channel_001: WARNING
e \modules\PythonScript\script_wrapper.cpp:15   OK - Test successfull: simple warning
d    ..\..\..\trunk\service\NSClient++.cpp:1021 Injecting: _pytest_test_channel_001...
d    ..\..\..\trunk\service\NSClient++.cpp:1051 Result _pytest_test_channel_001: CRITICAL
e \modules\PythonScript\script_wrapper.cpp:15   OK - Test successfull: simple critical
d    ..\..\..\trunk\service\NSClient++.cpp:1021 Injecting: _pytest_test_channel_001...
d    ..\..\..\trunk\service\NSClient++.cpp:1051 Result _pytest_test_channel_001: WARNING
e \modules\PythonScript\script_wrapper.cpp:15   OK - Test successfull: simple unknown
d    ..\..\..\trunk\service\NSClient++.cpp:1021 Injecting: _pytest_test_channel_001...
d    ..\..\..\trunk\service\NSClient++.cpp:1051 Result _pytest_test_channel_001: OK
e \modules\PythonScript\script_wrapper.cpp:15   OK - Test successfull: simple performance data 001
d    ..\..\..\trunk\service\NSClient++.cpp:1021 Injecting: _pytest_test_channel_001...
d    ..\..\..\trunk\service\NSClient++.cpp:1051 Result _pytest_test_channel_001: OK
e \modules\PythonScript\script_wrapper.cpp:15   FAILED - Test did not get the correct retuirn code: 'foo'=5% = 'foo'=5%;10
d    ..\..\..\trunk\service\NSClient++.cpp:1021 Injecting: _pytest_test_channel_001...
d    ..\..\..\trunk\service\NSClient++.cpp:1051 Result _pytest_test_channel_001: OK
e \modules\PythonScript\script_wrapper.cpp:15   OK - Test successfull: simple performance data 003
d    ..\..\..\trunk\service\NSClient++.cpp:1021 Injecting: _pytest_test_channel_001...
d    ..\..\..\trunk\service\NSClient++.cpp:1051 Result _pytest_test_channel_001: OK
e \modules\PythonScript\script_wrapper.cpp:15   OK - Test successfull: simple performance data 004
d    ..\..\..\trunk\service\NSClient++.cpp:1021 Injecting: _pytest_test_channel_001...
d    ..\..\..\trunk\service\NSClient++.cpp:1051 Result _pytest_test_channel_001: OK
e \modules\PythonScript\script_wrapper.cpp:15   OK - Test successfull: simple performance data 005
e \modules\PythonScript\script_wrapper.cpp:15   ERROR: 1 tests failed
e \modules\PythonScript\script_wrapper.cpp:15   Tested Testing that channels work (1 of 9)
d    ..\..\..\trunk\service\NSClient++.cpp:1021 Injecting: _pytest_test_command_001...
d    ..\..\..\trunk\service\NSClient++.cpp:1051 Result _pytest_test_command_001: OK
e \modules\PythonScript\script_wrapper.cpp:15   OK - Test successfull: simple check
d    ..\..\..\trunk\service\NSClient++.cpp:1021 Injecting: _pytest_test_command_001...
d    ..\..\..\trunk\service\NSClient++.cpp:1051 Result _pytest_test_command_001: OK
e \modules\PythonScript\script_wrapper.cpp:15   OK - Test successfull: simple check: Ok
d    ..\..\..\trunk\service\NSClient++.cpp:1021 Injecting: _pytest_test_command_001...
d    ..\..\..\trunk\service\NSClient++.cpp:1051 Result _pytest_test_command_001: WARNING
e \modules\PythonScript\script_wrapper.cpp:15   OK - Test successfull: simple check: Warn
d    ..\..\..\trunk\service\NSClient++.cpp:1021 Injecting: _pytest_test_command_001...
d    ..\..\..\trunk\service\NSClient++.cpp:1051 Result _pytest_test_command_001: WARNING
e \modules\PythonScript\script_wrapper.cpp:15   OK - Test successfull: simple check: Unknown
d    ..\..\..\trunk\service\NSClient++.cpp:1021 Injecting: _pytest_test_command_001...
d    ..\..\..\trunk\service\NSClient++.cpp:1051 Result _pytest_test_command_001: CRITICAL
e \modules\PythonScript\script_wrapper.cpp:15   OK - Test successfull: simple check: Crit
e \modules\PythonScript\script_wrapper.cpp:15   OK: all tests successfull
e \modules\PythonScript\script_wrapper.cpp:15   Tested Testing that channels work (0 of 9)
d    ..\..\..\trunk\service\NSClient++.cpp:1051 Result pytest_test: CRITICAL
l rce\nscp\trunk\service\simple_client.hpp:12   CRITICAL:Tests failed 1 of 18

This is a big chunk of output and unfortunetly we get a lot of debug output here as well, some day I shall improve this to list all relevant output at the end. But the interesting tidbits (cleaned up below)

pytest_test
e \modules\PythonScript\script_wrapper.cpp:15   OK - Test successfull: simple ok
e \modules\PythonScript\script_wrapper.cpp:15   OK - Test successfull: simple warning
e \modules\PythonScript\script_wrapper.cpp:15   OK - Test successfull: simple critical
e \modules\PythonScript\script_wrapper.cpp:15   OK - Test successfull: simple unknown
e \modules\PythonScript\script_wrapper.cpp:15   OK - Test successfull: simple performance data 001
e \modules\PythonScript\script_wrapper.cpp:15   FAILED - Test did not get the correct retuirn code: 'foo'=5% = 'foo'=5%;10
e \modules\PythonScript\script_wrapper.cpp:15   OK - Test successfull: simple performance data 003
e \modules\PythonScript\script_wrapper.cpp:15   OK - Test successfull: simple performance data 004
e \modules\PythonScript\script_wrapper.cpp:15   OK - Test successfull: simple performance data 005
e \modules\PythonScript\script_wrapper.cpp:15   ERROR: 1 tests failed
e \modules\PythonScript\script_wrapper.cpp:15   Tested Testing that channels work (1 of 9)
e \modules\PythonScript\script_wrapper.cpp:15   OK - Test successfull: simple check
e \modules\PythonScript\script_wrapper.cpp:15   OK - Test successfull: simple check: Ok
e \modules\PythonScript\script_wrapper.cpp:15   OK - Test successfull: simple check: Warn
e \modules\PythonScript\script_wrapper.cpp:15   OK - Test successfull: simple check: Unknown
e \modules\PythonScript\script_wrapper.cpp:15   OK - Test successfull: simple check: Crit
e \modules\PythonScript\script_wrapper.cpp:15   OK: all tests successfull
e \modules\PythonScript\script_wrapper.cpp:15   Tested Testing that channels work (0 of 9)
l rce\nscp\trunk\service\simple_client.hpp:12   CRITICAL:Tests failed 1 of 18

And as we can see all tests but one succeeded and that is a but I shall fix at some point. When you only have a warning threshold and no critical threshold the warning one is discarded in the parser.

Now the cool thing is that this all work the same from linux... and with the right setup and some tinkering... remotely... pretty cool huh?

Michael Medin

Linux love!

Yaaay...

mickem@kubuntu-VirtualBox:/mnt/nscp/build/linux$ ./nscp --test
l   /mnt/nscp/trunk/service/NSClient++.cpp:553  Attempting to start
d ttings_manager/settings_manager_impl.cpp:156  No entries found looking in (adding default): /mnt/nscp/build/linux/boot.ini
d ttings_manager/settings_manager_impl.cpp:165  Boot order: old://${exe-path}/nsc.ini, ini://${shared-path}/nsclient.ini
d ttings_manager/settings_manager_impl.cpp:168  Activating: ini://${shared-path}/nsclient.ini
d ttings_manager/settings_manager_impl.cpp:68   Creating instance for: ini://${shared-path}//nsclient.ini
d /trunk/include/settings/settings_ini.hpp:254  Reading INI settings from: /mnt/nscp/build/linux/nsclient.ini
d /trunk/include/settings/settings_ini.hpp:228  Loading: /mnt/nscp/build/linux/nsclient.ini from ini://${shared-path}/nsclient.ini
l   /mnt/nscp/trunk/service/NSClient++.cpp:558  Booted settings subsystem...
e   /mnt/nscp/trunk/service/NSClient++.cpp:641  Warning Not compiled with google breakpad support!
d   /mnt/nscp/trunk/service/NSClient++.cpp:410  Found: PythonScript as 
d   /mnt/nscp/trunk/service/NSClient++.cpp:702  Processing plugin: libPythonScript.so as 
d   /mnt/nscp/trunk/service/NSClient++.cpp:986  addPlugin(/mnt/nscp/build/linux/modules/libPythonScript.so as )
d   /mnt/nscp/trunk/service/NSClient++.cpp:962  Loading plugin: PythonScript...
d nk/modules/PythonScript/PythonScript.cpp:187  Looking for: q
d nk/modules/PythonScript/PythonScript.cpp:187  Looking for: /mnt/nscp/build/linux/scripts/python/q
d nk/modules/PythonScript/PythonScript.cpp:187  Looking for: /mnt/nscp/build/linux/scripts/q
d nk/modules/PythonScript/PythonScript.cpp:187  Looking for: /mnt/nscp/build/linux/python/q
d nk/modules/PythonScript/PythonScript.cpp:187  Looking for: /mnt/nscp/build/linux/q
e nk/modules/PythonScript/PythonScript.cpp:191  Script not found: q
d nk/modules/PythonScript/PythonScript.cpp:187  Looking for: test.py
d nk/modules/PythonScript/PythonScript.cpp:187  Looking for: /mnt/nscp/build/linux/scripts/python/test.py
d nk/modules/PythonScript/PythonScript.cpp:205  Adding script: py (/mnt/nscp/build/linux/scripts/python/test.py)
e /modules/PythonScript/script_wrapper.cpp:12   Hello World
e /modules/PythonScript/script_wrapper.cpp:12   Got it: 
e /modules/PythonScript/script_wrapper.cpp:12   Testing to register a function
l /modules/PythonScript/script_wrapper.cpp:27   Added simple command: py_test to list of: py_test
l /modules/PythonScript/script_wrapper.cpp:27   Added simple command: py_normal to list of: py_normal, py_test
l /modules/PythonScript/script_wrapper.cpp:27   Added simple command: py_nop to list of: py_nop, py_normal, py_test
l /modules/PythonScript/script_wrapper.cpp:27   Added simple command: py_nom to list of: py_nom, py_nop, py_normal, py_test
l /modules/PythonScript/script_wrapper.cpp:27   Added simple command: py_nor to list of: py_nom, py_nop, py_nor, py_normal, py_test
e /modules/PythonScript/script_wrapper.cpp:12   Testing to register settings keys
e /modules/PythonScript/script_wrapper.cpp:12   Testing to get key (nonexistant): 4
e /modules/PythonScript/script_wrapper.cpp:12   Testing to get it (after setting it): 4
e /modules/PythonScript/script_wrapper.cpp:12   Saving configuration...
d   /mnt/nscp/trunk/service/NSClient++.cpp:727  NSClient++ - 0,4,0,83 2011-08-07 Started!
l mnt/nscp/trunk/service/simple_client.hpp:26   Enter command to inject or exit to terminate...
py_test
d   /mnt/nscp/trunk/service/NSClient++.cpp:1106 Injecting: py_test...
e /modules/PythonScript/script_wrapper.cpp:12   inside test
d   /mnt/nscp/trunk/service/NSClient++.cpp:1106 Injecting: py_normal...
e /modules/PythonScript/script_wrapper.cpp:12   inside normal
d   /mnt/nscp/trunk/service/NSClient++.cpp:1136 Result py_normal: OK
d   /mnt/nscp/trunk/service/NSClient++.cpp:1106 Injecting: py_normal...
e /modules/PythonScript/script_wrapper.cpp:12   inside normal
e /modules/PythonScript/script_wrapper.cpp:12    | Got argument: hello
d   /mnt/nscp/trunk/service/NSClient++.cpp:1136 Result py_normal: OK
d   /mnt/nscp/trunk/service/NSClient++.cpp:1106 Injecting: py_normal...
e /modules/PythonScript/script_wrapper.cpp:12   inside normal
e /modules/PythonScript/script_wrapper.cpp:12    | Got argument: hello
e /modules/PythonScript/script_wrapper.cpp:12    | Got argument: world
d   /mnt/nscp/trunk/service/NSClient++.cpp:1136 Result py_normal: OK
d   /mnt/nscp/trunk/service/NSClient++.cpp:1136 Result py_test: OK
l mnt/nscp/trunk/service/simple_client.hpp:12   OK:Tests ok
exit
l mnt/nscp/trunk/service/simple_client.hpp:12   Exiting...
d   /mnt/nscp/trunk/service/NSClient++.cpp:763  Attempting to stop
d   /mnt/nscp/trunk/service/NSClient++.cpp:766  Stopping: NON Message Handling Plugins
d   /mnt/nscp/trunk/service/NSClient++.cpp:916  Unloading plugin: PythonScript...
e /modules/PythonScript/script_wrapper.cpp:12   Unloading script...
d   /mnt/nscp/trunk/service/NSClient++.cpp:794  Stopping: Settings instance
d   /mnt/nscp/trunk/service/NSClient++.cpp:818  Stopping: Message handling Plugins
d   /mnt/nscp/trunk/service/NSClient++.cpp:916  Unloading plugin: PythonScript...
l   /mnt/nscp/trunk/service/NSClient++.cpp:826  Stopped succcessfully
mickem@kubuntu-VirtualBox:/mnt/nscp/build/linux$ uname -a
Linux kubuntu-VirtualBox 2.6.38-8-generic #42-Ubuntu SMP Mon Apr 11 03:31:24 UTC 2011 x86_64 x86_64 x86_64 GNU/Linux
mickem@kubuntu-VirtualBox:/mnt/nscp/build/linux$ 

A few issues here and there but at least the python script module is working on Linux :P Tomorrow I am gonna see if I can get NRPE and such up as well... Then I guess it is time to get some third party feedback

UPDATE: NRPE is also working actually:

mickem@kubuntu-VirtualBox:/mnt/nscp/build/linux$ /usr/lib/nagios/plugins/check_nrpe -H localhost -c py_test
Tests ok

Soo... maybe I shall writeup a guide on how to build it?

Michael Medin

  • Posted: 2011-08-10 14:54 (Updated: 2011-08-10 16:04)
  • Categories: 0.4.0 linux
  • Comments (0)

Welcome community!!! :P

Hello community!

Awesome to see someone actually helping out here :P Really really nice!

Also if there are any handy unix using people out there I will starting next week be doing a small (controlled) alpha of the up-coming 0.4.x branch which will (in addition to windows) also run on unix. The version is far from finished but it would be interesting to see how well it builds out there in the "big world" outside my Debian here at home.

The features currently supported in the 0.4.x branch is:

I would also really really like to get feedback on what people would like to see in the form of features and such. Especially on *nix where I am just now starting to thread lightly... Also feel free to let me know if I am stone crazy and should give upon this! :)

And again wicked big thanks to everyone who helps out and such on the forum/wiki/* here!!!

Michael Medin