kernelmonitor

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2016 License: Apache-2.0 Imports: 14 Imported by: 0

README

Kernel Monitor

Kernel Monitor is a problem daemon in node problem detector. It monitors kernel log and detects known kernel issues following predefined rules.

The Kernel Monitor matches kernel issues according to a set of predefined rule list in config/kernel-monitor.json. The rule list is extensible.

Limitations

  • Kernel Monitor only supports file based kernel log now. It doesn't support log tools like journald. There is an open issue to add journald support.

  • Kernel Monitor has assumption on kernel log format, now it only works on Ubuntu and Debian. However, it is easy to extend it to support other log format.

Add New NodeConditions

To support new node conditions, you can extend the conditions field in config/kernel-monitor.json with new condition definition:

{
  "type": "NodeConditionType",
  "reason": "CamelCaseDefaultNodeConditionReason",
  "message": "arbitrary default node condition message"
}

Detect New Problems

To detect new problems, you can extend the rules field in config/kernel-monitor.json with new rule definition:

{
  "type": "temporary/permanent",
  "condition": "NodeConditionOfPermanentIssue",
  "reason": "CamelCaseShortReason",
  "message": "regexp matching the issue in the kernel log"
}

Change Log Path

Kernel log in different OS distros may locate in different path. The log field in config/kernel-monitor.json is the log path inside the container. You can always configure it to match your OS distro.

Support Other Log Format

Kernel monitor uses Translator plugin to translate kernel log the internal data structure. It is easy to implement a new translator for a new log format.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewLogBuffer

func NewLogBuffer(maxLines int) *logBuffer

NewLogBuffer creates log buffer with max line number limit. Because we only match logs in the log buffer, the max buffer line number is also the max pattern line number we support. Smaller buffer line number means less memory and cpu usage, but also means less lines of patterns we support.

Types

type KernelLogWatcher

type KernelLogWatcher interface {
	// Watch starts the kernel log watcher and returns a watch channel.
	Watch() (<-chan *types.KernelLog, error)
	// Stop stops the kernel log watcher.
	Stop()
}

KernelLogWatcher watches and translates the kernel log. Once there is new log line, it will translate and report the log.

func NewKernelLogWatcher

func NewKernelLogWatcher(cfg WatcherConfig) KernelLogWatcher

NewKernelLogWatcher creates a new kernel log watcher.

type KernelMonitor

type KernelMonitor interface {
	// Start starts the kernel monitor.
	Start() (<-chan *types.Status, error)
	// Stop stops the kernel monitor.
	Stop()
}

KernelMonitor monitors the kernel log and reports node problem condition and event according to the rules.

func NewKernelMonitorOrDie

func NewKernelMonitorOrDie(configPath string) KernelMonitor

NewKernelMonitorOrDie create a new KernelMonitor, panic if error occurs.

type LogBuffer

type LogBuffer interface {
	// Push pushes log into the log buffer.
	Push(*types.KernelLog)
	// Match with regular expression in the log buffer.
	Match(string) []*types.KernelLog
	// String returns a concatenated string of the buffered logs.
	String() string
}

LogBuffer buffers the logs and supports match in the log buffer with regular expression.

type MonitorConfig

type MonitorConfig struct {
	// WatcherConfig is the configuration of kernel log watcher.
	WatcherConfig
	// BufferSize is the size (in lines) of the log buffer.
	BufferSize int `json:"bufferSize"`
	// Source is the source name of the kernel monitor
	Source string `json:"source"`
	// DefaultConditions are the default states of all the conditions kernel monitor should handle.
	DefaultConditions []types.Condition `json:"conditions"`
	// Rules are the rules kernel monitor will follow to parse the log file.
	Rules []kerntypes.Rule `json:"rules"`
}

MonitorConfig is the configuration of kernel monitor.

type WatcherConfig

type WatcherConfig struct {
	KernelLogPath string `json:"logPath, omitempty"`
}

WatcherConfig is the configuration of kernel log watcher.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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