...
Code Block |
---|
|
# su - uptime
$ /opt/uptime-agent/my-scripts/show_temp.sh
temp 74
rh 30 |
To define your password and command pair on a non-Windows agent system, do the following:
- Ensure that a file named .uptmpasswd is created in the up.time agent bin directory -- either /opt/SPYNuptm/bin/ or /opt/uptime-agent/bin, depending the version of your agent. This file must be owned and readable by the user that the agent is run as (ex. uptimeagent or uptime users).
- Open the file .uptmpasswd in a text editor.
- Enter a password and command pair for each command that you want to run on the agent system. The following is the example format and an example of a agent-side commands:
Format: [password] [command path, no arguments]
Example file contents:
Code Block |
---|
|
secretpassword /opt/uptime-agent/my-scripts/show_temp.sh
$%^& /usr/local/bin/appstatus.sh |
Windows agents do not require a password file. However, you must enter the equivalent settings into the Agent Console with the following steps:
...
Note |
---|
|
The 'rexec' text below does not indicate use of the 'rexec' system utility, it is simply a key word used to indicate to the agent that you are attempting to run a predefined command. |
...
Note |
---|
|
The syntax to use agentcmd is different than netcat. When using agentcmd, the above netcat example would like this: |
Code Block |
---|
|
'/usr/local/uptime/scripts/agentcmd my-agent -p 9998 rexec secretpassword /opt/uptime-agent/my-scripts/show_temp.sh my-arguments > $TMPFILE' |
Code Block |
---|
|
# we have the output from the agent. If it is ERR that means there was a problem running the script on the agent
`grep ERR $TMPFILE`
if [ $? -eq 0 ]
then
echo "Could not execute agent side script!"
# by exiting with a 2 we are forcing a CRIT service outage
exit 2
fi
|
Code Block |
---|
|
# given our parameters we can now extract the correct value from the agent output
if [ $TYPE -eq "temp" ]
then
VALUE=`head -1 $TMPFILE | awk '{print $2}'`
MSG="temperature"
else
VALUE=`tail -1 $TMPFILE | awk '{print $2}'`
MSG="humidity"
fi
|
Code Block |
---|
|
# now lets check our values to see if they are over the thresholds and set our status message
RET="OK - $msg is $VALUE on $AGENT"
if [ $VALUE -ge "$WNG" ]
then
# this is our warning message
# include WARNING for use in the web interface thresholds
RET="WARNING - $MSG is $VALUE on $AGENT"
fi
if [ $VALUE -ge "$CRIT" ]
then
# this is our critical message
# include CRITICAL for use in the web interface thresholds
echo "CRITICAL - $MSG is $VALUE on $AGENT"
fi
# here we simply print our status message to the console and exit with a 0,
# the thresholds provided in the up.time web interface will be used to set the monitor status
rm $TMPFILE
echo "$RET"
exit 0 |
...