Nagios downtime Issue with max sessions on remote server

Hi All,

I’m using below playbook to enable/disable nagios downtime. My problem here is since the hosts in my inventory file are a lot (around min 1000), I’m running into mux sessions limit Issue on the remote nagios server while executing the playbook

Because of security limitation, we cannot Increase the max_sessions(currently 30) on nagios server. Is there any other way to handle this playbook to avoid max_sessions Issue ? like writing the commands to a file & then transfer the file to remote nagios server to trigger downtime ?

Below things won’t work:

Using Serial ---- This will be too slow to execute downtime against 1000 hosts

Playbook:

`

  • hosts: all
    remote_user: ops
    become: true
    tasks:

  • name: Disable Nagios Alerts
    tags: disablenagios
    nagios:
    action: disable_alerts
    service: all
    host: “{{ inventory_hostname }}”
    cmdfile: /var/spool/nagios/cmd/nagios.cmd
    delegate_to: nagserver
    remote_user: nagiosctl

  • name: Enable Nagios Alerts
    tags: enablenagios
    nagios:
    action: enable_alerts
    service: all
    host: “{{ inventory_hostname }}”
    cmdfile: /var/spool/nagios/cmd/nagios.cmd
    delegate_to: nagserver
    remote_user: nagiosctl

`

Problem:

fatal: [beta-node]: UNREACHABLE! => {“changed”: false, “msg”: “Failed to connect to the host via ssh: mux_client_request_session: session request failed: Session open refused by peer\r\nssh_exchange_identification: read: Connection reset by peer\r\n”, “unreachable”: true}

Hi All,

I'm using below playbook to enable/disable nagios downtime. My problem here
is since the hosts in my inventory file are a lot (around min 1000), I'm
running into mux sessions limit Issue on the remote nagios server while
executing the playbook

Because of security limitation, we cannot Increase the
max_sessions(currently 30) on nagios server. Is there any other way to
handle this playbook to avoid max_sessions Issue ? like writing the
commands to a file & then transfer the file to remote nagios server to
trigger downtime ?

I'm not sure if it helps, but I think it might work if you do it in a loop from one host, but it would be a lot slower.

Below things won't work:

Using Serial ---- This will be too slow to execute downtime against 1000
hosts

Playbook:

- hosts: all
   remote_user: ops
   become: true
     tasks:
  
     - name: Disable Nagios Alerts
       tags: disablenagios
       nagios:
         action: disable_alerts
         service: all
         host: "{{ inventory_hostname }}"
         cmdfile: /var/spool/nagios/cmd/nagios.cmd
       delegate_to: nagserver
              remote_user: nagiosctl

So this task would be rewritten like so

  - name: Disable Nagios Alerts
    tags: disablenagios
    nagios:
      action: disable_alerts
      service: all
      host: "{{ item }}"
      cmdfile: /var/spool/nagios/cmd/nagios.cmd
    delegate_to: nagserver
    remote_user: nagiosctl
    run_once: true
    with_items: "{{ groups['all'] }}"