I attended the conference for the third time and as always the weather in Bolzano in conjunction with a nice conference made for a great time. I have already mentioned my experiences with the hotel in a previous post so here I will focus mainly on the conference itself and my trip.
Tag Archives: monitoring
Scripting on the Windows side
The biggest reason for Nagios success is the ability to extend it with custom scripts which makes it one of the most powerful monitoring systems. Now Nagios is not the only place where you can extend your monitoring! NSClient++ provides many ways to extend it with scripts and since I have gotten many questions about how to use scripts with NSClient++ lately I have decided to write this tutorial to help sort out the concepts.
What would you like to hear about?
I was asked to present at OSMC in October later this year and figured I would ask around a bit:
What would you like to hear me talk about?
Now I figured I would also use this to see what kind of blog post I shall write so two birds with one stone
A few ideas I have for topics are:
- Real-time monitoring
I started to dabble a bit with real time monitoring when I wrote/talked about the real time event-log monitoring stuff I added to NSClient++. But the subject is much larger and there is a lot of other areas such as performance counters, disk/io as well as log monitoring (files not event log). - The road ahead/Whats new (NSClient++).
This is to me always feel a bit cheep. Like I cant come up with a a topic so I tend to avoid it besides I did a lot of the ”whats new” last year. But perhaps people think it is interesting? - Extending NSClient++
NSClient++ can be extended with scripts but it is much more powerful then your normal scripting. There is also a myriad of ways it can be scripted and extended such as Lua, Python, dot-net etc etc. - Monitoring Windows
Now this is a big topic and the reason I often avoid it is that you either make it to general by not speaking about X which means you end up with ”monitor disk, cpu and memory” or you make it to detailed meaning everyone thinks ”but I don’t use X”. - Configuration management with NSClient++
Now this is a topic I think will become more and more interesting as the number of configuration options are exploding with more and more able versions. - Java monitoring
This is something I would like to talk about since I am a Java developer and I did a talk about this a few years back but the main problem is the details will be very application server specific meaning you again end up with everyone thinking ”I don’t use X”. - Distributed monitoring
Again a topic I feel much about and I spoke a bit about it here and there last year so probably not for OSMC but maybe some blog posts? - Monitoring Patterns
Now I am not a monitoring specialist but something I have been actively looking for are recipes and patterns for monitoring various things and I think it would be nice to start collecting various recipes for monitoring. Now this is (as I said) not really my field (I am more of an infrastructure guy) but perhaps I could start with what I know and see if we can get somewhere? - Feel free to add you own ideas here!
Interact, get back to me, let me know what you think!
Real time event-log monitoring with NSClient++
Monitoring the event log can quickly become straining for both the computer as well as the administrator as the event log grows and grows. To make this simpler for both the administrator and the computer NSClient++ 0.4.0 introduced real-time event log monitoring. This means we no longer scan the event log instead we simply scan events as they come in. The benefit, in addition to lowering the resources required, is that we can also get notified instantly when an error occurs instead of every 5 minutes or however often we check the log. Another addition is a simple client o generate event log message to help administrators debug event log filters. This is a quick introduction to event log monitoring and real-time event log monitoring showing how to set up real-time event log monitoring both for active and passive use via NSCA and NRPE.
Using WMI with NSClient++ 0.4.0 Part 1: Command line tools
This is a series detailing how you can leverage WMI to monitor you Computers from a monitoring tool such as Nagios or Icinga. Since I decided to clean up the command line syntax of the WMI plugin for NSClient++ for the up-coming 0.4.0 version a few days ago I will start by showing how you can use what has become an almost full featured WMI client.
Nagios World Conference vs. Open Source Monitoring Conference?
A BIG DISCLAIMER: This is all nonsense… but…
Since I was asked repeatedly at OSMC (Open Source Monitoring Conference) by various people how the conference compared I figured I would (in the spirit of me) do a bit of a spoof comparison. So please don’t take this seriously…
Tags
First off the biggest change you will notice is of course the “I am Michael” tag you get when you arrive, which like the sheep I am, I parade around with.
If we look we will quickly see the NWC (Nagios World Conference) is bigger. So the following question is bigger better, being from the US Ethan obviously thinks so, but I am not American so I am not so sure. The big benefit to the bigger one is name could be bigger making it simpler for people to read but here NWC has botched it using most of the available real-estate for a big white border. But on the other hand Netways has botched by using only caps and a rather narrow font making the name difficult to read at a casual glance.
Reversing the tag we find on the NWC one a lot of information where as OSMC reversed is the same (which incidentally is more difficult then you might think to achieve) The drawback to the NWC information page which seems like a better option is the layout which feels both Spartan and rather badly layouted (notice the inconsistent white spaces).![]()
Winner this round: OSMC
Mainly for the more professional tag and the ingenious idea of adding stars (one for each year) to the tag
Folders
Seems a lot of conference nowadays hands out some form of folder to put your papers in. Nagios here went all out giving us a fancy waterproof zip-locked plastic thing.So one might be tempted to just blindly hand it to NWC theirs was waay cooler. But unfortunately the coolness comes at a price. From the end user perspective (me) It is much more difficult to get papers in and out. it is also not very durable (meaning papers fold easily) which I guess is the main point (to keep my papers nice, organized and unfolded).![]()
Winner this round: NWC
Mainly for the rather dashing all out plastic waterproof thingy.
Lanyards
Another one of these modern conferences thing is handing out lanyards left and right. Both conference mainly used the lanyard for attaching the tag to the neck (so no pin attachment option was available at either conference). In all fairness neither of the lanyards was particularly fancy (Oracle really has that lead). But Nagios went the cheaper route and went with the most basic version (not even a proper non flex cord). Netways on the other hand at least out a bit more effort into it having a detachable part as well as the rather normal non-flex cord.
Winner this round: OSMC
Non of them were really spectacular and should perhaps say the looser was Nagios for going with the cheaper then normal option.
T-shirts
Or rather lack of. Nagios had a pretty basic standard thing going with a blue t-shirt with a black Nagios logo on the front and a rather fashionable cog design thing on the back (in gray-white-black). They opted for an American Apparel t-shirt with is ok, but after washing it a few times it is showing signs of deformation.
On the other hand Netways really missed this golden opportunity to score points as they provided no t-shirt at all.
Winner this round: NWC
Kind of hard to loose against no t-shirt at all I guess.
Internet
OSMC provide free internet access (WiFi) throughout the conference and hotel rooms which is really neat and gives you ample time to slack off and browse for pr0n and me ample time to prepare my presentation and fix bugs (read slack off and browser for pr0n). And on the flip side NWC presumably provided (in the conference rooms) free WiFi but no one I met managed to actually connect to any of the access points. What was even worth was the fact they provided no internet at all in the rooms which was an extra $10 per 24h (well, technically it was $9.95 but who counts).
Winner this round: OSMC
Again kind of hard to loose against paying $20 for Internet access in my room and not having a working WiFi in the conference area.
Loot
I have been several years to OSMC and Netways tend to provide very little in the way of loot. What you get is essentially a “certificate“ (read letter saying Michael was there) and for speaking and some adverts and what not. In addition to this you pretty much get nothing else for speaking. I guess you could call the “lunchbox” loot but that’s mainly a sandwich and some Juice and a fruit so not really my thing I guess. Where as Nagios went all the way here giving out candy, a book and one of them fancy mugs.
Winner this round: NWC
Mainly for actually providing loot…
Conclusion
So I guess the conclusion is a tie right?
And rightly so, both conference were really good and well worth a visit. For me as a speaker and long time visitor of OSMC it was pretty nice to get to see somewhere else for a change but both conference have excellent speaker and nice presentations (hay, I spoke at both of them
).
Tags |
||
Folders |
![]() |
|
Lanyards |
||
T-shirts |
![]() |
|
Internet |
||
Loot |
![]() |
|
Conclusion |
Final words!
Again, so, so so sorry Ethan, Mary, Bernd and Pamela for spoofing/bastardising your wonderful work! It was very nice conferences, very nice work and I enjoyed myself immensely! So to me you are all winners for putting in all this effort…
A big thank you to everyone involved in arranging these conferences!
Unit test your monitoring: Introducing unit tests in Python for NSClient++
One of the new features of the up-coming NSClient++ 0.4.0 will be Python scripting support. The main reason for me to include Python script (apart from the coolness factor) is to write unit tests. Writing unit test for a monitoring agent with a C++ unit test kit is pretty difficult but more importantly not very productive. The main feature of an agent is to interact with the system and thus you need to know about the system to be able to test it (or mock the system which is tedious at best).![]()
So how does the unit tests work and, perhaps more importantly, why should you care?
Well, where as I write unit tests to see if NSClient++ is working you should want to test if your monitoring is working. In essence it would really suck if you spent hours and hours to configure and setup your monitoring only to discover when some thing broke that it was in fact not setup correctly. So a good idea is to write unit tests to make sure your monitoring is actually working.
So how does the unit test framework in NSClient++ work? Well it is fairly straight forward as long as you understand some basic Python.
In this series (this is the first part) I will introduce how to write unit tests in Python and how to make sure your monitoring is actually working (before it breaks). As this is a work in progress the various topics are not nailed down but the over all idea is something like this:
- Unit test your monitoring: Introducing unit tests in Python for NSClient++
Where we learn how to get started with the unit test framework. - Unit test your monitoring: Write your first real unit test
Where we learn how to write a useful test which actually tests something. - Unit test your monitoring: Breaking (or faking) your system
How you can create event log messages, files, or fake system load? - ?
Writing a test
So lets start what is the minimum effort required to get a unit test setup and installed in NSClient++?
from test_helper import BasicTest, TestResult, setup_singleton, install_testcases, init_testcases, shutdown_testcases class SampleTest(BasicTest): pass setup_singleton(SampleTest) all_tests = [SampleTest] def __main__(): install_testcases(all_tests) def init(plugin_id, plugin_alias, script_alias): init_testcases(plugin_id, plugin_alias, script_alias, all_tests) def shutdown(): shutdown_testcases()
Now this is not to bad right?
Going through the code briefly we have:
- [1] Import some random stuff we need from the unit test framework
- [3-4] Create a dummy unit test (this is where we will expand and include the actual test later on).
- [6] This creates a singleton from our test case since the plugin might be called from various ends it is important to use single ton patterns or else a message might end up being sent to the “wrong” test.
- [8] Here we define all test instances in this file (not required but I think it is a neat way to have them all in one place)
- [10-11] This is the main function called when the script is executed from command line. Here we normally want to install the test script (which is what we do here)
- [13-14] The init function is called when the script is executed from NSCP and here we want to setup our unit test so we call the framework asking it to add and initialize our test case.
- [16-17] When NSCP is finished this function is called so we can un-initialize all resources just relay this on to the test framework.
Installing a test
One of the nice features of using the framework for writing your unit tests is that you get install automagically (and eventually uninstall as well). This is done when we call the install wrapper on line 11 above. So how do we call the script on command line?
Well the rather complicated way to do this now is:
nscp --client --module PythonScript --command run --script test_sample
This will be prettified eventually but for now all these arguments are required so lets try to explain them quickly to see if it makes sense.
- –client
Means we run in client mode (in other words don’t actually start NSClient++ just utilize some offline features) - –module
Not strictly required but makes it simpler for NSClient++. This tells NSClient++ which plugin to load. - –command run
This is the command to execute on the module in question. In this case tell “PytonScript” to execute “run”. - –script <script>
This is the actual script we want to load. The path is magically added by the module (which in turn will look inside various folders).
So it was not quite as complicated as it seemed right? Well it is far to complicated and it is on my TODO list so eventually you will most likely have something along the lines of nscp_client –script test_sample.py but for now we are stuck with the long version.
What this chunk does is add a few lines to the nsclient.ini file (or whatever settings store you are using).
[/modules] pytest = PythonScript [/settings/pytest/scripts] ; UNIT TEST SCRIPT: SampleTest - A script for running unittests for: TODO: Describe: SampleTest test_sample = test_sample.py
Running a test
So all that is left is actually running the test right?
Well, this is straight forward enough just start NSClient++ in test mode like so:
nscp --test
Once that is don we run the following command py_unittest.
Which yield the following:
py_unittest e \modules\PythonScript\script_wrapper.cpp:120 ERROR: Running suite: SampleTest (None) e \modules\PythonScript\script_wrapper.cpp:120 ERROR: TODO add implementation (None) l \modules\PythonScript\script_wrapper.cpp:113 ERROR: 0 of 2 test(s) succedded (2 failed) l rce\nscp\trunk\service\simple_client.hpp:12 CRITICAL:ERROR: 2/2 test(s) failed
So that’s pretty nice… all test failing (as we haven’t actually written one). But hopefully you get the idea. It is pretty damn simple to write unit tests in Python.
Thus ends this installment of this series and although it is not nailed down the general topic ideas for the next few installments are:
- Unit test your monitoring: Introducing unit tests in Python for NSClient++
Where we learn how to get started with the unit test framework. - Unit test your monitoring: Write your first real unit test
Where we learn how to write a useful test which actually tests something. - Unit test your monitoring: Breaking (or faking) your system
How you can create event log messages, files, or fake system load? - ???

