Create and Update OTRS Tickets from the Command-Line

I recently wrote a notification script for Centreon / Nagios to create and update tickets in OTRS. The ticket details and OTRS connection settings are all defined on the command-line. The GenericTicketConnector.yml must first be installed in OTRS, and a user (aka “Agent”) created for the script. I used perl’s taint mode, so had to hard-code the various log file locations ($logfile, $csvfile, and $dbfile). The Log::Handler module allows the script to output and log different amounts of activity detail, and the DBD::SQLite module is used to keep a local database of the Ticket ID (from OTRS) and the Problem ID (from Centreon / Nagios) associations — so the OTRS ticket can be updated with follow-up notifications from Centreon / Nagios for the same issue.

A few OTRS dynamic fields are used to improve OTRS searches, reports, etc. The ProblemID, HostName, HostAddress and ServiceDesc dynamic fields must be defined in OTRS before-hand. Although most command line arguments are mandatory, a few have default values if they are not specified. The script’s top-most comment section has a concise list of “Requirements for OTRS” and the Wiki Page on Google Code has additional installation notes for Centreon and OTRS.

Download the otrs-ticket.pl script here or visit the
otrs-ticket project on Google Code for additional installation notes.

Here’s an example of the screen output when creating and updating a ticket.

2 thoughts on “Create and Update OTRS Tickets from the Command-Line

  1. Hey,

    I m new to otrs system, please help me out by telling what all changes i’ll have to make in script provided above and do i need to install Get::opt, Pod::Usage on my system. My environment is Centos.

    And also i created the dynamic field as suggested by you those are not visible on my system.

    Waiting for your helpful reply.

    Thanks,
    Shreya Rangari

Comments are closed.