Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    Why No Status?

    Scheduled Pinned Locked Moved OpenVPN
    16 Posts 4 Posters 8.1k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • C
      cdenley
      last edited by

      This was a really easy modification, and something we can really use. Why isn't something like this already in PFSense?

      
      $pgtitle = "Diagnostics: OpenVPN status";
      require("guiconfig.inc");
      
      function dump_ovpnstat($logfile) {
      	$count=0;
      	$header=true;
      	$fh=@fopen($logfile,'r');
      	if(!$fh)
      		echo "status file not found
      required custom option:
      status $logfile";
      	else {
      		while(!feof($fh)) {
      			$line=trim(fgets($fh,1024));
      			$data = explode(",", $line);
      			if(count($data)==5) {
      				echo "\n";
      				$class="lr";
      				foreach($data as $val) {
      					if($header)
      						echo "" . htmlspecialchars($val) . "\n";
      					else {
      						$count++;
      						echo "" . htmlspecialchars($val) . "\n";
      					}
      					$class="r";
      				}
      				echo "\n";
      				$header=false;
      			}
      		}
      		fclose($fh);
      		if($count==0)
      			echo "no connections";
      	}
      }
      
      function mod_time($logfile) {
      	$ret=false;
      	$fh=@fopen($logfile,'r');
      	if(!$fh)
      		return false;
      	fgets($fh,1024);
      	$line=fgets($fh,1024);
      	$data=explode(",",$line,2);
      	if(count($data)>1 && $data[0]=='Updated')
      		$ret=$data[1];
      	fclose($fh);
      	return $ret;
      }
      
      include("head.inc");
      
      ?>
      
      $logfile='/var/log/openvpn-status.log';
      $mtime=mod_time($logfile);
      if($mtime)
      	print '
      
      updated '.htmlspecialchars($mtime).'
      
      ';
      ?>
      
      
      1 Reply Last reply Reply Quote 0
      • S
        Suprsurfr
        last edited by

        I would like to use this but have no idea where to implement it…
        I copied the contents and placed it in the /usr/local/www/vpn_status.php

        added: status /var/log/openvpn-status.log to Custom options in the vpn setup window.

        but all i get is:

        Diagnostics: OpenVPN status

        updated 12/10/2009 12:35:30 pm

        1 Reply Last reply Reply Quote 0
        • C
          cdenley
          last edited by

          Is someone connected to your OpenVPN server? It lists current connections, and /var/log/openvpn-status.log is updated once a minute, so it may not show up for up to 60 seconds.

          
          cat /var/log/openvpn-status.log
          
          
          1 Reply Last reply Reply Quote 0
          • S
            Suprsurfr
            last edited by

            I get this:

            cat /var/log/openvpn-status.log

            OpenVPN STATISTICS
            Updated,Thu Dec 10 12:51:34 2009
            TUN/TAP read bytes,260
            TUN/TAP write bytes,260
            TCP/UDP read bytes,5860
            TCP/UDP write bytes,9100
            Auth read bytes,1700
            pre-compress bytes,0
            post-compress bytes,0
            pre-decompress bytes,0
            post-decompress bytes,0
            END

            1 Reply Last reply Reply Quote 0
            • C
              cdenley
              last edited by

              Yep. You have no connections to list. I just updated my code in the first post so it displays "no connections" in that case.

              Actually, my file doesn't look like that. Are you running an OpenVPN server or client?

              1 Reply Last reply Reply Quote 0
              • S
                Suprsurfr
                last edited by

                Thanks!

                I dont think its running every minute.  I refreshed the page and it still shows the same time…
                Did I add the status option to the correct location?

                1 Reply Last reply Reply Quote 0
                • S
                  Suprsurfr
                  last edited by

                  @cdenley:

                  Yep. You have no connections to list. I just updated my code in the first post so it displays "no connections" in that case.

                  Actually, my file doesn't look like that. Are you running an OpenVPN server or client?

                  I am running the openvpn site to site.

                  1 Reply Last reply Reply Quote 0
                  • S
                    Suprsurfr
                    last edited by

                    The reason I would like to use this script is becuase i am getting this on the status page.

                    The servers are all up I can ping hosts on the other side but they are all reporting down except for the first one.

                    1 Reply Last reply Reply Quote 0
                    • C
                      cdenley
                      last edited by

                      My script shows the status of the OpenVPN server. It's not going to display anything from your status file, because there is no client list.

                      
                      # cat /var/log/openvpn-status.log
                      OpenVPN CLIENT LIST
                      Updated,Thu Dec 10 12:42:18 2009
                      Common Name,Real Address,Bytes Received,Bytes Sent,Connected Since
                      ROUTING TABLE
                      Virtual Address,Common Name,Real Address,Last Ref
                      GLOBAL STATS
                      Max bcast/mcast queue length,0
                      END
                      
                      
                      1 Reply Last reply Reply Quote 0
                      • jimpJ
                        jimp Rebel Alliance Developer Netgate
                        last edited by

                        There is an OpenVPN status in 2.0 that works much better.

                        The Dashboard widget doesn't work as well as I'd hoped, and I'm not sure that it ever really will on 1.2.x.

                        As for why such a thing hasn't been added to 1.2.x, it's probably considered too much of a "feature". Most of the changes in 1.2.3 were bug fixes, features that made their way in as a part of other bug fixes, or bits that were needed by commercial support customers.

                        I can try to work some of this OpenVPN status code into an add-on package though.

                        Remember: Upvote with the 👍 button for any user/post you find to be helpful, informative, or deserving of recognition!

                        Need help fast? Netgate Global Support!

                        Do not Chat/PM for help!

                        1 Reply Last reply Reply Quote 0
                        • S
                          Suprsurfr
                          last edited by

                          Is there any way you could add the private IP addresses assigned to the client in the webgui?

                          @cdenley:

                          This was a really easy modification, and something we can really use. Why isn't something like this already in PFSense?

                          
                          $pgtitle = "Diagnostics: OpenVPN status";
                          require("guiconfig.inc");
                          
                          function dump_ovpnstat($logfile) {
                          	$count=0;
                          	$header=true;
                          	$fh=@fopen($logfile,'r');
                          	if(!$fh)
                          		echo "status file not found
                          required custom option:
                          status $logfile";
                          	else {
                          		while(!feof($fh)) {
                          			$line=trim(fgets($fh,1024));
                          			$data = explode(",", $line);
                          			if(count($data)==5) {
                          				echo "\n";
                          				$class="lr";
                          				foreach($data as $val) {
                          					if($header)
                          						echo "" . htmlspecialchars($val) . "\n";
                          					else {
                          						$count++;
                          						echo "" . htmlspecialchars($val) . "\n";
                          					}
                          					$class="r";
                          				}
                          				echo "\n";
                          				$header=false;
                          			}
                          		}
                          		fclose($fh);
                          		if($count==0)
                          			echo "no connections";
                          	}
                          }
                          
                          function mod_time($logfile) {
                          	$ret=false;
                          	$fh=@fopen($logfile,'r');
                          	if(!$fh)
                          		return false;
                          	fgets($fh,1024);
                          	$line=fgets($fh,1024);
                          	$data=explode(",",$line,2);
                          	if(count($data)>1 && $data[0]=='Updated')
                          		$ret=$data[1];
                          	fclose($fh);
                          	return $ret;
                          }
                          
                          include("head.inc");
                          
                          ?>
                          
                          $logfile='/var/log/openvpn-status.log';
                          $mtime=mod_time($logfile);
                          if($mtime)
                          	print '
                          
                          updated '.htmlspecialchars($mtime).'
                          
                          ';
                          ?>
                          
                          
                          1 Reply Last reply Reply Quote 0
                          • P
                            pirateghost
                            last edited by

                            @Suprsurfr:

                            Is there any way you could add the private IP addresses assigned to the client in the webgui?

                            this is my biggest complaint.  i cant see the ip addresses that are assigned to each client.  and sometimes they change after rebooting a client

                            1 Reply Last reply Reply Quote 0
                            • jimpJ
                              jimp Rebel Alliance Developer Netgate
                              last edited by

                              This is already done in the 2.0 openvpn client status.

                              ovpnstatus-2.0.png
                              ovpnstatus-2.0.png_thumb

                              Remember: Upvote with the 👍 button for any user/post you find to be helpful, informative, or deserving of recognition!

                              Need help fast? Netgate Global Support!

                              Do not Chat/PM for help!

                              1 Reply Last reply Reply Quote 0
                              • P
                                pirateghost
                                last edited by

                                awesome.  i cant wait for it to become stable release.  i tried the beta for a few days, but i was having some intermittent issues with it

                                1 Reply Last reply Reply Quote 0
                                • jimpJ
                                  jimp Rebel Alliance Developer Netgate
                                  last edited by

                                  I just uploaded a package to add the OpenVPN status page from 2.0 to 1.2.3. Details here:
                                  http://forum.pfsense.org/index.php/topic,22301.msg114826.html#msg114826

                                  Remember: Upvote with the 👍 button for any user/post you find to be helpful, informative, or deserving of recognition!

                                  Need help fast? Netgate Global Support!

                                  Do not Chat/PM for help!

                                  1 Reply Last reply Reply Quote 0
                                  • P
                                    pirateghost
                                    last edited by

                                    @jimp:

                                    I just uploaded a package to add the OpenVPN status page from 2.0 to 1.2.3. Details here:
                                    http://forum.pfsense.org/index.php/topic,22301.msg114826.html#msg114826

                                    oh thank you SO much….this is exactly what i needed!

                                    1 Reply Last reply Reply Quote 0
                                    • First post
                                      Last post
                                    Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.