SXI Forum

A place to collect usefull tips, tricks and implementation strategies.

You are not logged in.

#1 Re: HOWTOS » X-EventCollector ReadNewOnly Does not work » 25-04-2024 10:51:53

When using Red Hat Open JDK with XLayer V2.
To address the issue with X-EventCollector not work, edit the java.policy file which can be found in the C:\SXI\jre\jre\lib\security directory.

Add the following line to the bottom of the grant { section.

permission org.apache.derby.security.SystemPermission "engine", "usederbyinternals";

Your policy file should end looking something like this:

permission java.util.PropertyPermission "sun.security.pkcs11.disableKeyExtraction", "read";
permission org.apache.derby.security.SystemPermission "engine", "usederbyinternals";       
};

#2 Utils and Useful little tools » iPerf3 is a tool for measure bandwidth on IP networks. » 21-11-2023 12:01:04

StephanB
Replies: 0

iPerf3 is a tool to measure the maximum achievable bandwidth on IP networks.
https://iperf.fr/

#3 Utils and Useful little tools » IIS Crypto is a free tool » 07-10-2022 11:18:30

StephanB
Replies: 0

IIS Crypto is a free tool that gives administrators the ability to enable or disable protocols, ciphers, hashes and key exchange algorithms on Windows Server 2008, 2012, 2016 and 2019.
It also lets you reorder SSL/TLS cipher suites offered by IIS, change advanced settings, implement Best Practices with a single click, create custom templates and test your website.
https://www.nartac.com/Products/IISCrypto

#4 HOWTOS » Debugging SSL Connections with X-Service Broker » 22-04-2022 21:49:44

StephanB
Replies: 0

Debugging SSL Connections problems with X-Service Broker can sometimes be difficult, especially when it is not clear what messages are actually being sent and received.

The X-Service Broker has a built-in debug facility and is activated by changing VM options in the X-ServiceBroker.vmoptions file located in the X:\SXI\X-ServiceBroker\bin folder.
The file looks like this:

# Enter one VM parameter per line
# For example, to adjust the maximum memory usage to 512 MB, uncomment the following line:
# To include another file, uncomment the following line:
# -include-options [path to other .vmoption file]

By add in "-Djavax.net.debug=ssl:handshake:keymanager:trustmanager:plaintext" to the file we can be able to see what messages are actually being sent and received in the X-ServiceBroker.StdOut_nnnnnnnn.log file located the this folder $\SXI\X-ServiceBroker\logs
Please take note the log file size will grow very fast when using the debugging op in the VM options file.

Here is how to Read the Debug output log file.

To turn on SSL/TSL debugging in X-ServiceBroker.vmoptions file use this -Djavax.net.debug:ssl 
The following parameters can be used with SSL/TLS Debugging:

record			"Enable per-record tracing"
handshake		"Print each handshake message"
keygen			"Print key generation data"
session			"Print session activity"
defaultctx		"Print default SSL initialization"
sslctx			"Print SSL Context tracing"
sessioncache		"Print session cache tracing"
keymanager		"Print key manager tracing"
trustmanagerprint	"Trust manager tracing"
pluggability		"Print pluggability tracing"

Handshake debugging can be widened with:

data		"hex dump of each handshake message"
verbose		"verbose handshake message printing"

Record debugging can be widened with:

plaintext	"hex dump of record plaintext"
packet		"print raw SSL packets"

The Debugging SSL Connections parameters can be used as following to display specific levels of detail in the log file. :

-Djavax.net.debug=ssl:record

or

-Djavax.net.debug=ssl:handshake

Here is an example to specify more than one option in X-ServiceBroker.vmoptions file. : 

-Djavax.net.debug=ssl:keymanager:record

#5 HOWTOS » Fixing a Certificate that has no keychain in the Certificate. » 22-02-2022 20:33:17

StephanB
Replies: 0

