Script monitoring with NetCrunch

Despite huge capabilities of monitoring, NetCrunch offers the possibility of executing and parsing any given script, this allows monitoring almost everything with any script on any machine. This article shows a very simple example of how script monitoring can be used to get data in specific conditions.

Script Sensors in NetCrunch

NetCrunch offers two kinds of script sensors:

  • Remote Script sensor - This sensor can be executed on a remote system
  • Script sensor - This sensor executes the script on the local NetCrunch machine

The scenario of this article will use Remote Script as an example

Remote Script pre-requisites

To use remote script it's mandatory to put the file that should be executed in a directory accessible by NetCrunch, the best way to do it is to use the user that NetCrunch uses for monitoring.

Since script result (in this case) is not formatted for NetCrunch, we need to use specific Data Parser to let NetCrunch understand the data that comes from the script. Both of the files

Scenario

This article scenario is really simple: Get an alert when the status of given service is changed from active to inactive, therefore instead of writing script, a simple command can be executed, also parsing response is not a problem because it's just a single status.

Keep in mind that you need to add parser prior to adding the script

Parser: Javascript

result .status('Status', data)

Setup remote script sensor

To add the remote script sensor follow steps below:

  • Open node status where the script should be executed
  • Click on +Add monitoring Sensor
  • Type: "Remote" in the search box and select Remote Script Sensor

Sensor Configuration:

  • Script File: systemctl
  • Script Parameter: name: is-active value:
  • Script Parameter: name: || value: true
  • Run As: user (for some cases, you may need to run as root - sudo)
  • Script Output Data Format:
sensor configuration

Alert Configuration:

  • Click on Add Alert and select "New Event for Status Object Change"
    • Object Id: Status
    • State: Custom Value: active
    • State: Custom Value: inactive
alert configuration

Result

With this simple configuration, it's possible to monitor the status of any service, status alerts will be generated on state change.

alert

netcrunch 10.5remoteremote scriptscript

NetCrunch Network Monitoring

Network Maps, Dashboards, and Alerts.
Monitor anything. Network, cloud, config.