#!/bin/sh

# Configuration
#REMOTE_HOST="your_remote_server_ip_or_hostname"
#REMOTE_USER="your_ssh_username"
# Optional: If your SSH key requires a passphrase, or if you use a specific identity file
# SSH_OPTIONS="-i /path/to/your/ssh/key" 

# Execute the Checkmk agent remotely via SSH and capture its output
SSH_COMMAND="sshpass -p 'Password' ssh -o StrictHostKeyChecking=no root@10.X.X.X /root/Scripts/check_mk_agent"
AGENT_OUTPUT=$(eval "${SSH_COMMAND}")

# Check for SSH command errors
if [ $? -ne 0 ]; then
  echo "<<<check_mk>>>"
  echo "AgentOS: linux"
  echo "<<<local>>>"
  echo "2 \"Remote Checkmk Agent\" - CRITICAL: Failed to connect to ${REMOTE_HOST} or execute agent."
  exit 2 
fi

# Output the captured agent data
echo "${AGENT_OUTPUT}"
