Monitor connection status of VPN and reconnect if disconnected I can connect to my VPN with :

/opt/cisco/anyconnect/bin/vpn connect SERVER

I can check the connection status with:

/opt/cisco/anyconnect/bin/vpn status

That gives a printout of 

Cisco AnyConnect Secure Mobility Client (version 4.3.03086) .

Copyright (c) 2004 - 2016 Cisco Systems, Inc.  All Rights Reserved.


  &gt;&gt; state: Connected
  &gt;&gt; state: Connected
  &gt;&gt; state: Connected
  &gt;&gt; notice: Connected to Not Available.
  &gt;&gt; registered with local VPN subsystem.
VPN&gt;


What's the most Mac-tastic way of always monitoring whether the VPN is connected and reconnecting it if it's not?  Don't be bashful.
here's how i did it:

save the following to /usr/local/bin/vpn

if [[ "{$(/opt/cisco/anyconnect/bin/vpn status)[0]}" == *"Disconnected"* ]]; then
    /opt/cisco/anyconnect/bin/vpn connect SERVER
fi


chmod +x /usr/local/bin/vpn

save the following to /Library/LaunchDaemons/com.example.utilities.vpn.plist

&lt;plist version="1.0"&gt;
&lt;dict&gt;
    &lt;key&gt;Label&lt;/key&gt;
    &lt;string&gt;com.example.whatever.vpn&lt;/string&gt;
    &lt;key&gt;ProgramArguments&lt;/key&gt;
    &lt;array&gt;
        &lt;string&gt;/usr/local/bin/vpn&lt;/string&gt;
    &lt;/array&gt;
    &lt;key&gt;StartInterval&lt;/key&gt;
    &lt;integer&gt;30&lt;/integer&gt;
&lt;/dict&gt;
&lt;/plist&gt;

load it into launchd:

launchctl load -w /Library/LaunchDaemons/com.example.whatever.vpn.plist

check that it's there:

launchctl list | grep whatever