Fixing a Certificate Chain with DigiCert Certificate Utility to use with Tomcat / XLayer API.
In this case we will be using a Wildcard Certificate "*.client.com" that does not have the full keychain.
Use the the following steps to fix the Wildcard Certificate keychain for all DigiCert Certificate:

  1. Download the DigiCert Certificate Utility from DigiCert.

  2. Open the DigiCert Certificate Utility and Click on Import

    ImportCrt

  3. Browse to where you have saved the Certificate you received from the Client.

    ImportCrt1

  4. In this case the file name is "client_wildcard_new.pfx" select the file and click Open.

    ImportCrt2

  5. The wizard will assist you with importing the Certificate, Click Next.

    ImportCrt3

  6. Enter the password you received from the Client, then Click Next.

    ImportCrt4

  7. The following screen will appear with the Name, Serial number, etcetera.. Don't change anything, Click Finish.

    ImportCrt5

  8. The following message will appear saying You have successfully imported the Certificate to DigiCert Certificate Utility, Click OK.

    ImportCrt6

  9. Click on the Lock SSL on the left side.

    ImportCrt7

  10. Now we going to Export the Certificate to use with Tomcat / XLayer API.
    Click on the SSL Certificate you want to Export, when you click on the Certificate it will highlight the line.
    In this case it will be the one at the top, then Click on Export Certificate.

    ExportCrt1

  11. The Certificate Export screen will appear, Don't change anything.
    The fille will be saved as a "pfx" file, Click on Next.

    ExportCrt2

  12. Now we going to add a Password to the Certificate we exporting.
    You need to take note of this Password you going to use here.
    This Password you entered will be used going forward to import the Certificate in to Tomcat / XLayer API, Click on Next.

    ExportCrt3

  13. Browse to where you what to save the Certificate, by clicking on the the three dots.
    In this cases the file name used is "wildcard_client_com.pfx", the file will be saved as a "pfx" file extension, Click on Finish.

    ExportCrt4

  14. The following message will appear saying You have successfully exported the Certificate, Click OK.

    ExportCrt5

  15. Now you can close the DigiCert Certificate Utility App and use the pfx file you exported in step 13 with Tomcat / XLayer API.
    ExportCrt6

    Done.

#6 Utils and Useful little tools » PortQryUI is a graphical front end to Query Port. » 20-01-2022 15:49:46

StephanB
Replies: 0

PortQryUI is a graphical front end to Query Port.

The PortQueryUI contains several predefined sets of queries to check the availability of the popular Microsoft services:

  • Domain and trusts (checking ADDS services on an Active Directory domain controller)

  • Exchange Server

  • SQL Server

  • Networking

  • IP Sec

  • Web Server

  • Net Meeting

PortQryUI - https://www.microsoft.com/en-us/downloa … x?id=24009

#7 General Discussion » MSSQL - DATEPART() function to get the integer value of datetime » 02-09-2021 20:15:31

StephanB
Replies: 0

The DATEPART() function returns a specified part of a datetime, this function returns the result as an integer value.
Example will give you only the data entries with the date of 2021-01-01:

SELECT [Flag],
       [Epoc],
       [Date],
       [Action],
       [EID],
       [UID] 
FROM MyTable 
WHERE DATEPART(year,[Date]) = '2021' and  DATEPART(month,[Date]) = '01' and DATEPART(day,[Date]) = '01'

#8 Re: HOWTOS » Using a regex on a Substitute Rules » 22-04-2021 08:05:20

Yes, when we get the following two values and do a split on the "\" and ":" we get Index 0.
"RFSSQL21\SQL1QBS" -----> RFSSQL21 = Index 0
"BDHPAM02Source:BJHVMH01" -----> BDHPAM02Source = Index 0, 
I need the "BJHVMH01" value by doing a substitute find replace with the regex "^(.*?)\:" will give the correct value "BJHVMH01"

Example :

        <sxi:Field name="mServer">
          <sxi:Rules>
            <sxi:Split>
              <sxi:Delimiter>\\</sxi:Delimiter>
              <sxi:OutputFields>
                <sxi:OutputField index="0">TmpServer</sxi:OutputField>
              </sxi:OutputFields>
            </sxi:Split>
            <sxi:TrimAllBlanks/>
          </sxi:Rules>
          <sxi:OutputField>Omit</sxi:OutputField>
        </sxi:Field>
        <sxi:Field name="TmpServer">
          <sxi:Rules>
            <sxi:Substitute>
              <sxi:Find>^(.*?)\:</sxi:Find>
              <sxi:Replace></sxi:Replace>
            </sxi:Substitute>
          </sxi:Rules>
          <sxi:OutputField>Server</sxi:OutputField>
        </sxi:Field>

#9 HOWTOS » Using a regex on a Substitute Rules » 21-04-2021 16:37:07

StephanB
Replies: 3

Using a regex to select everything before a character:

The values we receiving from the Client on the Server tag is not always the same :
Exsamples:

<Server>BDHPAM01 Source:BJHVMH01</Server>
<Server>BDHPAM02_Source:BJHVMH01</Server>
<Server>BDHPAMSource:BJHVMH01</Server>

I only want the "BJHVMH01" value.

This is how I was able to get the correct values by using a regex.

I used a regex "^(.*?)\:" to select everything before a character ":" and Replacing it with nothing giving me the value of "TJHVMH01".

