Skip to content

Commit

Permalink
Updated the readmes for all existing use cases and updated some use c…
Browse files Browse the repository at this point in the history
…ase templates for clarity

Updated the readmes for all existing use cases and updated some use case templates for clarity.
  • Loading branch information
alexdgilbert committed Nov 8, 2021
1 parent 67f11f4 commit 7a6ca5e
Show file tree
Hide file tree
Showing 12 changed files with 185 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This template shows how to monitor all Performance Counter Instances concurrentl

<strong>Command Line Monitor - Command Gathering All Desired Performance Counter Instances</strong>

Command ran on host:
Command run on host:
wmic path Win32_PerfFormattedData_PerfOS_Processor get Name,PercentUserTime /value /format:CSV

In this monitor, we are simply launching the command that will gather all the instances using the wmic command for windows. We added /value and /format:CSV for formatting reasons. Each value will be listed on a separate line and it will be formatted as a CSV, separated by commas. This will come in handy in the next step. Note that this will require valid System Credentials.
Expand Down
4 changes: 2 additions & 2 deletions examples/Automatic Log Truncation/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This template shows how to monitor a partition size and truncate the associated

<strong>Command Line Monitor - Command Log Size Verification</strong>

Command ran on host:
Command run on host:
df -h /EMC/backend/log_shared

In this monitor, we are simply launching the command that will gather the size of the partition where the log is stored. This command will likely be different based on the platform against which it is used or even based on system configuration.
Expand All @@ -21,7 +21,7 @@ We then also added an alarm alert at a threshold of 60% usage, so that we receiv

<strong>Command Line Monitor - Log Truncate</strong>

Command ran on host:
Command run on host:
psql -U c4 c4LoggingDatabase -c 'truncate "CST_LogRecord" cascade'

In this monitor, we are simply launching the command that will truncate our problematic log file. This command will almost certainly be different based on the platform against which it is used or even based on system configuration. Important note here is that we set this command to only run manually (or in our case, when called as an alert action). This is to avoid the host to attempt to truncate the logs every two minutes (default collection interval).
45 changes: 45 additions & 0 deletions examples/JSON Output Extraction/readme.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,48 @@
<strong>JSON Output Extraction</strong>
====================================================
This template shows how to monitor the output of a JSON file, then capturing specific objects for monitoring. We first capture the output of the JSON file, then we pass it through JSON Pre-Processing, which will convert it to a csv format. From here, we can create multiple instances, and extract specific objects using Value Map monitors, Numeric Extractions, etc.

<strong>Command Line Monitor - Sample JSON</strong>

Command run on host:
cat %{FILE:sample.json}

This monitor is the method with which we retrieve the JSON file. In our case, we simply embedded a JSON file to the template (at the template level). In your setup, you will be using a different monitor to do so. This template was made to demonstrate what is done after we've collected the JSON file, so we will not be going over all the different methods of obtaining said JSON file.

Sample Output:
{
"accounts": [
{
"userId": 1,
"firstName": "Krish",
"lastName": "Lee",
"accountLocked": "True",
"passwordExpiresIn": "32",
"daysSinceLastLogin": "1"
},
{
"userId": 2,
"firstName": "Racks",
"lastName": "Jacson",
"accountLocked": "False",
"passwordExpiresIn": "63",
"daysSinceLastLogin": "1"
},
]
}

<strong>Text Pre-Processing - JSON Pre-Processing</strong>

This monitor will be used to convert the JSON in a different format, in this case CSV. This will enable us to convert each line into Dynamic Instances further down the line. We set our Entry Key to /accounts/ and our properties to /userID;/firstName;/lastName;/accountLocked;/passwordExpiresIn;/daysSinceLastLogin, to match the key of the JSON file as well as specifying which properties we want included in our CSV. Finally, we set our result separator as ";", which will be the separator used in our CSV output.

<strong>Dynamic Instances - User Account Instances</strong>

