No Description
Felix Kronlage 2f00b1fb09 some followup changes to the renaming of the password parameter 1 month ago
artwork resize some more 1 month ago
rt add debug flag to rt as well 1 month ago
rt2 some followup changes to the renaming of the password parameter 1 month ago
.gitignore initial import of rotochute. 1 month ago
AUTHORS initial import of rotochute. 1 month ago
LICENSE initial import of rotochute. 1 month ago
Makefile adjust Makefile to changes 1 month ago
README.md move around 1 month ago
cache.go initial import of rotochute. 1 month ago
cache_test.go initial import of rotochute. 1 month ago
config.go support token as well as basic auth for rt-rest2 1 month ago
config_test.go initial import of rotochute. 1 month ago
go.mod initial import of rotochute. 1 month ago
go.sum initial import of rotochute. 1 month ago
main.go some followup changes to the renaming of the password parameter 1 month ago
rotochute.csv initial import of rotochute. 1 month ago
ticket.go initial import of rotochute. 1 month ago
ticket_test.go initial import of rotochute. 1 month ago

README.md

rotochute

rotochute logo

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 or false. should be false if old state is the empty string.
  • action: one of create, comment, delete or ignore

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