This article explains how to deal with the error "sshd[20152]: error: no more sessions" and stuck MGD Process
Jan 14 13:53:06 router01 mgd[3010]: UI_NETCONF_CMD: User 'root' used NETCONF client to run command 'get-task-memory-information level=detail'
Jan 14 13:53:06 router01 mgd[3008]: UI_NETCONF_CMD: User 'root' used NETCONF client to run command 'get-krt-state'
Jan 14 13:53:08 router01 mgd[3009]: UI_NETCONF_CMD: User 'root' used NETCONF client to run command 'get-task-memory-information level=detail'
Jan 14 13:53:10 router01 mgd[3012]: UI_NETCONF_CMD: User 'root' used NETCONF client to run command 'get-fpc-ipw-irm-drops'
Jan 14 13:53:36 router01 mgd[3008]: UI_NETCONF_CMD: User 'root' used NETCONF client to run command 'get-krt-state'
Jan 14 13:53:38 router01 mgd[3009]: UI_NETCONF_CMD: User 'root' used NETCONF client to run command 'get-task-memory-information level=detail'
Jan 14 13:53:40 router01 mgd[3012]: UI_NETCONF_CMD: User 'root' used NETCONF client to run command 'get-fpc-ipw-irm-drops'
Jan 14 13:54:06 router01 mgd[3008]: UI_NETCONF_CMD: User 'root' used NETCONF client to run command 'get-krt-state'
Jan 14 13:54:08 router01 mgd[3013]: UI_NETCONF_CMD: User 'root' used NETCONF client to run command 'get-rsvp-interface-information level=detail'
Jan 14 13:53:33 router01 sshd[18699]: error: no more sessions
The mgd process get stuck blocking remote access to the platform
On all Junos platforms the mgd process can get overwhelmed and stuck due to receiving high amounts of RPC (Remote Procedure Call) calls from NETCONF (The Network Configuration Protocol) sessions or CLI (Command Line Interface) sessions executing commands with large outputs such as (show class-of-service interface) leading to the inability to remotely accessing the platform.
Workaround
Use expensive commands that print more than 1K lines sparingly and judiciously. If query scripts are in use (Periodic calls), please ensure sufficient delay is incorporated to not hit the issue.
External-Description
This issue is expected to happen every time the mgd process gets overwhelmed by too many sessions executing commands with large outputs such as:'
show class-of-service interface'
To check if any mgd session is getting stuck use the following command:
hostname@platform> show system processes extensive | match mgd | match sbwait
xxxxx root <TIMESTAMP> sbwait 0 0:01 0.00% mgd
The pressence of multiple processes on the sbwait state indicate that mgd is getting overwelmed and will potentially get stuck if the number of sbwait processes keeps incrementing.