Icinga2 and NSClient++ integration

  • Hello all!


    I'm trying to get NSClient++ working to send data for Icinga2. I followed this guide step-by-step but can't seem to get it working. This may be because this guide was written for the 0.4.x version of NSClient++ (and more than two years ago), but I have installed the 0.5.x version on my Windows host. I noticed this thread somewhat relating to what I want to do, but I want to use NSClient++ instead of WMI checks.


    My current problem seems to lie in that my Icinga Web portal reports that the service that I've defined receives no passive check result. See image:



    This doesn't quite make sense because the ports that need to be open are open, and communication should be good between the hosts. I have an agent installed on the Windows server as well, and it communicates just fine.


    If any screenshots or additional information needs to be provided, please let me know.


    Thanks to anyone who could point me in the right direction.

  • I'm certain the communication is good between hosts. I found an updated "guide" here. I used the code located in the comments near the bottom of the feature tracker. It looks like this:


    The code goes on for a handful of different services.


    I have implemented the code in my Icinga2 instance:


    but am now getting a different error:


    Not really sure where it's calling scp.exe from...


    Thanks for the reply!



    -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


    EDIT 1 (9:38 AM): Now that I think about it, maybe that scp.exe is actually trying to call "nscp.exe" from the NSClient++ installation on Windows. This is just a theory, but could be the problem... does anyone know where this is calling from so that I could maybe fix the name so that it sees it correctly?


    EDIT 2 (10:22 AM): Theory has been confirmed. I looked through /var/log/icinga2/icinga2.log and found the following entry:

    I underlined the parts which are most important. The first one is the name of the node followed by the service name. The second underline is the name of the script that its executing (which is located on the my Windows server at "C:/Program Files/NSClient++"). The third underline is the error code that I'm getting on the Icinga2 web interface. The reason why the web interface shows ". scp.exe" is because "\n" is parsed as a carriage return in ".\nscp.exe".


    If I run the command on my Windows server, I get a valid output.


    Does this error occur on my Icinga2 server because the service is not located on the Icinga2 server itself? The next course of action would be to find out how to get the .\nscp.exe on the Icinga2 server, I guess. Note, I do have the nscp package included in the "/etc/icinga2/icinga2.conf/" directory.


    EDIT 3 (11:09 AM): I believe this problem is due to the vars.client_endpoint line in my host/service configuration listed above. I have it set to NodeName (which is the name of my local node). I believe it must be set to the name of the Windows server, because that's where the command will be executing (which makes sense that the command doesn't work on the Icinga2 Server). The problem is, when I set it equal to that, I get a different error, saying that I cannot set command_endpoint equal to host.vars.client_endpoint in the service definition. See pictures:


    My host/service configuration, with the vars.client_endpoint set equal to the name of the host:


    When I try to restart the Icinga2 service after changing the configs, I am presented with the following error:
    This is what the documentation says to do, but clearly it's not working for me. Unsure where to go from here.


    NOTE: I will bold all the questions so that they are easier to see.

  • What does your check comman definition for nscp-local-cpu look like? Please provide text and not a screenshot of text.



    Quote

    The reason why the web interface shows ". scp.exe" is because "\n" is parsed as a carriage return in ".\nscp.exe".

    That's funny but shouldn't happen ^^ I'll ask the webguys about it

  • I think perhaps I had some configuration errors. I was not fully grasping what the configuration should look like. After further review, I found out that the datacenter-dev object had to be defined as an endpoint. Since I have an Icinga2 agent installed on the host, that means I already have an Endpoint object (stored in /etc/icinga2/repository.d) defined for datacenter-dev.


    Therefore, I could either 1) create a new Endpoint object named datacenter-dev-test and create new services for it or 2) I can just use the already configured/defined datacenter-dev Endpoint object instead. I wound up with option 2, and it seems to be working:



    Only I have this problem now which is showing on my web interface instead of the error (.\nscp.exe failed, no such file or directory) before:


    UNKNOWN - Service: nscp-local-cpu

    Code
    1. INF: Detected crash...
    2. INF: Running: "C:\Program Files\NSClient++\reporter.exe" "archive" "C:\Windows\SERVIC~2\NETWOR~1\AppData\Local\Temp\\04ba38a2-b2ce-4cb1-bce7-640fa15912ca.dmp" "NSClient++" "0.5.0.62" "2016-09-14" "C:\Program Files\NSClient++/crash-dumps"
    3. boost::filesystem::copy_file: Access is denied: "C:\Windows\SERVIC~2\NETWOR~1\AppData\Local\Temp\\04ba38a2-b2ce-4cb1-bce7-640fa15912ca.dmp", "C:\Program Files\NSClient++/crash-dumps\04ba38a2-b2ce-4cb1-bce7-640fa15912ca.dmp"
    4. ERR: Failed to check service state
    5. INF: Running: "C:\Program Files\NSClient++\reporter.exe" "restart" "NSCP"

    I'm unsure if this has anything to do with this problem as pointed out by @dnsmichi about a little more than a month ago.


    As for your question about:


    What does your check comman definition for nscp-local-cpu look like?


    I am unsure how to check that. I know that my PluginDir (as defined in /etc/icinga2/constants.conf) points to /usr/lib64/nagios/plugins, but I don't see the check command and I'm not sure what exactly to look for. Whenever I try to edit one of these plugins, all I see is gibberish. Please give some more insight.


    Thanks for the reply!



    P.S.
    Regarding the \n problem, it can be easily fixed if there is another "\" added to the front of "\n". For example, in java:



    Not sure what language you guys are using, but the same principle should apply.

  • That "guide" in the linked Icinga 2 issue relies on the fact that there are changes required for both, the ITL CheckCommand on the Icinga 2 side, and NSClient++ itself. This hasn't been released yet with Icinga 2, therefore I'm also holding off a blog post which would explain that even more. Stick with 0.4.x provided by the Icinga 2 Windows package for now. Maybe Michael Medin already fixed the reported bug which causes the crash, but I fairly did not read anything during my vacation.

  • Just a few quick questions:


    I noticed on the documentation that it says that the nrpe plugin is deprecated/unsecure. Does that mean we can't use it anymore? Because I don't see it in my PluginDir (/usr/lib64/nagios/plugins/), which makes it so I can't use this even if I wanted to. Is there any way to add this plugin into the directory or is there no point if check_nt exists (which, allegedly, is a more secure but less powerful plugin that performs similar actions)?


    A lot of the threads regarding this topic are from a couple years ago. I'm not sure what to do at this point.


    Thanks!