You are not logged in.
Using the X-Service Broker configuration to collect X-HeatBeat files for replacing X-Notify.
Setting up the SendXNotifications to consume the X-HeartBeat files "X-Notify~nnnnnnnnnnnn.nnn.xml" in X-ServiceBroker configuration to replace X-Notify going forward.
I want to give credit to Sibu and Zwido for helping me on this.
Thanks you for helping me on this.....
The heartbeat is configured in the X-HBChecker Entities.xml file example below:
<MD name="ServerName">
<Entity type="XPress/Dispatch">
<Enabled>yes</Enabled>
<Timing poll="360" lag="2" />
<Notification enabled="yes" continuous="yes">
<Data>A :[TYPE]: Heartbeat for :[MD]: has :[STATUS]:</Data>
</Notification>
</Entity>
</MD>
When the server "MD" Server does not send a Heart Beat file to the Main XLayer Server that receives the X-HB files.
The X-HBChecker will create X-Notify~nnnnnnnnnnnn.nnn.xml file that is consumed by the X-Notify, going forward you can now disable X-Notify, once this is up and running. This will now be done in X-Service Broke with a Database.
The notification is now configured in the database and can be switched on or off.
You can also choose what type of notification you want to send to the recipients in the database.
The setup is divided into two sections:
Database Configuration.
X-ServiceBroker Configuration “SendXNotifications”.
The setup requirement is that you should have a MSSQL database running.
There are three tables as mentioned below which will be explained in detail in the database setup section steps and in the configuration setup section.
The DB tables will consist of the following tables
XNotification_SendMessageConfigtables.
XNotification_Clientstables.
XNotification_Signaltables.
Database Configuration:
Step.1 - Create a new Database and Call it XLayer using the following:
1. Open Microsoft SQL Management Studio.
2. Connect to the database engine using database administrator credentials.
3. Expand the server node.
4. Right click Database and click on New Database.
5. Enter a database name “XLayer” and click OK to create the database.
Step.2 - Create the XNotification_Signal table.
The XNotification_Signal table is designed with switches that can be turned ON or OFF in the table to send out notifications using SMS, Email and Slack with 1 as on and 0 as off.
The Slack switches is used to send a notification to SXI Slack Notifications #clientnotifications channel.
The XDec switch is used to enable the configuration to generate an Event doc to log a call to ITSM. (You will have to build this config, If you need an example I do have one available that is running at BCX".
The Non-Clustered Index on the table is to prevent any duplicate HBMessages.
The query below will create two examples in the database, one is a FAILED and the other one is REPAIRED for the HBMessage.
When setting up the XNotification_Signal with more HBMessage to the database you will have two HBMessage massages that is created by X-HBChecker manly a FAILED and a REPAIRED HBMessage.
Create the XNotification_Signal table with a Non-Clustered Index by executing the following query:
USE [XLayer]
GO
/****** Object: Table [dbo].[XNotification_Signal] ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[XNotification_Signal](
[Id] [int] IDENTITY(1,1) NOT NULL,
[MD] [nvarchar](max) NULL,
[Email] [int] NULL,
[XDec] [int] NULL,
[SMS] [int] NULL,
[Slack] [int] NULL,
[HBMessage] [varchar](320) NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
SET IDENTITY_INSERT [dbo].[XNotification_Signal] ON
INSERT [dbo].[XNotification_Signal] ([Id], [MD], [Email], [XDec], [SMS], [Slack], [HBMessage]) VALUES (1, N'ServerName', 1, 1, 0, 0, N'A XPress/Dispatch Heartbeat for ServerName has FAILED')
INSERT [dbo].[XNotification_Signal] ([Id], [MD], [Email], [XDec], [SMS], [Slack], [HBMessage]) VALUES (2, N'ServerName', 1, 1, 0, 0, N'A XPress/Dispatch Heartbeat for ServerName has REPAIRED')
SET IDENTITY_INSERT [dbo].[XNotification_Signal] OFF
SET ANSI_PADDING ON
GO
/****** Object: Index [NonClusteredIndex] ******/
CREATE UNIQUE NONCLUSTERED INDEX [NonClusteredIndex] ON [dbo].[XNotification_Signal]
(
[HBMessage] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
Step.3 - Create the XNotification_SendMessageConfig table.
The table is designed to have the details of the Recipients that will get the Notifications. Some of the fields that we collect recipients to send mails to is Full Name, CellNumber and email address.
The CellNumber is used to send SMS to Orion web service for SMS's (currently used at Gijima)
The Subject and Body are configurable and used as part of sending the email notification.
When sending an email notification, the ~#~ is used to make line break on the Body of the email.
Create the XNotification_SendMessageConfig by executing the following query:
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[XNotification_SendMessageConfig](
[Id] [int] IDENTITY(1,1) NOT NULL,
[MD] [nvarchar](max) NULL,
[FullName] [nvarchar](50) NULL,
[CellNumber] [nvarchar](50) NULL,
[Recipient] [nvarchar](max) NULL,
[HBMessage] [nvarchar](max) NULL,
[Subject] [nvarchar](max) NULL,
[Body] [nvarchar](max) NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
SET IDENTITY_INSERT [dbo].[XNotification_SendMessageConfig] ON
INSERT [dbo].[XNotification_SendMessageConfig] ([Id], [MD], [FullName], [CellNumber], [Recipient], [HBMessage], [Subject], [Body]) VALUES (1, N'ServerName', N'Stephan Booyzen', N'08212312345', N'stephan.booyzen@sxi.co.za', N'A XPress/Dispatch Heartbeat for ServerName has FAILED', N'XPress/Dispatch Heartbeat has failed for ServerName(Event Server @ The Client)', N'Good day,~#~~#~XPress/Dispatch Heartbeat has failed for ServerName(Event Server @ The Client)~#~~#~Yours in Service,~#~ITSM')
INSERT [dbo].[XNotification_SendMessageConfig] ([Id], [MD], [FullName], [CellNumber], [Recipient], [HBMessage], [Subject], [Body]) VALUES (2, N'ServerName', N'Sibusiso Skosana', N'08212312346', N'sibusiso.skosana@sxi.co.za', N'A XPress/Dispatch Heartbeat for ServerName has FAILED', N'XPress/Dispatch Heartbeat has failed for ServerName(Event Server @ The Client)', N'Good day,~#~~#~XPress/Dispatch Heartbeat has failed for ServerName(Event Server @ The Client)~#~~#~Yours in Service,~#~ITSM')
INSERT [dbo].[XNotification_SendMessageConfig] ([Id], [MD], [FullName], [CellNumber], [Recipient], [HBMessage], [Subject], [Body]) VALUES (3, N'ServerName', N'Zwidofhelangani Gabara', N'08212312347', N'zwido.gabara@sxi.co.za', N'A XPress/Dispatch Heartbeat for ServerName has FAILED', N'XPress/Dispatch Heartbeat has failed for ServerName(Event Server @ The Client)', N'Good day,~#~~#~XPress/Dispatch Heartbeat has failed for ServerName(Event Server @ The Client)~#~~#~Yours in Service,~#~ITSM')
INSERT [dbo].[XNotification_SendMessageConfig] ([Id], [MD], [FullName], [CellNumber], [Recipient], [HBMessage], [Subject], [Body]) VALUES (4, N'ServerName', N'Stephan Booyzen', N'08212312345', N'stephan.booyzen@sxi.co.za', N'A XPress/Dispatch Heartbeat for ServerName has REPAIRED', N'XPress/Dispatch Heartbeat has repaired for ServerName(Event Server @ The Client)', N'Good day,~#~~#~XPress/Dispatch Heartbeat has repaired for ServerName(Event Server @ The Client)~#~~#~Yours in Service,~#~ITSM')
INSERT [dbo].[XNotification_SendMessageConfig] ([Id], [MD], [FullName], [CellNumber], [Recipient], [HBMessage], [Subject], [Body]) VALUES (5, N'ServerName', N'Sibusiso Skosana', N'08212312346', N'sibusiso.skosana@sxi.co.za', N'A XPress/Dispatch Heartbeat for ServerName has REPAIRED', N'XPress/Dispatch Heartbeat has repaired for ServerName(Event Server @ The Client)', N'Good day,~#~~#~XPress/Dispatch Heartbeat has repaired for ServerName(Event Server @ The Client)~#~~#~Yours in Service,~#~ITSM')
INSERT [dbo].[XNotification_SendMessageConfig] ([Id], [MD], [FullName], [CellNumber], [Recipient], [HBMessage], [Subject], [Body]) VALUES (6, N'ServerName', N'Zwidofhelangani Gabara', N'08212312347', N'zwido.gabara@sxi.co.za', N'A XPress/Dispatch Heartbeat for ServerName has REPAIRED', N'XPress/Dispatch Heartbeat has repaired for ServerName(Event Server @ The Client)', N'Good day,~#~~#~XPress/Dispatch Heartbeat has repaired for ServerName(Event Server @ The Client)~#~~#~Yours in Service,~#~ITSM')
SET IDENTITY_INSERT [dbo].[XNotification_SendMessageConfig] OFF
Step.4 - Create the XNotification_Clients table.
The XNotification_Clients table is designed to have the server names and client names. This is to create the X-DEC document when the switch is enabled for XDec in the XNotification_Signal table. This is used to log the Events to the specific Client in ITSM.
The Non-Clustered Index on the table is to prevent any duplicate Server names in the Database.
USE [XLayer]
GO
/****** Object: Table [dbo].[XNotification_Clients] ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[XNotification_Clients](
[Id] [int] IDENTITY(1,1) NOT NULL,
[Server] [nvarchar](100) NULL,
[Client] [nvarchar](100) NULL
) ON [PRIMARY]
GO
SET IDENTITY_INSERT [dbo].[XNotification_Clients] ON
INSERT [dbo].[XNotification_Clients] ([Id], [Server], [Client]) VALUES (1, N'ServerName', N'Client')
SET IDENTITY_INSERT [dbo].[XNotification_Clients] OFF
SET ANSI_PADDING ON
GO
/****** Object: Index [NonClusteredIndex] ******/
CREATE UNIQUE NONCLUSTERED INDEX [NonClusteredIndex] ON [dbo].[XNotification_Clients]
(
[Server] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
X-ServiceBroker Configuration “SendXNotifications”:
<?xml version="1.0" encoding="iso-8859-1"?>
<Configuration xmlns="http://www.sxi.co.za/XMLSchema/StandardWorkflow" xmlns:sxi="http://www.sxi.co.za/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sxi.co.za/XMLSchema/StandardWorkflow ../../../schema/plugins/workflows/SendXNotification.xsd">
<sxi:Logging>
<sxi:Retention>7</sxi:Retention>
<sxi:Directory />
<sxi:Level>TRACE</sxi:Level>
<sxi:MaxFileSize>10</sxi:MaxFileSize>
</sxi:Logging>
<GlobalNotifications>
<Error enabled="no" dataDefinition="" transmitMethod="HIGH" destination="localhost" />
<General enabled="no" dataDefinition="Notifier" transmitMethod="LOW" destination="localhost" />
</GlobalNotifications>
<Heartbeats enabled="no">
<Destination>localhost</Destination>
<Interval>300</Interval>
</Heartbeats>
<Connectors>
<!-- SOAP Web Service to Send SMS for Gijima -->
<Connector id="SMSWEBConnector" type="SOAPWebService">
<Connection xsi:type="sxi:SOAPWebService">
<sxi:SOAPVersion>1.1</sxi:SOAPVersion>
<sxi:Namespaces>
<sxi:Namespace prefix="tem" uri="http://tempuri.org/"/>
</sxi:Namespaces>
<sxi:CustomHeaders>
<sxi:Header name="Content-Type" value="text/xml;charset=utf-8"/>
<sxi:Header name="Accept-Encoding" value="gzip,deflate"/>
<sxi:Header name="SOAPAction" value=""http://tempuri.org/SendSingleSMS""/>
</sxi:CustomHeaders>
<sxi:URL>http://172.25.82.95/UniserverLiveWeb/WebServices/UniserverLiveWebService.asmx</sxi:URL>
<sxi:Password/>
<sxi:Username/>
<sxi:RetryDelay>10</sxi:RetryDelay>
<sxi:Stylesheet>../../usr/stylesheets/SMSOut.xsl</sxi:Stylesheet>
<sxi:Timeout>30</sxi:Timeout>
<!-- SMSOut stylesheet for Gijima SMS -->
<!--
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:tem="http://tempuri.org/">
<soap:Header/>
<soap:Body>
<tem:SendSingleSMS>
<tem:PrmUserName><xsl:value-of select="//*[local-name()='UserName']"/></tem:PrmUserName>
<tem:PrmPassword><xsl:value-of select="//*[local-name()='Password']"/></tem:PrmPassword>
<tem:PrmMobileNumber><xsl:value-of select="//*[local-name()='cellNumber']"/></tem:PrmMobileNumber>
<tem:PrmSMSUserRef><xsl:value-of select="//*[local-name()='SMSUserRef']"/></tem:PrmSMSUserRef>
<tem:PrmMessageText><xsl:value-of select="//*[local-name()='message']"/></tem:PrmMessageText>
</tem:SendSingleSMS>
</soap:Body>
</soap:Envelope>
</xsl:template>
</xsl:stylesheet>
-->
</Connection>
<sxi:ReturnCodes>
<sxi:Success>
<sxi:Code>Success Code</sxi:Code>
<sxi:Code>.*200.*</sxi:Code>
</sxi:Success>
<sxi:RecoverableError>
<sxi:Code>Error Code</sxi:Code>
<sxi:Code>.*502.*</sxi:Code>
<sxi:Code>.*503.*</sxi:Code>
<sxi:Code>.*404*</sxi:Code>
<sxi:Code>.*Connection timed out.*+</sxi:Code>
<sxi:Code>.*404Not Found.*+</sxi:Code>
<sxi:Code>.*Message send failed.*+</sxi:Code>
<sxi:Code>Recoverable Error</sxi:Code>
<sxi:Code>Bad response:</sxi:Code>
</sxi:RecoverableError>
</sxi:ReturnCodes>
</Connector>
<!-- Collect X-Notify files -->
<Connector id="CollectXML" type="XML">
<Connection xsi:type="sxi:XML">
<sxi:RetryDelay>60</sxi:RetryDelay>
</Connection>
<sxi:ReturnCodes>
<sxi:Success>
<sxi:Code>Success Code</sxi:Code>
</sxi:Success>
<sxi:RecoverableError>
<sxi:Code>^.*FWK005.*$</sxi:Code>
</sxi:RecoverableError>
</sxi:ReturnCodes>
</Connector>
<!-- Create of X-DEC Event Doc's to Log a calls for a Heart Beat Events -->
<Connector id="XML" type="XML">
<Connection xsi:type="sxi:XML">
<sxi:Write>
<sxi:SaveLocation>E:\SXI\XPress\XmlOut</sxi:SaveLocation>
<sxi:FileName>X-DEC~CSS-XLAYER~%UNIQUE%.xml</sxi:FileName>
<sxi:Stylesheet>../../usr/stylesheets/CreateXDECDoc.xsl</sxi:Stylesheet>
</sxi:Write>
<sxi:RetryDelay>60</sxi:RetryDelay>
</Connection>
<sxi:ReturnCodes>
<sxi:Success>
<sxi:Code>Success Code</sxi:Code>
</sxi:Success>
<sxi:RecoverableError>
<sxi:Code>^.*FWK005.*$</sxi:Code>
</sxi:RecoverableError>
</sxi:ReturnCodes>
</Connector>
<!-- Create X-DEC Doc stylesheet for creating the X-Dec Event -->
<!-- Stylesheets for CreateXDECDoc.xsl
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" version="1.0" omit-xml-declaration="yes" indent="yes"/>
<xsl:template match="/">
<SouthernX>
<Agent_Class><xsl:value-of select="//*[local-name()='Agent_Class']"/></Agent_Class>
<ESMTool><xsl:value-of select="//*[local-name()='ESMTool']"/></ESMTool>
<MD><xsl:value-of select="//*[local-name()='MD']"/></MD>
<Agent_Instance><xsl:value-of select="//*[local-name()='Agent_Instance']"/></Agent_Instance>
<Server><xsl:value-of select="//*[local-name()='Server']"/></Server>
<Instance_Detail><xsl:value-of select="//*[local-name()='Instance_Detail']"/></Instance_Detail>
<Header><xsl:value-of select="//*[local-name()='Header']"/></Header>
<Date><xsl:value-of select="//*[local-name()='Date']"/></Date>
<Time><xsl:value-of select="//*[local-name()='Time']"/></Time>
<State><xsl:value-of select="//*[local-name()='State']"/></State>
<dest><xsl:value-of select="//*[local-name()='dest']"/></dest>
<UID><xsl:value-of select="//*[local-name()='UID']"/></UID>
<UserData><xsl:value-of select="//*[local-name()='UserData']"/></UserData>
<Client><xsl:value-of select="//*[local-name()='Client']"/></Client>
<Source><xsl:value-of select="//*[local-name()='Source']"/></Source>
</SouthernX>
</xsl:template>
-->
</xsl:stylesheet>
<!-- Send Notification Messages to SXI Slack #clientnotifications Channel -->
<Connector id="SlackConnector" type="RESTWebService">
<Connection xsi:type="sxi:RESTWebService">
<sxi:URL>https://hooks.slack.com/services/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</sxi:URL>
<sxi:DataTypeToSend>JSON</sxi:DataTypeToSend>
<sxi:RetryDelay>60</sxi:RetryDelay>
</Connection>
<sxi:ReturnCodes>
<sxi:Success>
<sxi:Code>Success Code</sxi:Code>
</sxi:Success>
<sxi:RecoverableError>
<sxi:Code>Recoverable Error</sxi:Code>
</sxi:RecoverableError>
</sxi:ReturnCodes>
</Connector>
<!-- Send Email Notification -->
<Connector id="Email" type="SMTP">
<Connection xsi:type="sxi:SMTP">
<sxi:Server>165.233.54.12</sxi:Server>
<sxi:User/>
<sxi:Password/>
<sxi:RetryDelay>10</sxi:RetryDelay>
<sxi:AuthType>Basic</sxi:AuthType>
<sxi:Port>25</sxi:Port>
<sxi:FromAddress>noreply@ourservicedesk.com</sxi:FromAddress>
</Connection>
<sxi:ReturnCodes>
<sxi:Success/>
<sxi:RecoverableError>
<sxi:Code>^Could\snot\sconnect\sto\sSMTP\shost.*</sxi:Code>
<sxi:Code>^.*Exception reading response.*$</sxi:Code>
</sxi:RecoverableError>
</sxi:ReturnCodes>
</Connector>
<!-- XLayerDB connector -->
<Connector id="XLayerDB" type="DB">
<Connection xsi:type="sxi:MSSQL">
<sxi:Server>10.220.7.61</sxi:Server>
<sxi:User>sxi</sxi:User>
<sxi:Password>sXi_pass</sxi:Password>
<sxi:RetryDelay>30</sxi:RetryDelay>
<sxi:DBName>XLayer</sxi:DBName>
<sxi:Port>1433</sxi:Port>
</Connection>
<sxi:ReturnCodes>
<sxi:Success />
<sxi:RecoverableError>
<sxi:Code>.+Read timed out.+</sxi:Code>
<sxi:Code>.*Invalid state.+</sxi:Code>
<sxi:Code>.*SHUTDOWN is in progress.+</sxi:Code>
<sxi:Code>I/O Error: Connection reset by peer: socket write error</sxi:Code>
</sxi:RecoverableError>
</sxi:ReturnCodes>
</Connector>
</Connectors>
<SignalRegistry xsi:type="sxi:SigReg.XML">
<sxi:ConnectorID>CollectXML</sxi:ConnectorID>
<sxi:FolderPath>../../XPress/XmlOut</sxi:FolderPath>
<!-- There is no Action Name in the X-Notify files form X-HBChecker, we going to using Send_X_Notification for the Action -->
<sxi:ActionElement>Send_X_Notification</sxi:ActionElement>
<sxi:FileName>^X-Notify~.*\.xml$</sxi:FileName>
<sxi:PollingDelay>1</sxi:PollingDelay>
<sxi:DeleteProcessed>no</sxi:DeleteProcessed>
</SignalRegistry>
<Actions>
<Action name="Send_X_Notification">
<Mappings>
<LogComment logLevel="TRACE" Comment="################################# Collect X-Notify XML File #################################"/>
<Collect dataDefinition="Collect_XML_Notification" connectorId="CollectXML" lookupField="NA" lookupValue="" source="../../XPress/XmlOut"/>
<!-- Test if the Message is in the Database by counting the HBMessage -->
<Collect dataDefinition="Cnt_Message" connectorId="XLayerDB" source="XNotification_Signal" lookupField="HBMessage" lookupValue="Message"
customQuery="SELECT COUNT(*) as Message_Count FROM XNotification_Signal where HBMessage = '~#~Message~#~' ">
<Conditions>
<Condition>
<When field="/*[local-name()='XServiceBroker' ]/*[local-name()='Message_Count']" operator="eq" value="0">
<LogComment logLevel="TRACE" Comment="################################# Write the MD and HBMessage to Database Table - XNotification_Signal #################################"/>
<!-- Write the MD and HBMessage to Database Table - XNotification_Signal -->
<Create dataDefinition="Write_Notification" connectorId="XLayerDB" source="XNotification_Signal"/>
<!-- The Get_MD is to collect the MD form the <Message> tag in the X-Notify XML files for the Collect to use a Custom Query to count Exiting the Recipient To Send Mail To -->
<MemoryDataManipulation dataDefinition="Get_MD"/>
<!-- A Email will be send to the Default Recipient, when the Notifications is not configured the Database -->
<Collect dataDefinition="CntExitingRecipientToSendMailTo" connectorId="XLayerDB" source="XNotification_SendMessageConfig" lookupField="HBMessage" lookupValue="Message"
customQuery="Select COUNT (*) as Recipient_Count from XNotification_SendMessageConfig where HBMessage = '~#~Message~#~'">
<Conditions>
<Condition>
<!-- Check if Recipient is configured in the Database -->
<When field="/*[local-name()='XServiceBroker' ]/*[local-name()='Recipient_Count']" operator="gt" value="0">
<LogComment logLevel="TRACE" Comment="################################# The Recipient is configured in the Database #################################"/>
<!-- If the Recipient exists in the Database, Send a Email to Recipient using the configured Email Addresses from the Database -->
<Create dataDefinition="Send_XNotification" connectorId="Email" source="NA" optional="no" />
<!-- The Output Memory To Log can be disabled, this is just to see what is in memory at this stage -->
<OutputMemoryToLog/>
</When>
<Otherwise>
<!-- The Recipient does not exist in the Database, use the configured Email Addresses from the Data Definition "SendEmailToDefaultRecipient" to send Emails -->
<LogComment logLevel="TRACE" Comment="################################# The Notification is not configured in the Database, Please configure it. #################################"/>
<Create dataDefinition="SendEmailToDefaultRecipient" connectorId="Email" source="NA"/>
<!-- The Output Memory To Log can be disabled, this is just to see what is in memory at this stage -->
<OutputMemoryToLog/>
</Otherwise>
</Condition>
</Conditions>
</Collect>
</When>
<Otherwise>
<!-- Check what Notification will be send from the Database XNotification_Signal tabel using the HBMessage received form the X-Notify files, with a Custom Query from the Database -->
<Collect dataDefinition="GetSignalData" connectorId="XLayerDB" source="XNotification_Signal" lookupField="HBMessage" lookupValue="Message"
customQuery="SELECT * FROM XNotification_Signal WHERE HBMessage = '~#~Message~#~'" >
<Conditions>
<Condition>
<!-- Check if the Slack switch in the Database is 'ON'=1 or 'OFF'=0. To send the Slack Message the switch must be 'ON'=1 -->
<When field="//*[local-name()='Slack']" operator="eq" value="1">
<!-- Set the Memory Data Manipulation for Slack Notification if we are going to Send the Slack Message to SXI #clientnotifications Channel -->
<MemoryDataManipulation dataDefinition="SendSlackMessage"/>
<!-- Send a Slack Message to SXI #clientnotifications Channel -->
<LogComment Comment="################################# Notification was Send to SXI #clientnotifications Channel on Slack #################################"/>
<Create dataDefinition="SendSlackMessage" connectorId="SlackConnector" source="POST"/>
</When>
<!-- Check if the XDec switch in the Database is 'ON'=1 or 'OFF'=0. To Create X-DEC file for a Event to ITSM the switch must be 'ON'=1 -->
<When field="//*[local-name()='XDec']" operator="eq" value="1">
<Collect dataDefinition="CollectClient" connectorId="XLayerDB" source="XNotification_Clients" lookupField="Server" lookupValue="MD">
<Conditions>
<Condition>
<When field="//*[local-name()='Server']" operator="DoesNotMatch" value="0">
<!-- The Output Memory To Log can be disabled, this is just to see what is in memory at this stage -->
<OutputMemoryToLog/>
<LogComment Comment="################################# The XDec Switch in the Database is On to Create the X-DEC #################################"/>
<!-- The X-DEC doc will be created here to log a call in to ITSM or to Resolve the calls in ITSM -->
<Create dataDefinition="Create_XDEC" connectorId="XML" source="E:\SXI\XPress\XmlOut"/>
</When>
<Otherwise>
<LogComment Comment="################################# The MD Doesn't exist in the Database!! #################################"/>
</Otherwise>
</Condition>
</Conditions>
</Collect>
</When>
<!-- Check if the SMS switch in the Database is 'ON'=1 or 'OFF'=0. To Send a SMS the switch must be 'ON'=1. -->
<When field="//*[local-name()='SMS']" operator="eq" value="1">
<ApplyStyleSheetToMemoryContents stylesheetFolder="E:\SXI\usr\stylesheets\" stylesheet="removeXMLUnprintableChars.xsl"></ApplyStyleSheetToMemoryContents>
<LogComment Comment="################################# The SMS Database Switch is On to Send the SMS #################################"/>
<Collect dataDefinition="CollectSMS" connectorId="XLayerDB" source="XNotification_SendMessageConfig" lookupField="HBMessage" lookupValue="HBMessage"
customQuery="SELECT * FROM XNotification_SendMessageConfig WHERE HBMessage = '~#~HBMessage~#~'" />
<!-- Send a SMS to the CellNumber from the Database by Posting to the SMS WEB Service -->
<Create dataDefinition="SendSMS" connectorId="SMSWEBConnector" source="POST"/>
</When>
<!-- Check if the Email switch in the Database is 'ON'=1 or 'OFF'=0. To Send a Email to Recipients the switch must be 'ON'=1. -->
<When field="//*[local-name()='mEmail']" operator="eq" value="1">
<LogComment Comment="################################# The Email Database Switch is On to Send the Email #################################"/>
<Collect dataDefinition="CntExitingRecipientToSendMailTo" connectorId="XLayerDB" source="XNotification_SendMessageConfig" lookupField="HBMessage" lookupValue="HBMessage"
customQuery="Select COUNT (*) as Recipient_Count from XNotification_SendMessageConfig where HBMessage = '~#~HBMessage~#~'">
<Conditions>
<Condition>
<!-- Check the number of Recipients returned from the Databse XNotification_SendMessageConfig table, a Email will be send to each Recipient -->
<When field="/*[local-name()='XServiceBroker' ]/*[local-name()='Recipient_Count']" operator="gt" value="0">
<!-- Collect the Email addresses form the Database to send notifications to the Recipients -->
<Collect dataDefinition="GetPeopleToSendNotificationDetails" connectorId="XLayerDB" source="XNotification_SendMessageConfig" lookupField="MD" lookupValue="MD"
customQuery="SELECT * from XNotification_SendMessageConfig where HBMessage = '~#~HBMessage~#~'"/>
<LogComment logLevel="TRACE" Comment="################################# Send Notification Message to Email - ~#~Recipient~#~ #################################"/>
<!-- Send Email to collected Recipients addresses -->
<Create dataDefinition="Send_XNotification" connectorId="Email" source="NA" optional="no" />
</When>
<Otherwise>
<!-- The Recipient does not exist in the Database, use the configured Email Addresses from the Data Definition "SendEmailToDefaultRecipient" to send Emails -->
<LogComment logLevel="TRACE" Comment="################################# Send Notification Message to Default User #################################"/>
<Create dataDefinition="SendEmailToDefaultRecipient" connectorId="Email" source="NA"/>
</Otherwise>
</Condition>
</Conditions>
</Collect>
</When>
</Condition>
</Conditions>
</Collect>
</Otherwise>
</Condition>
</Conditions>
</Collect>
</Mappings>
</Action>
</Actions>
<sxi:DataDefinitions>
<!-- Collect X-Notify XML file -->
<sxi:DataDefinition name="Collect_XML_Notification">
<sxi:Fields>
<sxi:Field name="//*[local-name()='Message']">
<sxi:OutputField>Message</sxi:OutputField>
</sxi:Field>
<!-- MD is collected form the <Message> tag in the X-Notify XML files -->
<sxi:Field name="//*[local-name()='Message']">
<sxi:Rules>
<sxi:Split>
<sxi:Delimiter>\sfor\s</sxi:Delimiter>
<sxi:OutputFields>
<sxi:OutputField index="1">TempMD</sxi:OutputField>
</sxi:OutputFields>
</sxi:Split>
</sxi:Rules>
<sxi:OutputField>Omit</sxi:OutputField>
</sxi:Field>
<sxi:Field name="TempMD">
<sxi:Rules>
<sxi:Split>
<sxi:Delimiter>\shas\s| </sxi:Delimiter>
<sxi:OutputFields>
<sxi:OutputField index="0">mMD</sxi:OutputField>
</sxi:OutputFields>
</sxi:Split>
</sxi:Rules>
<sxi:OutputField>Omit</sxi:OutputField>
</sxi:Field>
<sxi:Field name="mMD">
<sxi:OutputField>MD</sxi:OutputField>
</sxi:Field>
</sxi:Fields>
</sxi:DataDefinition>
<!-- Define Message Count -->
<sxi:DataDefinition name="Cnt_Message">
<sxi:Fields>
<sxi:Field name="Message_Count">
<sxi:OutputField>Message_Count</sxi:OutputField>
</sxi:Field>
</sxi:Fields>
</sxi:DataDefinition>
<!-- Write X-Notify XML files collected to the Database table -->
<sxi:DataDefinition name="Write_Notification">
<sxi:Fields>
<sxi:Field name="//*[local-name()='Message']">
<sxi:OutputField>HBMessage</sxi:OutputField>
</sxi:Field>
<!-- MD is collect form the <Message> tag in the X-Notify XML files -->
<!-- <Message>A XPress/Dispatch Heartbeat for NDCVCFGMGRP01 has FAILED</Message> -->
<sxi:Field name="//*[local-name()='Message']">
<sxi:Rules>
<sxi:Split>
<sxi:Delimiter>\sfor\s</sxi:Delimiter>
<sxi:OutputFields>
<sxi:OutputField index="1">TempMD</sxi:OutputField>
<!-- TempMD = "NDCVCFGMGRP01 has FAILED" -->
</sxi:OutputFields>
</sxi:Split>
</sxi:Rules>
<sxi:OutputField>Omit</sxi:OutputField>
</sxi:Field>
<sxi:Field name="TempMD">
<sxi:Rules>
<sxi:Split>
<sxi:Delimiter>\shas\s| </sxi:Delimiter>
<sxi:OutputFields>
<sxi:OutputField index="0">mMD</sxi:OutputField>
<!-- mMD = "NDCVCFGMGRP01" -->
</sxi:OutputFields>
</sxi:Split>
</sxi:Rules>
<sxi:OutputField>Omit</sxi:OutputField>
</sxi:Field>
<!-- MD = "NDCVCFGMGRP01" -->
<sxi:Field name="mMD">
<sxi:OutputField>MD</sxi:OutputField>
</sxi:Field>
<sxi:Field name="Email">
<sxi:Rules>
<sxi:Default>1</sxi:Default>
</sxi:Rules>
<sxi:OutputField>Email</sxi:OutputField>
</sxi:Field>
</sxi:Fields>
</sxi:DataDefinition>
<!-- Strip out the MD from the Message -->
<!-- <Message>A XPress/Dispatch Heartbeat for NDCVCFGMGRP01 has FAILED</Message> -->
<sxi:DataDefinition name="Get_MD">
<sxi:Fields>
<sxi:Field name="//*[local-name()='Message']">
<sxi:Rules>
<sxi:Split>
<sxi:Delimiter>\sfor\s</sxi:Delimiter>
<sxi:OutputFields>
<sxi:OutputField index="1">TempMD</sxi:OutputField>
<!-- TempMD = "NDCVCFGMGRP01 has FAILED" -->
</sxi:OutputFields>
</sxi:Split>
</sxi:Rules>
<sxi:OutputField>Omit</sxi:OutputField>
</sxi:Field>
<sxi:Field name="TempMD">
<sxi:Rules>
<sxi:Split>
<sxi:Delimiter>\shas\s| </sxi:Delimiter>
<sxi:OutputFields>
<sxi:OutputField index="0">mMD</sxi:OutputField>
<!-- mMD = "NDCVCFGMGRP01" -->
</sxi:OutputFields>
</sxi:Split>
</sxi:Rules>
<sxi:OutputField>Omit</sxi:OutputField>
</sxi:Field>
<!-- MD = "NDCVCFGMGRP01" -->
<sxi:Field name="mMD">
<sxi:OutputField>MD</sxi:OutputField>
</sxi:Field>
</sxi:Fields>
</sxi:DataDefinition>
<!-- Count Exiting Recipients to send mail to -->
<sxi:DataDefinition name="CntExitingRecipientToSendMailTo">
<sxi:Fields>
<sxi:Field name="Recipient_Count">
<sxi:OutputField>Recipient_Count</sxi:OutputField>
</sxi:Field>
</sxi:Fields>
</sxi:DataDefinition>
<!-- Send XNotification mails to the recipients form the Database -->
<sxi:DataDefinition name="Send_XNotification">
<sxi:Fields>
<sxi:Field name="Recipient">
<sxi:OutputField datatype="recipients">To</sxi:OutputField>
</sxi:Field>
<sxi:Field name="Message">
<sxi:OutputField>Subject</sxi:OutputField>
</sxi:Field>
<sxi:Field name="Body">
<sxi:OutputField>Body</sxi:OutputField>
</sxi:Field>
<sxi:Field name="cellNumber">
<sxi:OutputField>cellNumber</sxi:OutputField>
</sxi:Field>
<sxi:Field name="FullName">
<sxi:OutputField>FullName</sxi:OutputField>
</sxi:Field>
</sxi:Fields>
</sxi:DataDefinition>
<!-- Send Email To Default Email recipients -->
<!-- A Email will be send to the Default Recipient, when the Notifications is not configured the Database -->
<sxi:DataDefinition name="SendEmailToDefaultRecipient">
<sxi:Fields>
<sxi:Field name="EmailAddress">
<sxi:Rules>
<!-- Add Default the Email recipients that needs to be notified when the Notifications is not configured in the Database -->
<sxi:Default>stephan.booyzen@sxi.co.za,sibusiso.skosana@sxi.co.za</sxi:Default>
</sxi:Rules>
<sxi:OutputField datatype="recipients">To</sxi:OutputField>
</sxi:Field>
<sxi:Field name="Message">
<sxi:OutputField>Subject</sxi:OutputField>
</sxi:Field>
<sxi:Field name="Body">
<sxi:Rules>
<sxi:Concatenation>
<sxi:Delimiter/>
<sxi:Fields>
<sxi:Field staticValue="yes">Good day,

</sxi:Field>
<sxi:Field staticValue="yes">Please take note that the Notification is not configured in the Database.</sxi:Field>
<sxi:Field staticValue="yes">
"</sxi:Field>
<sxi:Field>Message</sxi:Field>
<sxi:Field staticValue="yes">"</sxi:Field>
<sxi:Field staticValue="yes">
</sxi:Field>
<sxi:Field staticValue="yes">Please configure the Notification in the XLayer Database.
</sxi:Field>
<sxi:Field staticValue="yes">
</sxi:Field>
<sxi:Field staticValue="yes">Kind regards,
</sxi:Field>
<sxi:Field staticValue="yes">SXI Team</sxi:Field>
</sxi:Fields>
</sxi:Concatenation>
<sxi:Substitute>
<sxi:Find>null</sxi:Find>
<sxi:Replace></sxi:Replace>
</sxi:Substitute>
</sxi:Rules>
<sxi:OutputField>Body</sxi:OutputField>
</sxi:Field>
</sxi:Fields>
</sxi:DataDefinition>
<!-- Collect Signal Data from Database -->
<sxi:DataDefinition name="GetSignalData">
<sxi:Fields>
<sxi:Field name="Id">
<sxi:OutputField>Id</sxi:OutputField>
</sxi:Field>
<sxi:Field name="MD">
<sxi:OutputField>MD</sxi:OutputField>
</sxi:Field>
<sxi:Field name="HBMessage">
<sxi:OutputField>HBMessage</sxi:OutputField>
</sxi:Field>
<sxi:Field name="XDec">
<sxi:OutputField>XDec</sxi:OutputField>
</sxi:Field>
<sxi:Field name="SMS">
<sxi:OutputField>SMS</sxi:OutputField>
</sxi:Field>
<sxi:Field name="Email">
<sxi:OutputField>mEmail</sxi:OutputField>
</sxi:Field>
<sxi:Field name="Slack">
<sxi:OutputField>Slack</sxi:OutputField>
</sxi:Field>
</sxi:Fields>
</sxi:DataDefinition>
<!-- Set variable for the XNotification Message to Slack -->
<sxi:DataDefinition name="SendSlackMessage">
<sxi:Fields>
<sxi:Field name="//*[local-name()='Message']">
<sxi:Rules/>
<sxi:OutputField>MESSAGE</sxi:OutputField>
</sxi:Field>
<sxi:Field name="TempMessage">
<sxi:Rules>
<sxi:Concatenation>
<sxi:Delimiter/>
<sxi:Fields>
<!-- The static value is to know form what Client the Notification is coming from in the SXI Slack #clientnotifications Channel -->
<sxi:Field staticValue="yes">BCX Heart Beat Notification - </sxi:Field>
<sxi:Field>MESSAGE</sxi:Field>
</sxi:Fields>
</sxi:Concatenation>
</sxi:Rules>
<sxi:OutputField>text</sxi:OutputField>
</sxi:Field>
</sxi:Fields>
</sxi:DataDefinition>
<!-- Collect Server and Client from Database -->
<sxi:DataDefinition name="CollectClient">
<sxi:Fields>
<sxi:Field name="Server">
<sxi:OutputField>Server</sxi:OutputField>
</sxi:Field>
<sxi:Field name="Client">
<sxi:OutputField>Client</sxi:OutputField>
</sxi:Field>
</sxi:Fields>
</sxi:DataDefinition>
<!-- Create a Event doc to log a call in ITSM -->
<sxi:DataDefinition name="Create_XDEC">
<sxi:Fields>
<!-- <Agent_Class>X-HBChecker</Agent_Class> -->
<sxi:Field name="Agent_Class">
<sxi:Rules>
<sxi:Default>X-HBChecker</sxi:Default>
</sxi:Rules>
<sxi:OutputField>Agent_Class</sxi:OutputField>
</sxi:Field>
<!-- <ESMTool>X-HBChecker</ESMTool> -->
<sxi:Field name="ESMTool">
<sxi:Rules>
<sxi:Default>X-HBChecker</sxi:Default>
</sxi:Rules>
<sxi:OutputField>ESMTool</sxi:OutputField>
</sxi:Field>
<!-- <MD>CSS-XLAYER</MD> -->
<sxi:Field name="TempMD">
<sxi:Rules>
<sxi:Default>CSS-XLAYER</sxi:Default>
</sxi:Rules>
<sxi:OutputField>MD</sxi:OutputField>
</sxi:Field>
<!-- Agent_Instance - <Message>XPress/Dispatch Heartbeat has failed for $$$$$$$$($$$$$$ Server @ $$$$$$)</Message> -->
<sxi:Field name="Message">
<sxi:Rules>
<sxi:Split>
<sxi:Delimiter>\shas\s</sxi:Delimiter>
<sxi:OutputFields>
<sxi:OutputField index="0">Agent_Instance</sxi:OutputField>
</sxi:OutputFields>
</sxi:Split>
</sxi:Rules>
<sxi:OutputField>Omit</sxi:OutputField>
</sxi:Field>
<!-- Server -->
<sxi:Field name="mMD">
<sxi:OutputField>Server</sxi:OutputField>
</sxi:Field>
<sxi:Field name="Message">
<sxi:OutputField>Instance_Detail</sxi:OutputField>
</sxi:Field>
<sxi:Field name="Header">
<sxi:Rules>
<sxi:Default>X-CALL</sxi:Default>
</sxi:Rules>
<sxi:OutputField>Header</sxi:OutputField>
</sxi:Field>
<sxi:Field name="Date">
<sxi:Rules>
<!-- <Date>01/06/2020</Date> -->
<sxi:InsertDateTime OutputDateFormat="MM/dd/yyyy"/>
</sxi:Rules>
<sxi:OutputField>Date</sxi:OutputField>
</sxi:Field>
<sxi:Field name="Time">
<sxi:Rules>
<sxi:InsertDateTime OutputDateFormat="HH:mm:ss"/>
</sxi:Rules>
<sxi:OutputField>Time</sxi:OutputField>
</sxi:Field>
<sxi:Field name="Message">
<sxi:Rules>
<sxi:Split>
<sxi:Delimiter>\shas\s</sxi:Delimiter>
<sxi:OutputFields>
<sxi:OutputField index="1">State</sxi:OutputField>
</sxi:OutputFields>
</sxi:Split>
</sxi:Rules>
<sxi:OutputField>State</sxi:OutputField>
</sxi:Field>
<!-- <Destination>127.0.0.1</Destination> -->
<sxi:Field name="Destination">
<sxi:Rules>
<sxi:Default>127.0.0.1</sxi:Default>
</sxi:Rules>
<sxi:OutputField>dest</sxi:OutputField>
</sxi:Field>
<!-- UID - Concatenation of (MD, Server, AgentClass, AgentInstance) -->
<sxi:Field name="tmpUID0">
<sxi:Rules>
<sxi:Concatenation>
<sxi:Delimiter/>
<sxi:Fields>
<sxi:Field>MD</sxi:Field>
<sxi:Field>Server</sxi:Field>
<sxi:Field>Agent_Class</sxi:Field>
<sxi:Field>Agent_Instance</sxi:Field>
</sxi:Fields>
</sxi:Concatenation>
</sxi:Rules>
<sxi:OutputField>tmpUID1</sxi:OutputField>
</sxi:Field>
<!-- Generate MD5Hash of above Concatenation -->
<sxi:Field name="tmpUID1">
<sxi:Rules>
<sxi:MD5Hash/>
</sxi:Rules>
<sxi:OutputField>UID</sxi:OutputField>
</sxi:Field>
<sxi:Field name="Message">
<sxi:OutputField>UserData</sxi:OutputField>
</sxi:Field>
<!-- <Action>Create</Action> -->
<sxi:Field name="Action">
<sxi:Rules>
<sxi:Default>Create</sxi:Default>
</sxi:Rules>
<sxi:OutputField>Action</sxi:OutputField>
</sxi:Field>
<sxi:Field name="Client">
<sxi:OutputField>Client</sxi:OutputField>
</sxi:Field>
<!-- <Source>X-Notify</Source> -->
<sxi:Field name="Source">
<sxi:Rules>
<sxi:Default>X-HBChecker</sxi:Default>
</sxi:Rules>
<sxi:OutputField>Source</sxi:OutputField>
</sxi:Field>
</sxi:Fields>
</sxi:DataDefinition>
<!-- Collect Cell Number to send the SMS to -->
<sxi:DataDefinition name="CollectSMS">
<sxi:Fields>
<sxi:Field name="//*[local-name()='cellNumber']">
<sxi:Rules/>
<sxi:OutputField>cellNumber</sxi:OutputField>
</sxi:Field>
<sxi:Field name="//*[local-name()='message']">
<sxi:Rules>
<sxi:Length>160</sxi:Length>
</sxi:Rules>
<sxi:OutputField>message</sxi:OutputField>
</sxi:Field>
</sxi:Fields>
</sxi:DataDefinition>
<!-- Send SMS message -->
<sxi:DataDefinition name="SendSMS">
<sxi:Fields>
<sxi:Field name="UserName">
<sxi:Rules>
<sxi:Default>xlayer</sxi:Default>
</sxi:Rules>
<sxi:OutputField>UserName</sxi:OutputField>
</sxi:Field>
<sxi:Field name="Password">
<sxi:Rules>
<sxi:Default>xlayer</sxi:Default>
</sxi:Rules>
<sxi:OutputField>Password</sxi:OutputField>
</sxi:Field>
<sxi:Field name="cellNumber">
<sxi:Rules />
<sxi:OutputField>cellNumber</sxi:OutputField>
</sxi:Field>
<sxi:Field name="message">
<sxi:Rules>
<sxi:Length>160</sxi:Length>
</sxi:Rules>
<sxi:OutputField>message</sxi:OutputField>
</sxi:Field>
</sxi:Fields>
</sxi:DataDefinition>
<!-- Define EMail Address form the Database -->
<sxi:DataDefinition name="GetPeopleToSendNotificationDetails">
<sxi:Fields>
<sxi:Field name="MD">
<sxi:OutputField>MD</sxi:OutputField>
</sxi:Field>
<sxi:Field name="FullName">
<sxi:OutputField>FullName</sxi:OutputField>
</sxi:Field>
<sxi:Field name="CellNumber">
<sxi:OutputField>CellNumber</sxi:OutputField>
</sxi:Field>
<sxi:Field name="Recipient">
<sxi:OutputField>Recipient</sxi:OutputField>
</sxi:Field>
<!-- Body of the Mail -->
<!-- "~#~" is used in the data in the Database to create a nice the mail massage to the Recipient by replacing the "~#~" with "
" carriage-return using the Substitute rule -->
<!-- Example data from the Database: "Good day,~#~~#~XPress/Dispatch Heartbeat has failed for ServerName(Event Server @ The Client)~#~~#~Yours in Service,~#~ITSM" -->
<!-- The Body of the Mail will look like the following when receiving the Mail Notification -->
<!--
Good day,
XPress/Dispatch Heartbeat has failed for ServerName(Event Server @ The Client)
Yours in Service,
ITSM
-->
<sxi:Field name="Body">
<sxi:Rules>
<sxi:Substitute>
<sxi:Find>~#~</sxi:Find>
<sxi:Replace>
</sxi:Replace>
</sxi:Substitute>
</sxi:Rules>
<sxi:OutputField>Body</sxi:OutputField>
</sxi:Field>
<sxi:Field name="Subject">
<sxi:OutputField>Subject</sxi:OutputField>
</sxi:Field>
</sxi:Fields>
</sxi:DataDefinition>
</sxi:DataDefinitions>
</Configuration>
Please feel free to test this, if you have any better suggestion please share it here with us.
Zwido, Sibu and Steph.
Last edited by StephanB (27-02-2022 09:39:57)
Offline