Admin Status
This commit is contained in:
parent
2233e08ca1
commit
12c8275326
|
@ -70,6 +70,26 @@ app.filter('hfcduration', function() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
app.controller('statusController', function ($scope, $http) {
|
||||||
|
console.log("statusController");
|
||||||
|
$scope.status_search = "";
|
||||||
|
|
||||||
|
var api = '/api/com.daplie.rvpn/status'
|
||||||
|
|
||||||
|
$scope.updateView = function() {
|
||||||
|
$http.get(api).then(function(response) {
|
||||||
|
console.log(response);
|
||||||
|
data = response.data;
|
||||||
|
if (data.error == 'ok' ){
|
||||||
|
$scope.status = data.result;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
$scope.updateView()
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
app.controller('serverController', function ($scope, $http) {
|
app.controller('serverController', function ($scope, $http) {
|
||||||
$scope.servers = [];
|
$scope.servers = [];
|
||||||
$scope.servers_search = "";
|
$scope.servers_search = "";
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<div class="panel panel-default" data-ng-controller="serverController">
|
<div class="panel panel-default" data-ng-controller="statusController">
|
||||||
<div class="panel-heading">
|
<div class="panel-heading">
|
||||||
<div class="panel-title">
|
<div class="panel-title">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
@ -19,4 +19,28 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<div class="panel-body">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-4"> </div>
|
||||||
|
<div class="col-md-8">Server Name: {{ status.name }} (Uptime: {{ status.uptime | hfcduration }}</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-4"> </div>
|
||||||
|
<div class="col-md-8">Administrative Domain: {{ status.admin_domain }} </div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-4"> </div>
|
||||||
|
<div class="col-md-8">Server Domain: {{ status.wss_domain }} </div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-4"> </div>
|
||||||
|
<div class="col-md-8">Default LB Method: {{ status.loadbalance_default_method }} </div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-4"> </div>
|
||||||
|
<div class="col-md-8">Deadtime: dwell:{{ status.dead_time.dwell}} idle:{{ status.dead_time.idle}} cancel:{{ status.dead_time.cancel_check}}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
package genericlistener
|
||||||
|
|
||||||
|
//ConnectionStatsAPI --
|
||||||
|
type ConnectionStatsAPI struct {
|
||||||
|
Connections int64 `json:"current_connections"`
|
||||||
|
TotalConnections int64 `json:"total_connections"`
|
||||||
|
}
|
||||||
|
|
||||||
|
//NewConnectionStatsAPI -- Consttuctor
|
||||||
|
func NewConnectionStatsAPI(connections int64, totalConnections int64) (p *ConnectionStatsAPI) {
|
||||||
|
p = new(ConnectionStatsAPI)
|
||||||
|
p.Connections = connections
|
||||||
|
p.TotalConnections = totalConnections
|
||||||
|
return
|
||||||
|
}
|
|
@ -6,16 +6,16 @@ import (
|
||||||
|
|
||||||
//StatusAPI -- Structure to support the server API
|
//StatusAPI -- Structure to support the server API
|
||||||
type StatusAPI struct {
|
type StatusAPI struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Uptime float64 `json:"uptime"`
|
Uptime float64 `json:"uptime"`
|
||||||
WssDomain string `json:"wss_domain"`
|
WssDomain string `json:"wss_domain"`
|
||||||
AdminDomain string `json:"admin_domain"`
|
AdminDomain string `json:"admin_domain"`
|
||||||
LoadbalanceDefaultMethod string `json:"loadbalance_default_method"`
|
LoadbalanceDefaultMethod string `json:"loadbalance_default_method"`
|
||||||
DeadTime *StatusDeadTimeAPI `json:"dead_time"`
|
DeadTime *StatusDeadTimeAPI `json:"dead_time"`
|
||||||
AdminStats *TrafficAPI `json:"admin_traffic"`
|
AdminStats *TrafficAPI `json:"admin_traffic"`
|
||||||
TrafficStats *TrafficAPI `json:"traffic"`
|
TrafficStats *TrafficAPI `json:"traffic"`
|
||||||
ExtConnections *ConnectionStats
|
ExtConnections *ConnectionStatsAPI `json:"ext_connections"`
|
||||||
WSSConnections *ConnectionStats
|
WSSConnections *ConnectionStatsAPI `json:"wss_connections"`
|
||||||
}
|
}
|
||||||
|
|
||||||
//NewStatusAPI - Constructor
|
//NewStatusAPI - Constructor
|
||||||
|
@ -29,6 +29,8 @@ func NewStatusAPI(c *Status) (s *StatusAPI) {
|
||||||
s.DeadTime = NewStatusDeadTimeAPI(c.DeadTime.dwell, c.DeadTime.idle, c.DeadTime.cancelcheck)
|
s.DeadTime = NewStatusDeadTimeAPI(c.DeadTime.dwell, c.DeadTime.idle, c.DeadTime.cancelcheck)
|
||||||
s.AdminStats = NewTrafficAPI(c.AdminStats.Requests, c.AdminStats.Responses, c.AdminStats.BytesIn, c.AdminStats.BytesOut)
|
s.AdminStats = NewTrafficAPI(c.AdminStats.Requests, c.AdminStats.Responses, c.AdminStats.BytesIn, c.AdminStats.BytesOut)
|
||||||
s.TrafficStats = NewTrafficAPI(c.TrafficStats.Requests, c.TrafficStats.Responses, c.TrafficStats.BytesIn, c.TrafficStats.BytesOut)
|
s.TrafficStats = NewTrafficAPI(c.TrafficStats.Requests, c.TrafficStats.Responses, c.TrafficStats.BytesIn, c.TrafficStats.BytesOut)
|
||||||
|
s.ExtConnections = NewConnectionStatsAPI(c.ExtConnections.Connections, c.ExtConnections.TotalConnections)
|
||||||
|
s.WSSConnections = NewConnectionStatsAPI(c.WSSConnections.Connections, c.ExtConnections.TotalConnections)
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,13 +17,14 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
var connectionTable *Table
|
var connectionTable *Table
|
||||||
|
var serverStatus *Status
|
||||||
var serverStatusAPI *Status
|
var serverStatusAPI *Status
|
||||||
|
|
||||||
//handleAdminClient -
|
//handleAdminClient -
|
||||||
// - expecting an existing oneConnListener with a qualified wss client connected.
|
// - expecting an existing oneConnListener with a qualified wss client connected.
|
||||||
// - auth will happen again since we were just peeking at the token.
|
// - auth will happen again since we were just peeking at the token.
|
||||||
func handleAdminClient(ctx context.Context, oneConn *oneConnListener) {
|
func handleAdminClient(ctx context.Context, oneConn *oneConnListener) {
|
||||||
serverStatus := ctx.Value(ctxServerStatus).(*Status)
|
serverStatus = ctx.Value(ctxServerStatus).(*Status)
|
||||||
|
|
||||||
connectionTable = serverStatus.ConnectionTable
|
connectionTable = serverStatus.ConnectionTable
|
||||||
serverStatusAPI = serverStatus
|
serverStatusAPI = serverStatus
|
||||||
|
@ -33,11 +34,16 @@ func handleAdminClient(ctx context.Context, oneConn *oneConnListener) {
|
||||||
|
|
||||||
router.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
router.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||||||
loginfo.Println("HandleFunc /")
|
loginfo.Println("HandleFunc /")
|
||||||
|
|
||||||
|
serverStatus.AdminStats.IncRequests()
|
||||||
|
|
||||||
switch url := r.URL.Path; url {
|
switch url := r.URL.Path; url {
|
||||||
case "/":
|
case "/":
|
||||||
// check to see if we are using the administrative Host
|
// check to see if we are using the administrative Host
|
||||||
if strings.Contains(r.Host, "rvpn.daplie.invalid") {
|
if strings.Contains(r.Host, "rvpn.daplie.invalid") {
|
||||||
http.Redirect(w, r, "/admin", 301)
|
http.Redirect(w, r, "/admin", 301)
|
||||||
|
serverStatus.AdminStats.IncResponses()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -74,6 +80,8 @@ func getStatusEndpoint(w http.ResponseWriter, r *http.Request) {
|
||||||
pc, _, _, _ := runtime.Caller(0)
|
pc, _, _, _ := runtime.Caller(0)
|
||||||
loginfo.Println(runtime.FuncForPC(pc).Name())
|
loginfo.Println(runtime.FuncForPC(pc).Name())
|
||||||
|
|
||||||
|
serverStatus.AdminStats.IncRequests()
|
||||||
|
|
||||||
statusContainer := NewStatusAPI(serverStatusAPI)
|
statusContainer := NewStatusAPI(serverStatusAPI)
|
||||||
|
|
||||||
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
|
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
|
||||||
|
@ -81,13 +89,15 @@ func getStatusEndpoint(w http.ResponseWriter, r *http.Request) {
|
||||||
env := envelope.NewEnvelope("domains/GET")
|
env := envelope.NewEnvelope("domains/GET")
|
||||||
env.Result = statusContainer
|
env.Result = statusContainer
|
||||||
env.GenerateWriter(w)
|
env.GenerateWriter(w)
|
||||||
|
serverStatus.AdminStats.IncResponses()
|
||||||
}
|
}
|
||||||
|
|
||||||
func getDomainsEndpoint(w http.ResponseWriter, r *http.Request) {
|
func getDomainsEndpoint(w http.ResponseWriter, r *http.Request) {
|
||||||
pc, _, _, _ := runtime.Caller(0)
|
pc, _, _, _ := runtime.Caller(0)
|
||||||
loginfo.Println(runtime.FuncForPC(pc).Name())
|
loginfo.Println(runtime.FuncForPC(pc).Name())
|
||||||
|
|
||||||
|
serverStatus.AdminStats.IncRequests()
|
||||||
|
|
||||||
domainsContainer := NewDomainsAPIContainer()
|
domainsContainer := NewDomainsAPIContainer()
|
||||||
|
|
||||||
for domain := range connectionTable.domains {
|
for domain := range connectionTable.domains {
|
||||||
|
@ -102,13 +112,15 @@ func getDomainsEndpoint(w http.ResponseWriter, r *http.Request) {
|
||||||
env := envelope.NewEnvelope("domains/GET")
|
env := envelope.NewEnvelope("domains/GET")
|
||||||
env.Result = domainsContainer
|
env.Result = domainsContainer
|
||||||
env.GenerateWriter(w)
|
env.GenerateWriter(w)
|
||||||
|
serverStatus.AdminStats.IncResponses()
|
||||||
}
|
}
|
||||||
|
|
||||||
func getDomainEndpoint(w http.ResponseWriter, r *http.Request) {
|
func getDomainEndpoint(w http.ResponseWriter, r *http.Request) {
|
||||||
pc, _, _, _ := runtime.Caller(0)
|
pc, _, _, _ := runtime.Caller(0)
|
||||||
loginfo.Println(runtime.FuncForPC(pc).Name())
|
loginfo.Println(runtime.FuncForPC(pc).Name())
|
||||||
|
|
||||||
|
serverStatus.AdminStats.IncRequests()
|
||||||
|
|
||||||
env := envelope.NewEnvelope("domain/GET")
|
env := envelope.NewEnvelope("domain/GET")
|
||||||
|
|
||||||
params := mux.Vars(r)
|
params := mux.Vars(r)
|
||||||
|
@ -130,12 +142,15 @@ func getDomainEndpoint(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
|
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
|
||||||
env.GenerateWriter(w)
|
env.GenerateWriter(w)
|
||||||
|
serverStatus.AdminStats.IncResponses()
|
||||||
}
|
}
|
||||||
|
|
||||||
func getServersEndpoint(w http.ResponseWriter, r *http.Request) {
|
func getServersEndpoint(w http.ResponseWriter, r *http.Request) {
|
||||||
pc, _, _, _ := runtime.Caller(0)
|
pc, _, _, _ := runtime.Caller(0)
|
||||||
loginfo.Println(runtime.FuncForPC(pc).Name())
|
loginfo.Println(runtime.FuncForPC(pc).Name())
|
||||||
|
|
||||||
|
serverStatus.AdminStats.IncRequests()
|
||||||
|
|
||||||
serverContainer := NewServerAPIContainer()
|
serverContainer := NewServerAPIContainer()
|
||||||
|
|
||||||
for c := range connectionTable.Connections() {
|
for c := range connectionTable.Connections() {
|
||||||
|
@ -149,12 +164,15 @@ func getServersEndpoint(w http.ResponseWriter, r *http.Request) {
|
||||||
env := envelope.NewEnvelope("servers/GET")
|
env := envelope.NewEnvelope("servers/GET")
|
||||||
env.Result = serverContainer
|
env.Result = serverContainer
|
||||||
env.GenerateWriter(w)
|
env.GenerateWriter(w)
|
||||||
|
serverStatus.AdminStats.IncResponses()
|
||||||
}
|
}
|
||||||
|
|
||||||
func getServerEndpoint(w http.ResponseWriter, r *http.Request) {
|
func getServerEndpoint(w http.ResponseWriter, r *http.Request) {
|
||||||
pc, _, _, _ := runtime.Caller(0)
|
pc, _, _, _ := runtime.Caller(0)
|
||||||
loginfo.Println(runtime.FuncForPC(pc).Name())
|
loginfo.Println(runtime.FuncForPC(pc).Name())
|
||||||
|
|
||||||
|
serverStatus.AdminStats.IncRequests()
|
||||||
|
|
||||||
env := envelope.NewEnvelope("server/GET")
|
env := envelope.NewEnvelope("server/GET")
|
||||||
|
|
||||||
params := mux.Vars(r)
|
params := mux.Vars(r)
|
||||||
|
@ -185,4 +203,5 @@ func getServerEndpoint(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
|
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
|
||||||
env.GenerateWriter(w)
|
env.GenerateWriter(w)
|
||||||
|
serverStatus.AdminStats.IncResponses()
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@ type Status struct {
|
||||||
GenericListeners *GenericListeners
|
GenericListeners *GenericListeners
|
||||||
LoadbalanceDefaultMethod string
|
LoadbalanceDefaultMethod string
|
||||||
AdminStats *TrafficStats
|
AdminStats *TrafficStats
|
||||||
|
AdminReqTyoe *AdminReqType
|
||||||
TrafficStats *TrafficStats
|
TrafficStats *TrafficStats
|
||||||
ExtConnections *ConnectionStats
|
ExtConnections *ConnectionStats
|
||||||
WSSConnections *ConnectionStats
|
WSSConnections *ConnectionStats
|
||||||
|
|
|
@ -2,22 +2,27 @@ package genericlistener
|
||||||
|
|
||||||
//ConnectionStats --
|
//ConnectionStats --
|
||||||
type ConnectionStats struct {
|
type ConnectionStats struct {
|
||||||
Connections int64
|
Connections int64
|
||||||
|
TotalConnections int64
|
||||||
}
|
}
|
||||||
|
|
||||||
//NewConnectionStats -- Consttuctor
|
//NewConnectionStats -- Consttuctor
|
||||||
func NewConnectionStats() (p *ConnectionStats) {
|
func NewConnectionStats() (p *ConnectionStats) {
|
||||||
p = new(ConnectionStats)
|
p = new(ConnectionStats)
|
||||||
p.Connections = 0
|
p.Connections = 0
|
||||||
|
p.TotalConnections = 0
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//IncConnections --
|
//IncConnections --
|
||||||
func (p *ConnectionStats) IncConnections() {
|
func (p *ConnectionStats) IncConnections() {
|
||||||
p.Connections++
|
p.Connections++
|
||||||
|
p.TotalConnections++
|
||||||
}
|
}
|
||||||
|
|
||||||
//DecConnections --
|
//DecConnections --
|
||||||
func (p *ConnectionStats) DecConnections() {
|
func (p *ConnectionStats) DecConnections() {
|
||||||
p.Connections--
|
if p.Connections > 0 {
|
||||||
|
p.Connections--
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue