An Asterisk Allstar
Node Status and Control
I have created a simple HTML form and Perl script to display an Allstar nodes status in a html page. It also optionally allows any valid Allstar command to be entered for the given node. I call it 'lsnodes' and there is a version that works in both command mode and as a web page either locally or anywhere on the web. This is not intended to be in competition with any other display program out there but rather to be a simple script that anyone with Perl and html/css knowledge can modify to their own requirements.
The html form queries the node number and optionally a command and sends them to a Perl script on the server. This script takes the optional Allstar command and executes it on the server and then displays status information for the given node. This information is refreshed at a one minute rate. The refresh rate as well as what is displayed and how it is display on the returned page can be changed by editing the Perl script.
If you follow the instructions on how to install this it should work but I make no guarantees. This was a learning experience for me and writing it in Perl makes text manipulation straightforward and the resultant html code clear. Certainly using jquery/ajax/php as was done in Allmon makes for a much more powerful and capable product but it is also hard for the average person to understand and modify. My intent was something that worked for me and was easy to modify. I present it here for others to use, modify, etc. If anyone has ideas about improvements feel free to make them or let me know your desires and maybe I will implement them and make updated code available. I have tested this code but the only good test is when others use it in many different environments. It plays well in Firefox and Chrome. Windows Explorer is problematic. I don't use it and I suspect most others don't either so I made no attempt to make it work better. Consider this beta code and if you have problems please let me know. I find it to be very useful and I hope you do also.
Installation involves several steps and you must make several changes to the system that are minor but involve some knowledge of Linux, like how to edit and save files and get about the directory structure. If you are not sure of something I would be glad to answer any questions. These instruction are for the Acid release in Centos.
If you have already installed httpd to use the web server on your Allstar server you can skip this step. If you are not sure if you have httpd installed type -
If it returns files or nothing then you have httpd installed and you can skip the httpd installation steps below. If you get a no such file or directory error then you do not have it installed and you must complete the http installation steps.
httpd Installation Steps
First we download and install the httpd from the repository.
yum install httpd
Answer yes to the question to install and if all goes well it should tell you Complete!
We have to edit one line in the httpd.conf file to specify a server name.
Find the line that defines the server name near the end of the file and make it look like the example below. If you don't have a dns name for your server add the 127.0.0.1 IP address otherwise put your domain name there.
# If your host doesn't have a registered DNS name, enter its IP address here.
# You will have to access it by its address anyway, and this will make
# redirections work in a sensible way.
Now start the server, you should get no errors.
Now lets make it start at boot -
/sbin/chkconfig httpd on
and check runlevels it will start in. Runlevels 2,3,4,5 should be ON.
/sbin/chkconfig --list httpd
Which should look like this -
httpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
If you have not installed the Allmon requirements or you do not have PHP installed on your Allstar server then you will need to install it. To test if it is installed type -
If this returns the version like below then you can skip the PHP installation steps. If it returns an error then complete the PHP installation steps. The build date and version does not need to be the same.
PHP 5.1.6 (cli) (built: Dec 10 2013 22:14:51)
Copyright (c) 1997-2006 The PHP Group
Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies
PHP Installation Steps
yum install php
Once installed it should show the version as above.
Download lsnodes files
Download the tarball and copy to to /var/www/html and extract. This will create a /var/www/html/lsnodes directory with the extracted files.
or use wget on your Allstar computer.
tar -xvzf lsnodes-1.03.tgz
This should create a directory under html called lsnodes and untar the files there.
This Perl script lsnodes_web relies on the Allstar database to display information about nodes. If you are already using Allmon then the directory /var/www/html/allmon probably exists and you have a cron entry to update the local text file daily
The file which creates/accesses the database is astdb.php This file creates a file called astdb.txt in the same directory. It is updated by a crontab entry once daily.
If you have Allmon installed the cron entry would look like this -
03 03 * * * cd /var/www/html/allmon; ./astdb.php
This would update the astdb.txt file in /var/www/html/allmon at 3:03 AM daily. The 03 03 can be any hour and minute you desire.
In case you don't have Allmon installed (no /var/www/html/allmon directory) I am including the astdb.php file which gets the database. To implement this method create the following cron entry by editing using crontab -
37 04 * * * cd /var/www/html/lsnodes; ./astdb.php
Here we select the directory where the astdb.php file was extracted. The time is completely random and once a day.
The database needs to be initially created if you have not installed Allmon To execute this file manually just type the full path and name -
This will create the astdb.txt file in the same directory.
DO NOT access this file more than once daily in a crontab. If you need to access it manually to see a change you made that is fine but don't hammer the server for no reason.
If you are not using the default Allmon astdb.php directory you also need to change the entry for it in the lsnodes_web Perl script. There is a note above the line there.
The stock line in lsnodes_web looks like this and would be used if you have Allmon installed.
# Specify the location of the Allstar database
my $allstardb = "/var/www/html/allmon/astdb.txt";
if you don't have Allmon installed change it to this -
# Specify the location of the Allstar database
my $allstardb = "/var/www/html/lsnodes/astdb.txt";
Now we need to change the sudoers execution rights for Asterisk so we need to change the permission on this file so we can edit it.
chmod 750 sudoers
Edit sudoers and add the three lines below starting with Cmnd_Alias ASTERISK. Spelling and case is important! Use your editor of choice.
#Cmnd_Alias PROCESSES = /bin/nice, /bin/kill, /usr/bin/kill, /usr/bin/killall
Cmnd_Alias ASTERISK = /usr/sbin/asterisk, /usr/bin/curl
User_Alias ADMINS = apache
ADMINS ALL = NOPASSWD: ASTERISK
Further down in the file the following line should be commented out. Add a '#' before it as shown below.
Now save the file
IMPORTANT! - the sudoers file must be returned to 440 permission to work!
chmod 440 sudoers
Edit the httpd config file using vi, nano, or your favorite editor.
If you want to change your http port for Allstar edit the listen line to the port you would like to use or leave it at the default 80. Shown below with default value.
# Listen: Allows you to bind Apache to specific IP addresses and/or
# ports, in addition to the default. See also the
# Change this to Listen on specific IP addresses as shown below to
# prevent Apache from glomming onto all bound IP addresses (0.0.0.0)
Further down in the file Make sure the cgi-bin definition looks like this -
<Directory "/var/www/cgi-bin"> AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Allow from all
If not change and save the file.
cd to the directory where the extracted lsnodes files are located and mv the files.
mv lsnodes_web /var/www/cgi-bin
Now lets test the command prompt lsnodes. Type lsnodes followed by one of your local node numbers.
You should see a listing of your currently connected nodes and the info on each node.Nodes connected to - 27225 WA3DSP 446.1 Simplex Richboro, PA ---------------------------------------------------------------- Node Call Description Location ---------------------------------------------------------------- 28164 AE6TV IRLP 7227 Bridge Grand Terrace, Ca 28190 AE6TV Micro-Node SOCAL Hub Grand Terrace, CA 28194 AE6TV TEST Grand Terrace, CA 29971 WA3EZT 446.2 Jenkintown, PA
You can test the web Perl script at the command prompt by executing it manually.
If there are no errors it will print out text that looks like html code. If there are errors they have to be resolved. This code may require that a couple of Perl modules be loaded depending on your Perl configuration. If that is the case the error message will list the module. You then must go to the CPAN search site - http://search.cpan.org/ and enter the name of the module. You will then need to download, untar, compile, and install it. The README file explains how to do all that. You will need to do this for each module that is required. Once the required modules are loaded you should see no errors and just html code print on the screen. what you see won't make any sense but it is important to not have any errors at this point.
Running lsnodes on the web
To execute the web form open your browser and type -
if the IP address was 192.168.1.20 port 80 you do not need to specify the port (80 is the default)
If the IP address was 192.168.0.50 port 15600
If accessing from outside your local lan substitute your domain name for the IP address
If you want external http access to the Allstar server you must port forward in your router the listen port you configured in httpd.conf. For just local access this is not required.
Entering Data on the Form
Enter the local port you want to view in the node block and submit
The status window for that node should display. To select another node or to send a command select the Search/Command link at the top.
You can open as many windows as you wish. I have three nodes and keep three windows opened in tabs in Firefox.
Be sure to bookmark the URL's so you don't have retype at each session.
If you are using this only locally in a secure environment then you can disregard the following.
If the form page is available to the world unsecured anyone who guesses the port and file name could execute commands on your node. To make this more secure put a password on the lsnodes directory.
First edit /etc/httpd/conf/httdp.conf and find the following lines. Comment out 'allowoverides none' and add 'allowoverides authconfig' as shown below.
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
# AllowOverride None
Save the file and restart httpd -
cd to the lsnodes directory - /var/www/html/lsnodes
create the file .htaccess -
Enter the following (add the user name you want to use) -
AuthName "Authorization Required"
Require user YOURUSERNAME
Replace the full path with the path to where you are putting the .htpasswd file This could be anywhere you desire. I created a directory below /etc/asterisk with my call letters where I put personal stuff, scripts, etc. so I put it there.
In my case the first line looks like this -
Save the file in the directory you are in /var/www/html/lsnodes
Now create the password file. Replace USERNAME with your choice for username and change the directory to the location you specified above in the .htacess file.
htpasswd -c /etc/asterisk/wa3dsp/.htpasswd USERNAME
It will then ask for a new password twice to confirm and then write the encrypted file to the specified directory.
You will now have to provide a username and password to access the lsnodes form page. This is only done once per session and if you desire you can allow your browser to remember the password.
After running the code you should have no errors in the httpd error log or the system messages log file. To look type the following -
Each access will make an entry in the httpd access log '/var/log/httpd/access_log' which is normal. Over time this log will expand in size and you can delete it if it becomes too large. This should not be a problem with today's large hard drives but I wanted you to be aware of that. The httpd access entries from lsnodes will look similar to this -
126.96.36.199 - - [04/Jan/2014:00:29:49 -0500] "GET /cgi-bin/lsnodes_web?node=27225 HTTP/1.1" 200 6190 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:26.0) Gecko/20100101 Firefox/26.0"
Each access will also show up in the Asterisk client as a UNIX connection/disconnection in the CLI which is normal. If this bothers you setting the verbosity to 1 will stop the display of these messages. Also when entering the CLI only use one 'v' - asterisk -rv
WA3DSP_Allstar*CLI> core set verbose 1
Verbosity is at least 1
ScreenshotsScreenshot in Firefox of node 27225. At the top the update time and public IP address are shown as well as link to a graphical display of connections and a link to change the displayed node or send a command.On the left are status details about the node. To the right is the connected node list with a list of nodes directly connected to this node below. The bottom list is local nodes and their registration status.An example of what happens if the node list is longer than the screen height. The bar on the right appears and allows you to move the column up and view data previously off the screenAnother screenshot in Firefox of node 29014This screenshoot shows the addition of EchoLink node call identification. This requires the addition of EchoLink to your server.Another shot showing EchoLink and IRLPThe data entry form. This shows sending a command to connect to node 29332 from local node 27225. If the command was blank it would just show status for the local node.
Displaying EchoLink Nodes
The code will display EchoLink nodes but will show no info unless you have EchoLink installed on your server and you are using the EchoLink version of lsnodes_web. Version 1.01 or later. Installing EchoLink is easy. Copy the echolink.conf file to the /etc/asterisk directory and change the settings to match your nodes, names, passwords, station parameters, etc. The best way is to use a spare Allstar node not connected to any radio and set it up as 'rxchannel=Zap/pseudo' in the stanza for the dedicated EchoLink node in rpt.cont. Restart and you should have the echolink command in the CLI. If all is working well you should be able to see your own node. Attach other Allstar nodes to the EchoLink Allstar node as desired.
EchoLink allows three callsign variations in my case I have each of WA3DSP, WA3DSP-L, and WA3DSP-R registered BUT like IRLP you can only use one call and its assigned node per public IP address. So the one Windows computer where you might use EchoLink would have the two UDP ports forwarded to it from your router. In that case you could not use Allstar to connect to or accept connections from another EchoLink site. You could however setup Allstar EchoLink as above and use it just to download the EchoLink node list for call lookups in lsnodes. Making it fully EchoLink functional would require forwarding the two EchoLink UDP ports to the Allstar server which would then disable EchoLink communications on the Windows computer. So you need to make some choices unless you have multiple public IP's. In my case I don't use EchoLink in Windows so I have it permanently connected to my Allstar server. More information on EchoLink can be found at www.echolink.org and at the Asterisk app_rpt Knowledge-base.
cp /usr/src/astsrc/configs/examples/echolink/echolink.conf /etc/asterisk
Check your node lookup in CLI by node number.
WA3DSP_Allstar*CLI> echolink dbget n 147090
or to look up a call (call must be uppercase and exact)
WA3DSP_Allstar*CLI> echolink dbget c WA3DSP-L
A good place to check the EchoLink database is www.repeaterbook.com/repeaters/echolink/index.php
Data for private nodes (<2000) can be stored in the file "privatenodes.txt" located in the same directory as the astdb.php file. The format for this file is the following:
27225|WA3DSP|446.1 Simplex|Richboro, PA
The format is node, call, description, location separated by a vertical bar. This is strictly local and it is tacked onto the end of the master database on your system. Other than the node all other info does not have to conform to call, description, location but should be limited to the number of characters for that field. Note that changing the "privatenodes.txt" file will not update the local database until the "astdb.php" file is run.
Version 1.0 - First edition
Version 1.01 - Added Echolink display of calls
Version 1.02 - Corrected display of private nodes and added 80K range node labelling
Version 1.03 - Fixed bug in Echolink display - should display all node numbers if data exists.
Customizing the code
All of the code for the local command prompt display resides in the file 'lsnodes' and for the web display in 'lsnodes_web'. If you understand Perl and HTML/CSS coding then feel free to make changes. In particular you might have color, refresh time, or layout preferences. This code is just an example of one method of sending commands to Asterisk from a web page and displaying the results. I hope it is useful to you in some way.
My email is good at QRZ. 73, Doug, WA3DSP
This page last updated 1/29/2014
© 2014 - WA3DSP