Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/uniwue-rz/hubot-icinga2
Hubot icinga2 connector
https://github.com/uniwue-rz/hubot-icinga2
hubot-scripts icinga2
Last synced: about 2 months ago
JSON representation
Hubot icinga2 connector
- Host: GitHub
- URL: https://github.com/uniwue-rz/hubot-icinga2
- Owner: uniwue-rz
- License: mit
- Created: 2017-07-11T13:37:20.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-07-12T13:24:30.000Z (over 7 years ago)
- Last Synced: 2024-11-04T08:37:29.306Z (about 2 months ago)
- Topics: hubot-scripts, icinga2
- Language: Shell
- Size: 15.6 KB
- Stars: 2
- Watchers: 5
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG
- License: LICENSE
Awesome Lists containing this project
README
# hubot-icinga2
A hubot script that receives and shows icinga2 notification in the chat-room
## Installation
In hubot project repo, run:```bash
npm install hubot-icinga2 --save
```or add hubot-icinga2 to the hubot package.json dependency file:
```json
dependencies:{
"hubot-icinga2" : "^0.0.1"
}
```Then add **hubot-icinga2** to your `external-scripts.json`:
```json
[
"hubot-icinga2"
]
```## Configuration
The configuration for the this bot has two parts, one should add the bot in hubot settings and the other configure icinga2 for the notification.### Hubot
On hubot server you should set the `HUBOT_ICINGA2_TOKEN` environment variable so your icinga2 notifier can send queries. You can also set custom prefixes for the messages posted in the room using `HUBOT_ICINGA2_NOTIFICATION_PRE`. The first variable is mandatory, the second is optional. You should also make hubot to listen on the ip address of your designation and given port using:
```bash
"PORT=8090"
"BIND_ADDRESS=...."
```
Make sure your firewall is not blocking the queries. The hubot will be listening on `/hubot/icinga2/:room` address and it is waiting for the notifications.### Icinga2
On Incinga2 server to make the configuration easier, you should have the `icinga2 director` installed. Then you must create a notification command using the `notification.sh` file. You can change `notification.sh` to suite your settings. You need `curl` also installed on the icinga2 server. The command can look like this:```conf
object NotificationCommand "notify-hubot" {
import "plugin-notification-command"
command = [ "/etc/icinga2/scripts/notification.sh" ]
arguments += {
"-a" = {
required = true
value = "$address$"
}
"-b" = "$notification.author$"
"-c" = "$notification.comment$"
"-d" = {
required = true
value = "$icinga.short_date_time$"
}
"-e" = {
required = true
value = "\"$service.name$\""
}
"-l" = {
required = true
value = "$host.name$"
}
"-o" = {
required = true
value = "$service.output$"
}
"-r" = {
required = true
value = "$rocketchat_room$"
}
"-s" = "$service.state$"
"-t" = {
required = true
value = "$notification.type$"
}
"-v" = "$notification_logtosyslog$"
"-x" = "$hubot_host$"
"-z" = {
required = true
value = "$hubot_token$"
}
}
}
```
Add the following parameters in icinga2 director as fields:
```bash
hubot_token (string)
hubot_host (string)
rocketchat_room (string)
```Then add the command as notification using icinga director by adding a notification template:
```conf
template Notification "generic-service-hubot" {
command = "notify-hubot"
}
```and the notification itself:
```conf
apply Notification "Status Alarm to Hubot" to Service {
import "generic-service-hubot"interval = 0s
assign where match("*", service.name)
types = [ Problem, Recovery ]
users = [ "admin" ]
vars.hubot_host = "http://yourhost:8090"
vars.hubot_token = "token"
vars.rocketchat_room = "general"
}```
## NPM Module
https://www.npmjs.com/package/hubot-icinga2## License
See LICENSE file