AddMonitor APIs - Custom Monitors


This section explains how to use the AddMonitor API to add monitors of the category type 'Custom Monitors'. The following monitors are supported:

Windows Performance Counters

Syntax:
http://[Host]:[Port]/AppManager/xml/AddMonitor?apikey=[APIKEY]&type=[TYPE]&displayname=[DISPLAYNAME]&host=[HOST]&username=[USERNAME]&password=[PASSWORD]&pollinterval=[POLLINTERVAL]

Request Parameters:

The parameters involved in the API request are described below. Also, refer the list of common Request Parameters.

Field Description        
type The type of the monitor you want to add. Value should be Windows Performance Counters.
host The name of the host where the Windows Performance Counters is running.
username The user name of the host running Windows Performance Counters.
password The password of the host running Windows Performance Counters.
pollinterval The interval at which you want the polling to happen.

Sample Request:

http://app-xp4:9090/AppManager/xml/AddMonitor?apiey=ee8d8e237bd5e1a0d8aed16a381c3b73&type=Windows Performance Counters&host=app-xpmll&displayname=hhhh&username=asasaa&password=admin123

Database Query Monitor

Syntax:

http://[Host]:[Port]/AppManager/xml/AddMonitor?apikey=[APIKEY]&type=[TYPE]&displayname=[DISPLAYNAME]&host=[HOST]&port=[PORT]&username=[USERNAME]&password=[PASSWORD]&databasetype=[DATABASETYPE]&databasename=[DATABASENAME]&SSLEnabled=[SSL ENABLED]&showqueryoutput=[SHOWQUERYOUTPUT]&queries=[QUERIES]

Request Parameters:

The parameters involved in the API request are described below. Also, refer the list of common Request Parameters.

Field Description
type The type of monitor you want to add. Value should be QueryMonitor.
host The name of the host where the databae server is running.
port The port number where the database is running
username The user name of the database server.
password The password of the database server.
databasetype The database type for which the query is executed.
databasename The name of the database server.
SSLEnabled Option to enable SSL. Possible values are either true or false.
showqueryoutput Option to specify whether you prefer query output. Values are yes or no
queries Denotes the database query. There can be a maximum of five queries.

Sample Request:

http://prod-server8:9090/AppManager/xml/AddMonitor?apikey=bbab7f01458e96595b06d5c27efcc3af&type=QueryMonitor&displayname=qury&host=app-xp2&port=1433&username=sa&password=Advent1&databasetype=MsSQL&databasename=AMDB&SSLEnabled=true&showqueryoutput=yes&queries=select * from user

File/Directory Monitor

Syntax:

http://[Host]:[Port]/AppManager/xml/AddMonitor?apikey=[APIKEY]&type=File Monitor&displayname=[DISPLAYNAME]&filepath=[FILEPATH]&serversite=[SERVERSITE]&pollinterval=[POLLINTERVAL]&timeout=[TIMEOUT]

Request Parameters:

The parameters involved in the API request are described below. Also, refer the list of common Request Parameters.

Field Description        
type The type of the monitor you want to add. Value should be File Monitor or Directory Monitor.
host The name of the host where the File Monitor is running.
serversite Specifies whether the File / Directory to be monitored is on the Local or Remote Server.
filepath The path to the file to be monitored
contentChk Specifies if you wish to run a content check. If Content check is to be performed then use contentChk=on
monitoringmode Specifies the Mode Of Monitoring (WMI for Windows, Telnet/SSH for Linux)
choosehost
 
If the File / Directory to be monitored is in the Remote Server, you can choose the Host by providing the host name or using the value -1 to add a new host.
username The username to add a new host.
password The password for the new host username.
timeval Configuring daily basis created files / directories are supported in both Windows and Linux Servers.Say for example you can configure filename as localhost.$YYYY-$MM-$DD-$HH-$mm.log or directoryname as $YYYY$MM$DD$HH$mm.
monitoringmode

The Mode Of Monitoring :

  • WMI for Windows
  • Telnet/SSH for Linux
prompt The Command Prompt to connect in the Telnet/SSH mode. Specify the command prompt value, which is the last character in your command prompt
port The port number where the File/Directory Monitor is running.
fileCheckType

The File Parsing Options to perform content check. Possible Values are:

  • 0 - Perform content check to only appended content
  • 1, Whole - Perform content check to the whole file.
selectStatusType

You can set the monitor status to UP / DOWN if ANY/ALL of the contents/Regular Expressions are matched. Possible values are:

  • UP
  • DOWN
selectRuleType

You can set the monitor status to UP / DOWN if ANY / ALL of the contents/Regular Expressions are matched. Possible values are:

  • Any - Set monitor status when any of the contents/Regular Expressions is matched.
  • All - Set monitor status when all of the contents/Regular Expressions are matched.
countval  
fileDirAge For both File and Directory monitor, you can select the Do file/directory age check check box if you wish to display the Monitor Status to UP/DOWN if the FILE/DIRECTORY is MODIFIED/NOT MODIFIED within a certain time.
selectMonStatus

You can set the Monitor Status to UP / DOWN if the FILE or DIRECTORY is MODIFIED or NOT MODIFIED within a certain time. Possible Values are:

  • UP
  • DOWN
selectChangeType

You can set the Monitor Status to UP / DOWN if the FILE/DIRECTORY is MODIFIED/NOT MODIFIED within a certain time:

  • MODIFIED
  • NOT MODIFIED
timeUnit The time unit for which the above said selectMonStatus and selectChangeType should be set.
sshkey The SSH Key for SSH authentication.
passphrase The passphrase for key based authentication for SSH.
ccontent The string for which you want to check content matching.
regexChk You can perform content check for regular expressions by specifying regexChk=on
subDirCntChk Use subDirCntChk=on to display the subdirectory count of a directory.

Sample Request:

For a Local File

http://prod-server8:9090/AppManager/xml/AddMonitor?apikey=bbab7f01458e96595b80f042db3eff62f0&type=File Monitor&displayname=test1&filepath=F:\LATEST\AppManager\logs\stdout.txt&serversite=local&pollinterval=5&timeout=60

For a Remote File

http://prod-server8:9090/AppManager/xml/AddMonitor?apikey=1bbab7f01458e96595bb3eff62f0&type=File Monitor&displayname=test7&filepath=F:\LATEST\AppManager\logs\stdout.txt&serversite=remote&pollinterval=5&timeout=60&
choosehost=-1&monitoringmode=WMI&host=app-support-w7&username=administrator&password=Apmsupport1

For a Local File when Content Check is enabled

http://prod-server8:9090/AppManager/AppManager/xml/AddMonitor?apikey=945bbab7f01458e96595b795cd7&type=File Monitor&displayname=test2&filepath=d:\stdout.txt&serversite=local&pollinterval=5&timeout=60&contentChk=on®exChk=on&
ccontent=a*b&fileCheckType=whole&selectStatusType=down&selectRuleType=all

For a Remote File when Content Check is enabled

http://prod-server8:9090/AppManager/xml/AddMonitor?apikey=6a3803a905cbbab7f01458e96595b856&type=File Monitor&displayname=test12&filepath=C:\Test\Grep.txt&serversite=remote&pollinterval=5&timeout=60&contentChk=on&
ccontent=Exception&fileCheckType=whole&selectStatusType=down&selectRuleType=all&choosehost=-1&monitoringmode=WMI&host=app-xp2&username=asasaa&password=001

When both file/directory age check and content check are enabled

http://prod-server8:9090/AppManager//AppManager/xml/AddMonitor?apikey=1561056503f5164180f042db3eff62f0&type=File Monitor&displayname=test6&filepath=F:\LATEST\AppManager\logs\stdout.txt&serversite=local&pollinterval=5&timeout=60&
fileDirAge=yes&selectMonStatus=down&selectChangeType=notmodified&timeval=50&timeUnit=Minutes&contentChk=on&
ccontent=test&fileCheckType=whole&selectStatusType=down&selectRuleType=any&countval=3

Script Monitor

Syntax:

http://[Host]:[Port]/AppManager/xml/AddMonitor?apikey=[APIKEY]&type=[Script Monitor]&displayname=[DISPLAYNAME]&serverpath=[SERVERPATH]&workingdirectory=[FILEPATH]&serversite=[LOCAL/REMOTE]&pollinterval=[POLLINTERVAL]&timeout=[TIMEOUT]

Request Parameters:

The mandatory parameters involved in the API request are described below. Also, refer the list of common Request Parameters.

