BASH Script to find ClientSSL's mapped to Virtual Servers
Problem this snippet solves:
Often times we may require to generate a report to know how many of the clientssl profiles are mapped to which virtual servers. One can use the simple
tmsh list ltm virtual all one-line | grep ssl-profile-name
.
But this would focus on one particular profile alone.
How about for every clientssl profiles that's present and to which vip its mapped.
How to use this snippet:
Create a simple bash file and paste the below code.
[ltm1:Active:In Sync] ~ # vi find-clientssl-mapped-to-virtuals
Save and exit (wq).
Run the bash script.
[ltm1:Active:In Sync] ~ # bash find-clientssl-mapped-to-virtuals
Final output will be in CSV file like below, You can winscp the output from the location /var/tmp/
Filename would be
clientssl-mapped-to-virtuals-output.csv
Code :
#!/bin/bash echo "Virtual Server, Client-SSL Profile" > /var/tmp/clientssl-mapped-to-virtuals-output.csv profile_names=`tmsh list ltm profile client-ssl one-line | awk -F" " '{print $4}'` for x in ${profile_names} do virtual_name=`tmsh list ltm virtual one-line | grep $x | awk -F" " '{print $3}'` if [ "${virtual_name}" != "" ] then for y in ${virtual_name} do echo "$y,$x" >> /var/tmp/clientssl-mapped-to-virtuals-output.csv done fi done
Tested this on version:
11.5Updated Jun 06, 2023
Version 2.0