Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Related DocumentationVersion of up.time affectedAffected Platforms
This article is part

\n

\n \n \n \n \n \n Related \nDocumentation \n \n Version \nof up.time \naffected \n \n Affected \nPlatforms \n \n \n \n \n \n This article is \npart
of a series:
\n \n
\n \n

Part 1 - Creating
\nCustom
Custom Service Monitors in up.time
\n \n
Part 2 - Creating
\nCustom
Custom Service Monitors with Retained Data Collection
\n \nPart
Part 3 - Creating Plug-in Service Monitors in up.time

\n \n \n \n
All
\n \n
All
\n \n \n \n \n

...

...

Article \nContents \n

...

 

 

Article Contents

 

...

 

...

 

Overview \n \n

...

 

Plug-in service monitors allow you to add service \nmonitors monitors directly into the up.time interface. You can use plug-in \nservice service monitors to check, alert on and graph your own custom \napplication application or business metrics. Plug-in in monitors have the following \nbenefitsbenefits: \n

...

 

    \n \n \n
  • Plug-in monitors \nenable enable you create more meaningful graphs with customized headings for \nyour your retained application and business metrics.
  • \n \n
  • They are installed \ndirectly directly into the up.time interface, beside the standard up.time \nservice service monitors. Your plug-in monitors are as transparent as other \nmonitors monitors to your end users.
  • \n \n
  • Creating instances \nof of your monitor much easier using a standard service monitor template \nthat that you define. Once you create your monitor template you never have \nto to remember the exact arguments or location of your custom script, they \nare are included right in the interface automatically.
  • \n \n \n

...

 

Example graph produced using a plug-in \nmonitormonitor.
\n \nImage Removed
\n \n

...

Image Added

 

The process of updating your existing scripts and service monitors to be \nplugplug-in monitors can usually be \ncompleted completed in just a few minutes. This article builds on the scripts and \nknowledge knowledge that were developed in previous articles. Take some time to \nreview review the previous articles before continuing.

...

 

...

 

Formatting your monitoring \nstation station script for retained data tracking \n \n

...

 

To format your custom script for use with a plug-in monitor, \nyou you will only need to make changes to the way that it outputs \ninformation information when the script is run. Instead of printing a \nnumber number to screen on individual lines -- like the Custom with Retained \nData Data -- you must also print a variable name along with the numerical or \nstring string value. Choosing a variable name is the most important part of \nsetting setting up the plug-in monitor. The variable name must be exactly the \nsame same within your script output and the XML definition for your service \nmonitormonitor. This is discussed later in this article.

...

 

The format of plug-in monitor output is included below along \nwith with an example set of output that includes two integer variables (transactions \nand and users) \nand and two string values (lasterror \nand and connectmsg). The output format is a simple name and value pairing, the variable naming coming first on a line and the value for that variable following it. \n

...

 

Expected format:
\n \nvariable variable value
\n \nvariableX variableX valueX
\n \n
\n \nExample
Example Script Execution and Output
\n \n> > gather_data.sh
\n \ntransactions transactions 2398
\n \nusers users 5
\n \nlasterror lasterror Error opening user connection!
\n \nconnectmsg connectmsg Connection refused \n \n

...

 

...

 

Changing the check_temp script \nfor for use within a plug-in service monitor \n \n

...

 

Using the check_temp.sh \nscript script as an example, change the output format so that it can be used \nwithin within a plug-in monitor. You must first decide what to call \nthe the variables that the script will output. Currently, the \nscript outputs script outputs temperature and relative humidity -- name the \ntwo two variables temp \nand  and rh

...

 

Next, change the output of the script check_temp.sh \nas as detailed below: \n

...

 

Previous \nPrevious Format - For a custom service monitor with retained \nperformance performance data.
\n \n> > ./check_temp.sh test-agent 9998
\n \n64 64.5
\n \n32 32.8 \n \n

...

 