<sxi:Field name="mServer">
   <sxi:Rules>
       <sxi:Substitute>
            <!-- regex to select everything before ":" -->
            <sxi:Find>^(.*?)\:</sxi:Find>
            <sxi:Replace></sxi:Replace>
        </sxi:Substitute>
   </sxi:Rules>
   <sxi:OutputField>Server</sxi:OutputField>
</sxi:Field>

There is a couple ways this can be done .... 
Please add to this post how you will do it.

#11 General Discussion » ERROR - Signal Registry Polling disabled » 01-02-2021 09:31:54

StephanB
Replies: 0

This is to prevent the creation of duplicate transaction, the Signal Registry Polling will be disabled.
The specific workflow configuration will stop working when a condition for a non recoverable error was detected in the Signal Registry.

#13 Utils and Useful little tools » A quick and simple editor for cron schedule expressions » 31-08-2020 07:57:52

StephanB
Replies: 0

crontab guru - https://crontab.guru/
Is a quick and simple editor for cron schedule expressions to setup a Schedule time in the X-ServiceBroker Initialisation file config.
Example of cron job at 06:00 on ever Monday.

<AT>0 6 * * mon</AT>

#14 Re: HOWTOS » CSV Field names » 16-08-2020 18:54:21

This is how, I have it working to collecting data from a CSV file.


<Connector id="Input_File" type="CSV">
     <Connection xsi:type="sxi:CSV">
       <sxi:OutputFileName/>
       <sxi:Delimiter>,</sxi:Delimiter>
       <sxi:RetryDelay>30</sxi:RetryDelay>
     </Connection>
     <sxi:ReturnCodes>
       <sxi:Success>
         <sxi:Code>Success Code</sxi:Code>
       </sxi:Success>
       <sxi:RecoverableError>
         <sxi:Code>Error Code</sxi:Code>
         <sxi:Code>^.*No data collected for field.*$</sxi:Code>
       </sxi:RecoverableError>
     </sxi:ReturnCodes>
</Connector>
<SignalRegistry xsi:type="sxi:SigReg.CSV">
    <sxi:ConnectorID>Input_File</sxi:ConnectorID>
    <sxi:FolderPath>C:\CSVFILES\</sxi:FolderPath>
    <sxi:ActionElement>ProcessCSV</sxi:ActionElement>
    <sxi:FileName>^TestCSV_.*\.csv$</sxi:FileName>
    <sxi:PollingDelay>10</sxi:PollingDelay>
    <sxi:DeleteProcessed>yes</sxi:DeleteProcessed>
    <sxi:ReadHeaders>no</sxi:ReadHeaders>
</SignalRegistry>
<Action name="ProcessCSV">
      <Mappings>
        <Collect dataDefinition="Read_Input_csv" connectorId="Input_File" source="C:\CSVFILES\" lookupField="na" lookupValue="na" />
      </Mappings>
</Action>
<sxi:DataDefinition name="Read_Input_csv">
      <sxi:Fields>

        <sxi:Field name="0">
          <sxi:OutputField datatype="string">TabelName1</sxi:OutputField>
        </sxi:Field>

        <sxi:Field name="2">
          <sxi:OutputField datatype="string">TabelName2</sxi:OutputField>
        </sxi:Field>

        <sxi:Field name="3">
          <sxi:OutputField datatype="string">TabelName3</sxi:OutputField>
        </sxi:Field>

         ........
 
      </sxi:Fields>
</sxi:DataDefinition>

#15 Re: General Discussion » SXI License Request » 05-08-2020 14:15:14

How many NIC "network interface card" do you have on the machine ?

#16 Utils and Useful little tools » Find and Replace (FNR) » 05-08-2020 12:30:21

StephanB
Replies: 0

I came across a nice app to do a Find and Replace (FNR) it is an open source tool to find and replace text in multiple files.
It can quickly search through large numbers of files and also find the information using regular expressions specifying the form of what you want, instead of literal text.

http://findandreplace.io/

#17 General Discussion » Using the X-Service Broker configuration to replace X-Notify » 06-07-2020 16:30:33

StephanB
Replies: 0

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="&quot;http://tempuri.org/SendSingleSMS&quot;"/>
        </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,&#xD;&#xD;</sxi:Field>
                <sxi:Field staticValue="yes">Please take note that the Notification is not configured in the Database.</sxi:Field>
                <sxi:Field staticValue="yes">&#xD;&quot;</sxi:Field>
                <sxi:Field>Message</sxi:Field>
                <sxi:Field staticValue="yes">&quot;</sxi:Field>
                <sxi:Field staticValue="yes">&#xD;</sxi:Field>
                <sxi:Field staticValue="yes">Please configure the Notification in the XLayer Database.&#xD;</sxi:Field>
                <sxi:Field staticValue="yes">&#xD;</sxi:Field>
                <sxi:Field staticValue="yes">Kind regards,&#xD;</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 "&#xD;" 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>&#xD;</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.

#18 Case Exchange » "Exception reading response" Error with SMTP Connector » 26-06-2020 10:47:25

StephanB
Replies: 0

I came across the following issue on the SMTP Connector after making the "Non Recoverable Error" to a "Recoverable Error" in the <ReturnCodes>.

The Error was gone, but sending the mails was taking a log time to got out.
After investigating the issue. I released why I got the issues.

In the SMTP connector the FromAddress is <sxi:FromAddress>noreply@ourservicedesk.com</sxi:FromAddress> and in the Data Definition the "From" was "xlayer@Client.co.za" clearly not the same. roll
I have removed the Field "From" in the Data Definition, that fixed the issue.

Log with ERROR:
06:37:31.495 - WARN  - Non Recoverable error detected but will reset connector and retry operation one more time
06:37:31.495 - WARN  - Recoverable error while creating data using connector 'SMTP' and Data Definition 'ClientEscalationEmail': javax.mail.MessagingException: Exception reading response;
  nested exception is:
java.net.SocketTimeoutException: Read timed out
06:37:31.495 - WARN  - Retrying transaction in 10 seconds (Attempt 1)
06:37:51.506 - ERROR - Got the error javax.mail.MessagingException: Exception reading response;
  nested exception is:
java.net.SocketTimeoutException: Read timed out
exceptions.ErrorProcessingException: javax.mail.MessagingException: Exception reading response;
  nested exception is:
java.net.SocketTimeoutException: Read timed out

at bin.ProcessRc.processError(ProcessRc.java:158)
at plugins.connectors.SMTP.createData(SMTP.java:378)
at plugins.connectors.SMTP.createDataAndApplyRules(SMTP.java:155)
at plugins.workflows.StandardWorkflow.processCreateData(StandardWorkflow.java:723)
at plugins.workflows.StandardWorkflow.processMappings(StandardWorkflow.java:306)
at plugins.workflows.StandardWorkflow.applyAction(StandardWorkflow.java:203)
at plugins.workflows.StandardWorkflow.access$6000(StandardWorkflow.java:56)
at plugins.workflows.StandardWorkflow$SignalRegistryProcessor.monitoredRun(StandardWorkflow.java:1740)
at za.co.sxi.concurrent.MonitoredTimerTask.run(MonitoredTimerTask.java:25)
at java.util.TimerThread.mainLoop(Unknown Source)
at java.util.TimerThread.run(Unknown Source)
Caused by: javax.mail.MessagingException: Exception reading response
at com.sun.mail.smtp.SMTPTransport.readServerResponse(SMTPTransport.java:2460)
at com.sun.mail.smtp.SMTPTransport.issueSendCommand(SMTPTransport.java:2337)
at com.sun.mail.smtp.SMTPTransport.finishData(SMTPTransport.java:2110)
at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:1316)
at plugins.connectors.SMTP.createData(SMTP.java:354)
... 9 common frames omitted
Caused by: java.net.SocketTimeoutException: Read timed out
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.socketRead(Unknown Source)
at java.net.SocketInputStream.read(Unknown Source)is as fo
at java.net.SocketInputStream.read(Unknown Source)
at com.sun.mail.util.TraceInputStream.read(TraceInputStream.java:126)
at java.io.BufferedInputStream.fill(Unknown Source)
at java.io.BufferedInputStream.read(Unknown Source)
at com.sun.mail.util.LineInputStream.readLine(LineInputStream.java:106)
at com.sun.mail.smtp.SMTPTransport.readServerResponse(SMTPTransport.java:2440)
... 13 common frames omitted
06:37:51.506 - ERROR - Message for action 'SendEscalation' and connectorId 'SMTP' with ID 'X-ServiceBroker~Client_Escalation~393862490446336.71.xml'. Error: javax.mail.MessagingException: Exception reading response;
  nested exception is:
java.net.SocketTimeoutException: Read timed out
06:37:51.506 - INFO  - Marking record as processed with error
06:37:51.508 - ERROR - One or more required mappings failed, cannot process the transaction

The Field in the Data Definition:

        <sxi:Field name="From">
          <sxi:Rules>
            <sxi:Default>xlayer@Client.co.za</sxi:Default>
          </sxi:Rules>
          <sxi:OutputField>From</sxi:OutputField>
        </sxi:Field>

SMTP Connector id:

    <Connector id="SMTP" 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>

I don't think you need the "From" in the Data Definition, if the FromAddress is specified in the SMTP Connector.
smile

