Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagesql
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:

  1. Ensure that a file named .uptmpasswd is created in the Uptime Infrastructure Monitor 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).
  2. Open the file .uptmpasswd in a text editor.
  3. Enter Type 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]
  4. Example file contents:
    Code Block
    languagesql
    secretpassword /opt/uptime-agent/my-scripts/show_temp.sh

...

  1. 
    $%^& /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:

  1. Launch the Agent Console on the system where the script

...

  1. runs. By default, this is located in the Start Menu under

...

  1. All Programs

...

  1. > Uptime agent

...

  1. > Uptime Agent Console.

...

  1. In Agent Options,

...

  1. set a password

...

  1. , and then click Save. This password

...

  1. is used to authenticate with the agent before running the script.

...

  1. Click Advanced in the dropdown list, and then select Custom Scripts. This step tells the agent where the custom script is located on the server

...

  1. .

...

  1. On the Custom Scripts screen, you should see an example similar to:
    • Custom Command: dir
    • Path to Script: cmd.exe /c "dir c:"
  2. To continue this show-temp example, set the parameters to something similar to:
    • Custom Command: temp
    • Path to Script: cmd.exe /c "C:scriptsshow_temp.pl"

...


    • Info

      Make sure to click Add/Edit before closing the window, otherwise your command

...

    • is not

...

    • saved

...

    • .

  1. If you haven't done so yet, click Save, and then click Yes when asked to restart the agent. This

...

  1. makes sure that your new settings take effect.

The following is a sample configuration. Note the additional folder named rexec_commands, which contains a key/value pair of the command key. !worddav81a2f5861b9291cc8f3c6eaa1054bb9b.png|height=16,width=16! <span style="color: #333333"><strong>Note</strong></span> <span style="color: #333333">If any changes are made to

Info

If any changes are made to the Windows agent registry, please restart the

...

up.time agent

...

service to see these changes take effect.

...

Code Block
languagesql
[HKEY_LOCAL_MACHINE\SOFTWARE\uptime software\up.time agent

...

]
"CmdsTimeout"=dword:00000014

...


"Port"=dword:0000270e
"MaxClients"=dword:00000005
"Debug"=dword:00000000
"CmdsPassword"="secretpassword"
"LogFile"="log.txt"

...


 
[HKEY_LOCAL_MACHINE\SOFTWARE\uptime software\up.time agent\rexec_commands

...

]
"dir"= cmd.exe /c "dir c:"
"show-temp"= cmd.exe /c "C:\scripts\show_temp.pl"

...

Step 2

...

: Creating the

...

monitoring station script

The next step is to write the monitoring station script that will attempt attempts to execute your agent side script, validate the output, and then return status or performance information to Uptime Infrastructure Monitor.The

You can write the monitoring station script can be written in any language and format, provided that it adheres to these general rules:

  1. The script must return at least one line of output to the system console. Uptime Infrastructure Monitor will use this output to determine the status of the custom service monitor.
  2. The script must exit with a success status, unless there has been a problem during the execution of the script or you want to force a status for the service monitor. Acceptable return codes are:

    ...

      • exit 0

    ...

      • . The script executed without any errors, all output produced from the script will be parsed by Uptime Infrastructure Monitor to determine the service monitor status.

    ...

      • exit 1

    ...

      • . The service monitor status will be set to WNG (warning) and an outage will be recorded. The console output from the script will be placed in the custom service monitor status message.

    ...

      • exit 2

    ...

      • . The service monitor status will be set to CRIT (critical) and an outage will be recorded. The console output from the script will be placed in the custom service monitor status message.
    1. The script must accept the host name of the agent system as the first argument. Uptime Infrastructure Monitor will automatically add this argument to the arguments that are passed to the script.

    ...

    In

    ...

    most

    ...

    cases,

    ...

    the

    ...

    monitoring

    ...

    station

    ...

    script

    ...

    contacts an

    ...

    agent

    ...

    system

    ...

    and

    ...

    attempts to

    ...

    run

    ...

    a

    ...

    predefined

    ...

    agent-side

    ...

    script

    ...

    like

    ...

    the

    ...

    one

    ...

    that

    ...

    was

    ...

    defined

    ...

    in step 1 above. You can use any transport tool, such as rexec, rsh, or ssh, to contact the agent system.

    However, we recommend using the bundled agentcmd utility the netcat utility to contact your agent systems from your monitoring station script:

    • To get started with custom scripts, or for implementations with only a handful of custom monitor instances, use agentcmd. The agentcmd utility is commonly called in the format listed below to execute a command on the agent side system. Please note that this utility is a helper tool, if you are using many custom monitor instances we recommend using an alternate tool.
      This example uses the settings that were configured above to execute the agent side script:
      Format:
      Code Block
      languagesql
      /usr/local/uptime/scripts/agentcmd 

    ...

    • [-s/+s

    ...

    • ] -p 

    ...

    • [agent port

    ...

    • ] 

    ...

    • [agent hostname

    ...

    • ] rexec 

    ...

    • [password

    ...

    • ] 

    ...

    • [path

    ...

    • ]
      Example:

    ...


    • Code Block
      languagesql
      /usr/local/uptime/scripts/agentcmd -p 9998 my-agent rexec secretpassword /opt/uptime-agent/my-scripts

    ...

    • /show_temp.sh my-arguments

    ...

    • For

    ...

    • more

    ...

    • information, see Using the agentcmd utility.
    • If you plan on implementing a number of custom monitor instances, use netcat. netcat must be downloaded and installed on the monitoring station if it isn't already installed as part of your operating system. The netcat utility is commonly called in the format listed below to execute a command on the agent side system. This example uses the settings that were configured above to execute the agent side script:
      Format:
      Code Block
      languagesql
      echo -n rexec [password] [path] | /usr/local/uptime/bin/netcat [agent hostname] [agent port]
      Example:
      Code Block
      languagesql
      echo -n rexec secretpassword /opt/uptime-agent/my-scripts/show_temp.sh my-arguments | /usr/local/uptime/bin/netcat 

    ...

    • my-agent 

    ...

    • 9998


    Example:

    echo -n rexec secretpassword /opt/uptime-agent/my-scripts/show_temp.sh my-arguments | /usr/local/uptime
    /bin/netcat my-agent 9998 Image Removed 9998  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.
    You will normally use netcat or agentcmd in the monitoring station script to return the results of an agent-side script, validate the status of those results, and return the status to Uptime Infrastructure Monitor. The following is an example of a monitoring station script:
    #!/bin/sh

    ...