Created
April 3, 2016 01:22
Star
You must be signed in to star a gist
Zabbix Action remote script: Open Redmine issue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
####################################################################### | |
# | |
# Joaquín de la Zerda <joaquindelazerda@gmail.com> | |
# Zabbix Custom alertscripts: Open Redmine issue | |
# 20160402 | |
# | |
####################################################################### | |
## PARAMETERS | |
# Script Params: | |
# 1. Priority ID: | |
# Urgent: 4 | |
# High: 3 | |
# 2. Issue title. | |
# 3. Description | |
# | |
# Ex. | |
# script.sh "{TRIGGER.SEVERITY}" "{HOST.NAME} - {TRIGGER.STATUS}: {TRIGGER.NAME}" "Trigger: {TRIGGER.NAME}\r\nTrigger status: {TRIGGER.STATUS}\r\nTrigger severity: {TRIGGER.SEVERITY}\r\nTrigger URL: {TRIGGER.URL}\r\n\r\nItem values:\r\n\r\n1. {ITEM.NAME1} ({HOST.NAME1}:{ITEM.KEY1}): {ITEM.VALUE1}\r\n\r\nOriginal event ID: {EVENT.ID}" | |
## VARIABLES | |
PARAM_CONTENTTYPE="application/json" | |
PARAM_REDMINE_APIKEY="" # Redmine zabbix user | |
PARAM_REDMINE_PROJID="2" | |
PARAM_REDMINE_SUBJECT="$2" | |
PARAM_REDMINE_PRIORITYID="$1" # 3: High / 4: Urgent | |
PARAM_REDMINE_TRACKERID="4" # 4: Inicident tracker id | |
PARAM_REDMINE_ASSIGNEDID="15" # 15: Redmine Infrastructure group | |
PARAM_REDMINE_DESCRIPTION="$3" | |
PARAM_REDMINE_URL="http://redmine.server.com/issues.json" | |
# priority_id normalize | |
if [[ "$PARAM_REDMINE_PRIORITYID" == "High" ]]; then | |
PARAM_REDMINE_PRIORITYID=4 | |
elif [[ "$PARAM_REDMINE_PRIORITYID" == "Warning" ]]; then | |
PARAM_REDMINE_PRIORITYID=3 | |
fi | |
/usr/bin/curl -s -H "Content-Type: $PARAM_CONTENTTYPE" -H "X-Redmine-API-Key: $PARAM_REDMINE_APIKEY" -X POST -d "{\"issue\": {\"project_id\": $PARAM_REDMINE_PROJID,\"subject\": \"$PARAM_REDMINE_SUBJECT\",\"priority_id\": $PARAM_REDMINE_PRIORITYID,\"tracker_id\": $PARAM_REDMINE_TRACKERID,\"assigned_to_id\": $PARAM_REDMINE_ASSIGNEDID,\"description\": \"<pre>$PARAM_REDMINE_DESCRIPTION</pre>\"}}" $PARAM_REDMINE_URL >/dev/null 2>&1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment