Compare commits
No commits in common. "03b616622e7f511e40c7360d72e5ea4efe38f626" and "ea7124db5230f79e80af1a1856dd6efdb6f2597f" have entirely different histories.
03b616622e
...
ea7124db52
9 changed files with 33 additions and 96 deletions
|
@ -195,7 +195,6 @@ services:
|
||||||
glance:
|
glance:
|
||||||
container_name: glance
|
container_name: glance
|
||||||
image: glanceapp/glance
|
image: glanceapp/glance
|
||||||
restart: unless-stopped
|
|
||||||
volumes:
|
volumes:
|
||||||
- ./config:/app/config
|
- ./config:/app/config
|
||||||
ports:
|
ports:
|
||||||
|
|
|
@ -389,7 +389,6 @@ The following helper functions provided by Glance are available:
|
||||||
- `trimSuffix(suffix string, str string) string`: Trims the suffix from a string.
|
- `trimSuffix(suffix string, str string) string`: Trims the suffix from a string.
|
||||||
- `trimSpace(str string) string`: Trims whitespace from a string on both ends.
|
- `trimSpace(str string) string`: Trims whitespace from a string on both ends.
|
||||||
- `replaceAll(old string, new string, str string) string`: Replaces all occurrences of a string in a string.
|
- `replaceAll(old string, new string, str string) string`: Replaces all occurrences of a string in a string.
|
||||||
- `replaceMatches(pattern string, replacement string, str string) string`: Replaces all occurrences of a regular expression in a string.
|
|
||||||
- `findMatch(pattern string, str string) string`: Finds the first match of a regular expression in a string.
|
- `findMatch(pattern string, str string) string`: Finds the first match of a regular expression in a string.
|
||||||
- `findSubmatch(pattern string, str string) string`: Finds the first submatch of a regular expression in a string.
|
- `findSubmatch(pattern string, str string) string`: Finds the first submatch of a regular expression in a string.
|
||||||
- `sortByString(key string, order string, arr []JSON): []JSON`: Sorts an array of JSON objects by a string key in either ascending or descending order.
|
- `sortByString(key string, order string, arr []JSON): []JSON`: Sorts an array of JSON objects by a string key in either ascending or descending order.
|
||||||
|
@ -397,7 +396,6 @@ The following helper functions provided by Glance are available:
|
||||||
- `sortByFloat(key string, order string, arr []JSON): []JSON`: Sorts an array of JSON objects by a float key in either ascending or descending order.
|
- `sortByFloat(key string, order string, arr []JSON): []JSON`: Sorts an array of JSON objects by a float key in either ascending or descending order.
|
||||||
- `sortByTime(key string, layout string, order string, arr []JSON): []JSON`: Sorts an array of JSON objects by a time key in either ascending or descending order. The format must be provided in Go's [date format](https://pkg.go.dev/time#pkg-constants).
|
- `sortByTime(key string, layout string, order string, arr []JSON): []JSON`: Sorts an array of JSON objects by a time key in either ascending or descending order. The format must be provided in Go's [date format](https://pkg.go.dev/time#pkg-constants).
|
||||||
- `concat(strings ...string) string`: Concatenates multiple strings together.
|
- `concat(strings ...string) string`: Concatenates multiple strings together.
|
||||||
- `unique(key string, arr []JSON) []JSON`: Returns a unique array of JSON objects based on the given key.
|
|
||||||
|
|
||||||
The following helper functions provided by Go's `text/template` are available:
|
The following helper functions provided by Go's `text/template` are available:
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,6 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/shirou/gopsutil/v4/disk"
|
|
||||||
"github.com/shirou/gopsutil/v4/sensors"
|
"github.com/shirou/gopsutil/v4/sensors"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -19,13 +18,11 @@ const (
|
||||||
cliIntentConfigPrint
|
cliIntentConfigPrint
|
||||||
cliIntentDiagnose
|
cliIntentDiagnose
|
||||||
cliIntentSensorsPrint
|
cliIntentSensorsPrint
|
||||||
cliIntentMountpointInfo
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type cliOptions struct {
|
type cliOptions struct {
|
||||||
intent cliIntent
|
intent cliIntent
|
||||||
configPath string
|
configPath string
|
||||||
args []string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseCliOptions() (*cliOptions, error) {
|
func parseCliOptions() (*cliOptions, error) {
|
||||||
|
@ -49,7 +46,6 @@ func parseCliOptions() (*cliOptions, error) {
|
||||||
fmt.Println(" config:validate Validate the config file")
|
fmt.Println(" config:validate Validate the config file")
|
||||||
fmt.Println(" config:print Print the parsed config file with embedded includes")
|
fmt.Println(" config:print Print the parsed config file with embedded includes")
|
||||||
fmt.Println(" sensors:print List all sensors")
|
fmt.Println(" sensors:print List all sensors")
|
||||||
fmt.Println(" mountpoint:info Print information about a given mountpoint path")
|
|
||||||
fmt.Println(" diagnose Run diagnostic checks")
|
fmt.Println(" diagnose Run diagnostic checks")
|
||||||
}
|
}
|
||||||
configPath := flags.String("config", "glance.yml", "Set config path")
|
configPath := flags.String("config", "glance.yml", "Set config path")
|
||||||
|
@ -76,12 +72,6 @@ func parseCliOptions() (*cliOptions, error) {
|
||||||
} else {
|
} else {
|
||||||
return nil, unknownCommandErr
|
return nil, unknownCommandErr
|
||||||
}
|
}
|
||||||
} else if len(args) == 2 {
|
|
||||||
if args[0] == "mountpoint:info" {
|
|
||||||
intent = cliIntentMountpointInfo
|
|
||||||
} else {
|
|
||||||
return nil, unknownCommandErr
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
return nil, unknownCommandErr
|
return nil, unknownCommandErr
|
||||||
}
|
}
|
||||||
|
@ -89,7 +79,6 @@ func parseCliOptions() (*cliOptions, error) {
|
||||||
return &cliOptions{
|
return &cliOptions{
|
||||||
intent: intent,
|
intent: intent,
|
||||||
configPath: *configPath,
|
configPath: *configPath,
|
||||||
args: args,
|
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,23 +106,3 @@ func cliSensorsPrint() int {
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
func cliMountpointInfo(requestedPath string) int {
|
|
||||||
usage, err := disk.Usage(requestedPath)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Printf("Failed to retrieve info for path %s: %v\n", requestedPath, err)
|
|
||||||
if warns, ok := err.(*disk.Warnings); ok {
|
|
||||||
for _, w := range warns.List {
|
|
||||||
fmt.Printf(" - %v\n", w)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
|
|
||||||
fmt.Println("Path:", usage.Path)
|
|
||||||
fmt.Println("FS type:", ternary(usage.Fstype == "", "unknown", usage.Fstype))
|
|
||||||
fmt.Printf("Used percent: %.1f%%\n", usage.UsedPercent)
|
|
||||||
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
|
@ -51,8 +51,6 @@ func Main() int {
|
||||||
fmt.Println(string(contents))
|
fmt.Println(string(contents))
|
||||||
case cliIntentSensorsPrint:
|
case cliIntentSensorsPrint:
|
||||||
return cliSensorsPrint()
|
return cliSensorsPrint()
|
||||||
case cliIntentMountpointInfo:
|
|
||||||
return cliMountpointInfo(options.args[1])
|
|
||||||
case cliIntentDiagnose:
|
case cliIntentDiagnose:
|
||||||
runDiagnostic()
|
runDiagnostic()
|
||||||
}
|
}
|
||||||
|
|
|
@ -649,7 +649,7 @@ function setupTruncatedElementTitles() {
|
||||||
|
|
||||||
for (let i = 0; i < elements.length; i++) {
|
for (let i = 0; i < elements.length; i++) {
|
||||||
const element = elements[i];
|
const element = elements[i];
|
||||||
if (element.getAttribute("title") === null) element.title = element.textContent;
|
if (element.title === "") element.title = element.textContent;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2038,7 +2038,6 @@ details[open] .summary::after {
|
||||||
.color-primary { color: var(--color-primary); }
|
.color-primary { color: var(--color-primary); }
|
||||||
|
|
||||||
.cursor-help { cursor: help; }
|
.cursor-help { cursor: help; }
|
||||||
.rounded { border-radius: var(--border-radius); }
|
|
||||||
.break-all { word-break: break-all; }
|
.break-all { word-break: break-all; }
|
||||||
.text-left { text-align: left; }
|
.text-left { text-align: left; }
|
||||||
.text-right { text-align: right; }
|
.text-right { text-align: right; }
|
||||||
|
|
|
@ -468,15 +468,16 @@ var customAPITemplateFuncs = func() template.FuncMap {
|
||||||
return strings.TrimSuffix(s, suffix)
|
return strings.TrimSuffix(s, suffix)
|
||||||
},
|
},
|
||||||
"trimSpace": strings.TrimSpace,
|
"trimSpace": strings.TrimSpace,
|
||||||
"replaceAll": func(old, new, s string) string {
|
"replaceAll": func(oldOrPattern, new, s string) string {
|
||||||
return strings.ReplaceAll(s, old, new)
|
|
||||||
},
|
|
||||||
"replaceMatches": func(pattern, replacement, s string) string {
|
|
||||||
if s == "" {
|
if s == "" {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
return getCachedRegexp(pattern).ReplaceAllString(s, replacement)
|
regex := getCachedRegexp(oldOrPattern)
|
||||||
|
if regex == nil {
|
||||||
|
return strings.ReplaceAll(s, oldOrPattern, new)
|
||||||
|
}
|
||||||
|
return regex.ReplaceAllString(s, new)
|
||||||
},
|
},
|
||||||
"findMatch": func(pattern, s string) string {
|
"findMatch": func(pattern, s string) string {
|
||||||
if s == "" {
|
if s == "" {
|
||||||
|
@ -543,18 +544,6 @@ var customAPITemplateFuncs = func() template.FuncMap {
|
||||||
"concat": func(items ...string) string {
|
"concat": func(items ...string) string {
|
||||||
return strings.Join(items, "")
|
return strings.Join(items, "")
|
||||||
},
|
},
|
||||||
"unique": func(key string, results []decoratedGJSONResult) []decoratedGJSONResult {
|
|
||||||
seen := make(map[string]struct{})
|
|
||||||
out := make([]decoratedGJSONResult, 0, len(results))
|
|
||||||
for _, result := range results {
|
|
||||||
val := result.String(key)
|
|
||||||
if _, ok := seen[val]; !ok {
|
|
||||||
seen[val] = struct{}{}
|
|
||||||
out = append(out, result)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return out
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for key, value := range globalTemplateFunctions {
|
for key, value := range globalTemplateFunctions {
|
||||||
|
|
|
@ -182,8 +182,8 @@ func workerPoolDo[I any, O any](job *workerPoolJob[I, O]) ([]O, []error, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(job.data) == 1 {
|
if len(job.data) == 1 {
|
||||||
results[0], errs[0] = job.task(job.data[0])
|
output, err := job.task(job.data[0])
|
||||||
return results, errs, nil
|
return append(results, output), append(errs, err), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
tasksQueue := make(chan *workerPoolTask[I, O])
|
tasksQueue := make(chan *workerPoolTask[I, O])
|
||||||
|
|
|
@ -227,50 +227,35 @@ func Collect(req *SystemInfoRequest) (*SystemInfo, []error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
addedMountpoints := map[string]struct{}{}
|
filesystems, err := disk.Partitions(false)
|
||||||
addMountpointInfo := func(requestedPath string, mpReq MointpointRequest) {
|
if err == nil {
|
||||||
if _, exists := addedMountpoints[requestedPath]; exists {
|
for _, fs := range filesystems {
|
||||||
return
|
mpReq, ok := req.Mountpoints[fs.Mountpoint]
|
||||||
}
|
isHidden := req.HideMountpointsByDefault
|
||||||
|
if ok && mpReq.Hide != nil {
|
||||||
isHidden := req.HideMountpointsByDefault
|
isHidden = *mpReq.Hide
|
||||||
if mpReq.Hide != nil {
|
}
|
||||||
isHidden = *mpReq.Hide
|
if isHidden {
|
||||||
}
|
continue
|
||||||
if isHidden {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
usage, err := disk.Usage(requestedPath)
|
|
||||||
if err == nil {
|
|
||||||
mpInfo := MountpointInfo{
|
|
||||||
Path: requestedPath,
|
|
||||||
Name: mpReq.Name,
|
|
||||||
TotalMB: usage.Total / 1024 / 1024,
|
|
||||||
UsedMB: usage.Used / 1024 / 1024,
|
|
||||||
UsedPercent: uint8(math.Min(usage.UsedPercent, 100)),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
info.Mountpoints = append(info.Mountpoints, mpInfo)
|
usage, err := disk.Usage(fs.Mountpoint)
|
||||||
addedMountpoints[requestedPath] = struct{}{}
|
if err == nil {
|
||||||
} else {
|
mpInfo := MountpointInfo{
|
||||||
addErr(fmt.Errorf("getting filesystem usage for %s: %v", requestedPath, err))
|
Path: fs.Mountpoint,
|
||||||
}
|
Name: mpReq.Name,
|
||||||
}
|
TotalMB: usage.Total / 1024 / 1024,
|
||||||
|
UsedMB: usage.Used / 1024 / 1024,
|
||||||
|
UsedPercent: uint8(math.Min(usage.UsedPercent, 100)),
|
||||||
|
}
|
||||||
|
|
||||||
if !req.HideMountpointsByDefault {
|
info.Mountpoints = append(info.Mountpoints, mpInfo)
|
||||||
filesystems, err := disk.Partitions(false)
|
} else {
|
||||||
if err == nil {
|
addErr(fmt.Errorf("getting filesystem usage for %s: %v", fs.Mountpoint, err))
|
||||||
for _, fs := range filesystems {
|
|
||||||
addMountpointInfo(fs.Mountpoint, req.Mountpoints[fs.Mountpoint])
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
addErr(fmt.Errorf("getting filesystems: %v", err))
|
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
|
addErr(fmt.Errorf("getting filesystems: %v", err))
|
||||||
for mountpoint, mpReq := range req.Mountpoints {
|
|
||||||
addMountpointInfo(mountpoint, mpReq)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sort.Slice(info.Mountpoints, func(a, b int) bool {
|
sort.Slice(info.Mountpoints, func(a, b int) bool {
|
||||||
|
|
Loading…
Add table
Reference in a new issue