# performMonitors

## Overview

The `performMonitors` command executes system monitoring checks and health diagnostics on the Hyp payment platform. This command allows merchants to monitor system status, check connectivity, and verify that all payment processing components are functioning correctly.

## Use cases

Use `performMonitors` when you need to:

* Monitor payment system health and availability
* Perform diagnostic checks on payment processing components
* Verify connectivity to payment networks and processors
* Check system performance and response times
* Implement automated health monitoring for your integration

## Request structure

{% hint style="info" %}
For general API request structure and authentication, see [API Request & Response General Structure](/enterprise/introduction/request-and-response-general-structure.md).
{% endhint %}

The `performMonitors` command uses the following endpoint:

**POST** `https://your-hyp-environment-url/xpo/Relay`

### XML request structure

```xml
<ashrait>
    <request>
        <command>performMonitors</command>
        <user>[username]</user>
        <password>[password]</password>
        <terminalNumber>[terminal]</terminalNumber>
        <monitor>[monitor_type]</monitor>
    </request>
</ashrait>
```

## Required parameters

<details>

<summary><strong>user</strong> - string</summary>

Your merchant username for API authentication.

</details>

<details>

<summary><strong>password</strong> - string</summary>

Your merchant password for API authentication.

</details>

<details>

<summary><strong>terminalNumber</strong> - string</summary>

The terminal number associated with your merchant account.

</details>

<details>

<summary><strong>monitor</strong> - string</summary>

The type of monitoring check to perform. Available options: "system", "network", "terminal", "all".

</details>

## Response structure

### Success response

```xml
<ashrait>
    <response>
        <result>000</result>
        <message>Monitoring completed successfully</message>
        <systemStatus>[operational/degraded/down]</systemStatus>
        <networkStatus>[online/offline]</networkStatus>
        <terminalStatus>[active/inactive]</terminalStatus>
        <responseTime>[milliseconds]</responseTime>
        <lastCheck>[timestamp]</lastCheck>
        <monitorResults>
            <system>OK</system>
            <network>OK</network>
            <terminal>OK</terminal>
        </monitorResults>
    </response>
</ashrait>
```

### Error response

```xml
<ashrait>
    <response>
        <result>001</result>
        <message>Monitoring check failed or access denied</message>
    </response>
</ashrait>
```

## Code examples

{% tabs %}
{% tab title="cURL" %}

```bash
#!/bin/bash

# Perform comprehensive system monitoring
curl -X POST https://your-hyp-environment-url/xpo/Relay \
  -H "Content-Type: application/x-www-form-urlencoded" \
  --data-urlencode "cgGateway" \
  --data-urlencode "txnId=12345" \
  --data-urlencode "amount=100.00" \
  --data-urlencode "currency=ILS" \
  --data-urlencode "cardId=12345" \
  --data-urlencode "int_in=<?xml version='1.0' encoding='UTF-8'?>
<ashrait>
    <request>
        <command>performMonitors</command>
        <user>your_username</user>
        <password>your_password</password>
        <terminalNumber>1234567</terminalNumber>
        <monitor>all</monitor>
    </request>
</ashrait>"

```

{% endtab %}

{% tab title="Python" %}

```py
import requests
import xml.etree.ElementTree as ET

def perform_system_monitoring(username, password, terminal, monitor_type="all"):
    """
    Perform system monitoring checks on Hyp platform
    """
    # Build XML request
    ashrait = ET.Element("ashrait")
    request = ET.SubElement(ashrait, "request")
    
    ET.SubElement(request, "command").text = "performMonitors"
    ET.SubElement(request, "user").text = username
    ET.SubElement(request, "password").text = password
    ET.SubElement(request, "terminalNumber").text = terminal
    ET.SubElement(request, "monitor").text = monitor_type
    
    xml_string = ET.tostring(ashrait, encoding='unicode')
    
    # Send request
    response = requests.post(
        "https://your-hyp-environment-url/xpo/Relay",
        data={
            "int_in": xml_string
        },
        headers={
            "Content-Type": "application/x-www-form-urlencoded"
        }
    )
    
    if response.status_code == 200:
        # Parse response
        root = ET.fromstring(response.text)
        result = root.find(".//result").text
        
        if result == "000":
            system_status = root.find(".//systemStatus").text
            network_status = root.find(".//networkStatus").text
            terminal_status = root.find(".//terminalStatus").text
            response_time = root.find(".//responseTime").text
            
            print(f"System Monitoring Results:")
            print(f"System Status: {system_status}")
            print(f"Network Status: {network_status}")
            print(f"Terminal Status: {terminal_status}")
            print(f"Response Time: {response_time}ms")
            
            # Check individual monitor results
            monitor_results = root.find(".//monitorResults")
            if monitor_results is not None:
                system_check = monitor_results.find("system").text
                network_check = monitor_results.find("network").text
                terminal_check = monitor_results.find("terminal").text
                print(f"Detailed Results: System={system_check}, Network={network_check}, Terminal={terminal_check}")
            
            return {
                "success": True,
                "system_status": system_status,
                "network_status": network_status,
                "terminal_status": terminal_status,
                "response_time": response_time
            }
        else:
            message = root.find(".//message").text
            print(f"Error: {message}")
            return {"success": False, "error": message}
    else:
        return {"success": False, "error": f"HTTP {response.status_code}"}

# Example usage
result = perform_system_monitoring(
    username="your_username",
    password="your_password",
    terminal="1234567",
    monitor_type="all"
)

```

{% endtab %}

{% tab title="Java" %}

```java
import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.*;

public class SystemMonitoring {
    
    public static class MonitoringResult {
        public boolean success;
        public String systemStatus;
        public String networkStatus;
        public String terminalStatus;
        public String responseTime;
        public String error;
        
        public MonitoringResult(boolean success, String systemStatus, String networkStatus, 
                              String terminalStatus, String responseTime, String error) {
            this.success = success;
            this.systemStatus = systemStatus;
            this.networkStatus = networkStatus;
            this.terminalStatus = terminalStatus;
            this.responseTime = responseTime;
            this.error = error;
        }
    }
    
    public static MonitoringResult performSystemMonitoring(String username, String password, 
                                                         String terminal, String monitorType) {
        try {
            // Build XML request
            StringBuilder xml = new StringBuilder();
            xml.append("<?xml version='1.0' encoding='UTF-8'?>");
            xml.append("<ashrait>");
            xml.append("<request>");
            xml.append("<command>performMonitors</command>");
            xml.append("<user>").append(username).append("</user>");
            xml.append("<password>").append(password).append("</password>");
            xml.append("<terminalNumber>").append(terminal).append("</terminalNumber>");
            xml.append("<monitor>").append(monitorType).append("</monitor>");
            xml.append("</request>");
            xml.append("</ashrait>");
            
            // Send HTTP request
            URL url = new URL("https://your-hyp-environment-url/xpo/Relay");
            HttpURLConnection conn = (HttpURLConnection) url.openConnection();
            conn.setRequestMethod("POST");
            conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
            conn.setDoOutput(true);
            
            String postData = "int_in=" + URLEncoder.encode(xml.toString(), "UTF-8");
            
            try (OutputStream os = conn.getOutputStream()) {
                os.write(postData.getBytes("UTF-8"));
            }
            
            // Parse response
            if (conn.getResponseCode() == 200) {
                DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
                DocumentBuilder builder = factory.newDocumentBuilder();
                Document doc = builder.parse(conn.getInputStream());
                
                String result = doc.getElementsByTagName("result").item(0).getTextContent();
                
                if ("000".equals(result)) {
                    String systemStatus = doc.getElementsByTagName("systemStatus").item(0).getTextContent();
                    String networkStatus = doc.getElementsByTagName("networkStatus").item(0).getTextContent();
                    String terminalStatus = doc.getElementsByTagName("terminalStatus").item(0).getTextContent();
                    String responseTime = doc.getElementsByTagName("responseTime").item(0).getTextContent();
                    
                    System.out.println("System Monitoring Results:");
                    System.out.println("System Status: " + systemStatus);
                    System.out.println("Network Status: " + networkStatus);
                    System.out.println("Terminal Status: " + terminalStatus);
                    System.out.println("Response Time: " + responseTime + "ms");
                    
                    return new MonitoringResult(true, systemStatus, networkStatus, terminalStatus, responseTime, null);
                } else {
                    String message = doc.getElementsByTagName("message").item(0).getTextContent();
                    System.out.println("Error: " + message);
                    return new MonitoringResult(false, null, null, null, null, message);
                }
            } else {
                return new MonitoringResult(false, null, null, null, null, "HTTP " + conn.getResponseCode());
            }
            
        } catch (Exception e) {
            e.printStackTrace();
            return new MonitoringResult(false, null, null, null, null, e.getMessage());
        }
    }
    
    public static void main(String[] args) {
        MonitoringResult result = performSystemMonitoring(
            "your_username",
            "your_password",
            "1234567",
            "all"
        );
        
        if (result.success) {
            System.out.println("Success! System Status: " + result.systemStatus);
        } else {
            System.out.println("Failed: " + result.error);
        }
    }
}

```

{% endtab %}

{% tab title="Node.js" %}

```js
const https = require('https');
const querystring = require('querystring');
const { DOMParser } = require('xmldom');

function performSystemMonitoring(username, password, terminal, monitorType = 'all') {
    return new Promise((resolve, reject) => {
        // Build XML request
        const xml = `<?xml version='1.0' encoding='UTF-8'?>
<ashrait>
    <request>
        <command>performMonitors</command>
        <user>${username}</user>
        <password>${password}</password>
        <terminalNumber>${terminal}</terminalNumber>
        <monitor>${monitorType}</monitor>
    </request>
</ashrait>`;

        // Prepare POST data
        const postData = querystring.stringify({
            int_in: xml
        });

        // HTTP request options
        const options = {
            hostname: 'cguat2.creditguard.co.il',
            path: '/xpo/Relay',
            method: 'POST',
            headers: {
                'Content-Type': 'application/x-www-form-urlencoded',
                'Content-Length': Buffer.byteLength(postData)
            }
        };

        // Send request
        const req = https.request(options, (res) => {
            let responseData = '';

            res.on('data', (chunk) => {
                responseData += chunk;
            });

            res.on('end', () => {
                try {
                    // Parse XML response
                    const parser = new DOMParser();
                    const doc = parser.parseFromString(responseData, 'text/xml');
                    
                    const result = doc.getElementsByTagName('result')[0]?.textContent;
                    
                    if (result === '000') {
                        const systemStatus = doc.getElementsByTagName('systemStatus')[0]?.textContent;
                        const networkStatus = doc.getElementsByTagName('networkStatus')[0]?.textContent;
                        const terminalStatus = doc.getElementsByTagName('terminalStatus')[0]?.textContent;
                        const responseTime = doc.getElementsByTagName('responseTime')[0]?.textContent;
                        
                        console.log('System Monitoring Results:');
                        console.log(`System Status: ${systemStatus}`);
                        console.log(`Network Status: ${networkStatus}`);
                        console.log(`Terminal Status: ${terminalStatus}`);
                        console.log(`Response Time: ${responseTime}ms`);
                        
                        resolve({
                            success: true,
                            systemStatus: systemStatus,
                            networkStatus: networkStatus,
                            terminalStatus: terminalStatus,
                            responseTime: responseTime
                        });
                    } else {
                        const message = doc.getElementsByTagName('message')[0]?.textContent;
                        console.log(`Error: ${message}`);
                        resolve({
                            success: false,
                            error: message
                        });
                    }
                } catch (error) {
                    reject(error);
                }
            });
        });

        req.on('error', (error) => {
            reject(error);
        });

        // Send POST data
        req.write(postData);
        req.end();
    });
}

// Example usage
(async () => {
    try {
        const result = await performSystemMonitoring(
            'your_username',
            'your_password',
            '1234567',
            'all'
        );
        
        if (result.success) {
            console.log('Success! System Status:', result.systemStatus);
        } else {
            console.log('Failed:', result.error);
        }
    } catch (error) {
        console.error('Error:', error.message);
    }
})();
```

{% endtab %}
{% endtabs %}

## Error codes

| Code | Description           | Solution                                                        |
| ---- | --------------------- | --------------------------------------------------------------- |
| 000  | Success               | Monitoring completed successfully                               |
| 001  | Monitoring failed     | Check system connectivity and try again                         |
| 002  | Invalid monitor type  | Use valid monitor types: "system", "network", "terminal", "all" |
| 003  | Authentication failed | Verify username and password                                    |
| 004  | Access denied         | Ensure your account has monitoring permissions                  |
| 005  | Terminal not found    | Check that your terminal number is correct                      |

## Monitor types

| Type     | Description          | Checks Performed                                                     |
| -------- | -------------------- | -------------------------------------------------------------------- |
| system   | System health check  | Overall platform status, database connectivity, service availability |
| network  | Network connectivity | Connection to payment networks, processor availability               |
| terminal | Terminal status      | Terminal configuration, authorization status, processing capability  |
| all      | Comprehensive check  | All of the above monitor types combined                              |

## Related commands

* [`getSessionId`](/enterprise/api-reference/getsessionid.md) - Test authentication connectivity
* [`doDeal`](/enterprise/api-reference/dodeal.md) - Test transaction processing capability

## Best practices

1. **Regular monitoring** - Implement scheduled monitoring checks to detect issues early
2. **Alert thresholds** - Set up alerts when response times exceed acceptable limits
3. **Monitor different types** - Use specific monitor types to isolate issues to particular system components
4. **Log monitoring results** - Keep historical monitoring data for trend analysis
5. **Escalation procedures** - Define clear escalation paths when monitoring indicates system issues
6. **Integration with monitoring tools** - Integrate with your existing monitoring and alerting infrastructure
7. **Test in production** - Use monitoring calls in production to verify actual system health
8. **Monitor before high-volume periods** - Check system health before expected traffic spikes


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://developers.hyp.co.il/enterprise/api-reference/performmonitors.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
