<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Script to Check if OpenVPN is Up or Down]]></title><description><![CDATA[<p dir="auto">I am wanting to make a script that periodically checks it see if my OpenVPN client is up or down. What command can I issue from an SSH session that will tell me if the VPN client is Up or Down?</p>
]]></description><link>https://forum.netgate.com/topic/90103/script-to-check-if-openvpn-is-up-or-down</link><generator>RSS for Node</generator><lastBuildDate>Wed, 11 Mar 2026 19:36:29 GMT</lastBuildDate><atom:link href="https://forum.netgate.com/topic/90103.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 08 Oct 2015 23:30:55 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Script to Check if OpenVPN is Up or Down on Fri, 09 Oct 2015 20:57:55 GMT]]></title><description><![CDATA[<p dir="auto">go into the developer shell once and create a script:</p>
<pre><code>
pfSense shell: record checkopenvpn_status 
Recording of checkopenvpn_status started.
pfSense shell: require_once("openvpn.inc");
pfSense shell: $clients = openvpn_get_active_clients();
pfSense shell: print_r(array_values($clients));
pfSense shell: stoprecording 
Recording stopped.

</code></pre>
<p dir="auto">then either do from devshell</p>
<pre><code>
playback checkopenvpn_status

</code></pre>
<p dir="auto">or from normal shell or console:</p>
<pre><code>
[2.3-ALPHA][root@pfsense.xxxx]/root: pfSsh.php playback checkopenvpn_status

Starting the pfSense developer shell....

Array
(
    [0] =&gt; Array
        (
            [port] =&gt; 
            [name] =&gt; vpn to xxxx
            [vpnid] =&gt; 1
            [mgmt] =&gt; client1
            [status] =&gt; up
            [connect_time] =&gt; Sat Oct 3 1:49:14 2015
            [virtual_addr] =&gt; xxxx
            [remote_host] =&gt; xxxxx

            [bytes_recv] =&gt; 151003156

            [bytes_sent] =&gt; 151211004

        )

)

</code></pre>
<p dir="auto">adjust however you want offcourse.</p>
<p dir="auto">relevant functions:</p>
<pre><code>
openvpn_get_active_servers();
openvpn_get_active_servers("p2p");
openvpn_get_active_clients();

</code></pre>
<p dir="auto">for more insight: <a href="https://github.com/pfsense/pfsense/blob/master/src/usr/local/www/status_openvpn.php" target="_blank" rel="noopener noreferrer nofollow ugc">https://github.com/pfsense/pfsense/blob/master/src/usr/local/www/status_openvpn.php</a></p>
]]></description><link>https://forum.netgate.com/post/575892</link><guid isPermaLink="true">https://forum.netgate.com/post/575892</guid><dc:creator><![CDATA[heper]]></dc:creator><pubDate>Fri, 09 Oct 2015 20:57:55 GMT</pubDate></item></channel></rss>