agentutils

package
v0.0.0-...-19a4618 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 6, 2025 License: GPL-3.0 Imports: 10 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrMsg

func ErrMsg(err error) string

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

func Keys(m map[string]bool) []string

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

func LoadCursor(path string) (string, error)

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

func LoadTLSConfig(cfg *config.Config) (*tls.Config, error)

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

func SaveCursor(path, cursor string) error

SaveCursor writes the given journald cursor to a file.

func ToFloat64

func ToFloat64(v interface{}) float64

ToFloat64 converts a given value to float64. It handles various numeric types such as float64, int, uint64, uint32, int64, and int32. If the value is of an unknown type, it logs a warning and returns 0.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL