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

    Asterisk status on pfSense2.0.1 webGUI

    webGUI
    5
    18
    19.5k
    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.
    • R
      robi
      last edited by

      Here's a basic script I wrote which adds a new status page for Asterisk server running on the same box as pfSense. Very easy to install, just copy the code below to a file named status_asterisk.php in /usr/local/www

      /* $Id$ */
      /*
      	status_asterisk.php
      	part of pfSense
      	Copyright (C) 2009 Scott Ullrich <sullrich@gmail.com>.
      	All rights reserved.
      
      	originally part of m0n0wall (http://m0n0.ch/wall)
      	Copyright (C) 2003-2005 Manuel Kasper <mk@neon1.net>.
      	All rights reserved.
      
      	Redistribution and use in source and binary forms, with or without
      	modification, are permitted provided that the following conditions are met:
      
      	1\. Redistributions of source code must retain the above copyright notice,
      	   this list of conditions and the following disclaimer.
      
      	2\. Redistributions in binary form must reproduce the above copyright
      	   notice, this list of conditions and the following disclaimer in the
      	   documentation and/or other materials provided with the distribution.
      
      	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
      	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
      	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
      	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
      	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
      	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
      	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
      	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
      	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
      	POSSIBILITY OF SUCH DAMAGE.
      */
      /*	
      	pfSense_MODULE:	asterisk
      */
      
      ##|+PRIV
      ##|*IDENT=page-status-asterisk
      ##|*NAME=Status: Asterisk page
      ##|*DESCR=Allow access to the 'Status: Asterisk' page.
      ##|*MATCH=status_asterisk.php*
      ##|-PRIV
      
      require_once("guiconfig.inc");
      
      $pgtitle = array(gettext("Status"),gettext("Asterisk"));
      include("head.inc");
      
      ?>
      
      /* Data input processing */
      $cmd =  $_GET['cmd'];
      $cmd  = str_replace("+", " ", $cmd);
      
      if ($cmd == "") {
      	$cmd = "core show version";
      }
      
      $file = $_SERVER["SCRIPT_NAME"];
      $break = Explode('/', $file);
      $pfile = $break[count($break) - 1]; 
      
      /* Print command buttons */
      echo "[]($pfile?cmd=sip+show+registry)";
      echo "[]($pfile?cmd=sip+show+peers)";
      echo "[]($pfile?cmd=sip+show+channels)";
      echo "[]($pfile?cmd=core+show+codecs+audio)";
      echo "[]($pfile?cmd=core+show+uptime)";
      
      /* Run commands and print results */
      $asterisk_command=shell_exec("asterisk -rx '$cmd'");
      echo "```
      ";
      echo $asterisk_command;
      echo "
      ```";
      ?></mk@neon1.net></sullrich@gmail.com> 
      

      To make it appear in the dropdown menu, edit /usr/local/www/fbegin.inc, add a new line after line 150 (// Status section, right after $status_menu = array();), like this:

      $status_menu[] = array("Asterisk", "/status_asterisk.php");
      

      And you'll get something like the attached picture.
      It queries asterisk locally using shell, no manager interface needed on asterisk side.

      pfsene_asterisk_status.png_thumb
      pfsene_asterisk_status.png

      1 Reply Last reply Reply Quote 0
      • S
        Supermule Banned
        last edited by

        I like that!

        1 Reply Last reply Reply Quote 0
        • marcellocM
          marcelloc
          last edited by

          Maybe it will be the first alpha release of asterisk package to pfsense.  :)

          If freepbx runs on pfsense without issues, it will be a nice package option fro sip server/gatway/proxy.

          Treinamentos de Elite: http://sys-squad.com

          Help a community developer! ;D

          1 Reply Last reply Reply Quote 0
          • S
            Supermule Banned
            last edited by

            Yes :)

            1 Reply Last reply Reply Quote 0
            • R
              robi
              last edited by

              Also in status_services.php if you add this at lines 271 (below the similar ntpd entry), you'll get service status info, and start/stop commands will also work correctly.

              $pconfig = array();
              $pconfig['name'] = "asterisk";
              $pconfig['description'] = gettext("Asterisk VoIP telephony");
              $services[] = $pconfig;
              

              For the dashboard, in widgets/widgets/services_status.widget.php add this at line 76 (similarly below the similar ntpd entry):

              $svcconfig = array();
              $svcconfig['name'] = "asterisk";
              $svcconfig['description'] = gettext("Asterisk VoIP telephony");
              $services[] = $svcconfig;
              
              

              pfsene_asterisk_services_dash.png
              pfsene_asterisk_services_dash.png_thumb
              pfsene_asterisk_services.png
              pfsene_asterisk_services.png_thumb

              1 Reply Last reply Reply Quote 0
              • R
                robi
                last edited by

                @marcelloc:

                Maybe it will be the first alpha release of asterisk package to pfsense.  :)

                If freepbx runs on pfsense without issues, it will be a nice package option fro sip server/gatway/proxy.

                Got no clue how to make a pfSense-compatible full-blown package. Configuring Asterisk is no easy task at all, so beside status info, manual editing of config files remains for now.

                Fivn's Asterisk Managemnet GUI brings much more than these, all we need to do is make it run on the box, it's just a single script.

                1 Reply Last reply Reply Quote 0
                • S
                  Supermule Banned
                  last edited by

                  Therefore Tommyboy180 or Marcello is the guys to talk to. They can make a pacakage happen and if one could use an alternate free product like Freepbx instead, then it would make a lot of PFSense… :D

                  1 Reply Last reply Reply Quote 0
                  • R
                    robi
                    last edited by

                    I've extended the capability of my Asterisk Status page.

                    • look & feel matching pfSense's skin
                    • more useful status commands + reload
                    • detailed callog, with option to download original CSV file, trim, clear
                    • asterisk log, with option to trim, clear the file

                    Download the attached status_asterisk.zip.xls file, and rename it to status_asterisk.zip.

                    Copy status_asterisk.php, status_asterisk_calls.php, status_asterisk_log.php to /usr/local/www

                    Good luck!

                    pfsense_Asterisk_Status_OK.png
                    pfsense_Asterisk_Status_OK.png_thumb
                    status_asterisk.zip.xls

                    1 Reply Last reply Reply Quote 0
                    • R
                      robi
                      last edited by

                      Updates:

                      • calls list in reversed order
                      • log lines 50 instead of 200

                      (rename .xls to .zip after download)

                      status_asterisk_v01_pfSense.zip.xls

                      1 Reply Last reply Reply Quote 0
                      • B
                        blietaer
                        last edited by

                        This rocks !
                        Any way this becomes an insstallable pfSense package ?  ::)

                        1 Reply Last reply Reply Quote 0
                        • marcellocM
                          marcelloc
                          last edited by

                          It will soon.  ;)

                          Treinamentos de Elite: http://sys-squad.com

                          Help a community developer! ;D

                          1 Reply Last reply Reply Quote 0
                          • R
                            robi
                            last edited by

                            Update:

                            • added a config file editor, based on original edit.php

                            pfsense_Asterisk_Edit_config_files.png
                            pfsense_Asterisk_Edit_config_files.png_thumb
                            status_asterisk_v02.zip.xls

                            1 Reply Last reply Reply Quote 0
                            • marcellocM
                              marcelloc
                              last edited by

                              First package release is out.  :)

                              http://forum.pfsense.org/index.php/topic,47210.msg248054.html#msg248054

                              I did some changes to improve stability and checks for nanobsd or normal install.

                              Treinamentos de Elite: http://sys-squad.com

                              Help a community developer! ;D

                              1 Reply Last reply Reply Quote 0
                              • E
                                easyhugo
                                last edited by

                                HI

                                and thats what i am looking for waiting for  only great

                                and now my question
                                is it possible to get info from an external asterisk?
                                i have read that is possible that to make an ssh connect over php
                                over an ssh connection that script would work or?

                                thx max

                                1 Reply Last reply Reply Quote 0
                                • marcellocM
                                  marcelloc
                                  last edited by

                                  You need to enable asterisk managment to get stats but this package has no options for remote connections. Maybe you can edit asterisk.Inc file and point to your remote server

                                  Treinamentos de Elite: http://sys-squad.com

                                  Help a community developer! ;D

                                  1 Reply Last reply Reply Quote 0
                                  • E
                                    easyhugo
                                    last edited by

                                    The first part of your answer i understood but the second part i did totaly not.

                                    thx max

                                    1 Reply Last reply Reply Quote 0
                                    • E
                                      easyhugo
                                      last edited by

                                      hi

                                      no idea ?

                                      max

                                      1 Reply Last reply Reply Quote 0
                                      • marcellocM
                                        marcelloc
                                        last edited by

                                        Asterisk.Inc file is the script that creates asterisk config file. You can edit it to include your config to asterisk.

                                        Treinamentos de Elite: http://sys-squad.com

                                        Help a community developer! ;D

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