Forum Discussion

TuxanForLife's avatar
12 years ago

How to List All Active Clients (on a linux master server)

Here is a single command the dumps all active clients from a Linux Master Sever.

   bppllist -L -allpolicies  | egrep "^Policy Name:|^Active:" | paste - - | awk '$NF~yes { print $3 }' | xargs -i bpplclients {} -noheader 2> /dev/null | awk '{ print $3 }'


It does the following

  1. List details of all policies
  2. Extract only policy name and active status
  3. Put all that info on one line
  4. If the last field of that line is yes, print the third field which is the policy name
  1. This long list of active policies is passed (one at a time) to bpplclients, errors are hidden and only the client name is printed (assuming clients have no spaces in the name)



-- OR --

 

Run this script for a little prettier output of the same thing:
   Sample ::

   ##### DenverWebservers  #####
                              bubbles
                                   nerf
                            billybong

   ##### DenverDatbases  #####
                          spaceman
                                   nerf
                              kooliba


  for POLICY in  ` bppllist -L -allpolicies  | egrep "^Policy Name:|^Active:" | paste - - | awk '$NF~yes { print $3 }'`; do

    echo "####  $POLICY ###"
         bpplclients $POLICY -noheader 2> /dev/null | awk '{ printf "%30s\n", $3 }'
    echo " "
  done

----

 

  •  

    It's probably more useful if you sort the output:

    bppllist -L -allpolicies  | egrep "^Policy Name:|^Active:" | paste - - | awk '$NF~yes { print $3 }' | xargs -i bpplclients {} -noheader 2> /dev/null | awk '{ print $3 }' | sort -u 

     

     

  •  

    It's probably more useful if you sort the output:

    bppllist -L -allpolicies  | egrep "^Policy Name:|^Active:" | paste - - | awk '$NF~yes { print $3 }' | xargs -i bpplclients {} -noheader 2> /dev/null | awk '{ print $3 }' | sort -u