#19 Utils and Useful little tools » SMTP Test, Diagnostic, & Monitoring Tool » 25-06-2020 14:21:36

StephanB
Replies: 0

This is a free SMTP Test, Diagnostic, & Monitoring Tool that will enables you to easily troubleshoot and test SMTP connections without telnet.
It supports both open and secure (SSL) SMTP server connections and contains a built-in library of commands such as EHLO, DATA, RCPT TO, etc…

https://www.socketlabs.com/smtp-server- … tics-tool/

#20 Inventory » Limit Access to DB by Time and Day with a Logon Trigger (Asset) » 30-03-2020 21:04:29

StephanB
Replies: 0

There are many situations in production when you may want to limit user access to SQL Server during times, when Assets are update to a Data Base.
For instance, say a particular login should not be connecting to the database on weekends when the Asset update are running.
The way to go about this is with a Logon Trigger, here is the definition of a Logon Trigger straight from MSDN:

Logon Trigger
Logon Triggers fire stored procedures in response to a LOGON event.
This event is raised when a user session is established with an instance of SQL Server.
Logon triggers fire after the authentication phase of logging in finishes, but before the user session is actually established.

A Logon Trigger is really just a DDL Trigger, and two popular functions of a Logon Trigger are for auditing and preventing connections.
We are going to focus on the latter with this post in order to limit particular logins from connecting to the instance during certain times of the day or certain days altogether.

The T-SQL code will consist of three objects:

  • A table to contain the login and deny time parameters.

  • A stored procedure to add the data to that table.

  • The Logon Trigger code.

Login Deny Time Table
This is the table that will house the times/days per login that will be denied access to the Data Base. 
The Logon Trigger will use this table to reference if the connecting login should be permitted to successfully connect.

USE [master]
GO

if object_id('server_login_admission') is NOT NULL
      DROP TABLE dbo.server_login_admission
GO
CREATE TABLE dbo.server_login_admission
(
      admission_id int IDENTITY(1, 1) not null primary key clustered,
      login_name nvarchar(256) NOT NULL,
      deny_day int NOT NULL
            check (deny_day between 1 and 7),
      deny_time_begin time NULL,
      deny_time_end time NULL,
      deny_full_day bit NOT NULL default 0
)
GO

ALTER TABLE dbo.server_login_admission
add constraint CK_TimeOrFullDay check
(
      (
            deny_time_begin is NOT NULL
            and deny_time_end is NOT NULL
      )
      or deny_full_day = 1
)
GO

ALTER TABLE dbo.server_login_admission
add constraint CK_DenyTimeNullHandling check
(
      (
            deny_time_begin is NULL
            and deny_time_end is NULL
      ) or
      (
            deny_time_begin is NOT NULL
            and deny_time_end is NOT NULL
      )
)
GO

alter table dbo.server_login_admission
add constraint CK_DenyTimeRelativity check
(
      deny_time_begin < deny_time_end
      or
      (
            deny_time_begin is NULL
            and deny_time_end is NULL
      )
)
GO

Add Login Deny Data Stored Procedure
This is the stored procedure that will be called to enter data into the table.
A quick review is that Sunday = 1, Monday = 2, so on and so forth, Saturday = 7.

USE [master]
GO

if object_id('dbo.sp_add_server_login_admission') is not null
      DROP PROCEDURE dbo.sp_add_server_login_admission
GO

CREATE PROCEDURE dbo.sp_add_server_login_admission
      @login_name nvarchar(256),
      @deny_day int,
      @deny_time_begin time = NULL,
      @deny_time_end time = NULL,
      @deny_full_day bit = 0
AS

      set nocount on;
     
      -- check to make sure the login actually exists
      if suser_id(@login_name) is NULL
            begin
                  raiserror
                  (
                        'Unknown login name',
                        16,
                        1
                  )
                  return -1
            end
     
      -- make sure the @deny_day is a valid day of the week
      if @deny_day not between 1 and 7
            begin
                  raiserror
                  (
                        'Invalid deny day',
                        16,
                        1
                  )
                  return -1
            end
           
      if
      (
            @deny_time_begin is NULL
            and @deny_time_end is NOT NULL
      ) or
      (
            @deny_time_begin is NOT NULL
            and @deny_time_end is NULL
      )
            begin
                  raiserror
                  (
                        'Both deny time parameters must have a value,
                        or both must be NULL',
                        16,
                        1
                  )
                  return -1
            end
           
      -- ensure @deny_time and @deny_full_day aren't null and 0
      if @deny_time_begin is NULL
      and @deny_full_day = 0
            begin
                  raiserror
                  (
                        'Deny time cannot be NULL
                        if login is not denied for a whole day',
                        16,
                        1
                  )
                  return -1
            end
           
      insert into dbo.server_login_admission
      (
            login_name,
            deny_day,
            deny_time_begin,
            deny_time_end,
            deny_full_day
      )
      values
      (
            @login_name,
            @deny_day,
            @deny_time_begin,
            @deny_time_end,
            @deny_full_day
      )
     
