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 /icingabeat.test
*.pyc *.pyc
logs/ logs/
icingabeat.test.yml

View File

@ -19,19 +19,26 @@ icingabeat:
# Defines how fast to reconnect to the API after a connection loss # Defines how fast to reconnect to the API after a connection loss
retry_interval: 10s retry_interval: 10s
# Decide which events to receive from the event stream. # Icingabeat supports capturing of an evenstream and periodical polling of the
# The following event stream types are available, at least one must be set: # Icinga status data.
# * CheckResult #
# * StateChange # To disable the eventstream, comment out the whole section
# * Notification eventstream:
# * AcknowledgementSet # Decide which events to receive from the event stream.
# * AcknowledgementCleared # The following event stream types are available:
# * CommentAdded # * CheckResult
# * CommentRemoved # * StateChange
# * DowntimeAdded # * Notification
# * DowntimeRemoved # * AcknowledgementSet
# * DowntimeStarted # * AcknowledgementCleared
# * DowntimeTriggered # * CommentAdded
event_types: # * CommentRemoved
- CheckResult # * DowntimeAdded
- StateChange # * 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 // Run evenstream receiver
func (es *Eventstream) Run() error { 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 { for {
ticker := time.NewTicker(es.config.RetryInterval) ticker := time.NewTicker(es.config.RetryInterval)

View File

@ -18,7 +18,11 @@ func requestURL(bt *Icingabeat, method, path string) (*http.Response, error) {
Transport: transport, 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) request, err := http.NewRequest(method, url, nil)
if err != nil { if err != nil {

View File

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

View File

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

View File

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

View File

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