-
-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
175 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
function getKamailioStats(elmnt) { | ||
//elmnt.style.backgroundColor = "red"; | ||
//elmnt.style.borderColor = "red" | ||
var msg_bar = $(".message-bar"); | ||
var reload_button = $('#reloadkam'); | ||
|
||
|
||
$.ajax({ | ||
type: "GET", | ||
url: "/v1/kamailio/stats", | ||
dataType: "json", | ||
success: function(msg) { | ||
if (msg.status === 1) { | ||
msg_bar.addClass("alert alert-success"); | ||
msg_bar.html("<strong>Success!</strong> Kamailio was reloaded successfully!"); | ||
reload_button.removeClass('btn-warning'); | ||
reload_button.addClass('btn-primary'); | ||
} | ||
else { | ||
msg_bar.addClass("alert alert-danger"); | ||
msg_bar.html("<strong>Failed!</strong> Kamailio was NOT reloaded successfully!"); | ||
} | ||
|
||
msg_bar.show(); | ||
msg_bar.slideUp(3000, "linear"); | ||
//elmnt.style.backgroundColor = "#337ab7"; | ||
//elmnt.style.borderColor = "#2e6da4"; | ||
} | ||
}); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
from flask import Blueprint, session, render_template,jsonify | ||
from flask import Flask, render_template, request, redirect, abort, flash, session, url_for, send_from_directory | ||
from sqlalchemy import case, func, exc as sql_exceptions | ||
from werkzeug import exceptions as http_exceptions | ||
from database import loadSession, Domain, DomainAttrs, dSIPDomainMapping, dSIPMultiDomainMapping, Dispatcher, Gateways | ||
from shared import * | ||
import settings | ||
|
||
db = loadSession() | ||
api = Blueprint('api', __name__) | ||
|
||
@api.route("/api/v1/kamailio/stats", methods=['GET']) | ||
def getKamailioStats(): | ||
try: | ||
if (settings.DEBUG): | ||
debugEndpoint() | ||
|
||
#if not session.get('logged_in'): | ||
# return render_template('index.html', version=settings.VERSION) | ||
|
||
payload = {"jsonrpc": "2.0", "method": "tm.stats","id": 1} | ||
#r = requests.get('https://www.google.com',data=payload) | ||
r = requests.get('http://127.0.0.1:5060/api/kamailio',json=payload) | ||
#print(r.text) | ||
|
||
return r.text | ||
|
||
except sql_exceptions.SQLAlchemyError as ex: | ||
debugException(ex, log_ex=False, print_ex=True, showstack=False) | ||
error = "db" | ||
db.rollback() | ||
db.flush() | ||
return showError(type=error) | ||
except http_exceptions.HTTPException as ex: | ||
debugException(ex, log_ex=False, print_ex=True, showstack=False) | ||
error = "http" | ||
db.rollback() | ||
db.flush() | ||
return showError(type=error) | ||
except Exception as ex: | ||
debugException(ex, log_ex=False, print_ex=True, showstack=False) | ||
error = "server" | ||
db.rollback() | ||
db.flush() | ||
return showError(type=error) | ||
finally: | ||
db.close() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
.dashboard-metric { | ||
font-size: 80px; | ||
text-align: center; | ||
} | ||
|
||
.dashboard-metric-label { | ||
font-size: 35px; | ||
text-align: center; | ||
color: #ddd; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
function getKamailioStats(elmnt) { | ||
|
||
|
||
$.ajax({ | ||
type: "GET", | ||
url: "/api/v1/kamailio/stats", | ||
dataType: "json", | ||
success: function(msg) { | ||
document.getElementById("dashboard_current_calls").innerHTML=msg.result.current; | ||
document.getElementById("dashboard_calls_inqueue").innerHTML=msg.result.waiting; | ||
document.getElementById("dashboard_total_calls_processed").innerHTML=msg.result.total; | ||
}}); | ||
} | ||
|
||
getKamailioStats(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters