| 1 | ** ROUGH DRAFT ** |
|---|
| 2 | ** Spelling missate etc... :) ** |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | NSClient++ is a windows service that allows performance metrics to be gathered by Nagios |
|---|
| 6 | (and possibly other monitoring tools). It is an attempt to create a NSClient compatible |
|---|
| 7 | but yet extendable performance service for windows. |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | Installation: |
|---|
| 11 | NSClient++ -install |
|---|
| 12 | Will install the NT service |
|---|
| 13 | |
|---|
| 14 | NSClient++ -uninstall |
|---|
| 15 | Will uninstall the service |
|---|
| 16 | |
|---|
| 17 | NSClient++ -start |
|---|
| 18 | Will start the service |
|---|
| 19 | |
|---|
| 20 | NSClient++ -stop |
|---|
| 21 | Will stop the service |
|---|
| 22 | |
|---|
| 23 | NSClient++ -test |
|---|
| 24 | Will start in interactive mode: |
|---|
| 25 | enter exit<return> to exit. ANything else will be interpreted as a command ie: foo&bar<enter> will be interpreted as a command name foo with argument bar. |
|---|
| 26 | It also listens to the port in this mode so it can be used to run the client standalone. |
|---|
| 27 | Notice output is *NOT* piped t othe stdard output unless you enable the console logger module. |
|---|
| 28 | |
|---|
| 29 | |
|---|
| 30 | |
|---|
| 31 | |
|---|
| 32 | |
|---|
| 33 | The API is quite simple: |
|---|
| 34 | The following functions are available for a module to "export": (think DLL) |
|---|
| 35 | |
|---|
| 36 | NSLoadModule |
|---|
| 37 | - Loading of modules (done when the service starts) |
|---|
| 38 | NSGetModuleName |
|---|
| 39 | - Used to get a nice name for the module. |
|---|
| 40 | NSGetModuleVersion |
|---|
| 41 | - Not really used but... |
|---|
| 42 | NSHasCommandHandler |
|---|
| 43 | - Let the "core" know it can handle commands (from nagios) |
|---|
| 44 | NSHasMessageHandler |
|---|
| 45 | - Used to let the "core" know it wants to see all log/debug/error messages that are generated. |
|---|
| 46 | NSHandleMessage |
|---|
| 47 | - Used to digest a log/debug/error message. |
|---|
| 48 | NSHandleCommand |
|---|
| 49 | - Used to (possibly) digest a command. |
|---|
| 50 | When a command is "injected" then command is parsed and then sent along to all plugins (which accept commands) in order (they are listed in NSC.ini) and they are allowed to act on the command. If they do act on the command the "injection" is aborted and the resulting "return string" is returned to the "injecter" (normaly check_nt through a TCP stream. The ordering can thus be used to 1, optimize if things are slow (though I fail to see that unless someone makes some pretty f*cked up modules) and priority if one module overlaps the command of another (though then I would recommend someone to change the plugin command strings :) |
|---|
| 51 | |
|---|
| 52 | NSUnloadModule |
|---|
| 53 | - Used to unload and terminate "stuff" nicely. (Generally this is when the service terminates) |
|---|
| 54 | NSModuleHelperInit |
|---|
| 55 | - Used to send along callbacks to the module (for making calls to the "core". (Ie. To allow the module to inject commands, get versions, names, and settings) |
|---|
| 56 | |
|---|
| 57 | So the API is quite simple and straight forward (I hope :) |
|---|
| 58 | |
|---|
| 59 | To make a simple call graph: |
|---|
| 60 | |
|---|
| 61 | * Service starts: |
|---|
| 62 | * For each plugin |
|---|
| 63 | - call NSLoadModule |
|---|
| 64 | - call NSModuleHelperInit |
|---|
| 65 | - if NSHasCommandHandler |
|---|
| 66 | . Send to "command plugin" stack |
|---|
| 67 | - if NSHasMessageHandler |
|---|
| 68 | . Send to "message plugin" stack |
|---|
| 69 | * Wait for socket data |
|---|
| 70 | - Parse socket data |
|---|
| 71 | - For each "command plugin" |
|---|
| 72 | . call NSHandleCommand |
|---|
| 73 | . if Command handled abort |
|---|
| 74 | |
|---|
| 75 | <termination signal sent to service> |
|---|
| 76 | * For each plugin |
|---|
| 77 | - NSUnloadModule |
|---|
| 78 | * Terminate service |
|---|
| 79 | |
|---|
| 80 | <Log/debug/error message generated in a module> |
|---|
| 81 | * On incoming message: |
|---|
| 82 | - For each "message plugin" |
|---|
| 83 | . call NSHandleMessage |
|---|
| 84 | |
|---|
| 85 | There are a few more things to this but overall I have tried to keep things simple. |
|---|
| 86 | |
|---|
| 87 | The extensions (to the API) I'm considering as of now (depending on the fallout) is: |
|---|
| 88 | * "SettingsHandler" to allow registry/INI/* settings modules. As the overhead of reg/ini settings system is quite low, perhaps this is overkill. But I don't know: thinking wildly there might be a reason for someone to want to load settings from a central server or whatever :) |
|---|
| 89 | |
|---|
| 90 | * "SocketHandlers" though this will not be a specific handler I have considered to refactor out the code and allow the socket handler (that reads the TCP socket and parses the command) to be a plugin when I do SSL as I assume SSL will come with quite a high overhead and thus I might not need it all the time. |
|---|
| 91 | |
|---|
| 92 | Also as mentioned this might be a good place to do a NRPE socket parser module to allow compatibility with NRPE. But this I assume is a bit in the future as I need to get "NSClient++" before I can get "NRPEClient++"... |
|---|
| 93 | |
|---|
| 94 | As for PassiveChecks that could be implemented as a plugin today as any plugin can inject commands into the "core". Thus a plugin can be loaded, have a background thread that every X minutes calls "core".injectCommand(); and sends the result over to nagios. (This is how I assume that passive checks work) |
|---|
| 95 | |
|---|
| 96 | |
|---|
| 97 | |
|---|
| 98 | |
|---|
| 99 | // Michael Medin - michael <at> medin <dot> name - http://www.medin.name |
|---|