nmon2influxdblib

package
v2.1.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Jan 5, 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 PrintHTTPRequest

func PrintHTTPRequest(request *http.Request)

PrintHTTPRequest print raw http request for debugging purpose

func PrintHTTPResponse

func PrintHTTPResponse(response *http.Response)

PrintHTTPResponse print raw http response for debugging purpose

func PrintPrettyJSON

func PrintPrettyJSON(contents []byte)

PrintPrettyJSON helper used to display JSON output in a nicer way

func ReplaceComma

func ReplaceComma(s string) string

ReplaceComma replaces comma by html tabs tag

Types

type Config

type Config struct {
	Debug                bool
	Timezone             string
	InfluxdbUser         string
	InfluxdbPassword     string
	InfluxdbServer       string
	InfluxdbPort         string
	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

type File

type File struct {
	Name     string
	FileType string
	Host     string
	SSHUser  string
	SSHKey   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