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=[TYPE]&displayname=[DISPLAYNAME]&filepath=[FILEPATH]&serversite=[SERVERSITE]&pollinterval=[POLLINTERVAL]&timeout=[TIMEOUT]&fileDirAge=[FILEDIRAGE]&clearAlerts=[CLEARALERTS]&contentChk=[CONTENTCHK]

Request Parameters

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

Field Description        
type The type of monitor you want to add. Value should be File Monitor or Directory Monitor.
serversite Specifies whether the file/directory to be monitored is located on the Local or Remote server. (local or remote)
filepath Absolute path of the file to be monitored.
fileDirAge Option to perform file/directory age check. (on or off)
selectMonStatus The monitor availability to be set if the file/directory is MODIFIED or NOT MODIFIED within a certain time. (up or down)
selectChangeType The file/directory change type for which the configured monitor availability should be set. Possible values are:
  • 0 - When file/directory is not modified
  • 1 - When file/directory is modified
timeVal Amount of time for which the file/directory age should be checked.
timeUnit The time unit for which the file/directory age should be checked.
checkAvailability Alerts when the file does not exist in the specified location (on or off). Default value is on.
choosehost If the File / Directory to be monitored is in the Remote Server, you can choose the host by providing the host ID if the host was already added or using the value -1 to add a new host.
host The name of the host where the File Monitor is running.
monitoringmode Specifies the Mode Of Monitoring (WMI for Windows, Telnet/SSH for Linux)
username The username to connect with the host.
password The password for the new host username.
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. Default value is 23.
contentChk Specifies whether content check needs to be configured. (on or off)
fileCheckType The File Parsing Options to perform content check. Possible Values are:
  • 0 - Perform content check to only appended content.
  • 1 - Perform content check to the whole file.
ccontent The string for which you want to check content matching. Content should be specified in JSON array format as:

[{"severityCriteria":contentMatchSeverity, "contents": actualContent, "isRegex":regexCheck, "ruleType":ruleNum, "caseSensitive":caseSensitiveCheck, ,"matchWholeWord":matchWholeWord}]


Parameter Description
contentMatchSeverity The severity to be set when content match occurs. Possible values are:
  • 0 - Availability Down
  • 1 - Availability Up
  • 2 - Health Critical
  • 3 - Health Warning
  • 4 - Health Clear
actualContent The actual content that needs to be matched.
regexCheck Specifies whether Regex match should be performed. (true or false)
ruleNum The number of contents that are to be matched.
caseSensitiveCheck Specifies whether exact content match should be performed. (true or false)
matchWholeWord Specifies whether content match should be performed for the whole word. (true or false)
clearAlerts Specifies whether monitor status should be cleared when file is not modified. (on or off)
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.

Sample Request

For a Local File

http://prod-server8:9090/AppManager/xml/AddMonitor?apikey=cb4078d8e8ef6859139d3727e6e6991e&type=File%20Monitor&displayname=test12345&filepath=D:\test.txt&serversite=local&pollinterval=5&timeout=60&fileCheckType=1&selectRuleType=all

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=45d321201d8393b02a643a69f31197cf&type=File%20Monitor&displayname=test12345&filepath=D:\test.txt&serversite=local&pollinterval=5&timeout=60&contentChk=on&fileCheckType=1&ccontent=[{"severityCriteria":"1", "contents": ["error", "exception"], "isRegex":"false", "ruleType":"1", "caseSensitive":true,"matchWholeWord":true}]&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 to 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
manageTableRow retain/delete/unmanage Options to manage table row. (retain, delete, or unmanage)

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=|&manageTableRow=delete