Derdack

Targeted Alert Notifications – Anywhere Actions

Derdack
  • Use Cases
    • Overview
    • Enterprise IT Alerting
    • IT Managed Services
    • Mobile Alerting in Manufacuring
    • Critical Operations Alerting in Banking & Financial
    • Field Service Dispatching in Energy & Utilities
    • Use Cases in other Industries
  • Products
    • Overview
    • Enterprise Alert®
      • Overview
      • Alert Notifications
      • On-call Duty Scheduling
      • Collaboration
      • Anywhere Remediation
      • Incident Mgmt. App
      • Integrations
      • Technical Support
      • Online Knowledge Base
      • Derdack FAQ
    • SIGNL4® Cloud
    • References & More
  • How to Buy
    • Overview
    • Pricing and Quotes
    • Find a local Partner
    • Azure Marketplace
  • About Derdack
    • About
    • Careers
    • Partner Program
    • Strategic Partners
    • Derdack Podcast
    • Contact Derdack
  • News & Blog
  • Request Demo
    • de de
  • News & Blog

    • Home
    • News & Blog
    • Technical
    • Two-Way Integration with any Backend System using Scripting

    Two-Way Integration with any Backend System using Scripting

    • August 17, 2016
    • Technical
    Two-Way Integration with any Backend System using Scripting

    Enterprise Alert offers code-less integration with a variety of standard tools, e.g. Microsoft System Center, HP Operations Manager, HP Service Manager, etc. Besides this open API’s like command line, Web service, SMTP and more are available for easy integration almost every backend system.

    There is also a neat way for integrating backend systems using the Enterprise Alert Scripting Host. This has the following advantages:

    • Scripting is flexible and in-depth integration with a lot of backend systems is possible (e.g. access a database, Web services, files, etc.)
    • You can define the event parameters as you need them
    • The script integration behaves like Web service integration in Enterprise Alert and you can easily process them using policies
    • Two-way integration is possible including updates and reset event
    • Easy to adapt, e.g. for adding event parameters or changing the implementation to cope with changes in the backend system

    The following script is a basic example for reading event data from a backend database:

    /*
    =============================================================================
    CONFIGURATION
    =============================================================================
    */

    // The interval in milliseconds when the messages get read from the MMSEND database table
    var APPCONFIG_CHECK_MESSAGES_INTERVAL = 10000;

    // The script ID used for marking the field “EA_Status”. This is unique for each script running in a high-availability environment, e.g. 1001, 1002.
    // Must be greater than 1000
    var APPCONFIG_SCRIPT_ID = 1002;

    // Enterprise Alert database connection string
    var APPCONFIG_DBCONNECTIONSTRING = “Driver=SQL Server Native Client 11.0;Server=sqlserver;Trusted_Connection=Yes;Database=EnterpriseAlert2016;Connect Timeout=120;General Timeout=120”;

    /*
    =============================================================================
    Main functions
    =============================================================================
    */

    EAScriptHost.LogInfo(“Script Interface process started”);

    function CheckEvents()
    {

    while (true)
    {

    var oConn = null;
    var oRs = null;
    var bInTrans = false;

    try
    {

    //Open the db connection
    //
    oConn = new ActiveXObject(“ADODB.Connection”);
    oConn.IsolationLevel = 1048576; // Set the isolation level to Serializable
    oConn.Open(APPCONFIG_DBCONNECTIONSTRING);
    EAScriptHost.LogDebug(“Db Connection Opened”);

    oConn.BeginTrans();
    bInTrans = true;

    oConn.Execute(“UPDATE EnterpriseAlert_Central_EventSync SET EA_Status = ” + APPCONFIG_SCRIPT_ID + “WHERE EA_Status = 0”);

    // Get the details of the message
    //
    var iNumMessages = 0;
    oRs = DbGetRS(oConn, “SELECT * FROM EnterpriseAlert_Central_EventSync WHERE EA_Status = ” + APPCONFIG_SCRIPT_ID + ” ORDER BY intID ASC”);
    while (!oRs.EOF)
    {

    var iRecordId = oRs.Fields.Item(“intID”).Value;

    // Create new event
    EAScriptHost.LogDebug(“Script Interface: Create new event”);
    objevent = EAScriptHost.CreateEvent();
    objevent.SetEventType(“ConnectorEvent”);
    objevent.SetEventName(“NewAlert”);
    objevent.SetProperty(“serviceFrom”, “//q:mmwebservice/EventProviderAPI/Custom Script Interface/EnterpriseAlert_Central_EventSync”);

    // Set event parameters and values
    // objevent.SetProperty(“externalTicketId”, oRs.Fields.Item(“EventID”).Value == null ? “” : oRs.Fields.Item(“EventID”).Value);
    objevent.SetEventParameter(“intID”, oRs.Fields.Item(“intID”).Value == null ? “” : oRs.Fields.Item(“intID”).Value);

    objevent.SetEventParameter(“EventID”, oRs.Fields.Item(“EventID”).Value == null ? “” : oRs.Fields.Item(“EventID”).Value);
    objevent.SetEventParameter(“Description”, oRs.Fields.Item(“Description”).Value == null ? “” : oRs.Fields.Item(“Description”).Value);
    objevent.SetEventParameter(“MachineName”, oRs.Fields.Item(“MachineName”).Value == null ? “” : oRs.Fields.Item(“MachineName”).Value);
    objevent.SetEventParameter(“EA_Status”, oRs.Fields.Item(“EA_Status”).Value == null ? “” : oRs.Fields.Item(“EA_Status”).Value);

    // Send event
    objevent.Send();

    iNumMessages++;

    oRs.MoveNext();
    }

    // Update the processed records
    oConn.Execute(“UPDATE EnterpriseAlert_Central_EventSync SET EA_Status=1 WHERE EA_Status = ” + APPCONFIG_SCRIPT_ID);

    // Delete the processed records
    // oConn.Execute(“DELETE EnterpriseAlert_Central_EventSync WHERE EA_Status = ” + APPCONFIG_SCRIPT_ID);

    EAScriptHost.LogDebug(“Number of events processed: ” + iNumMessages.toString());

    oRs.Close();
    oRs = null;

    oConn.CommitTrans();

    } catch (e) { // catch all thrown errors

    try
    {

    EAScriptHost.LogError(“Error processing event. Error message (Exception): ” + e.message);

    if (bInTrans == true && oConn != null)
    {
    oConn.RollbackTrans();
    }

    }
    catch (e2)
    {
    EAScriptHost.LogError(“Error processing exception. ” + e2.message);
    }

    }
    finally
    {

    try
    {

    // Release all resources at the end of message processing
    //
    if (oRs != null)
    {
    oRs.Close();
    oRs = null;
    }

    if (oConn != null)
    {
    oConn.Close();
    oConn = null;
    }

    EAScriptHost.LogDebug(“Resources released.”);

    } catch (e3)
    {
    EAScriptHost.LogError(“Error releasing resources. ” + e3.message);
    }

    }

    Sleep(APPCONFIG_CHECK_MESSAGES_INTERVAL);

    }

    }

    // Returns an ADODB.Recordset object for the specified query
    function DbGetRS(oConn, strSQL)
    {

    //Set some constants
    var adOpenStatic = 3;
    var adUseClient = 3;
    var adLockBatchOptimistic = 4;

    //Declare our variables
    var oRS;

    // Create the Recordset object
    oRS = new ActiveXObject(“ADODB.Recordset”);

    // Populate the Recordset object with a SQL query
    oRS.Open(strSQL, oConn, adOpenStatic, adLockBatchOptimistic, 0);

    // Return the Recordset
    return oRS;

    }

    // Gets a date string for the date object
    //
    function GetDateString(date)
    {

    var strDate = date.getFullYear().toString() + “-” + GetDoubleDigit((date.getMonth() + 1).toString()) + “-” + GetDoubleDigit(date.getDate().toString()) + ” ” + GetDoubleDigit(date.getHours().toString()) + “:” + GetDoubleDigit(date.getMinutes().toString()) + “:” + GetDoubleDigit(date.getSeconds().toString());
    return strDate;

    }

    // Gets a double digit for the date
    //
    function GetDoubleDigit(strText)
    {

    var strOutput;
    if (strText.length == 1)
    strOutput = “0” + strText;
    else
    strOutput = strText;
    return strOutput;

    }

    // Run
    CheckEvents();

     

     

    Additionally to the script you would need to create a respective event provider in the database, e.g. using the following SQL statement:

     

    BEGIN
    IF NOT EXISTS (SELECT * FROM [dbo].[EventProviders] WHERE Name = ‘Custom Script Interface’)
    BEGIN
    INSERT INTO [dbo].[EventProviders] (Name, DisplayName, Description, DateCreated, Type, Options, UserID, ResponseAddress, LicenseName, ClientAddress)
    VALUES (‘Custom Script Interface’, ‘Custom Script Interface’, ‘Custom Script Interface’, GETDATE(), 3, 2, 1, ”, null, ‘::1’)
    END
    BEGIN
    DECLARE @ProviderID AS INT
    SET @ProviderID = (SELECT ID FROM [dbo].[EventProviders] WHERE Name = ‘Custom NetIQ’)

    INSERT INTO [dbo].[EventParameters] (ProviderID, Name, DisplayName, XPath, Description, Options, ForbiddenEvaluations) VALUES (@ProviderID, ‘intID’, ‘intID’, ”, ”, 0, 0)
    INSERT INTO [dbo].[EventParameters] (ProviderID, Name, DisplayName, XPath, Description, Options, ForbiddenEvaluations) VALUES (@ProviderID, ‘EventID’, ‘EventID’, ”, ”, 0, 0)
    INSERT INTO [dbo].[EventParameters] (ProviderID, Name, DisplayName, XPath, Description, Options, ForbiddenEvaluations) VALUES (@ProviderID, ‘Description’, ‘Description’, ”, ”, 0, 0)
    INSERT INTO [dbo].[EventParameters] (ProviderID, Name, DisplayName, XPath, Description, Options, ForbiddenEvaluations) VALUES (@ProviderID, ‘MachineName’, ‘MachineName’, ”, ”, 0, 0)
    INSERT INTO [dbo].[EventParameters] (ProviderID, Name, DisplayName, XPath, Description, Options, ForbiddenEvaluations) VALUES (@ProviderID, ‘EA_Status’, ‘EA_Status’, ”, ”, 0, 0)

    END
    END

     

    Data read from the database will appear as events in Enterprise Alert then. For two-way integration you can implement the respective code in the event handler, e.g. in OnTicketStatus().

    Tagged

    backendIntegrationscripting

    Share

    Related Posts

    Enterprise Alert 9.4.1 comes with fixes and the revised version of the sentinel connector app

    February 1, 2023

    Critical System Alerts via SIGNL4

    December 29, 2022

    Enterprise Alert 9.4 Update introduces Remote Actions for hybrid scenarios and proxy support for MS Teams

    October 25, 2022

    Upgrade your shopfloor alerting with Derdack

    September 8, 2022

    About

    DERDACK products combine automated alert notification workflows, 24/7 duty scheduling, ad-hoc collaboration and anywhere IT troubleshooting – reducing unexpected IT downtimes at large enterprises and organizations by 60%.

    Most popular

    • Derdack Company Take your ITIL incident management to the next level with Enterprise Alert
    • Mobile alert notifications for HP Service Manager (HPSM)
    • How to forward alerts to Microsoft Teams
    • Oncall Scheduling On-Call Schedule Management with Auto-Rotation
    • checking-mobile Enhancing SCOM alert notifications
    • Announcing Enterprise Alert 2019
    • Even, Alert, Incident, Notification Definition of Event, Alert, Incident and Notification
    • who-is-on-call-sharepoint Add a live “Who is On-Call” Dashboard into Sharepoint and other Tools

    Categories

    • Business (37)
    • Cloud Services (5)
    • Consultancy (1)
    • Customers (18)
    • Energy & Utilities (7)
    • Events (23)
    • Financial & Banking (4)
    • IT Ops (19)
    • Manufacturing (8)
    • News (48)
    • Schools (1)
    • Software (9)
    • Staffing (1)
    • Support (4)
    • Technical (141)
    • Transport & Logistics (5)

    Tags

    alert alert notifications Anywhere Resolution Anywhere Response Azure azure BMC customer reference Database derdack enterprise alert Enterprise Alert Enterprise Alert 2016 Enterprise Alert 2019 Gartner HPE HPE ITSM incident Incident Management Incident resolution incident response Industrie 4.0 Integration IT Alerting IT Operations Maintenance microsoft mobile Mobile App monitoring OMS on-call on-call schedule Operational Alerting rapid response release Remote Action REST API SCOM security SolarWinds NPM System Center update User Group voice

    Follow us

    • Twitter
    • Facebook
    • LinkedIn
    • XING
    • YouTube
    • Vimeo
    • Home
    • News & Blog
    • Technical
    • Two-Way Integration with any Backend System using Scripting

    CONTACT US:
    Intl: +49 331 29878-0

    US: +1 (202) 470-0885
    UK: +44 (20) 88167095
    CH: +41 (31) 5391990

    CONTACT VIA EMAIL:
    info@derdack.com

    OFFICES:
    US & Europe

    NEWSLETTER:
    Sign up here

    CAREER:
    Latest job offers

    EVENTS

    • No Upcoming Events
    • Who we help
    • Products
    • How to Buy
    • About Derdack
    • News & Blog
    • Free Trial
    • Twitter
    • LinkedIn
    • XING
    • YouTube
    • Vimeo

     © 2022 Derdack – Imprint, Privacy policy

    • Use Cases
      • Overview
      • Enterprise IT Alerting
      • IT Managed Services
      • Mobile Alerting in Manufacuring
      • Critical Operations Alerting in Banking & Financial
      • Field Service Dispatching in Energy & Utilities
      • Use Cases in other Industries
    • Products
      • Overview
      • Enterprise Alert®
        • Overview
        • Alert Notifications
        • On-call Duty Scheduling
        • Collaboration
        • Anywhere Remediation
        • Incident Mgmt. App
        • Integrations
        • Technical Support
        • Online Knowledge Base
        • Derdack FAQ
      • SIGNL4® Cloud
      • References & More
    • How to Buy
      • Overview
      • Pricing and Quotes
      • Find a local Partner
      • Azure Marketplace
    • About Derdack
      • About
      • Careers
      • Partner Program
      • Strategic Partners
      • Derdack Podcast
      • Contact Derdack
    • News & Blog
    • Request Demo
    Manage Cookie Consent
    We use cookies to optimize our website and our service.
    Functional Always active
    The technical storage or access is strictly necessary for the legitimate purpose of enabling the use of a specific service explicitly requested by the subscriber or user, or for the sole purpose of carrying out the transmission of a communication over an electronic communications network.
    Preferences
    The technical storage or access is necessary for the legitimate purpose of storing preferences that are not requested by the subscriber or user.
    Statistics
    The technical storage or access that is used exclusively for statistical purposes. The technical storage or access that is used exclusively for anonymous statistical purposes. Without a subpoena, voluntary compliance on the part of your Internet Service Provider, or additional records from a third party, information stored or retrieved for this purpose alone cannot usually be used to identify you.
    Marketing
    The technical storage or access is required to create user profiles to send advertising, or to track the user on a website or across several websites for similar marketing purposes.
    Manage options Manage services Manage vendors Read more about these purposes
    View preferences
    {title} {title} {title}