Forum Discussion

Anonymous's avatar
Anonymous
25 days ago

Bug Report: Cisco_NTP DS lacks proper error handling output

If you're getting no data on Cisco NTP and you can't tell why, even after running poll now or running the script in debug, it's because there's some helpful information that wasn't included in the catch block of the script (at least for NX OS).

Today I was trying to troubleshoot why we were getting no data on Cisco NTP for a Nexus device. That device happens to have 10+ peers (this is important later on). Running the script in poll now/debug would only result in this:

Something went wrong: java.io.IOException: End of stream reached, no match found

This is a common thing with expect scripts. The script issued a command and is waiting for a response from the device that matches the prompt. If we were to get a response matching the prompt, it means the device has received the command, executed it, put the output to stdout, and returned to the prompt; the device is ready for the next command. However, this error means that the device responded with something that doesn't eventually match the prompt; the device is not waiting for the next command, it's waiting for something else. The script is waiting for the prompt and the device is waiting for something else. The script waited an appropriate amount of time then executed the catch block, outputing the helpful message above. It would be nice if the catch block output more so we could tell what's going on. How about it outputs the entirety of the SSH session? That would be helpful. 

Go to line 438 and insert the following in the catch block:

        println("==================== SSH SESSION TRANSCRIPT ====================")
        println(ssh.stdout())
        println("==================== END SESSION TRANSCRIPT ====================")

After adding this, when I executed the script in the debug console, i got this output:

$ !groovy
agent has fetched the task, waiting for response
agent has fetched the task, waiting for response
agent has fetched the task, waiting for response
agent has fetched the task, waiting for response
agent has fetched the task, waiting for response
agent has fetched the task, waiting for response
returns 0
output:
Something went wrong: java.io.IOException: End of stream reached, no match found

[MOTD Omitted]
sxxxxxxxxxxxxx1# show ntp peer-status

Total peers : 11
* - selected for sync, + -  peer mode(active), 
- - peer mode(passive), = - polled in client mode 
    remote                                 local                                
   st   poll   reach delay   vrf
--------------------------------------------------------------------------------
---------------------------------------
=xxxx:xx:xxxx::x                         ::                                     
 16   64       0   0.00000
=xxx.xxx.xxx.xx                          x.x.x.x                            
  2   64       0   0.07820default
=x.x.x.x                           x.x.x.x                            
  2   64       0   0.04123default
=x.x.x.x                           x.x.x.x                            
  2   64     377   0.07166default
=x.x.x.x                           x.x.x.x                            
  2   64     377   0.07191default
*x.x.x.x                            x.x.x.x                            
  1   64     377   0.05200default
=x.x.x.x                           x.x.x.x                            
  4   64     337   0.01245default
+x.x.x.x                             x.x.x.x                            
 16   64       0   0.00000default
.[7m--More--.[m

In this case, the device was waiting for me to press the enter or space keys because the last line of the output was " --More-- ". It took overly long to find this out because the module needs that one thing in the catch block to help troubleshoot.

No Replies