背景:通过shell脚本输出F5配置到csv表格


1.创建脚本

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
vi f5config.sh

echo vs name, destination, pool, pool members
VIRTUALS=$(tmsh -q -c "cd / ; list /ltm virtual recursive" | grep "ltm virtual" | awk -F' ' '{print "/"$3}')
for VS in $VIRTUALS;
do
echo -n $VS,
DEST=$(tmsh list ltm virtual $VS | grep destination | cut -d" " -f6)
echo -n $DEST,
POOL=$(tmsh list ltm virtual $VS | grep pool | cut -d" " -f6)
echo -n $POOL,
if [ -n "$POOL" ];
then
MBRS=$(tmsh list ltm pool "$POOL" | grep address | cut -d" " -f14)
echo -n $MBRS
fi
echo
done

2.赋予脚本执行权限

1
chmod 777 excel.sh

3.执行脚本

1
./excel.sh >> f5config.csv

4.把csv表格下载到本地打开即可

5.官方参考链接

1
https://support.f5.com/csp/article/K72255145?utm_source=f5support&utm_medium=RSS