nmon2influxdblib

package
v2.1.6+incompatible Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2017 License: AGPL-3.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckError

func CheckError(e error)

CheckError check error message and display it

func CheckInfo

func CheckInfo(e error)

CheckInfo wrap info message

func GetCfgFile

func GetCfgFile() string

GetCfgFile returns the current configuration file path

func GetPrettyJSON

func GetPrettyJSON(contents []byte) bytes.Buffer

GetPrettyJSON returns pretty json string

func InitSFTP

func InitSFTP(sshUser string, host string, key string) *sftp.Client

InitSFTP init sftp session

func IsFile

func IsFile(file string) bool

IsFile returns true if the file doesn't exist

func ReplaceComma

func ReplaceComma(s string) string

ReplaceComma replaces comma by html tabs tag

func SPrintHTTPRequest

func SPrintHTTPRequest(request *http.Request) string

SPrintHTTPRequest print raw http request for debugging purpose

func SPrintHTTPResponse

func SPrintHTTPResponse(response *http.Response) string

SPrintHTTPResponse print raw http response for debugging purpose

func SPrintPrettyJSON

func SPrintPrettyJSON(contents []byte) string

SPrintPrettyJSON helper used to display JSON output in a nicer way

Types

type Config

type Config struct {
	Debug                 bool
	DebugFile             string
	Timezone              string
	InfluxdbUser          string
	InfluxdbPassword      string
	InfluxdbServer        string
	InfluxdbPort          string
	InfluxdbSecure        bool
	InfluxdbSkipCertCheck bool
	InfluxdbDatabase      string
	GrafanaUser           string
	GrafanaPassword       string
	GrafanaURL            string `toml:"grafana_URL"`
	GrafanaAccess         string
	GrafanaDatasource     string
	HMCServer             string `toml:"hmc_server"`
	HMCUser               string `toml:"hmc_user"`
	HMCPassword           string `toml:"hmc_password"`
	HMCDatabase           string `toml:"hmc_database"`
	HMCDataRetention      string `toml:"hmc_data_retention"`
	HMCManagedSystem      string `toml:"hmc_managed_system"`
	HMCManagedSystemOnly  bool   `toml:"hmc_managed_system_only"`
	HMCSamples            int    `toml:"hmc_samples"`
	ImportSkipDisks       bool
	ImportAllCpus         bool
	ImportBuildDashboard  bool
	ImportForce           bool
	ImportSkipMetrics     string
	ImportLogDatabase     string
	ImportLogRetention    string
	ImportDataRetention   string
	ImportSSHUser         string `toml:"import_ssh_user"`
	ImportSSHKey          string `toml:"import_ssh_key"`
	DashboardWriteFile    bool
	StatsLimit            int
	StatsSort             string
	StatsFilter           string
	StatsFrom             string
	StatsTo               string
	StatsHost             string
	Metric                string `toml:"metric,omitempty"`
	ListFilter            string `toml:",omitempty"`
	ListHost              string `toml:",omitempty"`
	Inputs                Inputs `toml:"input"`
}

Config is the configuration structure used by nmon2influxdb

func InitConfig

func InitConfig() Config

InitConfig setup initial configuration with sane values

func ParseParameters

func ParseParameters(c *cli.Context) (config *Config)

ParseParameters parse parameter from command line in Config struct

func (*Config) AddDashboardParams

func (config *Config) AddDashboardParams()

AddDashboardParams initialize default parameters for dashboard

func (*Config) BuildCfgFile

func (config *Config) BuildCfgFile(cfgfile string)

BuildCfgFile creates a default configuration file

func (*Config) ConnectDB

func (config *Config) ConnectDB(db string) *influxdbclient.InfluxDB

ConnectDB connect to the specified influxdb database

func (*Config) GetDB

func (config *Config) GetDB(dbType string) *influxdbclient.InfluxDB

GetDB create or get the influxdb database used for nmon data

func (*Config) GetLogDB

func (config *Config) GetLogDB() *influxdbclient.InfluxDB

GetLogDB create or get the influxdb database like defined in config

func (*Config) LoadCfgFile

func (config *Config) LoadCfgFile() (cfgfile string)

LoadCfgFile loads current configuration file settings

func (*Config) Sanitized

func (config *Config) Sanitized() (debugConfig Config)

Sanitized returns a copy of the config struct without the password. Used for debug

type File

type File struct {
	Name     string
	FileType string
	Host     string
	SSHUser  string
	SSHKey   string

	Delimiter string
	// contains filtered or unexported fields
}

File structure used to select nmon files to import

func (*File) Checksum

func (nmonFile *File) Checksum() (fileHash string)

Checksum generates SHA1 file checksum

func (*File) Content

func (nmonFile *File) Content() []string

Content returns the nmon files content sorted in an slice of string format

func (*File) GetRemoteScanner

func (nmonFile *File) GetRemoteScanner() (*RemoteFileScanner, error)

GetRemoteScanner open an nmon file based on file extension and provides a bufio Scanner

func (*File) GetScanner

func (nmonFile *File) GetScanner() (*FileScanner, error)

GetScanner open an nmon file based on file extension and provides a bufio Scanner

type FileScanner

type FileScanner struct {
	*os.File
	*bufio.Scanner
}

FileScanner struct to manage

type Files

type Files []File

Files array of File

func (*Files) Add

func (nmonFiles *Files) Add(file string, fileType string)

Add a file in the NmonFIles structure

func (*Files) AddRemote

func (nmonFiles *Files) AddRemote(file string, fileType string, host string, user string, key string)

AddRemote a remote file in the NmonFIles structure

func (*Files) Parse

func (nmonFiles *Files) Parse(args []string, sshUser string, key string)

Parse parameters

func (*Files) Valid

func (nmonFiles *Files) Valid() (validFiles Files)

Valid returns only valid fiels for nmon import

type Input

type Input struct {
	Measurement string
	Name        string
	Match       string
	Tags        Tags `toml:"tag"`
}

Input specify how to apply new filters

type Inputs

type Inputs []Input

Inputs allows to put multiple input in the configuration file

type RemoteFileScanner

type RemoteFileScanner struct {
	*sftp.File
	*bufio.Scanner
}

RemoteFileScanner struct for remote files

type SSHConfig

type SSHConfig struct {
	User string
	Key  string
}

SSHConfig contains SSH parameters

type Tag

type Tag struct {
	Name   string
	Value  string
	Regexp *regexp.Regexp `toml:",skip"`
}

Tag is a struct to store additional tags

type TagParsers

type TagParsers map[string]map[string]Tags

TagParsers access struct : TagParsers[mesurement][tag name]

func ParseInputs

func ParseInputs(inputs Inputs) TagParsers

ParseInputs process user inputs and compile regular expressions

type Tags

type Tags []Tag

Tags array

Jump to

Keyboard shortcuts

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