GO

Logon Trigger
As you can see, this code simply does a check on the server_login_admission table to see if the connecting login is not denied to connect at the current time of the current day.

USE [master]
GO

if exists
(
      select *
      from master.sys.server_triggers
      where name = 'logon_trigger_deny_by_time'
)
      drop trigger logon_trigger_deny_by_time
      on all server
GO

create trigger logon_trigger_deny_by_time
on all server
with execute as self
for logon
as

      declare
            @current_login nvarchar(256),
            @current_weekday int,
            @current_time time
           
      select
            @current_login = original_login(),
            @current_weekday = datepart(dw, getdate()),
            @current_time = cast(getdate() as time)
           
      if exists
      (
            select *
            from master.dbo.server_login_admission
            where login_name = @current_login
            and deny_day = @current_weekday
            and
            (
                  @current_time between deny_time_begin and deny_time_end
                  or deny_full_day = 1
            )
      )
            begin
                  rollback
            end

GO

Here is how you can deny login access for a specific user executing the following Procedure:
Sunday = 1, Monday = 2, so on and so forth, Saturday = 7

Denies User1 from connecting to the Data Base on Monday the whole day.

EXEC dbo.sp_add_server_login_admission
      @login_name = 'User1', -- This is the user you want to block
      @deny_day = 2,         -- deny user access on Mondays
      @deny_full_day = 1     -- deny the user for the whole day
GO

Denies User1 from connecting to the Data Base on Saturday from 5:00pm to 11:00pm.

EXEC dbo.sp_add_server_login_admission
      @login_name = 'User1', -- This is the user you want to block
      @deny_day = 7,              -- deny user access during Saturday
      @deny_time_begin = '17:00', -- deny user access form 5:00pm
      @deny_time_end = '23:00'    -- deny user access To 11:00pm
GO

#21 HOWTOS » Adding a Heart Beat to X-ServiceBroker contracts » 16-02-2020 11:35:16

StephanB
Replies: 0

Adding a Heart Beat to X-ServiceBroker contracts to replace the one in the current configurations :
I have added a Heart Beat to a X-ServiceBroker contract by doing the following.

In the configuration you will need to do the following:

Connectors:

<Connector id="CreateHB" type="XML">
      <Connection xsi:type="sxi:XML">
        <sxi:Write>
          <sxi:SaveLocation>E:\SXI\XPress\XmlOut</sxi:SaveLocation>
          <sxi:FileName>X-HB~%UNIQUE%.xml</sxi:FileName>
          <sxi:Stylesheet>..\..\usr\stylesheets\HeartBeat_DOC.xsl</sxi:Stylesheet>
        </sxi:Write>
        <sxi:RetryDelay>60</sxi:RetryDelay>
        <sxi:WaitForWriteCompletion>10</sxi:WaitForWriteCompletion>
      </Connection>
      <sxi:ReturnCodes>
        <sxi:Success/>
        <sxi:RecoverableError/>
      </sxi:ReturnCodes>
</Connector>

The style sheets I have used 'HeartBeat_DOC.xsl'

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0" xmlns="http://www.sxi.co.za/XMLSchema" xmlns:sxi="http://www.sxi.co.za/XMLSchema" exclude-result-prefixes="sxi">
    <xsl:output method="xml" indent="yes" encoding="UTF-8"/>
    <xsl:template match="/">
        <XHb xmlns="http://www.sxi.co.za/XMLSchema">
            <XHeader>
                <XPress>
                    <Destination>
                            <xsl:if test="//dest">
                                <xsl:value-of select="//dest"/>
                            </xsl:if>
                            <xsl:if test="//sxi:Destination">
                                <xsl:value-of select="//sxi:Destination"/>
                            </xsl:if>
                    </Destination>
                </XPress>
            </XHeader>
            <MD>
                <xsl:if test="//md">
                    <xsl:value-of select="//md"/>
                </xsl:if>
                <xsl:if test="//MD">
                    <xsl:value-of select="//MD"/>
                </xsl:if>
                <xsl:if test="//Md">
                    <xsl:value-of select="//Md"/>
                </xsl:if>
                <xsl:if test="//sxi:MD">
                    <xsl:value-of select="//sxi:MD"/>
                </xsl:if>
            </MD>
            <Type>
                <xsl:if test="//type">
                    <xsl:value-of select="//type"/>
                </xsl:if>
                <xsl:if test="//Type">
                    <xsl:value-of select="//Type"/>
                </xsl:if>
                <xsl:if test="//TYPE">
                    <xsl:value-of select="//TYPE"/>
                </xsl:if>
                <xsl:if test="//sxi:Type">
                    <xsl:value-of select="//sxi:Type"/>
                </xsl:if>
            </Type>
        </XHb>
    </xsl:template>
    
