|
||
---|---|---|
artwork | ||
rt | ||
rt2 | ||
.gitignore | ||
AUTHORS | ||
LICENSE | ||
Makefile | ||
README.md | ||
cache.go | ||
cache_test.go | ||
config.go | ||
config_test.go | ||
go.mod | ||
go.sum | ||
main.go | ||
rotochute.csv | ||
ticket.go | ||
ticket_test.go |
README.md
rotochute
rotochute is based on icinga2rt and much of the code originates from there. rotochute adds the ability to work with the RT-REST2 api. rotochute is a tool which automatically creates, updates and closes request tracker tickets on status changes of hosts or services monitored by icinga2.
Commandline Arguments
-config string
configuration file (default "rotochute.json")
-debug
debug mode, print log messages
-debugevents
print received events
-example
write example configuration file as rotochute.json.example to current directory
-exportCache string
export contents of cache to this file, and quit
-importCache string
import contents of cache from this file, and quit
-version
display version and exit
Configuration
A configuration is expected to be in rotochute.json
, other paths can be used with the -config
switch.
The rotochute.json.example
file is a good starting point for a config.
Supported Configurations
rotochute supports the traditional RT-REST api as well as the newer RT-REST2 api. The latter can be configured either with http basic authentication as well as token-based authentication (please refer to the RT-REST2 docs for this). If the User is set to "" in the configuration, the token based authentication scheme is used and the string given for the password becomes the token.
Explained Example Configuration
If parts of this are used, comments (//...) must be removed. Using the -example
switch is recommended.
{
"Icinga": {
"URL": "https://monitoring.example.com:5665", // URL to Icinga2 API
"User": "root", // Icinga2 API user
"Password": "secret", // Icinga2 API password
"Insecure": true, // Ignore SSL certificate errors
"Retries": 5 // Maximum tries for connecting to Icinga2 API
},
"RT": {
"URL": "https://support.example.com", // Request Tracker base URL
"User": "apiuser", // Request Tracker API user
"Password": "secret", // Request Tracker password
"Insecure": true // Ignore SSL certificate errors
},
"RT2": {
"URL": "https://support.example.com", // Request Tracker base URL
"User": "apiuser", // Request Tracker API user
"Password": "secret", // Request Tracker password
"Insecure": true // Ignore SSL certificate errors
},
"Cache": {
"File": "rotochute.bolt" // Path to cache file storing event-ticket associations
},
"Ticket": {
"Mappings": "rotochute.csv", // File with mappings
"Nobody": "Nobody", // A Request Tracker ticket is unowned if owned by this user.
"Queue": "general", // Request Tracker queue where tickets are created
"ClosedStatus": [ // List of Request Tracker stati for which tickets are considered to be closed.
"done",
"resolved",
"deleted"
]
}
}
Mappings
A mapping is the tuple of an events state, the old state (if any), if the ticket is owned, and an action to perform for this event. These mappings are stored in a CSV file with the columns
- state: one of
UNKNOWN
,WARNING
,CRITICAL
,OK
- old state: one of
UNKNOWN
,WARNING
,CRITICAL
,OK
or an empty string for non existing tickets. - owned: one of
true
orfalse
. should befalse
if old state is the empty string. - action: one of
create
,comment
,delete
orignore
The values supplied are read case-insensitive, but the values provided above are preferred.
Lines can be commented if their first character is #
.
Example
# state, old state, owned, action
# ignore OK events if no old state is known
OK,,false,ignore
# delete ticket if unowned and was WARNING, CRITICAL or UNKNOWN
OK,WARNING,false,delete
OK,CRITICAL,false,delete
OK,UNKNOWN,false,delete
# comment ticket if unowned and was WARNING, CRITICAL or UNKNOWN
OK,WARNING,true,comment
OK,CRITICAL,true,comment
OK,UNKNOWN,true,comment
# create tickets for WARNING, CRITICAL or UNKNOWN if not exisiting
WARNING,,false,create
CRITICAL,,false,create
UNKNOWN,,false,create
# ignore if state hasn't changed
WARNING,WARNING,false,ignore
WARNING,WARNING,true,ignore
CRITICAL,CRITICAL,false,ignore
CRITICAL,CRITICAL,true,ignore
UNKNOWN,UNKNOWN,false,ignore
UNKNOWN,UNKNOWN,true,ignore
# comment tickets on state changes
WARNING,CRITICAL,false,comment
WARNING,CRITICAL,true,comment
WARNING,UNKNOWN,false,comment
WARNING,UNKNOWN,true,comment
CRITICAL,WARNING,false,comment
CRITICAL,WARNING,true,comment
CRITICAL,UNKNOWN,false,comment
CRITICAL,UNKNOWN,true,comment
UNKNOWN,WARNING,false,comment
UNKNOWN,WARNING,true,comment
UNKNOWN,CRITICAL,false,comment
UNKNOWN,CRITICAL,true,comment
Running
Upstart
description "rotochute ticket creator"
start on (net-device-up and local-filesystems and runlevel [2345])
stop on runlevel [016]
respawn
respawn limit 10 5
console log
setuid icingatort
setgid icingatort
exec /usr/sbin/rotochute
systemd
I'm not really used to systemd, but this should work as a unit file:
[Unit]
Description=rotochute ticket creator
After=network-online.target
[Service]
Restart=on-failure
User=icingatort
Group=icingatort
ExecStart=/usr/sbin/rotochute
[Install]
WantedBy=multi-user.target