Design question
Design question
Hello,
I have implemented a set of chains which can automate Windows WSUS installation. At this moment servers that need an update are manually added in a schedule on Nagios Reactor after an alert is triggered from this plugin http://outsideit.net/check-ms-win-updates/. This schedule will start at the configured hour (mostly 00:30), take a snapshot of the server, install the WSUS updates on the server and reboot the server if necessary. The day after the scheudle has to be deasactivated manually, as there is not yet a way in reactor to run a chain once in the future (please tell me if i'm wrong). That's why I made this feature request: http://tracker.nagios.com/view.php?id=747
We would like to create a quick action which can initiate such a Windows update chain during the night. There are many possible ways to do this and I would like your opinion on some of the options.
It is also no yet possible to pass a variable in the popup window of a Reactor quick action, so I can't pass the time we would like the WSUS updates to be installed. Check out this thread where I asked for this feature https://support.nagios.com/forum/viewto ... ctor+popup and Trevot said he would make it for me. (Could I have the id for that pls?)
So then I was thinking to make a quick action which adds the host to a hostgroup. Then I could make a schedule which would every nigh update all WSUS hosts in the hostgroup and the remove the host from the hostgroup. This seemed like a good approach, but has a few disadvantages. As every time a host is added or removed from a hostgroup, an apply is needed and an apply take +- 30 seconds, during which there is a window where we are not seeing or finding any hosts. As we have 500+ Windows servers, the above method would imply too many interruptions in the monitoring.
In the meantime I have added a database to our MSSQL database Nagios_Extensions (which also stores our real-time event id exclusions for NSCLient) to store the Windows hosts which need to be updated. I'm 25 % on the way of finishing a Python script which can read and write hosts in the MSSQL database which contains the hosts. But my Python knowledge is basic and I'm not yet convinced this is the best idea. As I would in time publish this set of chains, I cannot be sure every Nagios XI user has access to MSSQL databases, I think I'm in need of a better option.
Today I read about static configuration files like /usr/local/nagios/etc/static/xiobjects.cfg
The documentation about this is very basic and does not contain enough info for me. Would it be usable in my above setup? Is it necessary to apply configuration when adding and removing hosts from this static configuration file? Could I make a bash script which adds hosts to a hostgroup in this static config file and later use a json query to extract the hosts in that hostgroup? Or are static config files not taken into account in JSON queries?
Is there any other option i'm not seeing I could use. The main requirement would be that I don't need to apply configuration in order to add/ remove hosts to a hostgroup or database table.
Thanks for any input on this.
I have implemented a set of chains which can automate Windows WSUS installation. At this moment servers that need an update are manually added in a schedule on Nagios Reactor after an alert is triggered from this plugin http://outsideit.net/check-ms-win-updates/. This schedule will start at the configured hour (mostly 00:30), take a snapshot of the server, install the WSUS updates on the server and reboot the server if necessary. The day after the scheudle has to be deasactivated manually, as there is not yet a way in reactor to run a chain once in the future (please tell me if i'm wrong). That's why I made this feature request: http://tracker.nagios.com/view.php?id=747
We would like to create a quick action which can initiate such a Windows update chain during the night. There are many possible ways to do this and I would like your opinion on some of the options.
It is also no yet possible to pass a variable in the popup window of a Reactor quick action, so I can't pass the time we would like the WSUS updates to be installed. Check out this thread where I asked for this feature https://support.nagios.com/forum/viewto ... ctor+popup and Trevot said he would make it for me. (Could I have the id for that pls?)
So then I was thinking to make a quick action which adds the host to a hostgroup. Then I could make a schedule which would every nigh update all WSUS hosts in the hostgroup and the remove the host from the hostgroup. This seemed like a good approach, but has a few disadvantages. As every time a host is added or removed from a hostgroup, an apply is needed and an apply take +- 30 seconds, during which there is a window where we are not seeing or finding any hosts. As we have 500+ Windows servers, the above method would imply too many interruptions in the monitoring.
In the meantime I have added a database to our MSSQL database Nagios_Extensions (which also stores our real-time event id exclusions for NSCLient) to store the Windows hosts which need to be updated. I'm 25 % on the way of finishing a Python script which can read and write hosts in the MSSQL database which contains the hosts. But my Python knowledge is basic and I'm not yet convinced this is the best idea. As I would in time publish this set of chains, I cannot be sure every Nagios XI user has access to MSSQL databases, I think I'm in need of a better option.
Today I read about static configuration files like /usr/local/nagios/etc/static/xiobjects.cfg
The documentation about this is very basic and does not contain enough info for me. Would it be usable in my above setup? Is it necessary to apply configuration when adding and removing hosts from this static configuration file? Could I make a bash script which adds hosts to a hostgroup in this static config file and later use a json query to extract the hosts in that hostgroup? Or are static config files not taken into account in JSON queries?
Is there any other option i'm not seeing I could use. The main requirement would be that I don't need to apply configuration in order to add/ remove hosts to a hostgroup or database table.
Thanks for any input on this.
Nagios XI 5.8.1
https://outsideit.net
https://outsideit.net
Re: Design question
Feature Request ID 4952 was filed in April of this year requesting the ability to run a chain in the future - does not appear to have been worked on.
Feature Request ID 6168 was filed in July of this year (no idea why that didn't make it in sooner) requesting the ability to run an event chain from XI, but be able to specify certain variables in a popup window before it is run. - also does not appear to have been worked on.
To answer your questions about the static configs, you do not need to Apply Config, just restart nagios for those to be picked up. They will not appear in the CCM but will still be visible in Home -> Service Detail for example.
You will definitely need to at least restart nagios no matter what, but have you played with the new API in XI 5? At the very least that is a supported, programmatic way of adding hosts.
Feature Request ID 6168 was filed in July of this year (no idea why that didn't make it in sooner) requesting the ability to run an event chain from XI, but be able to specify certain variables in a popup window before it is run. - also does not appear to have been worked on.
To answer your questions about the static configs, you do not need to Apply Config, just restart nagios for those to be picked up. They will not appear in the CCM but will still be visible in Home -> Service Detail for example.
You will definitely need to at least restart nagios no matter what, but have you played with the new API in XI 5? At the very least that is a supported, programmatic way of adding hosts.
Former Nagios employee
Re: Design question
Well, as it is not yet possible to add a hostgroup to a host with the new REST api, check out https://support.nagios.com/forum/viewto ... 16&t=35344 this is not (yet) an option. Also I tested how much time it takes to restart the Nagios process and that seems to take 20 - 25 seconds, during which all problems in the 'open service problems' also just disappear. As adding hosts to the servers-to-be updated-hostgroup will be happening multiple times a day, this is just the kind of thing I want to avoid. It seems the static config option is also not the way to go for me. I'll continue working on the MSSQL db option, implying this set of chains will only work for people who have a MSSQL server. 
Nagios XI 5.8.1
https://outsideit.net
https://outsideit.net
Re: Design question
Definitely not a straight-forward thing :)
Reaching into the depths of the Nagios code, there is the CHANGE_CUSTOM_SVC_VAR command that does not (as far as I know) require a restart, so if you can find a way to leverage that you could potentially avoid the restart problem. Make a dummy service that has a list of all of the hosts that need to be updated, maintain that with the above command, and... magic?
Reaching into the depths of the Nagios code, there is the CHANGE_CUSTOM_SVC_VAR command that does not (as far as I know) require a restart, so if you can find a way to leverage that you could potentially avoid the restart problem. Make a dummy service that has a list of all of the hosts that need to be updated, maintain that with the above command, and... magic?
Former Nagios employee
Re: Design question
Trevor,
Thanks for this. Am I correct that this external command will update a custom free variable for a host or service? Without the need to apply configuration?
I'll have to spend some time on this, as I'm in need of a way to edit config objects without the need for an apply, for more then the WSUS update chain alone.
Grtz
Thanks for this. Am I correct that this external command will update a custom free variable for a host or service? Without the need to apply configuration?
I'll have to spend some time on this, as I'm in need of a way to edit config objects without the need for an apply, for more then the WSUS update chain alone.
Grtz
Nagios XI 5.8.1
https://outsideit.net
https://outsideit.net
Re: Design question
I will carve out some time to test this, but from my reading of the command's documentation it doesn't mention a restart.
Former Nagios employee
Re: Design question
I have tried this:
on my QA server. Localhost has a custom free var _osinfo. After running the above command nothing has changed. Also tried:
_xiwizard had windowsserver as value. After running the above, nothing has changed. Even after I apply config nothing has changed. I checked if I can execute external commands by scheduling a forced check which works fine.
Code: Select all
now=`date +%s`
commandfile='/usr/local/nagios/var/rw/nagios.cmd'
/usr//bin/printf "[%lu] CHANGE_CUSTOM_HOST_VAR;localhost;_osinfo;CentOS10\n" $now > $commandfile
Code: Select all
/usr/bin/printf "[%lu] CHANGE_CUSTOM_HOST_VAR;server;_xiwizard;testvalue\n" > /usr/local/nagios/var/rw/nagios.cmdNagios XI 5.8.1
https://outsideit.net
https://outsideit.net
Re: Design question
This is a pretty obscure command, I would not be surprised if it has been broken by a past release. I will see what the Core dev has to say about it.
As far as further recommendations, I can't think of much else from a Nagios perspective.
As far as further recommendations, I can't think of much else from a Nagios perspective.
Former Nagios employee
Re: Design question
Any new on the CHANGE_CUSTOM_HOST_VAR command?
Nagios XI 5.8.1
https://outsideit.net
https://outsideit.net
Re: Design question
If I had to give an answer, at this time I would say it is either not working as intended, or it is but is not documented properly. At this point for it to be addressed more thoroughly either you or myself will need to open a Github issue.
Former Nagios employee