New \nNew Format - For use within a plug-in service monitor, notice that we \nhave have added our variable names to the output lines:
\n \n> > ./check_temp.sh test-agent 9998
\n \ntemp temp 64.5
\n \nrh rh 32.8 \n \n

...

 

If you look back through the examples in previous articles, \nyou you will notice that the output format from the monitoring station \nscript script above now matches that of the agent side script. Note \nthat that this is not always the case, but works well for this example.

...

 

In order for the check_temp.sh \nscript script to produce the output listed above, edit the script so that it \nmatches matches the example below:

...

 

# \n#!/bin/sh
\n \n
\n \n#
# This script takes the following arguments:
\n \n# # check_temp.sh hostname port
\n \n# # Example execution:
\n \n# # ./check_temp.sh my-agent 9998
\n \n
\n \n#
# This script can be placed anywhere on the monitoring station system as long as it is
\n# # executable by the uptime user.
\n \n
\n \n#First
#First, collect our arguments
\nAGENT AGENT=$1
\nPORT PORT=$2
\n
\nTMPFILE
TMPFILE=/tmp/$$.temp
\n \n
\n \n#
# now use the info above to contact the agent, store the output in a file for parsing
\n \n`echo `echo -n rexec secretpassword /opt/uptime-agent/my-scripts/show_temp.sh \nmymy-arguments | /usr/local/uptime/bin/netcat $AGENT $PORT > $TMPFILE`

...

 

Note: If you are using agentcmd instead of netcat, replace netcat with agentcmd in the command above. For example:

...

 

`/usr/local/uptime/scripts/agentcmd -p $PORT $AGENT rexec secretpassword /opt/uptime-agent/my-scripts/show_temp.sh my-arguments > $TMPFILE`

...

 

For more information on the syntax used with agentcmd, see this Knowledge Base article.

...

 

# \n# we have the output from the agent. If it is ERR that means there was a problem running the script on the agent
\n \n`grep `grep ERR $TMPFILE`
\n \nif if [ $? -eq 0 ]
\n \nthen
\n \necho then
echo "Could not execute agent side script!"
\n \n# # by exiting with a 2 we are forcing a CRIT service outage
\n \nexit exit 2
\n \nfi
\n \n
\n \n# fi

# because our agent side script produces output that fits into the \nplugplug-in monitor format
\n \n# # we don't have to format our output at all, simply print it to the \nscreen screen and we are finished.
\n \n
\n \ncat $TMPFILE
\n \n
\n \nexit 0
\n \n

...


cat $TMPFILE

exit 0

 

...

 

Creating the XML definition for \nyour your plug-in service monitor \n \n

...

 

To integrate the plug-in monitor with up.time, you must \nproduce produce an XML definition that up.time will use to understand how to \nprocess process your custom script and what options should be displayed within \nthe the up.time interface. To create your XML definition browse to the Plug-in \nService Service Monitor XML Generation Tool and follow the steps on screen. 

...

 

This page will be your primary \ntool tool to create and edit your XML definition files. If you want to further customize the XML definition of your plug-in \nmonitormonitor, please contact [email protected]for assistance. \nBefore Before you use the XML Generation Tool, have the following information \nabout about your plug-in monitor available: \n

...

 

  • The name of your monitor, which will appear in the up.time services list. This name \nmust must be unique.
  • \n \n
  • The full path to \nyour your custom script
  • \n \n
  • For each variable \nthat that your script produces:
  • \n \n \n \n
    • Var Name: this \nmust must match the output variable name and be only one word.
    • \n \n
    • Title: for \ninstance instance if your variable was named 'temp' an appropriate title may be \n 'Temperature'
    • \n \n
    • Description: Full description \nof of the variable.
    • \n \n
    • Unit: if the \nvariable variable should have a unit associated with it for graphing
    • \n \n
    • Type: Either \nString String or Decimal based on the value for your variable.
    • \n \n
    \n \n