In this monitor, we use dynamic instances to create one MSX instance per CSV line. This way, we will be able to separate all of the instances, so that each can be monitored independently. By specifying the separators earlier, we can now set our Column Separators as ";". Since several set of names could theoretically contain duplicates, we opted to use multiple columns to name each instance.

<strong>Value Map - Account Locked</strong>

This monitor is used to create various status based on the content of a specific column. Similarly as the above monitor, we need to set the Column Separator to ";". We used column 5 which matches with "accountLocked". We set True as an alert, False as "OK" and anything else as "suspicious".

<strong>Numeric Extraction - Password Expires in (Days)</strong>

This monitor is where we will extract the PasswordExpiresIn value and set whichever alerts we may want. Similarly as the above monitor, we need to set the Column Separator to ";" and then specify the value as being in column number 6. In this example, we set the warning threshold at 7 days or above and the alarm threshold at 100%.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ PATROL_CONFIG
"/SENTRY/X/useCaseJsonOutputExtraction/description" = { REPLACE = "This template shows how to monitor the output of a JSON file, then capturing specific objects for monitoring. We first capture the output of the JSON file, then we pass it through JSON Pre-Processing, which will convert it to a csv format. From here, we can create multiple instances, and extract specific objects using Value Map monitors, Numeric Extractions, etc." },
"/SENTRY/X/useCaseJsonOutputExtraction/disabled" = { REPLACE = "0" },
"/SENTRY/X/useCaseJsonOutputExtraction/embeddedFileList" = { REPLACE = "sample.json" },
"/SENTRY/X/useCaseJsonOutputExtraction/embeddedFile_sample.json" = { REPLACE = "{ \"accounts\": [ { \"userId\": 1, \"firstName\": \"Krish\", \"lastName\": \"Lee\", \"accountLocked\": \"True\", \"passwordExpiresIn\": \"32\", \"daysSinceLastLogin\": \"1\"  { \"userId\": 2, \"firstName\": \"Racks\", \"lastName\": \"Jacson\", \"accountLocked\": \"False\", \"passwordExpiresIn\": \"63\", \"daysSinceLastLogin\": \"1\"  { \"userId\": 3, \"firstName\": \"Denial\", \"lastName\": \"Roast\", \"accountLocked\": \"True\", \"passwordExpiresIn\": \"45\", \"daysSinceLastLogin\": \"1\"  { \"userId\": 4, \"firstName\": \"Devid\", \"lastName\": \"Neo\", \"accountLocked\": \"False\", \"passwordExpiresIn\": \"43\", \"daysSinceLastLogin\": \"1\"  { \"userId\": 5, \"firstName\": \"Jone\", \"lastName\": \"Mac\", \"accountLocked\": \"True\", \"passwordExpiresIn\": \"31\", \"daysSinceLastLogin\": \"1\" } ]}" },
"/SENTRY/X/useCaseJsonOutputExtraction/embeddedFile_sample.json" = { REPLACE = "{ \"accounts\": [ { \"userId\": 1, \"firstName\": \"Krish\", \"lastName\": \"Lee\", \"accountLocked\": \"True\", \"passwordExpiresIn\": \"32\", \"daysSinceLastLogin\": \"1\" }, { \"userId\": 2, \"firstName\": \"Racks\", \"lastName\": \"Jacson\", \"accountLocked\": \"False\", \"passwordExpiresIn\": \"63\", \"daysSinceLastLogin\": \"1\" }, { \"userId\": 3, \"firstName\": \"Denial\", \"lastName\": \"Roast\", \"accountLocked\": \"True\", \"passwordExpiresIn\": \"45\", \"daysSinceLastLogin\": \"1\" }, { \"userId\": 4, \"firstName\": \"Devid\", \"lastName\": \"Neo\", \"accountLocked\": \"False\", \"passwordExpiresIn\": \"43\", \"daysSinceLastLogin\": \"1\" }, { \"userId\": 5, \"firstName\": \"Jone\", \"lastName\": \"Mac\", \"accountLocked\": \"True\", \"passwordExpiresIn\": \"31\", \"daysSinceLastLogin\": \"1\" } ]}" },
"/SENTRY/X/useCaseJsonOutputExtraction/label" = { REPLACE = "Use Case - JSON Output Extraction" },
"/SENTRY/X/useCaseJsonOutputExtraction/macroList" = { REPLACE = "" },
"/SENTRY/X/useCaseJsonOutputExtraction/messageList" = { REPLACE = "" },
Expand Down Expand Up @@ -89,7 +89,7 @@ PATROL_CONFIG
"/SENTRY/X/useCaseJsonOutputExtraction:sampleJson:jsonPreProcessing:userAccountInstances:passwordExpiresIn/convertUnits" = { REPLACE = "0" },
"/SENTRY/X/useCaseJsonOutputExtraction:sampleJson:jsonPreProcessing:userAccountInstances:passwordExpiresIn/discardNegativeDelta" = { REPLACE = "0" },
"/SENTRY/X/useCaseJsonOutputExtraction:sampleJson:jsonPreProcessing:userAccountInstances:passwordExpiresIn/fieldNumber" = { REPLACE = "6" },
"/SENTRY/X/useCaseJsonOutputExtraction:sampleJson:jsonPreProcessing:userAccountInstances:passwordExpiresIn/fieldSeparators" = { REPLACE = "[__SW_SENTRY__] [__SW_SENTRY__]" },
"/SENTRY/X/useCaseJsonOutputExtraction:sampleJson:jsonPreProcessing:userAccountInstances:passwordExpiresIn/fieldSeparators" = { REPLACE = "[__SW_SENTRY__];[__SW_SENTRY__]" },
"/SENTRY/X/useCaseJsonOutputExtraction:sampleJson:jsonPreProcessing:userAccountInstances:passwordExpiresIn/label" = { REPLACE = "Password Expires In (Days)" },
"/SENTRY/X/useCaseJsonOutputExtraction:sampleJson:jsonPreProcessing:userAccountInstances:passwordExpiresIn/lineMode" = { REPLACE = "1" },
"/SENTRY/X/useCaseJsonOutputExtraction:sampleJson:jsonPreProcessing:userAccountInstances:passwordExpiresIn/messageList" = { REPLACE = "" },
Expand All @@ -104,6 +104,6 @@ PATROL_CONFIG
"/SENTRY/X/useCaseJsonOutputExtraction:sampleJson:jsonPreProcessing:userAccountInstances:passwordExpiresIn/scale" = { REPLACE = "1" },
"/SENTRY/X/useCaseJsonOutputExtraction:sampleJson:jsonPreProcessing:userAccountInstances:passwordExpiresIn/scaleOption" = { REPLACE = "1" },
"/SENTRY/X/useCaseJsonOutputExtraction:sampleJson:jsonPreProcessing:userAccountInstances:passwordExpiresIn/scientificNotation" = { REPLACE = "0" },
"/SENTRY/X/useCaseJsonOutputExtraction:sampleJson:jsonPreProcessing:userAccountInstances:passwordExpiresIn/thresholdList" = { REPLACE = "" },
"/SENTRY/X/useCaseJsonOutputExtraction:sampleJson:jsonPreProcessing:userAccountInstances:passwordExpiresIn/thresholdList" = { REPLACE = "Value;0 0 0 0 0 0;1 -2147483647 1 0 0 2;1 -2147483647 7 0 0 1" },
"/SENTRY/X/useCaseJsonOutputExtraction:sampleJson:jsonPreProcessing:userAccountInstances:passwordExpiresIn/type" = { REPLACE = "NumericExtraction" },
"/SENTRY/X/useCaseJsonOutputExtraction:sampleJson:jsonPreProcessing:userAccountInstances:passwordExpiresIn/uniqueSeparator" = { REPLACE = "0" }
"/SENTRY/X/useCaseJsonOutputExtraction:sampleJson:jsonPreProcessing:userAccountInstances:passwordExpiresIn/uniqueSeparator" = { REPLACE = "0" }
16 changes: 16 additions & 0 deletions examples/Multiple Column Separators/readme.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
<strong>Multiple Column Separators</strong>
====================================================
This template shows how to set multiple column separators. This is a very basic scenario where for some reason, each line has a different separator, perhaps due to the merging of several files, or any other reason that may come to mind. In the Dynamic Instance monitor, we have configured all of these separators so that our data output could be separated properly.

