我需要帮助创建一个脚本,我可以通过 ssh 从 Linux 机器每十秒运行一次到防火墙 IP 以下。我必须将所有命令输出保存到可读的文件中
防火墙IP:10.121.8.100
这两个只运行一次(第一次)
set cli pager off
set cli scripting-mode on
这四个命令应按以下顺序每十秒运行一次
show running resource-monitor ingress-backlogs
show running resource-monitor second last 10
show session info
show counter global filter delta yes
答案1
while
使用带有 的无限循环sleep
。
set cli pager off
set cli scripting-mode on
while true; do
show running resource-monitor ingress-backlogs;
show running resource-monitor second last 10;
show session info;
show counter global filter delta yes;
sleep 10;
done
答案2
下面的脚本适用于您的场景
ssh serverip <<'EOF'
set cli pager off
set cli scripting-mode on
for ((i=1;i>=1;i++))
do
show running resource-monitor ingress-backlogs
sleep 10
show running resource-monitor second last 10
sleep 10
show session info
sleep 10
show counter global filter delta yes
sleep 10
done
EOF