updates - prometheus exporter /metrics

pull/10/head
Hunter Long 2018-06-23 23:44:15 -07:00
parent c9dd23b36e
commit ed96092530
7 changed files with 167 additions and 37 deletions

View File

@ -6,6 +6,14 @@ for you to build an even better status page.
Statup strives to remain future-proof and remain intact if a failure is created. Your Statup service should not be running on the same instance you're trying to monitor.
If your server crashes your Status Page should still remaining online to notify your users of downtime.
## Exporting Static HTML
If you want to use Statup as a CLI application without running a server, you can export your status page to a static HTML.
This export tool is very useful for people who want to export their HTML and upload/commit it to Github Pages or an FTP server.
```dash
statup export
```
###### `index.html` will be created in the current directory with CDN URL's for assets.
## Run on Docker
Use the [Statup Docker Image](https://hub.docker.com/r/hunterlong/statup) to create a status page in seconds.
```bash

View File

@ -20,6 +20,7 @@ type Core struct {
Repos []PluginJSON
PluginFields []PluginSelect
Communications []*types.Communication
OfflineAssets bool
}
func (c *Core) Update() (*Core, error) {

116
docs/base.css Normal file
View File

@ -0,0 +1,116 @@
HTML,BODY {
background-color: #efefef;
}
.container {
padding-top: 20px;
padding-bottom: 20px;
max-width: 860px;
}
.navbar {
margin-bottom: 30px;
}
.lg_number {
font-size: 26pt;
font-weight: bold;
display: block;
color: #3e3e3e;
}
.text_perfect {
color: #33b418;
text-shadow: 0px 1px 0 #0e6702;
}
.text_good {
color: #33b418;
text-shadow: 0px 1px 0 #0e6702;
}
.text_ok {
color: #33b418;
text-shadow: 0px 1px 0 #0e6702;
}
.text_bad {
color: #33b418;
text-shadow: 0px 1px 0 #0e6702;
}
.stats_area {
text-align: center;
color: #a5a5a5;
}
.offline_bg {
background-color: white !important;
}
.online_list {
}
.footer {
text-decoration: none;
margin-top: 20px;
}
.footer A {
color: #cccccc;
}
.online_badge {
color: #fff;
background-color: #35b317;
}
.offline_badge {
color: #fff;
background-color: #c51919;
}
.progress {
margin-top: -20px;
margin-left: -20px;
margin-bottom: 15px;
width: calc(100% + 40px);
height: 3px;
border-radius: 0;
}
.card-body {
overflow: hidden;
}
.card-body H4 A {
color: #239e07;
text-decoration: none;
}
@media (max-width: 767px) {
.container {
margin-top: 0 !important;
padding: 0 !important;
}
.navbar {
margin-left: 0px;
margin-top: 0px;
width: 100%;
margin-bottom: 0;
}
.card-body {
font-size: 6pt;
}
.lg_number {
font-size: 1.2rem;
}
}

View File

@ -4,12 +4,14 @@ import (
"bytes"
"fmt"
"html/template"
"io/ioutil"
"log"
)
var httpFunctions template.FuncMap
func ExportIndexHTML() string {
core.OfflineAssets = true
out := index{*core, services}
nav, _ := tmplBox.String("nav.html")
footer, _ := tmplBox.String("footer.html")
@ -45,3 +47,8 @@ func ExportIndexHTML() string {
fmt.Println(result)
return result
}
func SaveFile(filename string, data []byte) error {
err := ioutil.WriteFile(filename, data, 0644)
return err
}

View File

@ -4,10 +4,15 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
{{if .Core.OfflineAssets}}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<link rel="stylesheet" href="https://statup.io/base.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.2/Chart.bundle.min.js"></script>
{{ else }}
<link rel="stylesheet" href="/css/bootstrap.min.css">
<link rel="stylesheet" href="/css/base.css">
<script src="/js/Chart.bundle.min.js"></script>
{{end}}
<title>{{.Core.Name}} Status</title>
</head>
<body>
@ -163,7 +168,14 @@ var chartdata = new Chart(ctx, {
</style>
{{ end }}
{{if .Core.OfflineAssets}}
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
{{ else }}
<script src="/js/jquery-3.3.1.slim.min.js"></script>
<script src="/js/bootstrap.min.js"></script>
{{end}}
</body>
</html>

47
main.go
View File

@ -15,6 +15,7 @@ import (
plg "plugin"
"strconv"
"strings"
"time"
)
var (
@ -91,42 +92,26 @@ func DownloadFile(filepath string, url string) error {
return nil
}
//func DownloadPlugin(name string) {
// plugin := SelectPlugin(name)
// var _, err = os.Stat("plugins/" + plugin.Namespace)
// if err != nil {
// }
// if os.IsNotExist(err) {
// var file, _ = os.Create("plugins/" + plugin.Namespace)
// defer file.Close()
// }
// resp, err := http.Get("https://raw.githubusercontent.com/hunterlong/statup/master/plugins.json")
// if err != nil {
// panic(err)
// }
// defer resp.Body.Close()
// body, err := ioutil.ReadAll(resp.Body)
// if err != nil {
// panic(err)
// }
// file, err := os.OpenFile("plugins/"+plugin.Namespace, os.O_RDWR, 0644)
// if err != nil {
// panic(err)
// }
// defer file.Close()
//
// _, err = file.Write(body)
// if err != nil {
// panic(err)
// }
// err = file.Sync()
//}
func main() {
if len(os.Args) >= 2 {
if os.Args[1] == "version" {
fmt.Printf("Statup v%v\n", VERSION)
}
if os.Args[1] == "export" {
fmt.Printf("Statup v%v Exporting Static 'index.html' page...\n", VERSION)
RenderBoxes()
configs, _ = LoadConfig()
setupMode = true
mainProcess()
time.Sleep(10 * time.Second)
indexSource := ExportIndexHTML()
SaveFile("./index.html", []byte(indexSource))
fmt.Println("Exported Statup index page: 'index.html'")
}
os.Exit(0)
}

View File

@ -189,6 +189,7 @@ func (c *DbConfig) Save() error {
[]PluginJSON{},
[]PluginSelect{},
nil,
false,
}
col := dbSession.Collection("core")