<strong>Command Line Monitor - Sample File</strong>

Command run on host:
cat %{FILE:sampleoutput.txt}

This monitor is the method with which we retrieve our output to be parsed. In our case, we simply embedded a test file to the template (at the template level). In your setup, you will be using a different monitor to do so. This template was made to demonstrate what is done after we've collected the output, so we will not be going over all the different methods of obtaining said output.

Sample Output:
Name1:Test1
Name2>Test2
Name3=Test3

<strong>Dynamic Instances - Dynamic Examples</strong>

In this monitor, we use dynamic instances to create one MSX instance per line from out output. This way, we will be able to separate all of the instances, so that each can be monitored independently. We used 3 separate column separators (":","=" and ">" ). This can be useful when data is obtained and concatenated from several sources, or simply if we have several different separators in any given line. Any sub-monitors beyond this one will also require to have the same separators set to function properly.
14 changes: 14 additions & 0 deletions examples/Numeric Extraction Using Scientific Notations/readme.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
<strong>Numeric Extraction Using Scientific Notations</strong>
====================================================
This template shows how to use the numeric extraction function to read a scientific notation format number and convert it to a decimal value in order to monitor and alert as applicable.

<strong>Command Line Monitor - Scientific Notation Output</strong>

Command run on host:
echo Value:9.99e+30

