mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-22 23:58:44 +05:00
worked on the web interface for schedduler (dropped) and started new logging to syslog
This commit is contained in:
@@ -21,9 +21,9 @@ package main
|
||||
import (
|
||||
"errors"
|
||||
"flag"
|
||||
"github.com/cgrates/cgrates/balancer"
|
||||
"github.com/cgrates/cgrates/sessionmanager"
|
||||
"github.com/cgrates/cgrates/timespans"
|
||||
"github.com/cgrates/cgrates/balancer"
|
||||
"log"
|
||||
"runtime"
|
||||
"time"
|
||||
@@ -32,7 +32,7 @@ import (
|
||||
var (
|
||||
raterAddress = flag.String("rateraddr", "127.0.0.1:2000", "Rater server address (localhost:2000)")
|
||||
rpcAddress = flag.String("rpcaddr", "127.0.0.1:2001", "Json RPC server address (localhost:2001)")
|
||||
httpApiAddress = flag.String("httpapiaddr", "127.0.0.1:8000", "Http API server address (localhost:2002)")
|
||||
httpApiAddress = flag.String("httpapiaddr", "127.0.0.1:8000", "Http API server address (localhost:8000)")
|
||||
freeswitch = flag.Bool("freeswitch", false, "connect to freeswitch server")
|
||||
freeswitchsrv = flag.String("freeswitchsrv", "localhost:8021", "freeswitch address host:port")
|
||||
freeswitchpass = flag.String("freeswitchpass", "ClueCon", "freeswitch address host:port")
|
||||
|
||||
@@ -29,7 +29,7 @@ import (
|
||||
Handler for the statistics web client
|
||||
*/
|
||||
func statusHandler(w http.ResponseWriter, r *http.Request) {
|
||||
if t, err := template.ParseFiles("templates/status.html"); err == nil {
|
||||
if t, err := template.ParseFiles("templates/base.html", "templates/status.html"); err == nil {
|
||||
t.Execute(w, bal.GetClientAddresses())
|
||||
} else {
|
||||
log.Print("Error rendering status: ", err)
|
||||
|
||||
45
cmd/cgr-balancer/templates/actiontimings.html
Normal file
45
cmd/cgr-balancer/templates/actiontimings.html
Normal file
@@ -0,0 +1,45 @@
|
||||
{{define "title"}}CGRateS Action Timings{{end}}
|
||||
{{define "content"}}
|
||||
<div class="modal hide fade" id="myModal">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal">×</button>
|
||||
<h3>Modal header</h3>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p>One fine body…</p>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<a href="#" class="btn" data-dismiss="modal">Close</a>
|
||||
<a href="#" class="btn btn-primary">Save changes</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="span7">
|
||||
<h1>Action timings</h1>
|
||||
<table id="rater-table" class="table table-striped">
|
||||
{{range .}}
|
||||
<tr>
|
||||
<td>{{.}}</td>
|
||||
<td><a class="btn" data-toggle="modal" href="#myModal" >Edit</a></td>
|
||||
</tr>
|
||||
{{end}}
|
||||
</table>
|
||||
</div>
|
||||
<div class="span5">
|
||||
<h2>Heading</h2>
|
||||
<p>Donec sed odio dui. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Vestibulum id ligula porta felis euismod semper. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus.</p>
|
||||
<p><a class="btn" href="#">View details »</a></p>
|
||||
</div>
|
||||
</div>
|
||||
{{end}}
|
||||
|
||||
{{define "extrascripts"}}
|
||||
<script src="static/js/jquery.flot.min.js" type="text/javascript"></script>
|
||||
<script type="text/javascript">
|
||||
$(function(){
|
||||
$('#myModal').modal({
|
||||
show: false
|
||||
})
|
||||
});
|
||||
</script>
|
||||
{{end}}
|
||||
61
cmd/cgr-balancer/templates/base.html
Normal file
61
cmd/cgr-balancer/templates/base.html
Normal file
@@ -0,0 +1,61 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>{{template "title" .}}</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta name="description" content="Describes the internal status of CGRateS server.">
|
||||
<meta name="author" content="Radu Ioan Fericean">
|
||||
|
||||
<!-- Le styles -->
|
||||
<link href="static/css/bootstrap.min.css" rel="stylesheet">
|
||||
<style type="text/css">
|
||||
body {
|
||||
padding-top: 60px;
|
||||
padding-bottom: 40px;
|
||||
}
|
||||
</style>
|
||||
<link href="static/css/bootstrap-responsive.min.css" rel="stylesheet">
|
||||
|
||||
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="navbar navbar-fixed-top">
|
||||
<div class="navbar-inner">
|
||||
<div class="container">
|
||||
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</a>
|
||||
<a class="brand" href="#">CGRateS</a>
|
||||
<div class="nav-collapse">
|
||||
</div><!--/.nav-collapse -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="container">
|
||||
|
||||
{{template "content" .}}
|
||||
|
||||
<hr>
|
||||
|
||||
<footer>
|
||||
<p>© Radu Fericean 2012</p>
|
||||
</footer>
|
||||
|
||||
</div> <!-- /container -->
|
||||
|
||||
<!-- Le javascript
|
||||
================================================== -->
|
||||
<!-- Placed at the end of the document so the pages load faster -->
|
||||
<script src="static/js/jquery-1.7.2.min.js"></script>
|
||||
<script src="static/js/bootstrap.min.js"></script>
|
||||
</script>{{template "extrascripts" .}}
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,48 +1,5 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>CGRateS Status</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta name="description" content="Describes the internal status of CGRateS server.">
|
||||
<meta name="author" content="Radu Ioan Fericean">
|
||||
|
||||
<!-- Le styles -->
|
||||
<link href="static/css/bootstrap.min.css" rel="stylesheet">
|
||||
<style type="text/css">
|
||||
body {
|
||||
padding-top: 60px;
|
||||
padding-bottom: 40px;
|
||||
}
|
||||
</style>
|
||||
<link href="static/css/bootstrap-responsive.min.css" rel="stylesheet">
|
||||
|
||||
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<div class="navbar navbar-fixed-top">
|
||||
<div class="navbar-inner">
|
||||
<div class="container">
|
||||
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</a>
|
||||
<a class="brand" href="#">CGRateS</a>
|
||||
<div class="nav-collapse">
|
||||
</div><!--/.nav-collapse -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="container">
|
||||
|
||||
<!-- Main hero unit for a primary marketing message or call to action -->
|
||||
{{define "title"}}CGRateS Status{{end}}
|
||||
{{define "content"}}
|
||||
<div class="hero-unit">
|
||||
<h1>Conected raters</h1>
|
||||
<table id="rater-table" class="table table-striped">
|
||||
@@ -52,8 +9,7 @@
|
||||
</table>
|
||||
<p><a id="rater-refresh" href="#" class="btn btn-primary btn-large">Refresh</a></p>
|
||||
</div>
|
||||
|
||||
<!-- Example row of columns -->
|
||||
|
||||
<div class="row">
|
||||
<div class="span7">
|
||||
<h2>Memory consumption (KB)</h2>
|
||||
@@ -65,21 +21,10 @@
|
||||
<p><a class="btn" href="#">View details »</a></p>
|
||||
</div>
|
||||
</div>
|
||||
{{end}}
|
||||
|
||||
<hr>
|
||||
|
||||
<footer>
|
||||
<p>© Radu Fericean 2012</p>
|
||||
</footer>
|
||||
|
||||
</div> <!-- /container -->
|
||||
|
||||
<!-- Le javascript
|
||||
================================================== -->
|
||||
<!-- Placed at the end of the document so the pages load faster -->
|
||||
<script src="static/js/jquery-1.7.2.min.js"></script>
|
||||
<script src="static/js/bootstrap.min.js"></script>
|
||||
<script src="static/js/jquery.flot.min.js" type="text/javascript"></script>
|
||||
{{define "extrascripts"}}
|
||||
<script src="static/js/jquery.flot.min.js" type="text/javascript"></script>
|
||||
<script type="text/javascript">
|
||||
$(function () {
|
||||
// we use an inline data source in the example, usually data would
|
||||
@@ -134,5 +79,4 @@
|
||||
})
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
{{end}}
|
||||
@@ -19,9 +19,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/cgrates/cgrates/timespans"
|
||||
"log"
|
||||
"fmt"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
@@ -127,6 +127,7 @@ func (csvr *CSVReader) loadActionTimings(fn string) {
|
||||
}
|
||||
for _, t := range ts {
|
||||
at := ×pans.ActionTiming{
|
||||
Id: timespans.GenUUID(),
|
||||
Tag: record[2],
|
||||
Weight: weight,
|
||||
Timing: ×pans.Interval{
|
||||
@@ -139,7 +140,6 @@ func (csvr *CSVReader) loadActionTimings(fn string) {
|
||||
}
|
||||
actionsTimings[tag] = append(actionsTimings[tag], at)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,8 +22,8 @@ import (
|
||||
"github.com/cgrates/cgrates/timespans"
|
||||
"log"
|
||||
"strconv"
|
||||
"time"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Rate struct {
|
||||
|
||||
46
cmd/cgr-scheduler/actiontimings_webapp.go
Normal file
46
cmd/cgr-scheduler/actiontimings_webapp.go
Normal file
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
Rating system designed to be used in VoIP Carriers World
|
||||
Copyright (C) 2012 Radu Ioan Fericean
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"html/template"
|
||||
"log"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func handler(w http.ResponseWriter, r *http.Request) {
|
||||
actionTimings, err := storage.GetAllActionTimings()
|
||||
if err != nil {
|
||||
log.Print("Cannot get action timings:", err)
|
||||
}
|
||||
if t, err := template.ParseFiles("templates/base.html", "templates/actiontimings.html"); err == nil {
|
||||
t.Execute(w, actionTimings)
|
||||
} else {
|
||||
log.Print("Error rendering status: ", err)
|
||||
}
|
||||
}
|
||||
|
||||
func startWebApp() {
|
||||
http.Handle("/static/", http.FileServer(http.Dir("")))
|
||||
http.HandleFunc("/", handler)
|
||||
err := http.ListenAndServe(*httpAddress, nil)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
@@ -23,16 +23,17 @@ import (
|
||||
"github.com/cgrates/cgrates/timespans"
|
||||
"log"
|
||||
"os"
|
||||
"sort"
|
||||
"time"
|
||||
"os/signal"
|
||||
"sort"
|
||||
"syscall"
|
||||
"time"
|
||||
)
|
||||
|
||||
var (
|
||||
redisserver = flag.String("redisserver", "127.0.0.1:6379", "redis server address (tcp:127.0.0.1:6379)")
|
||||
redisdb = flag.Int("rdb", 10, "redis database number (10)")
|
||||
redispass = flag.String("pass", "", "redis database password")
|
||||
httpAddress = flag.String("httpapiaddr", "127.0.0.1:8000", "Http API server address (localhost:8000)")
|
||||
storage timespans.StorageGetter
|
||||
timer *time.Timer
|
||||
restartLoop = make(chan byte)
|
||||
@@ -115,5 +116,6 @@ func main() {
|
||||
timespans.SetStorageGetter(storage)
|
||||
loadActionTimings()
|
||||
go stopSingnalHandler()
|
||||
// go startWebApp()
|
||||
s.loop()
|
||||
}
|
||||
|
||||
1
cmd/cgr-scheduler/static
Symbolic link
1
cmd/cgr-scheduler/static
Symbolic link
@@ -0,0 +1 @@
|
||||
../cgr-balancer/static/
|
||||
1
cmd/cgr-scheduler/templates
Symbolic link
1
cmd/cgr-scheduler/templates
Symbolic link
@@ -0,0 +1 @@
|
||||
../cgr-balancer/templates/
|
||||
Reference in New Issue
Block a user