Update config format

This commit is contained in:
Blerim Sheqa 2016-12-30 14:44:23 +01:00
parent 18b5d87dc6
commit ae66968b98
8 changed files with 93 additions and 60 deletions

2
.gitignore vendored
View File

@ -6,3 +6,5 @@
/icingabeat.test
*.pyc
logs/
icingabeat.test.yml

View File

@ -19,19 +19,26 @@ icingabeat:
# Defines how fast to reconnect to the API after a connection loss
retry_interval: 10s
# Decide which events to receive from the event stream.
# The following event stream types are available, at least one must be set:
# * CheckResult
# * StateChange
# * Notification
# * AcknowledgementSet
# * AcknowledgementCleared
# * CommentAdded
# * CommentRemoved
# * DowntimeAdded
# * DowntimeRemoved
# * DowntimeStarted
# * DowntimeTriggered
event_types:
- CheckResult
- StateChange
# Icingabeat supports capturing of an evenstream and periodical polling of the
# Icinga status data.
#
# To disable the eventstream, comment out the whole section
eventstream:
# Decide which events to receive from the event stream.
# The following event stream types are available:
# * CheckResult
# * StateChange
# * Notification
# * AcknowledgementSet
# * AcknowledgementCleared
# * CommentAdded
# * CommentRemoved
# * DowntimeAdded
# * DowntimeRemoved
# * DowntimeStarted
# * DowntimeTriggered
#
# At least one type must be set
types:
- CheckResult
- StateChange

View File

@ -36,8 +36,8 @@ func NewEventstream(bt *Icingabeat, cfg config.Config) *Eventstream {
// Run evenstream receiver
func (es *Eventstream) Run() error {
types := strings.Join(es.icingabeat.config.EventTypes, "&types=")
types := strings.Join(es.config.Eventstream.Types, "&types=")
logp.Info(types)
for {
ticker := time.NewTicker(es.config.RetryInterval)

View File

@ -18,7 +18,11 @@ func requestURL(bt *Icingabeat, method, path string) (*http.Response, error) {
Transport: transport,
}
url := fmt.Sprintf("https://%s:%v%s", bt.config.Host, bt.config.Port, path)
url := fmt.Sprintf(
"https://%s:%v%s",
bt.config.Host,
bt.config.Port,
path)
request, err := http.NewRequest(method, url, nil)
if err != nil {

View File

@ -40,6 +40,7 @@ func (bt *Icingabeat) Run(b *beat.Beat) error {
bt.client = b.Publisher.Connect()
eventstream = NewEventstream(bt, bt.config)
logp.Info("hostname: %v", bt.config.Host)
go eventstream.Run()
for {

View File

@ -7,12 +7,17 @@ import "time"
// Config options
type Config struct {
Host string `config:"host"`
Port int `config:"port"`
User string `config:"user"`
Password string `config:"password"`
RetryInterval time.Duration `config:"retry_interval"`
EventTypes []string `config:"event_types"`
Host string `config:"host"`
Port int `config:"port"`
User string `config:"user"`
Password string `config:"password"`
RetryInterval time.Duration `config:"retry_interval"`
Eventstream EventstreamConfig `config:"eventstream"`
}
// EventstreamConfig optoins
type EventstreamConfig struct {
Types []string `config:"types"`
}
// DefaultConfig values

View File

@ -19,22 +19,29 @@ icingabeat:
# Defines how fast to reconnect to the API after a connection loss
retry_interval: 10s
# Decide which events to receive from the event stream.
# The following event stream types are available, at least one must be set:
# * CheckResult
# * StateChange
# * Notification
# * AcknowledgementSet
# * AcknowledgementCleared
# * CommentAdded
# * CommentRemoved
# * DowntimeAdded
# * DowntimeRemoved
# * DowntimeStarted
# * DowntimeTriggered
event_types:
- CheckResult
- StateChange
# Icingabeat supports capturing of an evenstream and periodical polling of the
# Icinga status data.
#
# To disable the eventstream, comment out the whole section
eventstream:
# Decide which events to receive from the event stream.
# The following event stream types are available:
# * CheckResult
# * StateChange
# * Notification
# * AcknowledgementSet
# * AcknowledgementCleared
# * CommentAdded
# * CommentRemoved
# * DowntimeAdded
# * DowntimeRemoved
# * DowntimeStarted
# * DowntimeTriggered
#
# At least one type must be set
types:
- CheckResult
- StateChange
#================================ General ======================================

View File

@ -5,13 +5,13 @@
icingabeat:
# Defines the Icina API endpoint
host: "demo"
host: "localhost"
# Defines the port of the API endpoint
port: 5665
# A user with sufficient permissions
user: "rooto"
user: "icinga"
# Password of the user
password: "icinga"
@ -19,22 +19,29 @@ icingabeat:
# Defines how fast to reconnect to the API after a connection loss
retry_interval: 10s
# Decide which events to receive from the event stream.
# The following event stream types are available, at least one must be set:
# * CheckResult
# * StateChange
# * Notification
# * AcknowledgementSet
# * AcknowledgementCleared
# * CommentAdded
# * CommentRemoved
# * DowntimeAdded
# * DowntimeRemoved
# * DowntimeStarted
# * DowntimeTriggered
event_types:
- CheckResult
- StateChange
# Icingabeat supports capturing of an evenstream and periodical polling of the
# Icinga status data.
#
# To disable the eventstream, comment out the whole section
eventstream:
# Decide which events to receive from the event stream.
# The following event stream types are available:
# * CheckResult
# * StateChange
# * Notification
# * AcknowledgementSet
# * AcknowledgementCleared
# * CommentAdded
# * CommentRemoved
# * DowntimeAdded
# * DowntimeRemoved
# * DowntimeStarted
# * DowntimeTriggered
#
# At least one type must be set
types:
- CheckResult
- StateChange
#================================ General =====================================
@ -59,7 +66,7 @@ icingabeat:
#-------------------------- Elasticsearch output ------------------------------
output.elasticsearch:
# Array of hosts to connect to.
hosts: ["demo:9200"]
hosts: ["localhost:9200"]
# Optional protocol and basic auth credentials.
#protocol: "https"