This monitor is the method with which we retrieve our output to be parsed. In our case, we simply used echo to receive an output to parse in the next monitor. In your setup, you will be using a different monitor to do so. This template was made to demonstrate what is done after we've collected the output, so we will not be going over all the different methods of obtaining said output.

Sample Output:
Value:9.99e+30

<strong>Numeric Extraction - Numeric Extraction</strong>

This monitor is where we will extract the scientific notation and set whichever alerts we may want. The important thing to note is that we enabled the option "Accept Scientific Notation". To be able to use alerting against this value, we divided it by 1e+28, leaving us with a value without scientific notations.
14 changes: 14 additions & 0 deletions examples/Numeric Extraction Using Timestamps/readme.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
<strong>Numeric Extraction Using Timestamps</strong>
====================================================
This template shows how to use the numeric extraction function to read a scientific notation format number and convert it to a decimal value in order to monitor and alert as applicable.

<strong>Command Line Monitor - Timestamp Output</strong>

Command run on host:
echo Value:9.99e+30

This monitor is the method with which we retrieve our output to be parsed. In our case, we simply used echo to receive an output to parse in the next monitor. In your setup, you will be using a different monitor to do so. This template was made to demonstrate what is done after we've collected the output, so we will not be going over all the different methods of obtaining said output.

Sample Output:
Timestamp: 01/01/2021 00:09:00

<strong>Numeric Extraction - Timestamp Extraction</strong>

This monitor is where we will extract the timestamp and calculate the time difference with the current time. To do so, we changed the Value Type to Timestamp and set the Value Parameter as "Time Elapsed From Now". Addtionally, we inputted our timestamp format "%d/%m/%Y %H:%M:%S". As this will output a result in seconds, we opted to convert it into days by dividing it by 86400 (24x60x60).
24 changes: 24 additions & 0 deletions examples/Powershell Script/readme.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
<strong>Powershell</strong>
====================================================
This template shows how to use a powershell script within Monitoring Studio X, leveraging the Command Line monitor. The first example uses an embedded file, specified in the template configuration. The second option, features the same script, but on the host where this template is active.

For powershell scripts to run successfully, the execution policy needs to be set accordingly on the host where they will be run. See microsoft documentation for more information: https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_execution_policies?view=powershell-7.1