...

 

Once you have generated your XML file, save it to your \nmonitoring monitoring station in the UPTIME_DIRxml folder and continue to the \nnext next step. Below is an example screen shot of the options used to \ncreate create an XML definition for the check_temp.sh script. The XML file \nthat that these options produce is attached to this article.

...

 

Example options used to produce XML for \n check_temp.sh.
\n \nImage Removed
\n \n

...

Image Added

 

...

 

Importing and managing your XML \nplugplug-in monitor definition \n \n

...

 

Now that you have both the XML definition for your custom \nscript script and your custom script in place, you can import your \nplugplug-in monitor into up.time. You use the erdcloader and erdcdeleter to import and export your plug-in monitor. Examples \nof of the options for these commands are included below.

...

 

The UPTIME_DIRscriptserdcloader utility is used to import \nyour your plug-in monitor XML definition as a service monitor template \nwithin within up.time. \n \n

...

 

Option NameDescription
\n \n \n \n \n \n Option \nName \n \n Description \n \n \n \n \n \n
-c
\n \n
Changes the
\ndefault
default launch configuration file
\n \n \n \n \n \n
-h, --help
\n \n
Prints help
\ninformation \n \n \n \n \n \n
information
-x, --xml
\n \n
Defines the XML
\nfile
file to load to create your plug-in monitor template.
\n \n \n \n \n

...

 

Example \nExample Execution:
\n \n> > cd UPTIME_DIR
\n \n> > scripts/erdcloader -x MyMonitor.xml \n \n

...

The UPTIME_DIRscriptserdcdeleter utility is used to

...

remove your plug-in monitor template from up.time.

...

\n

 

Option NameDescription
\n \n \n \n \n \n Option \nName \n \n Description \n \n \n \n \n \n
-l, --list
\n \n
Lists all
\nservice
service monitor templates that can be removed from up.time
\n \n
\n \n \n \n
-h, --help
\n \n \n \n \n \n \n \n
Prints help
\ninformation
information
-n, --name
\n \n
Deletes the
\nservice
service monitor template with the given name. A template must have no
\nservice
service monitors currently using it in order to be deleted.
\n \n \n \n \n

...

...

 

 

Example Execution:
\n \n> > cd UPTIME_DIR
\n \n> > scripts/erdcdeleter --list
\n \n .
\n \n .
\n \n .
\n \nMy My test monitor template
\n \n> > scripts/erdcdeleter --name "My test monitor template" \n \n

...

While working with your XML definition and

...

ensuring that your service monitor works correctly, you will probably run each of

...

these commands a number of times. Below is a quick example of the

...

output expected when importing the check_temp.xml template using the

...

erdcloader utility.

...

> cd UPTIME_DIR
\n \n> > ls scripts/check_temp.sh
\n \nscripts scripts/check_temp.sh
\n \n> > ls xml/check_temp.xml
\n \nxml xml/check_temp.xml
\n \n> > scripts/erdcloader -x xml/check_temp.xml
\n \n2006 2006-05-12 17:09:03,376 DEBUG (HibernateManager:178) - Configuring \ndatabase database for: mysql
\n \n2006 2006-05-12 17:09:08,743 DEBUG (ERDCXmlParser:56) - Plug-in monitor: \nTemp Temp and Humid \n \n

...

 

Now that the plug-in monitor has been imported, you can browse to \nthe the Add Service Instance page in the up.time user interface and see the \nplugplug-in monitor listed, as shown below:

...

Image Removed

...

 

Image Added

 

...

 

Adding Instances of your plug-in \nservice service monitor

...

 

To add an instance of your plug-in service monitor, browse to \nthe the Add Service Instance list, select your plug-in service monitor, and click Continue. The options displayed on the monitor template match the definition that you created with the XML generation tool. The service monitor settings that would \nappear appear based on the example XML definition are shown below: \n

...

Image Removed

...

 

Image Added