small reorg, some improvements, readme updates
- fix hemtt config to copy example
- add measurements table in Readme
- ENTITY COUNTS
- re add side tags
- use `side group _x` for units and players
- fix players_connected and add headless_clients
- get `_allUserInfos = allUsers apply {getUserInfo _x} select {count _x > 0};` from main loop and use in entity counts and player performance
This commit is contained in:
80
extension/IFXMetrics/internal/settings/settings.go
Normal file
80
extension/IFXMetrics/internal/settings/settings.go
Normal file
@@ -0,0 +1,80 @@
|
||||
package settings
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/indig0fox/a3go/a3interface"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
type CBAEventHandlerSetting struct {
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
Enabled bool `json:"enabled"`
|
||||
Bucket string `json:"bucket"`
|
||||
Measurement string `json:"measurement"`
|
||||
}
|
||||
|
||||
var Active *viper.Viper
|
||||
|
||||
func init() {
|
||||
Active = viper.New()
|
||||
}
|
||||
|
||||
func Setup(
|
||||
addonFolder string,
|
||||
) error {
|
||||
Active.SetConfigName("ifxmetrics.config")
|
||||
Active.SetConfigType("json")
|
||||
Active.AddConfigPath(addonFolder)
|
||||
|
||||
armaDir, err := os.Getwd()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
Active.AddConfigPath(armaDir)
|
||||
|
||||
Active.SetDefault("influxdb", map[string]interface{}{
|
||||
"enabled": false,
|
||||
"host": "http://localhost:8086",
|
||||
"token": "",
|
||||
"org": "",
|
||||
})
|
||||
|
||||
Active.SetDefault("arma3", map[string]interface{}{
|
||||
"refreshRateMs": 2000,
|
||||
"debug": "true",
|
||||
})
|
||||
|
||||
Active.SetDefault("cbaEventHandlers", []map[string]interface{}{})
|
||||
|
||||
if err := Active.ReadInConfig(); err != nil {
|
||||
if _, ok := err.(viper.ConfigFileNotFoundError); ok {
|
||||
// Config file not found; ignore error if desired
|
||||
a3interface.WriteArmaCallback(
|
||||
"ifxmetrics",
|
||||
":LOG:",
|
||||
"WARN",
|
||||
"Config file not found; using default values.",
|
||||
)
|
||||
return nil
|
||||
} else {
|
||||
// Config file was found but another error was produced
|
||||
a3interface.WriteArmaCallback(
|
||||
"ifxmetrics",
|
||||
":LOG:",
|
||||
"ERROR",
|
||||
err.Error(),
|
||||
)
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
a3interface.WriteArmaCallback(
|
||||
"ifxmetrics",
|
||||
":LOG:",
|
||||
"INFO",
|
||||
"Config file found; using values from config file.",
|
||||
)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user