Git Product home page Git Product logo

monitoring-agent's Introduction

Monitoring Agent

Test, Build and Release Go Report Card License: MIT

A simple, modern, maintainable and flexible monitoring agent that works cross platform.

Status

Released

Current Features

  • Designed to work with Nagios, Naemon and other similar monitoring platforms that perform active checks
  • Cross platform
  • Executes a passed in script (no need to deploy scripts to monitored hosts)
  • Continuous Integration/Delivery
  • Windows MSI / Service
  • Optional enforcement of script signing
  • Optional enforcement of client TLS
  • systemd service
  • Packaging for debian/ubuntu

Features in Development

  • Potentially peformance counter integration for Windows

Simple Usage Examples

Linux against Linux

$ curl -k -H "Content-Type: application/json" --data '{ "path": "perl", "args": [ "-e", "print \"Hello, World\"" ] }' https://test:[email protected]:9000/v1/runexecutable

Windows (cmd) against Linux

curl -k -H "Content-Type: application/json" --data "{""path"":""perl"",""args"":[""-e"",""print 'Hello, World'""]}" https://test:[email protected]:9000/v1/runexecutable

Windows (cmd) against Windows

curl -k -H "Content-Type: application/json" --data "{""path"":""C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe"",""args"":[""-Command"",""Write-Host Hello, World""]}" https://test:[email protected]:9000/v1/runexecutable

Windows (powershell 7) against Windows

Invoke-RestMethod -SkipCertificateCheck -Method POST -UseBasicParsing -Credential (Get-Credential) -Uri "https://127.0.0.1:9000/v1/runexecutable" -ContentType "application/json" -Body '{"path":"C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe","args":["-Command","Write-Host Hello, World"]}'

Linux against Windows

curl -k -H "Content-Type: application/json" --data '{ "path": "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe", "args": [ "-Command", "Write-Host Hello, World" ] }' https://test:[email protected]:9000/v1/runexecutable

All of these examples should produce the following output. Output:

{"exitcode":0,"output":"Hello, World\n"}

Integration with Nagios/Naemon etc.

See the Monitoring Agent Scripts Repository

For the performance optimised check_nrpe equivalent see the Monitoring Agent Client Repository

Wiki

For more information, including how to build and run Monitoring Agent, see the wiki.

Read the security page before using Monitoring Agent in a production environment. The default configuration has been created for ease of testing and is inherently insecure.

monitoring-agent's People

Contributors

dependabot[bot] avatar infraweavers avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

mintsoft

monitoring-agent's Issues

Powershell scripts using $Error blow up when executed through the stdin controller

It appears that scripts executed via stdin cannot use $Error otherwise they will blow up with things such as:

