Skip to content

Commit

Permalink
Release v0.3.0 (#43)
Browse files Browse the repository at this point in the history
* Use log.Error instead of log.Fatal for json parsing errors

* Added icinga2 module

* Fix Hackint Webchat markdown in the README

* Fix typo in log message

* Added RWMutex to track connection state of IRC client

* fixup! Fix Hackint Webchat markdown in the README

* prometheus: Better way to determine alert name

First it checks if the alert has an instance label. If not it falls back
to the alert name.
This fixes #26
  • Loading branch information
fleaz committed Mar 12, 2019
1 parent d2252a7 commit c4b081c
Show file tree
Hide file tree
Showing 10 changed files with 509 additions and 9 deletions.
9 changes: 9 additions & 0 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 18 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ different IRC channels according to the configuration.
Take a look at the [input](https://github.com/fleaz/CptHook/tree/master/input) folder to find out which services are
already supported by CptHook.

**If you have questions or problems visit #CptHook on HackInt -> [WebChat](*https://webirc.hackint.org/#irc://irc.hackint.org/#CptHook)**
**If you have questions or problems visit #CptHook on HackInt** -> [WebChat](https://webirc.hackint.org/#irc://irc.hackint.org/#CptHook)

## Installation

Expand Down Expand Up @@ -86,3 +86,20 @@ This dictionary maps full project paths (groupname/projectname) to IRC-channels.
Receives arbitrary messages as text via a HTTP `POST` request and forwards this message line by line to a channel.
The channel can be specified by the `channel` query parameter, otherwise the `default_channel` from the config will
be used.

### Icinga2
Receives webhooks from Icinga2. Add [icinga2-notifications-webhook] to your icinga2 installation to send the
required webhooks.

When a webhook is received this module will first check if there is an explicit
mapping in the configuration especially for this host. If yes, this channel will be used. If not, the module will
look if there exists for the hostgroup. If yes, this channel will be used. If not, the `default` channel will be used.

**Module specific configuration**
```
- hostgroups
This dictionary maps Icinga2 hostgroups to IRC-channels.
- explicit
This dictionary maps hostnames to IRC-channels.
```
[icinga2-notifications-webhook]: https://git.s7t.de/ManiacTwister/icinga2-notifications-webhook
9 changes: 9 additions & 0 deletions cpthook.yml.example
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,13 @@ modules:
simple:
enabled: True
default_channel: "#defaultChannel"
icinga2:
enabled: True
default: "#monitoring"
hostgroups:
"webservers":
- "#monitoring-web"
explicit:
"host.example.tld":
- "#monitoring-example"

10 changes: 5 additions & 5 deletions input/gitlab.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ func (m GitlabModule) GetHandler() http.HandlerFunc {
log.Printf("Got a Hook for a Pipeline Event")
var pipelineEvent PipelineEvent
if err := decoder.Decode(&pipelineEvent); err != nil {
log.Fatal(err)
log.Error(err)
return
}

Expand Down Expand Up @@ -303,7 +303,7 @@ func (m GitlabModule) GetHandler() http.HandlerFunc {
log.Printf("Got a Hook for a Job Event")
var jobEvent JobEvent
if err := decoder.Decode(&jobEvent); err != nil {
log.Fatal(err)
log.Error(err)
return
}

Expand All @@ -328,7 +328,7 @@ func (m GitlabModule) GetHandler() http.HandlerFunc {
log.Printf("Got Hook for a Merge Request")
var mergeEvent MergeEvent
if err := decoder.Decode(&mergeEvent); err != nil {
log.Fatal(err)
log.Error(err)
return
}

Expand All @@ -342,7 +342,7 @@ func (m GitlabModule) GetHandler() http.HandlerFunc {
log.Printf("Got Hook for an Issue")
var issueEvent IssueEvent
if err := decoder.Decode(&issueEvent); err != nil {
log.Fatal(err)
log.Error(err)
return
}

Expand All @@ -356,7 +356,7 @@ func (m GitlabModule) GetHandler() http.HandlerFunc {
log.Printf("Got Hook for a Push Event")
var pushEvent PushEvent
if err := decoder.Decode(&pushEvent); err != nil {
log.Println(err)
log.Error(err)
return
}

Expand Down
Loading

0 comments on commit c4b081c

Please sign in to comment.