</xsl:stylesheet>

Actions:

    <Action name="HeartBeat">
     
      <Mappings>
        <Create dataDefinition="GenerateHB" connectorId="CreateHB" source="../../XPress/XmlOut"/>
      </Mappings>
     
    </Action>

Data Definitions:

<sxi:DataDefinition name="GenerateHB">
      <sxi:Fields>
       
        <sxi:Field name="Destination">
          <sxi:Rules>
            <sxi:Default>127.0.0.1</sxi:Default>
          </sxi:Rules>
          <sxi:OutputField>Destination</sxi:OutputField>
        </sxi:Field>
		
        <!-- The MD is the Server Name -->
        <sxi:Field name="MD">
          <sxi:Rules>
            <sxi:Default>NRSSBLOG01</sxi:Default>
          </sxi:Rules>
          <sxi:OutputField>MD</sxi:OutputField>
        </sxi:Field>
       
        <!-- The Type is the X-ServiceBroker contract name Exp. 'DCXAfgri_Outgoing' with a prefix of 'X-ServiceBroker-'  -->
        <sxi:Field name="Type">
          <sxi:Rules>
            <sxi:Default>X-ServiceBroker-DCXAfgri_Outgoing</sxi:Default>
          </sxi:Rules>
          <sxi:OutputField>Type</sxi:OutputField>
        </sxi:Field>
       
      </sxi:Fields>
    </sxi:DataDefinition>

One you have done the above you will need to setup a Schedule in Service Broker to trigger the Heart Beat file. You can look at this post to do the a Trigger in X-ServiceBroker Schedule Configuring a Trigger in X-ServiceBroker Schedules

Entry Points in the ServiceBrokerTrigger.xml

<!-- ***************** Trigger for a X-ServiceBroker to create a Heart Beat doc ***************** -->        
        <EntryPoint name="Heartbeat_Client_PROD">
            <Format>
                <sxi:Transmission xsi:type="sxi:XmlTransmission">
                    <sxi:Destination>127.0.0.1</sxi:Destination>
                    <sxi:OutputMethod>
                        <sxi:TransmitMethod>Local</sxi:TransmitMethod>
                    </sxi:OutputMethod>
                </sxi:Transmission>
                <Action>HeartBeat</Action>
                <Provider>Client_PROD</Provider>
                <AdditionalElements>
                    <Element>HeartBeat</Element>
                </AdditionalElements>
            </Format>
        </EntryPoint>

        <!-- ***************** Triger for Client X-ServiceBroker to create a Heart Beat doc ***************** -->  
        <EntryPoint name="Heartbeat_Client">
            <Format>
                <sxi:Transmission xsi:type="sxi:XmlTransmission">
                    <sxi:Destination>127.0.0.1</sxi:Destination>
                    <sxi:OutputMethod>
                        <sxi:TransmitMethod>Local</sxi:TransmitMethod>
                    </sxi:OutputMethod>
                </sxi:Transmission>
                <Action>HeartBeat</Action>
                <Provider>Client</Provider>
                <AdditionalElements>
                    <Element>HeartBeat</Element>
                </AdditionalElements>
            </Format>
        </EntryPoint>

In the X-ServiceBroker Initialisation.xml file

<!-- ***************** HeartBeat triger for Client to check Service Broker ***************** -->      
      <Schedule name="Heartbeat_Client_PROD">
        <!-- The trigger will be triggered every 3 minutes -->
        <AT>*/3 * * * *</AT>
        <Action>
        <Path>E:\SXI\X-ServiceBroker\tasks</Path>
        <Command>ServiceBrokerTrigger.class</Command>
          <Arguments>HeartbeatClient_PROD</Arguments>
        </Action>
      </Schedule>
     
      <!-- ***************** HeartBeat triger for Client to check Service Broker ***************** -->      
      <Schedule name="Heartbeat_Client">
        <!-- The trigger will be triggered every 3 minutes -->
        <AT>*/3 * * * *</AT>
        <Action>
          <Path>E:\SXI\X-ServiceBroker\tasks</Path>
          <Command>ServiceBrokerTrigger.class</Command>
          <Arguments>HeartbeatClient</Arguments>
        </Action>
      </Schedule>

