Custom Monitor XMPP Ping

Prev Next

Introduction

Extensible Messaging and Presence Protocol (XMPP) is an open XML technology for real-time communication, which powers a wide range of applications including instant messaging, presence and collaboration.

With Custom Monitor you can proactively monitor XMPP based servers for the availability.

Learn more about Custom Monitor by reading this article or watching this video.

Prerequisites

The XMPP custom monitor uses Ncat to determine if the data was sent to an XMPP Server successfully.

Installation & Configuration

Install nc
$ yum -y install nc

Implementation

Write the Custom Script

  1. Navigate to/opt/3genlabs/hawk/syntheticnode/service/shellmonitor/sandbox to create a shell script:
    $ vi xmpp_ping.sh

  2. Paste the code below and save it:

#!/bin/sh
host=${CP_UNSAFE_VAR_host}
port=${CP_UNSAFE_VAR_port}
machineName=${CP_UNSAFE_VAR_machineName}
start_time=$(date +%s%3N)
xmpp_out=$(echo "<?xml version='1.0'?> <stream:stream to='$machineName' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' version='1.0'>" | nc $host $port 2>&1)
time_diff=$(echo {"(($stop_time - $start_time)/1000)"} | bc -l)
echo $xmpp_out
if [[ $xmpp_out == *"Ncat"* ]]; then
    xmpp_result=1
else
    xmpp_result=0
fi
echo "Status:"$xmpp_result
echo "Time to Ping XMPP Server:"$time_diff
  1. Run these commands to change the permission and owner of the shell script:
    $ chmod 500 xmpp_ping.sh
    $ chown serveruser xmpp_ping.sh

Create the Custom Test

Create a Custom Test within the Portal with the JSON template given below.  Make sure that you replace the necessary values.

{
   "shell_command_file_name": "xmpp_ping.sh",
   "host": "",
   "port": ""
}

Results

Based on the output that prints on the console, you can create Tracepoints and Indicators to capture the status to analyze in the Portal.

<stream:stream from="foo.com" id="A0B0D47CBD367122" version="1.0" xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client"><stream:features><starttls xmlns="urn:ietf:params:xml:ns:xmpp-tls"><required/></starttls><mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><mechanism>X-OAUTH2</mechanism><mechanism>X-GOOGLE-TOKEN</mechanism></mechanisms></stream:features>
Status:0
Time to Ping XMPP Server:.08600000000000000000 

Now we can set up Insight to capture and analyze the results.

image001.png

Add this Insight to your your XMPP Test Properties under Insight section.

image002.png