---
title: "Custom Monitor XMPP Ping"
slug: "custom-monitor-xmpp-ping"
updated: 2023-01-06T15:49:51Z
published: 2023-01-06T15:49:51Z
---

> ## Documentation Index
> Fetch the complete documentation index at: https://docs.catchpoint.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Custom Monitor XMPP Ping

## **Introduction**

E**x**tensible **M**essaging and **P**resence **P**rotocol (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](https://docs.catchpoint.com/docs/custom-test) or watching this [video](https://docs.catchpoint.com/docs/custom-monitor).

## **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:  

`$&nbsp;chmod&nbsp;500 xmpp_ping.sh`  

`$&nbsp;chown&nbsp;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](https://docs.catchpoint.com/docs/insight-guide) to capture and analyze the results.

![image001.png](https://cdn.document360.io/cb4af8f9-6751-4fd2-b39c-07aae832badb/Images/Documentation/360042433911-image001.png)

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

![image002.png](https://cdn.document360.io/cb4af8f9-6751-4fd2-b39c-07aae832badb/Images/Documentation/360042417892-image002.png)