<strong>Command Line Monitor - Powershell Command Embedded File</strong>

Command run on host:
@powershell.exe -inputformat none %{FILE:samplepowershell.ps1} test example result

In this monitor, we use the "@powershell.exe -inputformat none" to specify that we are launching the following script through Powershell. In this scenario, we embedded a Powershell script in our template, viewable at the template root level. We also added arguments (test example result) which will be added to the output of the script ($args[0] $args[1] $args[2]). This functions exactly like it typically would for powershell scripts.

Sample output:
This is the output of my powershell script. My arguments specified
in the command line are test, example and result.

<strong>Command Line Monitor - Powershell Command Host File</strong>

Command run on host:
@powershell.exe -inputformat none %{FILE:samplepowershell.ps1} test example result

In this monitor, we use the "@powershell.exe -inputformat none" to specify that we are launching the following script through Powershell. In this scenario, we are using a Powershell script located on the host system. We also added arguments (test example result) which will be added to the output of the script ($args[0] $args[1] $args[2]). This functions exactly like it typically would for powershell scripts.

Sample output:
This is the output of my powershell script. My arguments specified
in the command line are test, example and result.
18 changes: 18 additions & 0 deletions examples/Service Restart on Failure/readme.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
<strong>Service Restart on Failure</strong>
====================================================
This template shows how to setup monitoring and an alert action in order to restart a service should it stop. In this scenario, we have a service monitor set to alert us should it go down, and we have a command monitor, which is set to only run manually. In our service monitor configuration, we configured an alarm action for when the service is "stopped", which will launch the command line monitor, prompting the service to start.

<strong>Windows Service Monitor - Service: SNMP Trap</strong>

In this monitor, we are simply selecting a service to monitor. We can set different status based on what should be the expected status of the service. We have then set an Alarm that will automatically launch our other monitor, attempting to restart the service.

Sample output:
Service Name: SNMPTRAP
Description: SNMP Trap;
State: Running (OK)
Account: NT AUTHORITY\LocalService
Exit Code: 0

<strong>Command Line Monitor - Service Restart Command</strong>

Command run on host:
net start SNMPTRAP

In this monitor, we are simply launching the command that will start our problematic service. Important note here is that we set this command to only run manually (or in our case, when called as an alert action). This is to avoid the host to attempt to truncate the logs every two minutes (default collection interval).
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ PATROL_CONFIG
"/SENTRY/X/useCaseRestartServiceOnFailure:serviceRestart/thresholdList" = { REPLACE = "ExecutionTime;0 0 0 0 0 0;1 30 2147483646 0 0 1;0 0 0 0 0 0,Status;0 0 0 0 0 0;1 1 1 0 0 1;1 2 2 0 0 2" },
"/SENTRY/X/useCaseRestartServiceOnFailure:serviceRestart/timeout" = { REPLACE = "30" },
"/SENTRY/X/useCaseRestartServiceOnFailure:serviceRestart/type" = { REPLACE = "CommandLine" },
"/SENTRY/X/useCaseRestartServiceOnFailure:snmpTrap/actionList" = { REPLACE = "Status;alarm2;useCaseRestartServiceOnFailure:commandNetStartTermservice" },
"/SENTRY/X/useCaseRestartServiceOnFailure:snmpTrap/actionList" = { REPLACE = "Status;alarm2;useCaseRestartServiceOnFailure:serviceRestart" },
"/SENTRY/X/useCaseRestartServiceOnFailure:snmpTrap/label" = { REPLACE = "Service: SNMP Trap" },
"/SENTRY/X/useCaseRestartServiceOnFailure:snmpTrap/messageList" = { REPLACE = "" },
"/SENTRY/X/useCaseRestartServiceOnFailure:snmpTrap/parameterList" = { REPLACE = "ServiceDetails;1,Status;1" },
Expand Down
Loading

0 comments on commit 7a6ca5e

Please sign in to comment.