Documentation
¶
Overview ¶
SPDX-License-Identifier: GPL-3.0-or-later
Copyright (C) 2025 Aaron Mathis aaron.mathis@gmail.com
This file is part of GoSight.
GoSight is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
GoSight is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with GoSight. If not, see https://www.gnu.org/licenses/.
agent/internal/utils/cursor.go
Index ¶
- func ErrMsg(err error) string
- func GetHostname() string
- func Keys(m map[string]bool) []string
- func LoadCursor(path string) (string, error)
- func LoadTLSConfig(cfg *config.Config) (*tls.Config, error)
- func Metric(ns, sub, name string, value interface{}, typ, unit string, ...) model.Metric
- func SaveCursor(path, cursor string) error
- func ToFloat64(v interface{}) float64
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ErrMsg ¶
ErrMsg returns the error message if err is not nil, otherwise returns an empty string.
func GetHostname ¶
func GetHostname() string
GetHostname returns the system hostname, or "unknown" if it can't be determined.
func Keys ¶
Keys returns a slice of keys from the given map[string]bool. It iterates over the map and appends each key to a slice.
func LoadCursor ¶
LoadCursor reads the last saved journald cursor from a file. It returns an empty string and nil error if the file does not exist.
func LoadTLSConfig ¶
LoadTLSConfig loads the TLS configuration for the agent. It reads the CA certificate and client certificate/key from the specified paths. It returns a tls.Config object that can be used for secure communication.
func Metric ¶
func Metric(ns, sub, name string, value interface{}, typ, unit string, dims map[string]string, ts time.Time) model.Metric
Metric creates a new model.Metric instance with the provided parameters. It sets the namespace, sub-namespace, name, value, type, unit, dimensions, and timestamp for the metric. The value is converted to a float64 using the ToFloat64 function. The function returns the created model.Metric instance.
func SaveCursor ¶
SaveCursor writes the given journald cursor to a file.
Types ¶
This section is empty.