Automatically Create Jira Support Tickets From Network Events

Automatically Create Jira Support Tickets From Network Events

As a network administrator, you need to make sure that important events don't go unnoticed. Depending on the level of emails your team receive in a day, it's easy for a single email notification event to go unnoticed. That's why it's important to have important events automatically create help desk tickets so they can be tracked and not forgotten.

Using Jira by Atlassian and a bit of ingenuity it's easy to have help desk tickets be created when certain things occur. For instance, I have a script that monitors the health of our RAID-Z arrays. It will send out emails in the event that a drive fails.

Example zpool monitoring script:

#!/bin/sh
#
# This script is called by cron and monitors the status of the ZFS file system
# It creates /root/zpool.status to keep from paging more than once per event
#

REPORT_EMAIL=jira-tickets-network@mydomain.com
SERVER=`hostname`
STATUSFILE="/root/zpool.status"

ZPOOL_STATUS=`/sbin/zpool status -x 2>&1`
if [ "$ZPOOL_STATUS" = "all pools are healthy" -o "$ZPOOL_STATUS" = "no pools available" ]
then
        echo -n 0 > $STATUSFILE
else
        if [ `cat $STATUSFILE` -eq 0 ]
        then
                /sbin/zpool status 2>&1 | mail -s "$SERVER ZPOOL NOT HEALTHY" $REPORT_EMAIL
                echo -n 1 > $STATUSFILE
        fi
fi

This particular script runs every 15 minutes, and will fire off an email to the REPORT_EMAIL address in the script if anything has gone wrong with the pool of drives. Tying this to Jira is actually pretty easy - simply create an email address for your Jira install. If you have more than one project and want different types of events to go into different ones, you can set email aliases for the additional addresses and only use the one email account.

In Jira, in the system settings, scroll down to "Incoming Mail". Set up the POP server for the account with it's login. Now in the Mail Handlers section add a new incoming mail handler.

Give it a name, and pick the email server setup from the drop down. You can set an appropriate delay depending on how much lag you can accept. In the Handler drop-down choose "Create a new issue or add a comment".

On the next page, pick the project that we will create the new support ticket within, and an issue type. The Catch Email Address is the address that Jira will be expecting to receive it on. So for instance, I created an email account called "jira-tickets" with an alias of "jira-tickets-network" that deliver to the same account. I can now enter "jira-tickets-network@mydomain.com" in the Catch address tied to the "Network Admin" project. Only emails sent to "jira-tickets-network@" will create tickets in the Network Admin project. I can then create another alias "jira-tickets-mysoftware@mydomain.com" that goes to the same email account, and link those emails to a different Jira project. This keeps you from having to create several separate email accounts.

Properly monitoring and automatically creating help desk tickets helps to ensure that nothing important is overlooked and is part of not only good network hygiene but excellent network security. Just be sure that whatever generates the emails isn't creating false-positives. These are for the incidents that absolutely must be handled.

Posted by Tony on Apr 23, 2015 | Networking