Compare commits
5 Commits
35b475e46f
...
63956de837
Author | SHA1 | Date | |
---|---|---|---|
|
63956de837 | ||
|
e4dbabfea5 | ||
|
7724c742ad | ||
|
ff1c848c58 | ||
|
787009c621 |
@ -117,6 +117,8 @@ func DatapointAdd[T any](name string, value T) (err error) { // {{{
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
service.Db.Conn.Exec(`UPDATE datapoint SET last_value = NOW() WHERE name=$1`, name)
|
||||||
|
|
||||||
return
|
return
|
||||||
} // }}}
|
} // }}}
|
||||||
|
|
||||||
|
9
main.go
9
main.go
@ -26,12 +26,13 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
const VERSION = "v7"
|
const VERSION = "v9"
|
||||||
|
|
||||||
var (
|
var (
|
||||||
logger *slog.Logger
|
logger *slog.Logger
|
||||||
flagConfigFile string
|
flagConfigFile string
|
||||||
flagDev bool
|
flagDev bool
|
||||||
|
flagVersion bool
|
||||||
service *ws.Service
|
service *ws.Service
|
||||||
logFile *os.File
|
logFile *os.File
|
||||||
parsedTemplates map[string]*template.Template
|
parsedTemplates map[string]*template.Template
|
||||||
@ -59,6 +60,7 @@ func init() { // {{{
|
|||||||
cfgPath := path.Join(confDir, "smon.yaml")
|
cfgPath := path.Join(confDir, "smon.yaml")
|
||||||
flag.StringVar(&flagConfigFile, "config", cfgPath, "Path and filename of the YAML configuration file")
|
flag.StringVar(&flagConfigFile, "config", cfgPath, "Path and filename of the YAML configuration file")
|
||||||
flag.BoolVar(&flagDev, "dev", false, "reload templates on each request")
|
flag.BoolVar(&flagDev, "dev", false, "reload templates on each request")
|
||||||
|
flag.BoolVar(&flagVersion, "version", false, "Display version and exit")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
componentFilenames, err = getComponentFilenames(viewFS)
|
componentFilenames, err = getComponentFilenames(viewFS)
|
||||||
@ -70,6 +72,11 @@ func init() { // {{{
|
|||||||
} // }}}
|
} // }}}
|
||||||
|
|
||||||
func main() { // {{{
|
func main() { // {{{
|
||||||
|
if flagVersion {
|
||||||
|
fmt.Println(VERSION)
|
||||||
|
os.Exit(0)
|
||||||
|
}
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
werr.Init()
|
werr.Init()
|
||||||
|
@ -1,6 +1,2 @@
|
|||||||
{{ define "fonts" }}
|
{{ define "fonts" }}
|
||||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
||||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
||||||
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;500&display=swap" rel="stylesheet">
|
|
||||||
<link href="https://fonts.googleapis.com/css2?family=Roboto+Mono:ital,wght@0,100..700;1,100..700&display=swap" rel="stylesheet">
|
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
@ -5,6 +5,18 @@
|
|||||||
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
|
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
|
||||||
{{ template "fonts" }}
|
{{ template "fonts" }}
|
||||||
<link rel="stylesheet" type="text/css" href="/css/{{ .VERSION }}/main.css">
|
<link rel="stylesheet" type="text/css" href="/css/{{ .VERSION }}/main.css">
|
||||||
|
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/chart.js@4.2.1/dist/chart.umd.min.js"></script>
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/luxon@3.3.0/build/global/luxon.min.js"></script>
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/chartjs-adapter-luxon@1.3.1"></script>
|
||||||
|
|
||||||
|
<script type="importmap">
|
||||||
|
{
|
||||||
|
"imports": {
|
||||||
|
"chart.js": "/js/{{ .VERSION }}/lib/chartjs/index.d.ts"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="layout">
|
<div id="layout">
|
||||||
|
@ -2,8 +2,19 @@
|
|||||||
{{ $version := .VERSION }}
|
{{ $version := .VERSION }}
|
||||||
<link rel="stylesheet" type="text/css" href="/css/{{ .VERSION }}/datapoints.css">
|
<link rel="stylesheet" type="text/css" href="/css/{{ .VERSION }}/datapoints.css">
|
||||||
|
|
||||||
|
<script type="module" defer>
|
||||||
|
import { DataGraph } from "/js/{{ .VERSION }}/datapoint_graph.mjs"
|
||||||
|
const graph = new DataGraph({{ .Data.Datapoint }})
|
||||||
|
graph.setData({{ .Data.Values }})
|
||||||
|
graph.render('chart')
|
||||||
|
</script>
|
||||||
|
|
||||||
{{ block "page_label" . }}{{end}}
|
{{ block "page_label" . }}{{end}}
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<canvas id="chart"></canvas>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div id="values">
|
<div id="values">
|
||||||
{{ range .Data.Values }}
|
{{ range .Data.Values }}
|
||||||
<div class="value">{{ format_time .Ts }}</div>
|
<div class="value">{{ format_time .Ts }}</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user