@OutagesIO_Support Below is the script and output from the otminfo.log file.
- The only change to the script is the start variable at the top
- In the folder "/home/josh/agent" I have this script and the otminfo.log file.
- I can give you the agent ID if needed.
OTMinfo.log
HTTP/2 200
date: Wed, 09 Mar 2022 01:12:16 GMT
server: Apache
strict-transport-security: max-age=63072000; includeSubDomains
last-modified: Thu, 11 Feb 2021 12:34:03 GMT
etag: "28888-5bb0ebc1544c0"
accept-ranges: bytes
content-length: 166024
vary: User-Agent
content-security-policy: frame-ancestors 'none';
content-secure-policy: default-src 'self';
x-xss-protection: 1; mode=block
x-frame-options: SAMEORIGIN
x-content-type-options: nosniff
referrer-policy: same-origin
permissions-policy: fullscreen=(self 'https://app.outagesio.com'),geolocation=*, camera=()
Script
#!/bin/bash
#Version 1.0.3
# Enter the full path where you will be placing the starter_linux_otm.sh script into.
# Our example shows '/agent', change this to what ever your path is.
start="/home/josh/agent"
command -v curl >/dev/null 2>&1 || { echo >&2 "The curl package is needed but not installed. Please install it and try again. Aborting."; exit 1; }
echo ""
echo "Make sure to create /etc/agentid with credentials before starting this script"
echo "Make sure your starter file points to the same directory that you have it in - Edit the 'start' option above accordingly"
echo "You could add this to /etc/rc.local to start it or build a service for it. Please search Google for more."
echo ""
sleep 5
### Define Global Variables
OTMIN="otm"
IN="$start/updater_linux_ocp.sh"
DATE=`date +%d-%m-%y`
OTM_COMMAND="otm_linux"
USERNAME=`awk 'NR==1' /etc/agentid`
PASSWORD=`awk 'NR==2' /etc/agentid`
### OTM section
# Get rid of any old version
rm -f $start/otm_linux
OTM_HTTP_STATUS=''
OTM_REMOTE_LENGTH=''
### Loop
until [[ ${OTM_HTTP_STATUS} -eq 200 && ! -z ${OTM_REMOTE_LENGTH} ]]
do
sleep 5
##
echo "Receiving binary location"
BINARY_LOCATION=$(curl -m 20 -s -u $USERNAME:$PASSWORD --connect-timeout 10 -X POST https://www.foxymon.com/receiver/receiver2.php -F function=receive_binary_location)
echo "Getting the OTM Package"
curl -I -m 30 --connect-timeout 15 "$BINARY_LOCATION" -o $start/otminfo.log
OTM_HTTP_STATUS=$(cat $start/otminfo.log | awk '/HTTP/ {print $2}')
OTM_REMOTE_LENGTH=$( cat $start/otminfo.log | awk '/Content-Length/ {print $2}' | sed -e 's/[\r\n]//g' )
done
###
if [[ ${OTM_HTTP_STATUS} -eq 200 && ! -z ${OTM_REMOTE_LENGTH} ]]; then
echo "Downloading OTM"
curl -m 30 --connect-timeout 15 "$BINARY_LOCATION" -o $start/otm_linux
sleep 2
OTM_LOCAL_LENGTH=$( ls -l $start/otm_linux | awk '{print $5}' | sed -e 's/[\r\n]//g' )
if [ "${OTM_LOCAL_LENGTH}" == "${OTM_REMOTE_LENGTH}" ]; then
echo "OTM downloaded, starting program then exiting this script"
cd $start
chmod +x $start/otm_linux
## exec $start/otm_linux &
#$start/otm_linux &
ps cax | grep otm_linux > /dev/null
if [ $? -eq 0 ]; then
echo ""
echo "Congratulations, your agent is now monitoring your Internet connectivity."
echo "Type 'ps cax | grep otm_linux' to see the process number"
else
echo "Something didn't work, your agent is not running."
fi
fi
fi