mirror of
https://github.com/kubernetes/node-problem-detector.git
synced 2026-08-19 12:16:26 +00:00
add custom problem detector plugin
This commit is contained in:
@@ -27,9 +27,11 @@ import (
|
||||
"github.com/spf13/pflag"
|
||||
|
||||
"k8s.io/node-problem-detector/cmd/options"
|
||||
"k8s.io/node-problem-detector/pkg/custompluginmonitor"
|
||||
"k8s.io/node-problem-detector/pkg/problemclient"
|
||||
"k8s.io/node-problem-detector/pkg/problemdetector"
|
||||
"k8s.io/node-problem-detector/pkg/systemlogmonitor"
|
||||
"k8s.io/node-problem-detector/pkg/types"
|
||||
"k8s.io/node-problem-detector/pkg/version"
|
||||
)
|
||||
|
||||
@@ -67,15 +69,24 @@ func main() {
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
monitors := make(map[string]systemlogmonitor.LogMonitor)
|
||||
monitors := make(map[string]types.Monitor)
|
||||
for _, config := range npdo.SystemLogMonitorConfigPaths {
|
||||
if _, ok := monitors[config]; ok {
|
||||
// Skip the config if it's duplictaed.
|
||||
glog.Warningf("Duplicated log monitor configuration %q", config)
|
||||
// Skip the config if it's duplicated.
|
||||
glog.Warningf("Duplicated monitor configuration %q", config)
|
||||
continue
|
||||
}
|
||||
monitors[config] = systemlogmonitor.NewLogMonitorOrDie(config)
|
||||
}
|
||||
|
||||
for _, config := range npdo.CustomPluginMonitorConfigPaths {
|
||||
if _, ok := monitors[config]; ok {
|
||||
// Skip the config if it's duplicated.
|
||||
glog.Warningf("Duplicated monitor configuration %q", config)
|
||||
continue
|
||||
}
|
||||
monitors[config] = custompluginmonitor.NewCustomPluginMonitorOrDie(config)
|
||||
}
|
||||
c := problemclient.NewClientOrDie(npdo)
|
||||
p := problemdetector.NewProblemDetector(monitors, c)
|
||||
|
||||
|
||||
@@ -33,6 +33,9 @@ type NodeProblemDetectorOptions struct {
|
||||
// SystemLogMonitorConfigPaths specifies the list of paths to system log monitor configuration
|
||||
// files.
|
||||
SystemLogMonitorConfigPaths []string
|
||||
// CustomPluginMonitorConfigPaths specifies the list of paths to custom plugin monitor configuration
|
||||
// files.
|
||||
CustomPluginMonitorConfigPaths []string
|
||||
// ApiServerOverride is the custom URI used to connect to Kubernetes ApiServer.
|
||||
ApiServerOverride string
|
||||
// PrintVersion is the flag determining whether version information is printed.
|
||||
@@ -58,6 +61,8 @@ func NewNodeProblemDetectorOptions() *NodeProblemDetectorOptions {
|
||||
func (npdo *NodeProblemDetectorOptions) AddFlags(fs *pflag.FlagSet) {
|
||||
fs.StringSliceVar(&npdo.SystemLogMonitorConfigPaths, "system-log-monitors",
|
||||
[]string{}, "List of paths to system log monitor config files, comma separated.")
|
||||
fs.StringSliceVar(&npdo.CustomPluginMonitorConfigPaths, "custom-plugin-monitors",
|
||||
[]string{}, "List of paths to custom plugin monitor config files, comma separated.")
|
||||
fs.StringVar(&npdo.ApiServerOverride, "apiserver-override",
|
||||
"", "Custom URI used to connect to Kubernetes ApiServer")
|
||||
fs.BoolVar(&npdo.PrintVersion, "version", false, "Print version information and quit")
|
||||
|
||||
Reference in New Issue
Block a user