Skip to content

Instantly share code, notes, and snippets.

@mestizo
Last active July 21, 2016 13:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mestizo/2b283adcd7542ca90d95a06b928de483 to your computer and use it in GitHub Desktop.
Save mestizo/2b283adcd7542ca90d95a06b928de483 to your computer and use it in GitHub Desktop.
FreeSwitch Dashing Widget

FreeSwitch Widget

##Preview

##Description

This is a Dashing widget and all components needed to displace call information into an Dashing Widget. (Widget has only been tested with FreeSwitch v1.4)

##Usage

###Configure FreeSwitch

Edit the /etc/freeswitch/autoload_configs/xml_rpc.conf.xml file. Configure the desired username and password.

Edit the /etc/freeswitch/autoload_configs/modules.conf.xml file. Add or ensure that the following is not commented out:

Restart FreeSwitch.

###Configure Widget

To use this widget, copy query_site1_calls.rb, query_site1_g729.rb, and query_site1_reg.rb into the /jobs directory. Replace freeswitch.example.com with your servers DNS name. Update the username and password to match those configured in the FreeSwitch configuration.

Copy the voip.erb file into the /dashboards directory.

<% content_for(:title) { "Voip Monitoring" } %>
<div class="gridster">
<ul>
<li data-row="1" data-col="2" data-sizex="1" data-sizey="1">
<div data-id="site1_g729" data-view="Number" data-title="Active G7.29 License on Site_1"></div>
</li>
<li data-row="1" data-col="3" data-sizex="1" data-sizey="1">
<div data-id="site1_calls" data-view="Number" data-title="Active Calls on Site_1"></div>
</li>
<li data-row="1" data-col="4" data-sizex="1" data-sizey="1">
<div data-id="site1_reg" data-view="Number" data-title="Registered Phones on Site_1"></div>
</li>
</ul>
</div>
require 'net/http'
# :first_in sets how long it takes before the job is first run. In this case, it is run immediately
SCHEDULER.every '10s', :first_in => 0 do |job|
calls = 0
http = Net::HTTP.new('freeswitch.example.com', 8080)
http.start do |http|
req = Net::HTTP::Get.new('/xmlapi/show?calls%20count')
req.basic_auth 'freeswitch', 'PASSWORD'
response = http.request(req)
# regex = /Total items returned:\s*([\d]+)/
regex = /([\d]+)/
result = regex.match(response.body)
calls = result[1]
end
send_event('site1_calls', current: calls)
end
require 'net/http'
# :first_in sets how long it takes before the job is first run. In this case, it is run immediately
SCHEDULER.every '10s', :first_in => 0 do |job|
calls = 0
http = Net::HTTP.new('freeswitch.example.com', 8080)
http.start do |http|
req = Net::HTTP::Get.new('/xmlapi/g729_info')
req.basic_auth 'freeswitch', 'PASSWORD'
response = http.request(req)
regex = /G.729A license allocated =>\s*([\d]+)/
# regex = /([\d]+)/
result = regex.match(response.body)
calls = result[1]
end
send_event('site1_g729', current: calls)
end
require 'net/http'
# :first_in sets how long it takes before the job is first run. In this case, it is run immediately
SCHEDULER.every '60s', :first_in => 0 do |job|
registered = 0
http = Net::HTTP.new('freeswitch.example.com', 8080)
http.start do |http|
req = Net::HTTP::Get.new('/webapi/sofia?status%20profile%20internal%20reg')
req.basic_auth 'freeswitch', 'PASSWORD'
response = http.request(req)
regex = /Total items returned:\s*([\d]+)/
result = regex.match(response.body)
registered = result[1]
end
send_event('site1_reg', current: registered)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment