1 Reply Latest reply on Mar 23, 2018 11:44 AM by Quang Du

    Simple monitoring integration with simple-salesforce

    Adi Leibowitz
      Share This:

      Ever tried connecting your monitoring system/event manager to RemedyForce, only to be told that your monitoring solution does not support web services, or that it would simply cost too much to develop a wrapper?


      Obviously, there is always the SMTP option - most monitoring solutions can send out emails, and RemedyForce offers a pretty configurable email parser. Apart from SMTP being a boring option, what's wrong with that? Well, you won't be able to automatically close the incident once your alert has gone down: Any emails from the monitoring system telling RemedyForce that CPU is no longer at 99% (has your exchange server been mining cryptocoins?) will open a new incident in RemedyForce instead of closing an existing one, because this is just how the built-in email handler works (unless you include the incident number in the subject, or write your own custom email handler).


      This is exactly the sort of situation a customer of ours was facing, which led us to to think about using simple-salesforce, a very simple SFDC REST API client for Python.


      Since you can easily run Python scripts using shell commands, and most (if not all) monitoring systems are pretty adept at running shell commands, it was only a matter of upserting incidents, and mapping the alert identifier to an external id.


      This is how you login:

      sf = Salesforce(username='user', password='password', security_token='token')


      This is how you create an incident:

      sf.BMCServiceDesk__Incident__c.upsert('BMCServiceDesk__Event_ID__c/123123',{'BMCServiceDesk__incidentDescription__c': 'CPU is too high!!!!','BMCServiceDesk__TemplateName__c': 'Open Alert'})


      And this is how you close it:

      sf.BMCServiceDesk__Incident__c.upsert('BMCServiceDesk__Event_ID__c/123123',{'BMCServiceDesk__TemplateName__c': 'Close Alert'})


      Since we are mapping the alert identifier to an external id (BMCServiceDesk__Event_ID__c), the monitoring system doesn't have to know the identifier of the incident it is trying to close, only send a consistent alert identifier (123123). Also, in this example, there is an incident template that does all the heavy lifting (changing status values, assigning to queues, etc.) but you can use the upsert method to update any field on the incident object.


      That's it! lots of build-up, but this post would have otherwise been too short!


      Let me know if you find this useful, or if your exchange server has been used to mine crypto-currency!