Forum Discussion

Stewart's avatar
Stewart
Icon for Altostratus rankAltostratus
Jun 23, 2014

How to I list the VSs that has VLAN enabled on it?

Hello,

 

When a new VLAN is created on our LTMs in one of our environments, they should be enabled on a couple of Performance Layer 4 virtual servers. As part of the VS creation checks I'd like to be able to run a command to ensure that this has been done.

 

Is there a way of running a command where I can get a list of Virtual Servers that a VLAN is enabled on?

 

I can do "sh running-config ltm virtual vlans" and then check through but would like something that gets to the point a bit faster.

 

Thanks, Stewart.

 

2 Replies

  • How about a shell script?

    Against better judgement I wrote a very simple one for you (sensitive people should close their eyes):

    /bin/bash
    
    virtualcount=$(tmsh show running-config ltm virtual /Partition/*myname* vlans | grep virtual | wc -l)
    vlancount=$(tmsh show running-config ltm virtual /Partition/*myname* vlans | grep "External" | wc -l)
    
    if [ $virtualcount == $vlancount ]
        then
            echo "All have vlans"
    else
        echo "Missing vlans"
    fi
    

    /Patrik

  • A minor mod:

    !/bin/bash
    
    if [ "$1" == "" ]
    then
        echo "Usage: find-vlans.sh 
        echo ""
        echo "Example: find-vlans.sh vlan-1234
        echo ""
        echo ""
        exit
    fi
    
    echo "The following virtual servers are enabled for the $1 VLAN:"
    tmsh list ltm virtual one-line |grep vlans |grep $1 |awk -F" " '{ print $3 }'