Notifications2CSV (1/27/2014)

Notifications2CSV! Wooo!

This is a handy little utility that can pull notification reports to a CSV file. It uses the Integration Agent to pull the information down via the REST API. The configuration file allows for great flexibility to get just the info you need and put it just where you want it. This file can then be picked up by another application or utility for easy reporting. 

Requirements

  • An xMatters On Demand system
  • An Integration Agent installed and configured 

Installation

The following instructions are formatted for Linux users. The same steps will work on Windows; just swap the path formatting for Windows-compliant paths (i.e., change / to \) and use the Windows version of the iapassword utility (iapassword.bat).

  1. Login to your xM aters On-Demandt. Create a new regular user (not a web services user). This service will login as that user to pull down the notification information. Grant the "Full Access User" role and enter a password.
  2. Navigate a command line to IAHOME/bin and enter this command, replacing "passwordhere" with the password you entered in step 1.
    ./iapassword.sh --new "passwordhere" --file ./conf/notifications2csv.pwd
  3. Download the attached tar or zip file and drop the notifications2csv folder into IAHOME/integrationservices
  4. Open IAHOME/integrationservices/notifications2csv/conf.js in a text editor.
    1. Update the xMOD url with the appropriate company prefix and deployment.
    2. Update the USER entry with the user name from step 1.
    3. Update, if necessary) the PWD_FILE entry to point to the pwd file created in step 2.
    4. Update the OUTPUT_PATH, SEP_CHAR or COLUMNS variables depending on your environment or desired format.
  5. Open the IAHOME/conf/IAConfig.xml file in a text editor. Search for the "service-config" tag and add this line, then save the file.
    <path>notifications2csv/notifications2csv.xml</path>  
  6. Restart the Integration Agent.

Testing

The integration is fired from the command line and takes two parameters:

range - date or date interval in the ISO 8601 format.

status - a notification status category - one of ALL, PENDING, DELIVERED, RESPONDED or FAILED 

To test the integration, navigate a command prompt to the IAHOME/bin directory and run this command:

APClient.bin --map-data notifications2csv "2014-01-21T00:00:00Z/2014-01-27T00:00:00Z" "ALL"

Then note that a new file has been created in the IAHOME directory (Update the OUTPUT_PATH variable to put this file in a more accessible spot):

[user@host integrationagent-5.0.7]$ ll 
total 36 
drwxr-xr-x  3 user user 4096 Jan 27 06:50 bin
drwxr-xr-x  3 user user 4096 Jan 27 22:56 conf 
drwxr-xr-x  4 user user 4096 May 31  2013 docs 
drwxr-xr-x 15 user user 4096 Jan 27 22:44 integrationservices
drwxr-xr-x  8 user user 4096 Jul 21  2011 jre
drwxr-xr-x  5 user user 4096 May 31  2013 lib
drwxrwxr-x  2 user user 4096 Jan 27 22:49 log
-rw-r--r--  1 user user 2435 Jan 27 23:05 notifications_1390863942670.csv 
drwxr-xr-x  2 user user 4096 May 31  2013 tools 
[user@host integrationagent-5.0.7]$

However, a more likely scenario is that this will be called on a nightly basis and generating the ISO8601 format in a shell could be messy.... fortunately, the ISO spec takes care of that for us! This "range" can actually be a duration as well. For example, to get all the FAILED notifications from the last month:

APClient.bin --map-data notifications2csv "P1M" "FAILED"

Or, get all of the notifications from the last day:

APClient.bin --map-data notifications2csv "P1D" "ALL"

From here, just add a cron job or Windows scheduled task to fire the command at the appropriate interval. 

Happy Reporting!

(Edited 02/05/2014: Added "last day" example and link for ISO 8601. )

xMatters Reference

JDN-4447 Originally created by Doug Peete

Have more questions? Submit a request

4 Comments

  • 0
    Avatar
    Christina Pershey

    for installation step 2, this doesnt work on windows as the iapassword program is a batch file

  • 0
    Avatar
    Don Clark

    Thanks Christina - I updated the instructions to indicate that they are Linux-specific, and that Windows users will need to change some things.

  • 0
    Avatar
    Tom Kouhsari

    Hi Christina,

    You are right, that example is specific to Linux. The Windows batch file uses the same syntax, so you would execute the following:

    iapassword.bat --new "passwordhere" --file ./conf/notifications2csv.pwd

     

    Thanks,

    Tom

  • 0
    Avatar
    Christina Pershey

    iapassword.bat --new "passwordhere" --file .\conf\notifications2csv.pwd

Please sign in to leave a comment.
Powered by Zendesk