Versions Compared

Key

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

There are two main scenarios for using the agentcmd utility:

  • With an agent on a system that has been added to Uptime Infrastructure Monitor. In this case, the hostname is in the up.time DataStore.
  • With an agent that has been deployed on a system that has not been added to Uptime Infrastructure Monitor. If there is no agent on the system, or there are network problems, agentcmd returns the following error message:
    Code Block
    languagesql
    ERR Unable to contact Agent (10.1.2.34 on port 9998)

You can use agentcmd in two ways:
Using agentcmd at the command line Using agentcmd in an agent-side script  

Table of Contents
maxLevel2
minLevel2

Anchor
_bookmark16
_bookmark16
Using agentcmd at the command line

The command line syntax of agentcmd is:

Code Block
languagesql
 agentcmd <t#> <-/+s> <-p #> hostname command 

Where:

  • t# = use timeout.
  • -s = do not use an SSL connection to the agent (default).
  • +s = connect to the agent using SSL.
  • If SSL is not enabled on the host, the following error message appears:
    ERR The host was not configured to use SSL

...

  • -p # = connect to the agent on the specified port (default is 9998).

...

  • hostname = the name or IP address of the host on which the agent is running.

...

  • command = the agent command to run.

For example, to get basic system information from an agent running on the server Solaris1, type the following command:

Code Block
languagesql
agentcmd +s Solaris1

...

 sysinfo 

The agent will return output similar to the following:

Code Block
languagesql
SYSNAME=Solaris1 
DOMAIN=myDomain.com

...


ARCH="SunOS Solaris1 5.9 Generic_118558-03 sun4u sparc SUNW,Ultra-Enterprise" 
OSVER=5.9

...


NUMCPUS=4 
MEMSIZE=1048576 
PAGESIZE=8192 
SWAPSIZE=1021624 
GPGSLO=25 VXVM="" 
SDS="YES"

...


HOSTID="808cf673"

...


CPU0=" 0 - - 168 - UltraSPARC - " 
CPU1=" 1 - - 168 - UltraSPARC - " 
CPU4=" 4 - - 168 - UltraSPARC - " 
CPU5=" 5 - - 168 - UltraSPARC - " 
NET0=lo0=127.0.0.1 
NET1=hme0=10.0.0.010

...

Using agentcmd in an agent-side script

...

As with netcat, agentcmd is typically used in a script on the monitoring station to perform the following tasks: !worddav0e23da46291fd27cf7d38d55e66cea8d.png|height=4,width=4! Contact an agent system. !worddava138aea4622cb8d4b565b823c19c0a1d.png|height=4,width=4! Attempt to run a predefined agent-side script. !worddava138aea4622cb8d4b565b823c19c0a1d.png|height=4,width=4! Return the results of an agent-side script. !worddav62ecc2d7c09247ce1c091f70d783ad8c.png|height=4,width=4! Validate the status of those results. !worddav62ecc2d7c09247ce1c091f70d783ad8c.png|height=4,width=4! Return the status to Uptime Infrastructure Monitor. The following example illustrates how to run agentcmd in an agent side script: \\ \\ !worddav81a2f5861b9291cc8f3c6eaa1054bb9b.png|height=16,width=16!<span style="color: #333333"><strong>Note</strong></span> <span style="color: #333333">The</span> <span style="color: #333333">rexec</span> <span style="color: #333333">in</span> <span style="color: #333333">the</span> <span style="color: #333333">command</span> <span style="color: #333333">below</span> <span style="color: #333333">does</span> <span style="color: #333333">not</span> <span style="color: #333333">indicate</span> <span style="color: #333333">use</span> <span style="color: #333333">of</span> <span style="color: #333333">the</span> <span style="color: #333333">rexec</span> <span style="color: #333333">system</span> <span style="color: #333333">utility.</span> <span style="color: #333333">It</span> <span style="color: #333333">is</span> <span style="color: #333333">a</span> <span style="color: #333333">keyword</span> <span style="color: #333333">that</span> <span style="color: #333333">is</span> <span style="color: #333333">used</span> <span style="color: #333333">to</span> <span style="color: #333333">indicate</span> <span style="color: #333333">to</span> <span style="color: #333333">the</span> <span style="color: #333333">agent</span> <span style="color: #333333">that</span> <span style="color: #333333">you are attempting to run a pre-defined command.</span> /

  • Contact an agent system.
  • Attempt to run a predefined agent-side script.
  • Return the results of an agent-side script.
  • Validate the status of those results.
  • Return the status to Uptime Infrastructure Monitor.

The following example illustrates how to run agentcmd in an agent side script:

Info

The rexec in the command below does not indicate use of the rexec system utility. It is a keyword that is used to indicate to the agent that you are attempting to run a pre-defined command.

Code Block
languagesql
/usr/local/uptime4/scripts/agentcmd 

...

[-s/+s

...

] -p 

...

[agent port

...

] 

...

[agent hostname

...

] rexec 

...

[password

...

] 

...

[path

...

]

If you use netcat in your scripts, see the following Knowledge Base articles for information on replacing netcat with agentcmd: !worddav2766f781a85b7c965a96ccfb549ff0f5.png|height=4,width=4! <span style="color: #0052cc">Creating Custom Service Monitors in Uptime Infrastructure Monitor</span> !worddav62ecc2d7c09247ce1c091f70d783ad8c.png|height=4,width=4! [<span style="color: #0052cc">Creating</span> <span style="color: #0052cc">Custom</span> <span style="color: #0052cc">Service</span> <span style="color: #0052cc">Monitors</span> <span style="color: #0052cc">with</span> <span style="color: #0052cc">Retained</span> <span style="color: #0052cc">Data</span> <span style="color: #0052cc">Collection</span>|http://docs.uptimesoftware.com/display/KB/Creating%2BCustom%2BService%2BMonitors%2Bwith%2BRetained%2BData%2BCollection] !worddav0e23da46291fd27cf7d38d55e66cea8d.png|height=4,width=4! <span style="color: #0052cc">Creating</span> <span style="color: #0052cc">Plugin</span> <span style="color: #0052cc">Service</span> <span style="color: #0052cc">Monitors</span> <span style="color: #0052cc">in</span> <span style="color: #0052cc">Uptime</span> <span style="color: #0052cc">Infrastructure</span> <span style="color: #0052cc">Monitor</span>agentcmd: