User Scripts Collector


The User Scripts Collector runs external scripts and collects their output. This collector has a wide variety of uses as its output is entirely what you want it to be.


If you haven’t installed the Linux agent already, see the instructions on this page for how to install it. If you need to disable the Linux integration or view the unique API key assigned to your account, navigate to the Integrations page under the user account drop-down menu and click the integration designated as Infrastructure under the Integration column.

Collector Configuration

  1. Navigate to the collectors folder.
    The default location is /opt/netuitive-agent/conf/collectors.
  2. Open the UserScriptsCollector.conf file.
  3. Change the enabled setting to True.
  4. Update the scripts_path setting for the directory where your scripts are located. The default location is /opt/netuitive-agent/

    For the collector to work properly, your monitored scripts must be executable and should output metrics in the form of:

    metric.path.a value
    metric.path.b value
    metric.path.c value

    … where value can be a static integer or the value stored in a variable (only numerical values are valid). Each .separator in a metric name creates another “leaf” on the metric tree (see example 1). Poorly constructed names may not resemble an organized tree on the Metrics page. Note that if you duplicate FQNs, the metrics will be merged. As long as the metrics are not passed any arguments and do not return error codes, the metrics will be collected.

  5. Save the file, and restart the Linux agent.

Additional Configuration Options

Collector Options

Option Default Description
enabled False Enable collecting User Scripts metrics.
scripts_path /opt/netuitive-agent/ Path used to find scripts to run
byte_unit Default numeric output(s).
measure_collector_time Measure the collector’s run time in milliseconds.
metrics_blacklist Regex list to match metrics to block. Mutually exclusive with metrics_whitelist option.
metrics_whitelist Regex list to match metrics to transmit. Mutually exclusive with metrics_blacklistoption.


Redhat 6 and 7
CentOS 6 and 7
Amazon Linux (latest)
Ubuntu 12, 14, 15, and 16
Debian 7, 8, and 9


Linux Agent

Additional Information

Example Scripts

You can use the User Scripts Collector as a status check for processes (e.g., whether they are up or down).

If you need help constructing metric names, check out step 4 of the collector configuration section.

Example 1

This example checks the status of the metricly-agent service and outputs the value of 1 if it is running or 0 if it is not running. The value will be stored in the processes-running.netuitive-agent.count.value metric.


  • #!/bin/sh
        procscnt=`ps aux | grep -c "[n]etuitive-agent - Handlers"`
        echo processes-running.netuitive-agent.count.value $procscnt

Example 2

This example checks for total running processes and total running threads every 60 seconds.


PROCTOTAL=`ps -A --no-headers | wc -l`
PROCTHREADS=`ps -AL --no-headers | wc -l`

echo processes.total_processes.count.value $PROCTOTAL
echo processes.total_threads.count.value $PROCTHREADS

Example 3

This example will acknowledge a log every 60 seconds and count how many times a string shows in a log. This script is used to count log occurrences and converts that number into a metric.

CHECKCOUNT=(awk -v d1="$(date --date="-1 min" "+%b %_d %H:%M")" -v  d2="$(date "+%b %_d %H:%M")" '$0 > d1 && $0 < d2 || $0 ~ d2' /var/log/secure
echo possible_sudo_hacks.count.value $CHECKCOUNT