Code Monkey home page Code Monkey logo

resolve-open-alerts's Introduction

Resolve Open Alerts

A Datto RMM Component to resolve Open Alerts via the RMM API.

This Component compliments existing Alert Resolution options in RMM, offering more flexibility and control over Alert Resolution, especially for 100s and 1000s of Open Alerts.

License: GPL-3 Powershell: Version 4, 5 and 6 Platforms: Windows, macOS, Linux
Releave: Version 2 Release Date Downloads Open Issues

Resolve Open Alerts sample image

Prerequisites

Deployment

Import component in RMM

Save RMM API token on target device

  • In RMM, Activate the API
  • Save the API Key, API Secret Key and API URL in a text file
  • Download RMM API example files and extract powershell_token.ps1
  • Open Powershell ISE as Administrator and open script powershell_token.ps1
  • Scroll to the bottom of powershell_token.ps1, add code below and run script

For options outside Powershell, use curl_token.bat or csharp_token.cs

# Define parameters
$params = @{
  apiUrl        = '[API URL]'
  apiKey        = '[API Key]'
  apiSecretKey  = '[API Secret Key]'
}

# Call New-AemApiAccessToken function using defined parameters 
$key = New-AemApiAccessToken @params

# Save API Token as System Variable
[Environment]::SetEnvironmentVariable('RMMAPIKey',$key,'Machine')

Requires process refresh for changes, close and reopen Powershell ISE, then run below command to confirm token saved as System variable

[Environment]::GetEnvironmentVariable('RMMAPIKey', 'Machine')

If token is not displayed, try saving again by rerunning Powershell ISE as Administrator

RMM API token is not suitable as RMM Site Variable due to its character length exceeding limit.

Run component on target device

Environment Variables

If running in production (e.g. from RMM), you only need to configure $Env:RMMAPIKey at System level, see Deployment.

Other variables required at deployment time, must be set manually in Invoke-MockComponent for local development and mock testing.

  • $Env:CS_WS_ADDRESS - preconfigured in RMM {merlot-centrastage.net | concord-centrastage.net | etc}
  • $Env:Target {site | account}, default is site of device running component
  • $Env:SiteID, set here if $Env:Target = "site"
  • $Env:Priority {All | Information | Low | Moderate | High | Critical}
  • $Env:MonitorType, use Monitor Class names
  • $Env:DeviceType {Desktop | Laptop | Server | ESXI Host | Printer | Network Device}
  • $Env:UdfNumber {1-30}, UDF must be set to "resolvealerts" in RMM, see image below

Sample UDF value

See variables in Powershell and variables in RMM.

Running Directly in Powershell

The quickest way to try out this component is by running in Powershell.

The default RMM script timeout of 1 hour should resolve max 30,000 Alerts.

Running Tests

Requires environment variables.

Unit Tests have not been written for any functions yet, but Invoke-MockComponent can be used for local development, Integration Testing and/or Stress Testing. Just uncomment invocation at bottom of file, see snippet below.

Production/Live mode

#Invoke-MockComponent
Invoke-RMMComponent

Development mode

Invoke-MockComponent
#Invoke-RMMComponent

When using Invoke-MockComponent, Alerts are never resolved. Alert Resolution is simulated by using already Resolved Alerts as mock data.

For actual Alert Resolution in local development, use Invoke-RMMComponent directly with environment variables.

Contributing

Anyone can contribute.

  • Open a new issue to request bug fixes, features or a simple question
  • Create a pull request to submit your own fixes, unit tests, features, or for typos and document updates
  • Submit test cases

License

License: GPL-3

resolve-open-alerts's People

Contributors

piouson avatar

Stargazers

 avatar

Watchers

 avatar  avatar

resolve-open-alerts's Issues

Monitor type filter for CPU and Memory are the same

The same Performance Resource values is used for CPU and Memory monitor type filtering.
Thus, selecting CPU will also resolve Memory Alerts, and vice versa.
This is the same issue with Offline and Online Alerts, which can be similarly separated.

Todo:

  • Separate CPU and Memory filters to two distinct filtering options
  • Separate Online and Offline filters to two distinct filtering options

Anyone who would like to take on this issue should comment for more details.
Thank you.

Document features in readme

  • Add title
  • Add description / badges
  • Add prerequisites
  • Add getting started
  • Add required variables
  • Add tests description
  • Add deployment steps
  • Add contributing steps
  • Add license

Alerts outside filter options are being resolved

I noticed alerts are being resolved randomly, for example, filter options to only resolve alerts for Servers also resolves alerts for other device types.
Filter options implementation needs to be reviewed and corrected to ensure only alerts matching filter criteria are resolved

  • Review filter by priority
  • Review and correct filter by monitor type
  • Review and correct filter by device type
  • Review and correct filter by udf number

Add more alert filtering options

In addition to Priority, add new Alert Resolution filtering options;

  • Resolve Alerts by Monitor Type
  • Resolve Alerts by Device Type
  • Resolve Alerts by Device UDF Value

Reword page processing output

Change
Write-Host ("[Next Page] Processing {0} Alert(s)..."
To
Write-Host ("[New Page] Processing {0} Alert(s)..."

Refactor API error messages

Implement error handling for API error codes

  • Add message for error 401
  • Add message for error 403
  • Add message for error 404
  • Add message for other errors

Update variables in RMM component

  • Selection variables should have All as first selection
  • All should have an empty value
  • Script should correctly process options with empty values

Add api key and api secret key as component parameters

Currently users need to configure api token outside of RMM in order to use this component..
This can be avoided if the api key and api secret key are component parameters.
This way, users stay within RMM to configure and use this component..

  • Add component parameter for api key
  • Add component parameter for api secret key
  • Implement api token generation
  • Run integration/mock tests

Code cleanup

Refactor code, move repeating statements to function

Bump code compatibility to powershell 6.2

  • Code compatibility for Powershell 3.0
  • Code compatibility for Powershell 5.1
  • Code compatibility for Powershell 6.2
  • Code compatibility for Windows, macOS and Linux

Optimise alert filtering

  • Improve error handling for device filtering
  • Skip duplicate device search
  • Introduce Test threshold
  • Cleanup code

Validate alert filtering options for monitor types

These alert filtering options under MonitorTypes have not been tested and requires validation.

  • CPU Monitor
  • Datto (BCDR) Monitor
  • File and Folder Monitor
  • Memory Monitor
  • SNMP Throughput Monitor
  • Software Monitor
  • Performance Counter Monitor

This requires an RMM account with an open/resolved alert of the above types.
Please drop a comment if interested in taking this issue.

Thank you.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.