0

I've been trying to find some examples or documentation for writing .Net plugins for NSClient++.

Can someone direct me to a working sample application or some documentation?

I found the source code for the CSharpSamplePlugin on GitHub. Since I don't use CMake, I made a new VS2013 project and added the three DLL's referenced in the CMake setup to my project (Google.ProtocolBuffers.dll, NSCP.Core.dll, and NSCP.Protobuf.dll). I found the DLLs in the NSClient++ installation dir.

However it seems like the code in SamplePlugin.cs doesn't work with the current DLLs. I get an error on the line:

response.AddLines(Plugin.QueryResponseMessage.Types.Response.Types.Line.CreateBuilder().SetMessage("Hello from C#").Build());

... saying:

Error   2   'Plugin.QueryResponseMessage.Types.Response' does not contain a definition for 'Types'  C:\vs_projects\NSClientHelpers\NsClientPlugin\SamplePlugin.cs   45  74  NsClientPlugin
Error   1   'Plugin.QueryResponseMessage.Types.Response.Builder' does not contain a definition for 'AddLines' and no extension method 'AddLines' accepting a first argument of type 'Plugin.QueryResponseMessage.Types.Response.Builder' could be found (are you missing a using directive or an assembly reference?)   C:\vs_projects\NSClientHelpers\NsClientPlugin\SamplePlugin.cs   45  22  NsClientPlugin

So is there any place where I can find an updated sample plugin or example of how to make NSClient++ plugins?

After struggling with this for a while I just rewrote my commands as two standalone executables, but it irks me that I couldn't get this to work ;)

Cross posted to SO

0

1 Answer 1

2

Currently "master" is undergoing refactoring so currently sample will not build.

If you use 0.4.3 branch it should work fine.

I expect master to become stable in the next week or so (my vacation starts now so I hope to have time to finish things off). The code has been refactored and most modules are working again but the "samples" and a few other such things have yet to be fixed...

EDIT: As a side note one can add that the refactoring which is happening is simplifying the internal messages removing some fields as well as aligning it more with the "Nagios model" in terms of multi line returns.

2
  • I'll give it a try and report back!
    – mhvelplund
    Jul 3, 2015 at 7:33
  • It works :) Only snag was that the DLL has to be in the "modules/dotnet" subfolder which I think is only mentioned in a forum post from someone also having trouble getting it to work.
    – mhvelplund
    Jul 3, 2015 at 8:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .