mirror of https://github.com/statping/statping
updates - prometheus exporter /metrics
parent
c9dd23b36e
commit
ed96092530
|
@ -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.
|
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.
|
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
|
## Run on Docker
|
||||||
Use the [Statup Docker Image](https://hub.docker.com/r/hunterlong/statup) to create a status page in seconds.
|
Use the [Statup Docker Image](https://hub.docker.com/r/hunterlong/statup) to create a status page in seconds.
|
||||||
```bash
|
```bash
|
||||||
|
|
1
core.go
1
core.go
|
@ -20,6 +20,7 @@ type Core struct {
|
||||||
Repos []PluginJSON
|
Repos []PluginJSON
|
||||||
PluginFields []PluginSelect
|
PluginFields []PluginSelect
|
||||||
Communications []*types.Communication
|
Communications []*types.Communication
|
||||||
|
OfflineAssets bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Core) Update() (*Core, error) {
|
func (c *Core) Update() (*Core, error) {
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -4,12 +4,14 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"html/template"
|
"html/template"
|
||||||
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
)
|
)
|
||||||
|
|
||||||
var httpFunctions template.FuncMap
|
var httpFunctions template.FuncMap
|
||||||
|
|
||||||
func ExportIndexHTML() string {
|
func ExportIndexHTML() string {
|
||||||
|
core.OfflineAssets = true
|
||||||
out := index{*core, services}
|
out := index{*core, services}
|
||||||
nav, _ := tmplBox.String("nav.html")
|
nav, _ := tmplBox.String("nav.html")
|
||||||
footer, _ := tmplBox.String("footer.html")
|
footer, _ := tmplBox.String("footer.html")
|
||||||
|
@ -45,3 +47,8 @@ func ExportIndexHTML() string {
|
||||||
fmt.Println(result)
|
fmt.Println(result)
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func SaveFile(filename string, data []byte) error {
|
||||||
|
err := ioutil.WriteFile(filename, data, 0644)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
|
@ -4,10 +4,15 @@
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||||
|
|
||||||
<link rel="stylesheet" href="/css/bootstrap.min.css">
|
{{if .Core.OfflineAssets}}
|
||||||
<link rel="stylesheet" href="/css/base.css">
|
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
|
||||||
<script src="/js/Chart.bundle.min.js"></script>
|
<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>
|
<title>{{.Core.Name}} Status</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
@ -163,7 +168,14 @@ var chartdata = new Chart(ctx, {
|
||||||
</style>
|
</style>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
<script src="/js/jquery-3.3.1.slim.min.js"></script>
|
|
||||||
<script src="/js/bootstrap.min.js"></script>
|
{{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>
|
</body>
|
||||||
</html>
|
</html>
|
47
main.go
47
main.go
|
@ -15,6 +15,7 @@ import (
|
||||||
plg "plugin"
|
plg "plugin"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -91,42 +92,26 @@ func DownloadFile(filepath string, url string) error {
|
||||||
return nil
|
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() {
|
func main() {
|
||||||
if len(os.Args) >= 2 {
|
if len(os.Args) >= 2 {
|
||||||
if os.Args[1] == "version" {
|
if os.Args[1] == "version" {
|
||||||
fmt.Printf("Statup v%v\n", 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)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue