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:

Supported HTTP methods: POST

Allowed roles: Administrator

Windows Performance Counters

Syntax

https://[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.

FieldDescription        
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

https://apm-prod-server:8443/AppManager/xml/AddMonitor?apikey=aaaaaabbbbbbccccccddddddeeeeee&type=Windows Performance Counters&host=app-xpmll&displayname=wpc&username=admin&password=appman

Database Query Monitor

Syntax

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

Request Parameters

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

FieldDescription
type The type of monitor you want to add. Value should be QueryMonitor.
host The name of the host where the database 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.
mysqlDriverType The type of driver used to connect to the MySQL server. Values are mariadbdriver or mysqldriver.

Note: This parameter is required only for query monitors of the MySQL database type.

Sample Request

https://apm-prod-server:8443/AppManager/xml/AddMonitor?apikey=aaaaaabbbbbbccccccddddddeeeeee&type=QueryMonitor&displayname=qury&host=app-xp2&port=1433&username=admin&password=appman&databasetype=MsSQL&databasename=AMDB&SSLEnabled=true&showqueryoutput=yes&queries=select * from user

File/Directory Monitor

Syntax

https://[HOST]:[PORT]/AppManager/xml/AddMonitor?apikey=[APIKEY]&type=[TYPE]&displayname=[DISPLAYNAME]&filepath=[FILEPATH]&serversite=[SERVERSITE]&pollinterval=[POLLINTERVAL]&timeout=[TIMEOUT]&fileDirAge=[FILEDIRAGE]&checkAvailability=[CHECKAVAILABILITY]&contentChk=[CONTENTCHK]&filterFiles=[FILTERFILES]

Request Parameters

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

FieldDescription        
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/directory 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/directory 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}]


ParameterDescription
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)
filterFiles The condition to filter files in the directory. Filtering conditions should be specified in JSON array format as:

{"filepattern":"[FILE PATTERN]", "category":"[CATEGORY]", "condition":"[CONDITION]", "value":[VALUE], "unit":"[UNIT]", "alertSeverity":[SEVERITY]}


ParameterDescription
filepattern Regular expression for the file pattern (such as *.txt or *.zip)
category Indicates the parameters based on which the files need to be filtered. Possible values include:
  • size - Size
  • mod - Last Modified Time
  • create - Created time (supported only for Windows directory)
condition Indicates the filter condition. Possible values are:
  • LT - Lesser than
  • GT - Greater than
value Indicates the value specified for the filter condition. Specified value should be a positive integer.
unit The unit for the value specified. Posssible values are either Bytes/KB/MB/GB (for Size filter category) or Minutes/Hours (for Last Modified Time and Created Time filter categories)
alertSeverity The alert severity to be set when filtering conditions are met. Possible values are:
  • 1 - Health Critical
  • 4 - Health Warning
  • 5 - Health Clear

Sample Request

File Monitoring

For a Local File:

https://apm-prod-server:8443/AppManager/xml/AddMonitor?apikey=aaaaaabbbbbbccccccddddddeeeeee&type=File%20Monitor&displayname=test12345&filepath=D:\test.txt&serversite=local&pollinterval=5&timeout=60&fileCheckType=1

For a Remote File:

https://apm-prod-server:8443/AppManager/xml/AddMonitor?apikey=aaaaaabbbbbbccccccddddddeeeeee&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=admin&password=appman

For a Local File when Content Check is enabled:

https://apm-prod-server:8443/AppManager/AppManager/xml/AddMonitor?apikey=aaaaaabbbbbbccccccddddddeeeeee&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

For a Remote File when Content Check is enabled:

https://apm-prod-server:8443/AppManager/xml/AddMonitor?apikey=aaaaaabbbbbbccccccddddddeeeeee&type=File Monitor&displayname=test12&filepath=C:\Test\Grep.txt&serversite=remote&pollinterval=5&timeout=60&contentChk=on&
ccontent=Exception&fileCheckType=whole&choosehost=-1&monitoringmode=WMI&host=app-xp2&username=admin&password=appman

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

https://apm-prod-server:8443/AppManager/xml/AddMonitor?apikey=aaaaaabbbbbbccccccddddddeeeeee&type=File Monitor&displayname=test6&filepath=F:\LATEST\AppManager\logs\stdout.txt&serversite=local&pollinterval=5&timeout=60&
fileDirAge=yes&selectMonStatus=down&selectChangeType=0&timeval=50&timeUnit=Minutes&contentChk=on&
ccontent=test&fileCheckType=whole

Directory Monitoring

For a Local Directory:

https://apm-prod-server:8443/AppManager/xml/AddMonitor?apikey=aaaaaabbbbbbccccccddddddeeeeee&type=Directory Monitor&displayname=testAPI&filepath=E:\temp&serversite=local&pollinterval=5&timeout=60&checkAvailability=on

For a Remote Directory:

https://apm-prod-server:8443/AppManager/xml/AddMonitor?apikey=aaaaaabbbbbbccccccddddddeeeeee&type=Directory Monitor&displayname=testAPI4123&filepath=D:\test123&serversite=remote&monitoringmode=WMI&choosehost=-1&host=172.20.18.187&username=admin&password=appman&pollinterval=5&timeout=60&checkAvailability=on

For a Local Directory when Filter Files is enabled:

https://apm-prod-server:8443/AppManager/AppManager/xml/AddMonitor?apikey=aaaaaabbbbbbccccccddddddeeeeee&type=Directory Monitor&displayname=testAPI&filepath=E:\temp&serversite=local&pollinterval=5&timeout=60&checkAvailability=on&filterFiles={"condition":"GT","unit":"Minutes","alertSeverity":1,"filepattern":"*.txt","category":"mod","value":5}

For a Remote Directory when Filter Files is enabled:

https://apm-prod-server:8443/AppManager/xml/AddMonitor?apikey=aaaaaabbbbbbccccccddddddeeeeee&type=Directory%20Monitor&displayname=testAPI4123&filepath=D:\test123&serversite=remote&monitoringmode=WMI&choosehost=-1&host=172.20.18.187&username=admin&password=appman&pollinterval=5&timeout=60&checkAvailability=on&filterFiles={"condition":"GT","unit":"Minutes","alertSeverity":1,"filepattern":"*.txt","category":"mod","value":5}

Script Monitor

Syntax

https://[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 parametersValueDescription        
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.
globalseverity true/false Option to affect health when exception occurs.

If Remote Server option is selected, the parameters are:

FieldValueDescription        
host   The name or IP address of the host where the script monitor is running.
monitoringmode TELNET/SSH/POWERSHELL Specifies the Mode Of Monitoring. ( Telnet/SSH for Linux and Powershell for Windows)
choosehost -1/hostid For new host, use -1, else use id value from the query 'select * from AM_SCRIPTHOSTDETAILS'
port 23/22 The port number.
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:

FieldValueDescription        
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:

FieldValueDescription        
tablespresent on/off Output Settings. Default value: off
table_row   Number of rows in the table 
table<index>   Table name
numericatt<index>   Numeric attribute
stringatt<index>   String attribute
pcatt<index>   Unique column
cdl<index>   Column delimiter
message   Arguments
pollinterval   Polling interval
timeout   Time out
manageTableRow retain/delete/unmanage Options to manage table row. (retain, delete, or unmanage)
healthTableRow critical/warning/clear Options to manage table data. (critical, warning, or clear)

Sample Request

For a local server:

https://apm-prod-server:8443/AppManager/xml/AddMonitor?apikey=aaaaaabbbbbbccccccddddddeeeeee&type=Script Monitor&displayname=test1&serverpath=F:\AppManager\bin\CkServerConnection.bat&workingdirectory=
F:\Managed\AppManager\bin\&serversite=local&pollinterval=5&timeout=30&globalseverity=true

For a remote server:

https://apm-prod-server:8443/AppManager/xml/AddMonitor?apikey=aaaaaabbbbbbccccccddddddeeeeee&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=admin&password=appman&prompt=$&port=22&globalseverity=true

For a Command type script:

https://apm-prod-server:8443/AppManager/xml/AddMonitor?apikey=aaaaaabbbbbbccccccddddddeeeeee&type=Script Monitor&displayname=testAPI222&serverpath= echo helo&workingdirectory=/home/test&serversite=remote&pollinterval=5&timeout=60&choosehost=5&isCommand=true&globalseverity=true

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

https://apm-prod-server:8443/AppManager/xml/AddMonitor?apikey=aaaaaabbbbbbccccccddddddeeeeee&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==&globalseverity=true

With the tables in output file enabled:

https://apm-prod-server:8443/AppManager/xml/AddMonitor?apikey=aaaaaabbbbbbccccccddddddeeeeee&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&healthTableRow=critical&globalseverity=true