Follow Mike's blog
Archives for the month of: August, 2017

DESCRIPTION:

At my previous job I used the free edition of a ticketing system by FreshService.com. I liked it and integrated it with LogicMonitor to create tickets on certain alerts and change the ticket status to pending when I ack the alert and finally ‘close’ the ticket when the alert ‘clears’.

INSTRUCTIONS:

Below is how you configure the ‘webhooks’ in LogicMonitor. Copy and paste in the fields.
You need to add this to an escalation chain to send alerts/info to the ticketing system.

█████ ‘Active’ alerts aka new ██████████

Method: POST

URL: wowie.freshservice.com/helpdesk/tickets.json

RAW JSON:
{ “helpdesk_ticket”: { “subject”:”##ALERTID##”, “description”:”##MESSAGE##”, “email”:”al@wowie.us”, “priority”:1 }}

 

█████ acked ███████████████

Method: PUT

URL: wowie.freshservice.com/helpdesk/tickets/##EXTERNALTICKETID##.json

Raw JSON:
{ “helpdesk_ticket”: { “status”: 3, “custom_field”:{“note1_138794″:”ack note ##MESSAGE##” }}}

█████ cleared █████████████████

Method: PUT

URL: wowie.freshservice.com/helpdesk/tickets/##EXTERNALTICKETID##.json

Raw JSON:
{ “helpdesk_ticket”: { “status”: 4, “custom_field”:{“note2_138794″:”close note ##MESSAGE##” }}}

==================================================

x   Include an ID provided in HTTP response when updating alert status
Format: JSON

JSON Path:  item.helpdesk_ticket.display_id

 

Notes:

  1. The URL begins with https//.  Also replace ‘wowie.freshservice.com’ with your domain that you created on FreshService.
  2. The email al@wowie.us should be one of your valid email addresses that FreshService allows to submit tickets
  3. Status=3 means ‘pending’. Status=4 means ‘resolved’, and status=5 means ‘closed’
  4. The note1 and note2 are custom text fields I added in FreshService > Admin > Field templates. The 138794 is my account – replace it with your own that you get back from a ‘get’ command. I needed to do this because the API would not allow to add a ‘note’ and change the status in one step. Also, the API would not allow me to change the ‘subject’ or ‘description’ when updating with the ‘put’ method. Hopefully they’ll add a ‘patch’ method to their API soon.
  5. I learned how to do this with help docs on FreshService website http://api.freshservice.com/#introduction
I created a ‘PropertySource’ that creates a shortened ‘sysinfo’ string. It creates a new property that I called ‘short_sysinfo’. I did it for Cisco devices but it can be easily adapted to other devices.
See the example differences below.
It’s helpful for reports because it takes out the non-helpful text and redundant text that makes it too long.
It’s fairly flexible, so it can be tweaked
This is short_sysinfo…
Catalyst L3 Switch (CAT3K_CAA-UNIVERSALK9-M), Version 16.3.2, RELEASE (fc4)
instead of…
Cisco IOS Software [Denali], Catalyst L3 Switch Software (CAT3K_CAA-UNIVERSALK9-M), Version 16.3.2, RELEASE SOFTWARE (fc4) Technical Support: http://www.cisco.com/techsupport Copyright (c) 1986-2016 by Cisco Systems, Inc. Compiled Tue 08-Nov-16 17:31 b
————————————————————————
This is the short_sysinfo…
C2900 (C2900-UNIVERSALK9-M), Version 15.4(3)M7, RELEASE (fc1)
instead of…
Cisco IOS Software, C2900 Software (C2900-UNIVERSALK9-M), Version 15.4(3)M7, RELEASE SOFTWARE (fc1) Technical Support: http://www.cisco.com/techsupport Copyright (c) 1986-2017 by Cisco Systems, Inc. Compiled Thu 02-Feb-17 21:48 by prod_rel_team
————————-
This is short_sysinfo…
(ucs-6100-k9-system), Version 5.0(3)N2(3.12f), RELEASE
instead of long…
Cisco NX-OS(tm) ucs, Software (ucs-6100-k9-system), Version 5.0(3)N2(3.12f), RELEASE SOFTWARE Copyright (c) 2002-2013 by Cisco Systems, Inc. Compiled 2/27/2017 8:00:00
=========================
If you’re curious…Below is the groovy script I wrote:
info = hostProps.get(“system.sysinfo”)
step_one   = info.replaceAll(‘Technical Support: http://www.cisco.com/techsupport‘,”) // replace the string with nothing (remove it)
step_two   = step_one.replaceAll(‘SOFTWARE’,”) // replace the string ‘SOFTWARE ‘ with blank (remove it)
step_three = step_two.replaceAll(‘Software’,”)  
if (info.contains(‘Copyright’)){  // to avoid errors if it doesn’t contain ‘Copyright’ in string
    index_of_copyright = step_three.indexOf(‘Copyright’) // get position of where the string ‘Copyright’ starts
    step_four = step_three.substring(0,index_of_copyright) // grab from start to ‘Copyright’
}else{
    step_four = step_three
}
if (info.contains(‘,’)){ // to avoid errors if string doesn’t contain a comma
    index_of_first_comma = step_four.indexOf(‘,’) +1 // get position of first comma which is after ‘Cisco IOS Software’
    step_five   = step_four.substring(index_of_first_comma) // grab from first comma to end
}else{
    step_five = step_four
}
step_six   = step_five.trim() // trim the leading and ending spaces if they exist
length = step_six.size() 
println “short_sysinfo=” + step_six
return 0