- About LogicMonitor
- Cloud Monitoring
- Dashboards and Widgets
- Getting Started
- LM Service Insight
- About LogicModules
- Creating & Managing DataSources
- Active Discovery
- Data Collection Methods
- Groovy Support
- PowerShell Support
- Setting Up JobMonitors
- Help & Troubleshooting
- User-Defined AppliesTo Functions
- SNMP sysOID Maps
- Rest API Developers Guide
- RPC API Developers Guide - Deprecated
- Servicenow CMDB Integration
- Terminology and Syntax
PowerShell scripts can be integrated into LogicMonitor in order to monitor specific Windows stats which are unavailable from WMI or Perfmon.
The most useful way to utilise PowerShell in LogicMonitor is by using remote PowerShell scripts. Some setup in Windows is required to allow this to happen.
STEP 1: Open a PowerShell window on each pc to be monitored and enter the following (note the * can be replaced with a collector ip):
Note: The monitored devices may need to be added to the collectors trustedhosts with the command on line 2
STEP 2: Verify that remote Powershell is working and access is granted for a username and password which can be used in LogicMonitor. Open PowerShell on the machine the collector is running on and enter:
Step 3: Once this is done the collector needs to be set to allow unrestricted Powershell scripts in the agent.conf file. For information on editing this file, see Editing the Collector Config Files.
When creating the script in PowerShell, you first need to define the credentials we’re going to use to connect, this can be done with the following.
Once the credential is created this can be used to create a PowerShell session or invoke a command on a remote computer. Invoke command can be used on its own if a single command needs to be executed, if more than one command needs to be executed or a specific application is being connected to (Exchange) a PowerShell session can be created which can be reused.
Here is an example of connecting to exchange using PowerShell (Kerberos Authentication requires the use of a fully qualified domain name) and gathering the database names and servers of exchange databases. We then close the session, as there are a limited number.
Another way to execute remote commands with PowerShell is by using the Invoke-Command cmdlet. Below is an example which is for active discovery in the Veeam Backups datasource (Veeam Commands need the Veeam PSsnapin)
If a session is created, the Invoke-Command can be used multiple times to run multiple commands.
Invoke-Command doesn’t access global variables, they need to be passed within the command. See below for an example.
Discovering instances in PowerShell can be an easy task. It usually consists of using a foreach loop to find each name in a PowerShell object and printing them in the format LogicMonitor can interpret.
To collect the data for LogicMonitor we can utilise the use of the ##WILDVALUE## defined in Active Discovery to find the data for specific instances.
When you want to send data to logicmonitor the best method of achieving this is by using numerical values, this might mean converting boolean or states to integers, but this can be done with switches. A good way of pushing the data to LogicMonitor is following the format below. We can then use regex or key-value pairs as interpretation methods inside datapoints.
In this Article: