background 
Kris' Tech Blog ( and stuff ) Home About Kris Contact Kris

Categories


All by Date

Linux

Security

Networks

Religion

General





Kris Springer's Tech Blog - Xymon Client for MacOS
Xymon Client for MacOS 8-1-24
Kris Springer


There has never really been a Xymon Client for MacOS. There is a way to install the linux client via Macports, but the code is 10 years old and it doesn't report correct results because MacOS has changed so significantly since that original code was made, so it's useless. So I took it upon myself to build one. I started with the Windows Powershell client as a baseline template and went about creating a Powershell script to use as a MacOS Xymon Client. After many renditions, nearly giving up, and collaboration with ChatGPT and the Xymon Mailing List, I've at long last got a script that can be used in the real-world as a Xymon MacOS Client.

It should be noted that it's communication with the Xymon Server is 1-way, meaning that the 2-way 'client-local.cfg' communication built into Linux and Windows clients is non-existent in my MacOS client at this time. Perhaps I can add it in the future if there's a good reason to put myself through the firestorm of headache that it would inevitably take to accomplish that. For now I don't care about that functionality.

I may also package it up into a DMG download for easy clickable installation in the future. We'll see if I have a need for that or not.

IMPORTANT PRE-REQ'S:
  • I'm assuming you already have a functioning Xymon Server that can collect data, and you understand how to administrate it.
  • You have Admin access on the Mac. You'll need this to install Homebrew, Powershell, and create the daemon that runs the script every 5 minutes.
  • Here's the raw xymonclient-mac.ps1 script if you want to look at it.

ON MAC CLIENT MACHINE:
  1. Open a terminal
  2. Install Homebrew by running these 3 commands.
    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
    
    (echo; echo 'eval "$(/usr/local/bin/brew shellenv)"') >> /Users/sysadmin/.zprofile
    
    eval "$(/usr/local/bin/brew shellenv)"
    
  3. Install Powershell
    brew install --cask powershell
    
  4. Create new xymon folder in /usr/local/
    sudo mkdir -p /usr/local/xymon
    cd /usr/local/xymon
    
  5. Download the ps1 script
    sudo curl -o /usr/local/xymon/xymonclient-mac.ps1 'https://krisspringer.com/posts/img/xymonclient-mac.ps1'
    
  6. Edit the script to define your Xymon Server's URL or IP
    sudo nano /usr/local/xymon/xymonclient-mac.ps1
    
  7. Make the xymonclient-mac.ps1 file executable
    sudo chmod +x /usr/local/xymon/xymonclient-mac.ps1
    
  8. Run it manually to make sure your Xymon Server is receiving data from this new host
    sudo pwsh /usr/local/xymon/xymonclient-mac.ps1
    
  9. Fix the permissions so we can automate it.
    sudo chown root:wheel /usr/local/xymon/xymonclient-mac.ps1
    sudo chmod 755 /usr/local/xymon/xymonclient-mac.ps1
    
  10. Create the LaunchDaemon to automate it to run every 5 minutes and to auto-start at bootup.
    You can use your own domain name in the plist filename and plist config if you want to.
    sudo nano /Library/LaunchDaemons/com.ionetworkadmin.xymonclient.plist
    
    Put this in the plist file. <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Label</key> <string>com.ionetworkadmin.xymonclient</string> <key>ProgramArguments</key> <array> <string>/usr/local/bin/pwsh</string> <string>/usr/local/xymon/xymonclient-mac.ps1</string> </array> <key>StartInterval</key> <integer>300</integer> <!-- 300 seconds = 5 minutes --> <key>RunAtLoad</key> <true/> <key>StandardOutPath</key> <string>/var/log/xymonclient.out</string> <key>StandardErrorPath</key> <string>/var/log/xymonclient.err</string> <key>UserName</key> <string>root</string> </dict> </plist>
  11. Start it.
    sudo launchctl load /Library/LaunchDaemons/com.ionetworkadmin.xymonclient.plist
    

ON XYMON SERVER:
  1. Check the Ghost Clients list to see your new host.
  2. Add the new host to your Xymon hosts.cfg file.






© Copyright 2024 WarriorSon Productions. All rights reserved.