How to collect the output of CLI commands periodically using Tera Term script

How to collect the output of CLI commands periodically using Tera Term script

51842
Created On 02/19/19 09:06 AM - Last Modified 10/10/25 11:38 AM


Objective


For requirements where periodic CLI output information collection is needed from Firewall/Panorama, Tera Term scripts can be used to collect the relevant info without manual intervention. 
 



Environment


  • Palo Alto Firewalls or Panorama
  • Windows PC that can access the Palo Alto firewall or Panorama using SSH
  • TeraTerm application (An open-source, free terminal emulator)


Procedure


Refer to the script snippets below and edit it as per the requirement and save it with the extension of ".ttl".
  1. Run the Tera Term software on the Windows PC. 
  2. Start an SSH connection to the Firewall/Panorama and authenticate using the login credentials. (Make sure the login account has enough permissions to run the show commands)
  3. Log the session output to a file using the "File" Tab. 
  4. Then navigate to the Control > Macro.
  5. Select the script file that was created. Once done, the firewall will start executing the commands in the TeraTerm script file as configured in the script. 
  6. A separate window will automatically open with options "Pause" and "End" which can be used accordingly to stop or pause the script execution.


Additional Information


Sample Script:

  • The below script is to collect the dataplane performance outputs from the firewall every 5 seconds.
  • Adjust the "pause" timer to adjust the frequency of data collection.
i=0
sendln 'set cli pager off'
sendln 'show system info'
:continue

i=i+1
sendln 'show clock'
sendln 'show session info'
sendln 'show running resource-monitor second last 60'
sendln 'show running resource-monitor minute last 10'
sendln 'debug dataplane pool statistics'
sendln 'show running resource-monitor ingress-backlogs'
sendln 'show counter global filter delta yes'
sendln 'debug dataplane pow performance all'

pause 5

goto continue

end
  • To send a CLI command that includes a symbol such as a pipe symbol ( | ), use " ... " (double quotation mark) to include the entire CLI syntax to avoid encountering invalid syntax during the script execution. 
sendln "show counter global filter delta yes | match pkt_recv"

Note: Teraterm can be downloaded from many sites. Try using valid sites such as "https://download.cnet.com/".

Alternative: How to collect the output of CLI commands periodically using Python



Actions
  • Print
  • Copy Link

    https://knowledgebase.paloaltonetworks.com/KCSArticleDetail?id=kA10g000000bo8eCAA&refURL=http%3A%2F%2Fknowledgebase.paloaltonetworks.com%2FKCSArticleDetail

Choose Language