Once all is done you will have to add the Heart Beat Notifications for the FAILED and REPAIRED to X-Notify.
I have stated working on a configuration to replacing the X-Notify it still in working progress. Once I have it working correctly, I will add it to the Forum.

#22 HOWTOS » Configuring a Trigger in ServiceBroker Schedule » 09-02-2020 11:48:00

StephanB
Replies: 0

There is 2 file that you will need to edit.
The ServiceBrokerTrigger.xml in the \SXI\X-ServiceBroker\xml\tasks and the ServiceBroker Initialisation.xml in the \SXI\X-ServiceBroker\xml folder.

Take note of the Arguments. The <EntryPoint name="X-AssetClient"> in the ServiceBrokerTrigger.xml must be the same as the <Arguments>X-AssetClient</Arguments> in the Schedule. if it is not configured correctly no ServiceBroker trigger will be generated.

In the ServiceBrokerTrigger.xml you need to add a new EntryPoint in the EntryPoints.
Example:

<EntryPoint name="X-AssetClient">
            <Format>
                <sxi:Transmission xsi:type="sxi:XmlTransmission">
                    <sxi:Destination>127.0.0.1</sxi:Destination>
                    <sxi:OutputMethod>
                        <sxi:TransmitMethod>Local</sxi:TransmitMethod>
                    </sxi:OutputMethod>
                </sxi:Transmission>
                
                <Action>GetKeyData</Action>
                <Provider>X-AssetClient</Provider>
                
                <AdditionalElements>
                    <Element>Element1</Element> 
                </AdditionalElements>
            </Format>
</EntryPoint>

In the ServiceBroker Initialisation.xml you need to add a new Schedule in the Schedules like below.
Example:

<Schedule name="X-AssetClient">
        <!-- The trigger file X-AssetClient will be triggered every Friday at 1:00 -->
        <AT>00 1 * * 5</AT>
        <Action>
            <Path>C:\SXI\X-ServiceBroker\tasks</Path>
            <Command>ServiceBrokerTrigger.class</Command>
          <Arguments>X-AssetClient</Arguments> 
        </Action>
</Schedule>

Here is a example of the file that was generate from the config above in the XmlOut folder.

<?xml version="1.0" encoding="iso-8859-1"?>
<XServiceBroker xmlns="http://www.sxi.co.za/XMLSchema">
  <XHeader>
    <XPress>
      <Destination>127.0.0.1</Destination>
    </XPress>
    <XServiceBroker>
      <ActionName>GetKeyData</ActionName>
      <Provider>X-AssetClient</Provider>
    </XServiceBroker>
  </XHeader>
  <Element>Element1</Element>
  <TimeTriggerGenerated>1581237480</TimeTriggerGenerated>
</XServiceBroker>

#23 Utils and Useful little tools » Create Synchronicity - Open source backup and synchronization » 29-01-2020 07:54:56

StephanB
Replies: 0

Create Synchronicity is a powerful and lightweight open source backup and synchronization program.
http://synchronicity.sourceforge.net/

#24 HOWTOS » XPress Dispatch can Monitor Custom Directories » 20-08-2019 09:48:29

StephanB
Replies: 0

XPress Dispatch contains the following feature to Monitor Custom Directories, that allows for the monitoring of outgoing files in a different directory other than the standard XmlIn1 & XmlIn2 directories.

The feature is configured in the \SXI\XPress\Dispatch\xml\Initialisation.xml file.

Example:

<CustomDirectoriesToMonitor>
  <CustomDirectory path="E:\SXI\OutgoingFiles"/>
</CustomDirectoriesToMonitor>

#25 HOWTOS » Apache Tomcat Post Size Limit » 18-08-2019 17:49:51

StephanB
Replies: 0

Apache Tomcat has a limit on the size of request that can be made using the POST HTTP method.

However, when your repository snapshot reaches over 55MB in un-compressed form,
Apache Tomcat must be configured to accept large amounts of data being sent to it,
as the compressed size of the repository approaches the default 2MB Post size limit.

To remove this limit, edit the /conf/server.xml file in the Tomcat home directory as follows:

Find the tag entry for the HTTP 8080 connector

Add the maxPostSize="0" attribute and value to this tag such that it looks like:

<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" maxPostSize="0" />

Connector Attribute:
maxHttpHeaderSize="8192"
maxThreads="150"
minSpareThreads="25"
maxSpareThreads="75"
enableLookups="false"
redirectPort="8443"
acceptCount="100"
connectionTimeout="20000"
disableUploadTimeout="true"
maxPostSize="0"

Board footer

Powered by FluxBB