Monitoring Programs Installed with Centreon

Something that is also interesting to monitor in our equipment, it will be the software they have installed, In this post we will see how we can simply achieve it and alert ourselves when software is installed on a Windows computer, or uninstall.

That's right, through this script wonderful PowerShell we can know the number of programs/software that a computer has installed, as well as knowing their inventory. Well, Well, as we know and it is usual, with NRPE We can run remote scripts on machines. So thanks to Centreon, we will be able to centralize the control of the software of our machines in a single point. We will monitor the number of programs they have installed, and if this number varies with the previous check-in, will alert us.

¡Started! We will do this on each Windows computer to be monitored, where we will obviously have NSClient previously installed. We place the script in the folder where the NSClient scripts are left, we know it's 'C:\Program FilesNSClient++scripts', Once this is done, we will edit the NSClient configuration file called nsclient.ini. And we add in the corresponding sections something like this, where we define an alias and then the script that will execute when said alias is invoked:

...
[/settings/external scripts/scripts]
windows_app_installs = cmd /c echo scripts\check_windows_app_installs.ps1; exit($lastexitcode) | powershell.exe -
...

[/settings/external scripts/alias]
windows_app_installs = windows_app_installs
...

As usual, save the file and restart the NSClient service to reread the changes made.

Well, because at Centreon we create a new Service, We'll use the command of 'check_nrpe’ that we will have previously created, If you haven't skipped the NRPE Chapter. Total, that we create the service as usual, we give it a name like 'Installed Programs'’ or whatever imagination you have, and in the Argument it will be enough to indicate the 'alias’ that we have defined in the nsclient.ini. We will take into account that we will modify the frequency of the checks, It doesn't make sense every 5 minutes.

And most importantly, We will indicate in 'Max Check Attemps’ to '1’ so that it only does a check and is HARD immediately. Since by default Centreon performs 3 Checks before alerting/notifying, we have 3 SOFT before HARD. And what happens? That this wonderful script when running verifies the software that it had the previous time it was run, and if, Add/remove software, when the script is executed when ZAS is called! it will jump but it would be a SOFT and we want a HARD, since as we understand, If the script is run again (in the 2nd SOFT) the alert would be removed.

And nothing, after recording and exporting the Centreon configuration, we will be able to observe the results of this example, we have 3 Controlled Machines, where we see the number of programs they have installed.

We could click on one of the services and see the details of the software it has detected.

And if someone removes or adds software on a machine, We'll get you! This would be an example,

I hope you liked it, at least it is a curious way to continue controlling our environments, As always, wishing you well., May you be happy, Enjoy and have a hug!

Recommended Posts

Author

nheobug@bujarra.com
Autor del blog Bujarra.com Cualquier necesidad que tengas, Do not hesitate to contact me, I will try to help you whenever I can, Sharing is living ;) . Enjoy documents!!!