Categories
News

What’s coming in the next version of Leaf Node Monitoring?

In my spare time I’m slowly working on the next version of Leaf Node Monitoring. Sales have been above expectation and I have many more ideas I want to implement. Had quite some positive feedback, thanks to all of you who wrote in.

External Process checks

One of the big new features in the next release (v2022.02) will be external processes as monitor checks. Here is a screenshot of two external checks on Android:

You might notice that they’re orange, which means warning status. You might also notice the visual changes, rounded corners and other small tweaks. External processes are simple checks that are successful (OK) when the exit code is 0 and critical otherwise. In this case, they’re warning because some errors, like a nonexistent binary, do not trigger critical (since, no exit code is not the same as exit code > 0).

External processes allow you to have many more checks. I use the checks from Nagios / Icinga, available via https://www.monitoring-plugins.org/, which extend the functionality of Leaf Node Monitoring by a huge amount. I will still continue to implement new checks in native C++, both for speed and cross-platform functionality, but this feature will help in all the cases where there are no checks yet.

Retry attempts

  The next new feature is retry attempts. For all checks currently, like the TCP port or HTTP check I’m implementing an automated retry. Currently 4 times, but I might make that configurable in the future. If a check fails, it will be retried with the same parameters. No back-off timer or pause in between yet. I’ve been running LeafNodeMonitoring myself and have noticed some notifications which were flaky tests, with the automated retries I hope to have less of those.

Unit tests

The last new thing is that I’ve begun to add unit tests. For most of my private projects I don’t do unit tests since they’re not worth the time/effort. At work they’re required and we have automated checks that reject merge requests when there is not enough coverage. Unit tests are not user facing, but they do help in delivering better software. With the growing amount of checks and logic, I am now of the opinion that Leaf Node Monitoring benefits from tests. Since I’m used to write code that can be tested (small methods, decoupled, dependency injected, etc), it does not require any refactoring, I’m noticing most of the code is already testable just fine.

 

Here is an example test that checks if the new external process code fires off the correct signals and returns the correct result when it receives an exit code of 0:

TEST_F(ExternalProcessCheckTest, exitCodeZeroShouldGiveOkayResult)
{
    //arrange
    QString fullPath = "/bin/bash";
    QStringList arguments;
    arguments << "-c 'exit 0'";
    epck = new ExternalProcessCheck(*target, fullPath, arguments, timeout);
    QSignalSpy signalSpy_checkResultChanged(epck, &ExternalProcessCheck::checkResultChanged);

    //act
    emit epck->startCheck();
    signalSpy_checkResultChanged.wait(1000);

    //assert
    EXPECT_EQ(epck->checkResult(), MonitorEnums::CheckResult::Ok);
    EXPECT_EQ(signalSpy_checkResultChanged.count(), 1);
}

The constructor and destructor of this test suite handle the deletion of the pointers and further cleanup, so don’t worry about the naked new.

It’s always hard to test external programs like this, as is testing time-related stuff (without a lot of stubs/mocks). I’m using the googletest framework since I’m used to it. It requires a bit of shoehorning to make it works with Qt but once your project is setup correctly it’s a breeze to use. I had to convert the one project to three projects (a library, an application and a test-app) using SUBDIRS in qmake and linking to the library in the main application. Not rocket science, but I imagine it can be hard to do if you don’t know what to look for.

Code coverage is now up to 57% so that’s a great start.

 

That’s all for this post, I’m not sure when the next version is going to be released, but it will be a free update for all of you who purchased it. If you have any feature requests, issues or want to let me know something, don’t hesitate to contact me.