# Nagios downtime Issue with max sessions on remote server

**URL:** <https://forum.ansible.com/t/nagios-downtime-issue-with-max-sessions-on-remote-server/31504>\
**Category:** Ansible Project\
**Created:** [October 22, 2019, 6:57am UTC](https://forum.ansible.com/t/nagios-downtime-issue-with-max-sessions-on-remote-server/31504 "2019-10-22T06:57:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![abhijith.devaraju](https://avatars.discourse-cdn.com/v4/letter/a/ce7236/32.png) [@abhijith.devaraju](https://forum.ansible.com/u/abhijith.devaraju)\
**Post date:** [October 22, 2019, 6:57am UTC](https://forum.ansible.com/t/nagios-downtime-issue-with-max-sessions-on-remote-server/31504/1 "2019-10-22T06:57:58Z")

</div>

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}

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [October 22, 2019, 4:50pm UTC](https://forum.ansible.com/t/nagios-downtime-issue-with-max-sessions-on-remote-server/31504/2 "2019-10-22T16:50:56Z")

</div>

> 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  
> &nbsp;&nbsp;&nbsp;remote\_user: ops  
> &nbsp;&nbsp;&nbsp;become: true  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tasks:  
> &nbsp;&nbsp;  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- name: Disable Nagios Alerts  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tags: disablenagios  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nagios:  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;action: disable\_alerts  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;service: all  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;host: "{{ inventory\_hostname }}"  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cmdfile: /var/spool/nagios/cmd/nagios.cmd  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;delegate\_to: nagserver  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;remote\_user: nagiosctl

So this task would be rewritten like so

&nbsp;&nbsp;- name: Disable Nagios Alerts  
&nbsp;&nbsp;&nbsp;&nbsp;tags: disablenagios  
&nbsp;&nbsp;&nbsp;&nbsp;nagios:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;action: disable\_alerts  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;service: all  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;host: "{{ item }}"  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cmdfile: /var/spool/nagios/cmd/nagios.cmd  
&nbsp;&nbsp;&nbsp;&nbsp;delegate\_to: nagserver  
&nbsp;&nbsp;&nbsp;&nbsp;remote\_user: nagiosctl  
&nbsp;&nbsp;&nbsp;&nbsp;run\_once: true  
&nbsp;&nbsp;&nbsp;&nbsp;with\_items: "{{ groups['all'] }}"