Mandatory parameters Value Description        
type Script Monitor The type of the monitor you want to add. Value should be Script Monitor.
displayname   Display name of the monitor
serverpath   The path of the script file in the server, to be monitored 
workingdirectory   The directory in which the script will be executed
serversite local/remote Specifies whether the script to be monitored is on the Local or Remote Server.
pollinterval   Set the Polling Interval. By default, it is 5 minutes
timeout   Specify the Timeout value in seconds. The value can be the maximum time taken by the script to execute.
isCommand   To choose the Script Location as command, use the keyword "isCommand=true" in the API call.

If Remote Server option is selected, the parameters are:

Field Value Description        
host   The name or IP address of the host where the script monitor is running.
monitoringmode TELNT/SSH Specifies the Mode Of Monitoring ( Telnet/SSH for Linux)
choosehost -1/hostid For new host use -1, else use id value from the query select * from AM_SCRIPTHOSTDETAILS
port 23/22  
username   The username to add a new host.
password   The password to add a new host.
sshkey on/off The SSH Key for SSH authentication. Public Key Authentication (Supported for SSH2 only). Default value off
passphrase   The passphrase for key based authentication for SSH.
prompt   The Command Prompt to connect in the Telnet/SSH mode. Specify the command prompt value, which is the last character in your command prompt. Default value is $
mode sh Enter the mode. The default value will be 'sh'
description   Private key

If the Output Settings enabled, the parameters are:

Field Value Description        
opfile true/false Specify if you want to Get output from file.
outputfile   Specify the path of the output file
string_att   Enter the String attributes
numeric_att   Enter the Numeric attributes
delimiter   Enter the value of Delimiter used in the output file. By default, it is "=". If you don't specify a delimiter, then 'space' would be considered as a delimiter.

If Tables in output file is enabled, the parameters are:

Field Value Description        
tablepresent on/off Output Settings.Default value off
table_row   Number of rows in the table 
table<index>   Table name
numericati<index>   Numeric attribute
stringati<index>   String attribute
pcati<index>   Unique column
cdi<index>   Column delimiter
message   Arguments
pollinterval   Polling interval
timeout   Time out

Sample Request:

For a local server:

http://prod-server8:9090/AppManager/xml/AddMonitor?apikey=1561056503f5164180f2db3eff62f0&type=Script Monitor&displayname=test1&serverpath=F:\AppManager\bin\CkServerConnection.bat&workingdirectory=
F:\Managed\AppManager\bin\&serversite=local&pollinterval=5&timeout=30

For a remote server:

http://prod-server8:9090/AppManager/xml/AddMonitor?apikey=151056503f5164180f2db3b3eff62f0&type=Script Monitor&displayname=test2&serverpath=/home/likewise-open/ZOHOCORP/prodserver-9091/test.sh&workingdirectory=/home/ZOHOCORP/prodserver-9091&serversite=remote&pollinterval=5&timeout=60&choosehost=-1&monitoringmode=SSH&host=prodserver-9091&username=prodserver-9091&password=Zoho123&prompt=$port=22

For a Command type script:

http://prod-server8:9090/AppManager/xml/AddMonitor?apikey=a0c6b6d593637f737f34dab03132faca&type=Script Monitor&displayname=testAPI222&serverpath= echo helo&workingdirectory=/home/test&serversite=remote&pollinterval=5&timeout=60&choosehost=5&isCommand=true

With Output Settings enabled, (Give new line with %0A):

http://prod-server8:9090/AppManager/xml/AddMonitor?apikey=1561003f5164180f280f042db3eff62f0&type=Script Monitor&displayname=test3&serverpath=F:\AppManager\bin\ChkServerConnection.bat&workingdirectory=
F:\AppManager\bin\&serversite=local&pollinterval=5&timeout=60&opfile=true&outputfile=F:\AppManager\bin\result.txt&
string_att=Name1,Name2&numeric_att=Age1,Age2&delimiter==

With the tables in output file enabled:

http://prod-server8:9090/AppManager/xml/AddMonitor?apikey=1561056503f5164180f042db3eff62f0&type=Script Monitor&displayname=test3&serverpath=F:\AppManager\bin\ChkServerConnection.bat&workingdirectory=F:\AppManager\bin\
&serversite=local&pollinterval=5&timeout=60&opfile=true&outputfile=F:\AppManager\bin\result.txt&
string_att=Name1,Name2&numeric_att=Age1,Age2&delimiter==&tablespresent=on&table_row=1&
table1=Test1&numericatt1=Num1&stringatt1=Str1&pcatt1=Num1&cdl1==