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,8 +19,13 @@ 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
# 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. # Decide which events to receive from the event stream.
# The following event stream types are available, at least one must be set: # The following event stream types are available:
# * CheckResult # * CheckResult
# * StateChange # * StateChange
# * Notification # * Notification
@ -32,6 +37,8 @@ icingabeat:
# * DowntimeRemoved # * DowntimeRemoved
# * DowntimeStarted # * DowntimeStarted
# * DowntimeTriggered # * DowntimeTriggered
event_types: #
# At least one type must be set
types:
- CheckResult - CheckResult
- StateChange - 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

@ -12,7 +12,12 @@ type Config struct {
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,8 +19,13 @@ 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
# 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. # Decide which events to receive from the event stream.
# The following event stream types are available, at least one must be set: # The following event stream types are available:
# * CheckResult # * CheckResult
# * StateChange # * StateChange
# * Notification # * Notification
@ -32,7 +37,9 @@ icingabeat:
# * DowntimeRemoved # * DowntimeRemoved
# * DowntimeStarted # * DowntimeStarted
# * DowntimeTriggered # * DowntimeTriggered
event_types: #
# At least one type must be set
types:
- CheckResult - CheckResult
- StateChange - StateChange

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,8 +19,13 @@ 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
# 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. # Decide which events to receive from the event stream.
# The following event stream types are available, at least one must be set: # The following event stream types are available:
# * CheckResult # * CheckResult
# * StateChange # * StateChange
# * Notification # * Notification
@ -32,7 +37,9 @@ icingabeat:
# * DowntimeRemoved # * DowntimeRemoved
# * DowntimeStarted # * DowntimeStarted
# * DowntimeTriggered # * DowntimeTriggered
event_types: #
# At least one type must be set
types:
- CheckResult - CheckResult
- StateChange - StateChange
@ -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"