Page tree

Welcome to FreeSoftwareServers Confluence Wiki

Skip to end of metadata
Go to start of metadata

I have setup a basic script to generate a task in OpenProject when a service goes red, this is still a WIP and needs fine tuning:

ToDo:

  • Confirm only one task created
  • Possible Recovered Script
  • SOP on Resolving Task
  • Nest Tasks under service

XYMon Alerts.cfg: (no need to "replace" recipient it's just something that XYMon expects so I put a word in place.

HOST=%^.*
IGNORE SERVICE=libs,apt,files
SCRIPT /etc/xymon/api_scripts/create_task_proj_xymon_payload.json recipient FORMAT=sms

create_task_proj_xymon_payload.json:

#!/bin/bash

PWD=/etc/xymon/api_scripts

SUBJECT="Service:$BBSVCNAME on HOSTNAME:$BBHOSTNAME (IP:$MACHIP) is currently COLOR:$BBCOLORLEVEL"
RAW="An issue has been detected by XYMon - Please Investigate, Document and Acknowledge Error"
cat << EOF >$PWD/payload.json
{
    "subject":"$SUBJECT",
    "description": {
        "format": "textile",
        "raw": "$RAW"
    },
    "_links": {
        "type": {"href":"/api/v3/types/1"},
        "status":{"href":"/api/v3/statuses/1"},
        "priority":{"href":"/api/v3/priorities/8"}
    }
}
EOF

bash $PWD/create_task_proj_xymon_op.sh

rm $PWD/payload.json

create_task_proj_xymon_op.sh: 

Note: Replace API_KEY and PROJECTID

#!/bin/bash

PWD=/etc/xymon/api_scripts

API_KEY=asdasfasdasdasdasdasd
URL=https://domain/prefix
JSONFILE=payload.json
PROJECTID={id}
API=api/v3/project/form
curl -k -u apikey:$API_KEY $URL/api/v3/projects/$PROJECTID/work_packages -d @$PWD/$JSONFILE --header "Content-Type: application/json"

Test! (Go to XYMon Shell and Run Script w/ Test Arg)

  • No labels