Exception calling "ReadLine" with "2" argument(s): "Specified method is not supported." Exception calling "ReadLine" with "2" argument(s): "Specified method is not supported." Exception calling "ReadLine" with "2" argument(s): "Specified method is not supported." Exception calling "ReadLine" with "2" argument(s): "Specified method is not supported." System.Management.Automation.IncompleteParseException: Missing closing '}' in statement block or type definition.
   at System.Management.Automation.AutomationEngine.ParseScriptBlock(String script, String fileName, Boolean interactiveCommand)
   at System.Management.Automation.Runspaces.Command.CreateCommandProcessor(ExecutionContext executionContext, CommandFactory commandFactory, Boolean addToHistory, CommandOrigin origin)
   at System.Management.Automation.Runspaces.LocalPipeline.CreatePipelineProcessor()
   at System.Management.Automation.Runspaces.LocalPipeline.InvokeHelper()
   at System.Management.Automation.Runspaces.LocalPipeline.InvokeThreadProc() Exception calling "ReadLine" with "2" argument(s): "Specified method is not supported." The term 'Get-WdsInstallImage' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. Exception calling "ReadLine" with "2" argument(s): "Specified method is not supported." Exception calling "ReadLine" with "2" argument(s): "Specified method is not supported." Exception calling "ReadLine" with "2" argument(s): "Specified method is not supported." System.Management.Automation.IncompleteParseException: An empty pipe element is not allowed.
   at System.Management.Automation.AutomationEngine.ParseScriptBlock(String script, String fileName, Boolean interactiveCommand)
   at System.Management.Automation.Runspaces.Command.CreateCommandProcessor(ExecutionContext executionContext, CommandFactory commandFactory, Boolean addToHistory, CommandOrigin origin)
   at System.Management.Automation.Runspaces.LocalPipeline.CreatePipelineProcessor()
   at System.Management.Automation.Runspaces.LocalPipeline.InvokeHelper()
   at System.Management.Automation.Runspaces.LocalPipeline.InvokeThreadProc() Exception calling "ReadLine" with "2" argument(s): "Specified method is not supported." Exception calling "ReadLine" with "2" argument(s): "Specified method is not supported." Exception calling "ReadLine" with "2" argument(s): "Specified method is not supported." Exception calling "ReadLine" with "2" argument(s): "Specified method is not supported." Exception calling "ReadLine" with "2" argument(s): "Specified method is not supported." Exception calling "ReadLine" with "2" argument(s): "Specified method is not supported." Exception calling "ReadLine" with "2" argument(s): "Specified method is not supported." Exception calling "ReadLine" with "2" argument(s): "Specified method is not supported." Exception calling "ReadLine" with "2" argument(s): "Specified method is not supported." Exception calling "ReadLine" with "2" argument(s): "Specified method is not supported." Exception calling "ReadLine" with "2" argument(s): "Specified method is not supported." System.Management.Automation.IncompleteParseException: The hash literal was incomplete.
   at System.Management.Automation.AutomationEngine.ParseScriptBlock(String script, String fileName, Boolean interactiveCommand)
   at System.Management.Automation.Runspaces.Command.CreateCommandProcessor(ExecutionContext executionContext, CommandFactory commandFactory, Boolean addToHistory, CommandOrigin origin)
   at System.Management.Automation.Runspaces.LocalPipeline.CreatePipelineProcessor()
   at System.Management.Automation.Runspaces.LocalPipeline.InvokeHelper()
   at System.Management.Automation.Runspaces.LocalPipeline.InvokeThreadProc() Exception calling "ReadLine" with "2" argument(s): "Specified method is not supported." Exception calling "ReadLine" with "2" argument(s): "Specified method is not supported." Exception calling "ReadLine" with "2" argument(s): "Specified method is not supported." Exception calling "ReadLine" with "2" argument(s): "Specified method is not supported." Exception calling "ReadLine" with "2" argument(s): "Specified method is not supported." Exception calling "ReadLine" with "2" argument(s): "Specified method is not supported." Exception calling "ReadLine" with "2" argument(s): "Specified method is not supported." Exception calling "ReadLine" with "2" argument(s): "Specified method is not supported." Exception calling "ReadLine" with "2" argument(s): "Specified method is not supported." Exception calling "ReadLine" with "2" argument(s): "Specified method is not supported." Exception calling "ReadLine" with "2" argument(s): "Specified method is not supported." Exception calling "ReadLine" with "2" argument(s): "Specified method is not supported." System.Management.Automation.IncompleteParseException: The hash literal was incomplete.

This appears to be recursive. Tested with Powershell 5.1.19041.1

Are there any examples how to monitor a windows server?

Hi,
did i not look carefully enough or aren't there any examples of typical windows scripts? Like cpu, memory, disk. If this agent is supposed to replace NSClient++, did you create a set of (ideally compatible regarding output and performance data) scripts for your internal use? Would it be possible to show them publicly?

UTF8-BOM encoded content throws an error when executed through powershell

The attached script throws the below error:

Write-Host : The term 'Write-Host' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and
try again.
At line:1 char:1
+ Write-Host "1st line."
+ ~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Write-Host:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

unicode.txt

Windows: Service intermittently stops

We've had 3 occurrences over the last 6 months where the service stops by itself, there are currently no logs to indicate what the cause is other than in the system event log:

The monitoring-agent service terminated unexpectedly. It has done this 3 time(s).

Powershell scripts executed through stdin do not always execute entirely

There are a few problems with executing powershell scripts through -command - which is our canonical way of running them.

PowerShell/PowerShell#3223
https://stackoverflow.com/questions/42469918/how-to-use-mutli-line-commands-such-as-here-strings-when-piping-a-script/42475326#42475326

Example scripts that are reproducable outside of monitoring-agent can be executed from cmd like:
type executes.txt | powershell -command -
type does_not_execute.txt | powershell -command -

does_not_execute.txt
executes.txt

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.