Giter Club home page Giter Club logo

nad's Introduction

DEPRECATED

This project is no longer in active development.

NAD is obsolete and has been replaced by the circonus-agent.


NAD - Node Agent Daemon


Overview

NAD is a portable, extensible, lightweight metric collection agent. It is the recommended way to collect system metrics for the Circonus monitoring platform.

NAD comes with a rich set of plugins which collect:

Further, applications can be easily added using a simple but powerful plugin system. We welcome further contributions by the community. Just submit a pull request against this repository.

NAD Features:

  • Simple HTTP interface for metric collection
  • Metrics exposed in easy to parse JSON format
  • Supports SSL for securing HTTP interface
  • Full support for histogram metrics
  • Support for Circonus real-time (1s) dashboards and graphing
  • Provides local StatsD interface for application metric submission
  • Multiple data submission paradigms:
    • pull - Circonus collects metrics using HTTP interface
    • reverse - Function behind NAT. NAD initiates secure TCP connection, Circonus uses connection to collect metrics
  • Self-configure with Circonus via the command line with a user-provided JSON configuration file

Installation

Automated Install

The easiest, and recommended, method to install NAD for Linux and Illumos based systems is via the Circonus one-step Installer (COSI). See the COSI documentation for details.

Benefits of using COSI:

  • one command install (fully automated, install NAD, create checks, graphs, worksheets and dashboards)
  • or download the install script and customize to your needs
  • customizable templates for checks, graphs, dashboards and worksheets
  • supports automation via orchestration systems (e.g. ansible, puppet, shell scripts, etc.)
  • cosi-site can be installed and run locally for complete control

Manual Install

For convenience and flexibility, pre-built packages are available for selected platforms from updates.circonus.net. These are self-contained omnibus packages built for the target OS. Packages contain the correct version of NodeJS, binaries for platform-specific plugins, and applicable service configuration. These packages will install NAD in /opt/circonus/nad and configure and start NAD as a service.

At the time of this writing, these are:

  • deb packages - Ubuntu: 14.04, 16.04
  • rpm packages - CentOS: EL6, EL7

An up-to-date list of currently supported platforms is available from COSI (list returned in JSON).

Windows Install

  1. Download from NAD repository releases
  2. Unpack NAD file downloaded from releases
  3. Ensure node v6+ installed
  4. Change to directory where NAD was unpacked
  5. Create the default plugin directory etc/node-agent.d e.g. mkdir etc\node-agent.d
  6. Run npm install npm install
  7. Create nad directory in node_modules e.g. mkdir node_modules\nad
  8. Copy lib/* into node_modules/nad e.g. xcopy lib\*.* node_modules\nad /s /e
  9. Run NAD node sbin\nad.js

Updating

For RPM or DEB based installs, go to updates.circonus.net and retrieve most recent package.

curl -O http://updates.circonus.net/node-agent/packages/<name of rpm file>
rpm -Uvh <name of rpm file>
curl -O http://updates.circonus.net/node-agent/packages/<name of deb file>
dpkg -i <name of deb file>

For pkg based systems (e.g. OmniOS) run pkg update field/nad.

Source Install

Build requirements

  • NodeJS v4.4.5+ must be installed, node and npm available in the PATH.
  • A basic development environment (compiler, GNU make, etc.) in order to build certain plugins. For OmniOS/FreeBSD/etc. you must install and use gmake.

Basic install target

A basic install from source installs NAD in /opt/circonus/nad.

For CentOS/Ubuntu:

git clone https://github.com/circonus-labs/nad.git
cd nad
sudo make install

For Illumos/FreeBSD/OpenBSD:

git clone https://github.com/circonus-labs/nad.git
cd nad
sudo gmake install

OS install targets

In addition to the basic install target, there are OS-specific installation targets. Which will build certain plugins for the specific OS platform, enable default plugins, and install an OS-specific service configuration.

  • make install-ubuntu
  • make install-rhel
  • gmake install-illumos
  • gmake install-freebsd
  • gmake install-openbsd

Install files and directories

path description
Core Directories
/opt/circous base directory
/opt/circonus/nad default installation location
/opt/circonus/nad/bin nad utilities, if applicable
/opt/circonus/nad/etc configurations
/opt/circonus/nad/etc/node-agent.d plugin directory
/opt/circonus/nad/node_agent nad module packages
/opt/circonus/nad/log nad log directory (if applicable)
/opt/circonus/nad/man nad man page
/opt/circonus/nad/sbin nad daemon
/opt/circonus/nad/var/run                 Plugin state directory    
Core Files
/opt/circonus/nad/etc/nad.conf main nad configuration (see Options)
/opt/circonus/nad/sbin/nad nad startup script
/opt/circonus/nad/sbin/nad.js main nad process
Miscellaneous Files
/opt/circonus/nad/bin/nad-log nad log viewer script, if applicable
/opt/circonus/nad/log/nad.log nad log, if applicable
/var/run/nad.pid running nad pid file, if applicable
/lib/systemd/system/nad.service systemd service configuration, if applicable
/etc/init/nad.conf upstart service configuration, if applicable
/var/svc/manifest/network/circonus/nad.xml smf service configuration, if applicable
/var/svc/method/circonus-nad smf method script, if applicable
/etc/rc.d/nad FreeBSD service configuration, if applicable

Running

Command line

/opt/circonus/nad/sbin/nad [options]

As a service

  • Systemd based systems - CentOS 7.x and Ubuntu 16.04
    • Configuration: /lib/systemd/system/nad.service
    • Enable: systemctl enable nad
    • Start: systemctl start nad
  • Upstart based systems - CentOS 6.x and Ubuntu 14.04
    • Configuration: /etc/init/nad.conf
    • Enable: presence of configuration
    • Start: initctl start nad
  • SMF based systems - OmniOS/Illumos/etc.
    • Configuration: /var/svc/manifest/network/circonus/nad.xml
    • Enable: svccfg import /var/svc/manifest/network/circonus/nad.xml
    • Start: svcadm enable nad
  • FreeBSD
    • Configuration: /etc/rc.d/nad
    • Enable: add nad_enable="YES" to /etc/rc.conf
    • Start: service nad start
  • OpenBSD - manual service configuration/installation required

    For example, add the following to your /etc/rc.local:

    if [ -x /opt/circonus/nad/sbin/nad ]; then
       echo -n ' nad'
       /opt/circonus/nad/sbin/nad --daemon --syslog
    fi

    Will start NAD and redirect logging to syslog via the logger command. To redirect logging to a file or elsewhere, replace the --syslog option with redirection e.g. > /tmp/my.log 2>&1.

Interface

NAD exposes an HTTP endpoint, the default is to listen to TCP:2609 (e.g. curl http://127.0.0.1:2609/). The output from all requests is JSON.

URI description
/ run all plugins, consolidate output, return metrics.
/run run all plugins, consolidate output, return metrics.
/run/plugin run a single plugin and return metrics. plugin is file name minus extension.
e.g. the vm.sh plugin becomes /run/vm
/inventory return list of currently enabled and loaded plugins.
/inventory?full return list of currently enabled and loaded plugins with full details for each plugin.

Options

Options are configured in /opt/circonus/nad/etc/nad.conf. Options can be set using their individual environment variables or added to a single NAD_OPTS variable (for backwards compatibility).

Option Description
General
--plugin-dir <dir> Plugin directory.
Default: /opt/circonus/nad/etc/node-agent.d
NAD_PLUGIN_DIR="<dir>"
--listen <spec> Listening IP address and port. (ip|port|ip:port)
Default: 2609
NAD_LISTEN="<spec>"
--no-statsd Disable built-in StatsD interface.
NAD_STATSD="no"
--statsd-config <file> Configuration file for StatsD interface.
Default: none
NAD_STATSD_CONFIG="<file>"
Reverse
-r, --reverse Use reverse connection to broker.
Default: false
NAD_REVERSE="yes"
--cid <cid> Check bundle ID for reverse connection.
Default: from cosi
NAD_REVERSE_CID="<cid>"
--broker-ca <file> CA file for broker reverse connection.
Default: fetch from API
NAD_REVERSE_BROKER_CA="<file>"
--target <target> Target host -- see Target below.
Default: os.hostname()
NAD_REVERSE_TARGET="<target>"
API
--api-key <key> Circonus API Token key.
Default: none
NAD_API_KEY="<key>"
--api-app <app> Circonus API Token app.
Default: nad
NAD_API_APP="<app>"
--api-url <url> Circonus API URL.
Default: https://api.circonus.com/v2/
NAD_API_URL="<url>"
--api-ca <file> CA file for API URL.
Default: none
NAD_API_CA="<file>"
SSL
--ssl-listen <spec> SSL listening IP address and port. (ip|port|ip:port)
Default: none
NAD_SSL_LISTEN="<spec>"
--ssl-cert <file> SSL certificate PEM file, required for SSL.
Default: /opt/circonus/nad/etc/na.crt
NAD_SSL_CERT="<file>"
--ssl-key <file> SSL certificate key PEM file, required for SSL.
Default: /opt/circonus/nad/etc/na.key
NAD_SSL_KEY="<file>"
--ssl-ca <file> SSL CA certificate PEM file, required for SSL w/verify.
Default: /opt/circonus/nad/etc/na.ca
NAD_SSL_CA="<file>"
--ssl-verify Enable SSL verification.
Default: false
NAD_SSL_VERIFY="yes"
Miscellaneous
-u, --uid <id> User id to drop privileges to on start.
Default: nobody
NAD_UID="<id>"
-g, --gid <id> Group id to drop privileges to on start.
Default: nobody
NAD_GID="<id>"
--log-level <level> Log level (trace, debug, info, warn, error, fatal).
Default: info
NAD_LOG_LEVEL="<level>"
-d, --debug Enable debug logging (verbose).
Default: false
-t, --trace Enable trace logging (very verbose).
Default: false
--no-watch Disable automatic plugin-dir rescan on changes. Send SIGHUP to force rescan.
-h, --help Output usage information and exit.
-V, --version Output the version number and exit.
--debugdir Create debug files for each plugin and write to this directory.
Default: none
--wipedebugdir Wipe debug directory clean before each write.
Default: false
-i, --inventory Offline inventory and exit.
Self-configure
--hostname <host> Hostname self-configure to use in check and graph names.
Default: os.hostname()
--brokerid <id> Broker ID for self-configure to use for creating check.
Default: required
--configfile <file> File in plugin-dir for self-configure.
Default: required
DEPRECATED Obsolescence 1/2018
-c <dir> DEPRECATED use --plugin-dir
-p <spec> DEPRECATED use --listen
-s <spec> DEPRECATED use --ssl-listen
-v DEPRECATED use --ssl-verify
--authtoken <token> DEPRECATED use --api-key
--apihost <host> DEPRECATED use --api-url
--apiport <port> DEPRECATED use --api-url
--apipath <path> DEPRECATED use --api-url
--apiprotocol <proto> DEPRECATED use --api-url
--apiverbose DEPRECATED NOP, see --debug
--sslcert <file> DEPRECATED use --ssl-cert
--sslkey <file> DEPRECATED use --ssl-key
--sslca <file> DEPRECATED use --ssl-ca
--cafile <file> DEPRECATED use --broker-ca

Target

Is used by both Reverse and Self-configure.

  1. Reverse will use it to search for a check if a cid is not provided and cosi was not used to setup the host.
  2. Self-configure will use it to configure the check on the broker - it is the host (IP or FQDN) the broker will connect to in order to pull metrics.

Reverse mode

Set up reverse connection for metric collection.

If the host was registered with COSI then the only required parameter is --reverse, the rest of the information will be retrieved from the COSI configuration.

If the host was not registered with COSI then a valid API Token Key must be supplied. If an explicit Check Bundle ID is supplied, NAD will use the check if it is still active. If no Check Bundle ID is supplied, NAD will search for a json:nad check where the check target matches the supplied (or default) --target.

Required:

  • --reverse flag signals nad to setup a reverse connection to the broker.
  • --api-key - optional if cosi configuration exists on host, otherwise, api key is required.

Optional:

  • --cid - will pull from cosi configuration, if available.
  • --target - to enable searching for a check (e.g. on a host not registered by cosi).

Self-configure

DEPRECATED -- use of COSI is recommended.

Providing an API token key without the reverse flag will initiate a self-configuration attempt.

Required:

  • --api-key
  • --target - Note: environment variable NAD_REVERSE_TARGET is not used for self-configure, --target must be specified on command line.
  • --brokerid
  • --configfile

Optional:

  • --hostname

StatsD

NAD-StatsD (nad-statsd) provides support for applications on the local system to send metrics using the StatsD line protocol <metricname>:<value>|<type>. The core StatsD metric types (c, g, s, ms) are supported, as well as, additional types specific to Circonus.

  • h histogram, treated exactly the same as timing (ms) metrics.
  • t text metrics.

Additionally, nad-statsd does not automatically generate derivative metrics from timings since they are represented as histograms in Circonus offering much more flexibility for analysis.

Note: nad-statsd uses a push method for submitting metrics to Circonus, as such, it is not fully compatible with real-time graphing (graphs will update as metrics are received rather than at the normal one second cadence).

Place configuration options in a file, the default is /opt/circonus/nad/etc/statsd.json. If configuration saved to a different location, use either the NAD --statsd-config command line option or set NAD_STATSD_CONFIG in nad.conf or environment to indicate where the configuration file is located. e.g. nad --statsd-config=/etc/project_configs/nad_statsd.json.

The default nad-statsd configuration is:

{
    "servers": [
        {
            "server": "udp",
            "address": "127.0.0.1",
            "port": 8125
        }
    ],
    "flush_interval": 10000,
    "group_check_id": null,
    "group_key": "group.",
    "group_counter_op": "sum",
    "group_gauge_op": "average",
    "group_set_op": "sum",
    "host_key": null,
    "host_category": "statsd",
    "send_process_stats": true    
}
  • servers - array of objects - is the same as the StatsD servers list
  • flush_interval - milliseconds - is the same as the StatsD flushInterval
  • group_check_id - /^[0-9]+$/ - the ID (numeric portion of CID) for the group check, default is to retrieve from COSI installation
  • group_key - string - metrics prefixed with this key will be sent to the group check (if enabled)
  • group_counter_op - string - sum or average group counter metrics
  • group_gauge_op - string - sum or average group gauge metrics
  • group_set_op - string - sum or average group set metrics
  • host_key - string - metrics prefixed with this key will be sent to NAD. Show up in Circonus in the host check
  • host_category - string - the category to hold the host metrics e.g. with the default host_category of 'statsd', a metric named 'my_metric' would appear in Circonus as 'statsd`my_metric'
  • send_process_stats - boolean - send nad-statsd module's processing statistics

The nad-statsd module can bifurcate metrics - sending some metrics to NAD (host) and some to a group check (intended to be used by multiple hosts - e.g. a group of web servers). If the --group parameter is provided to COSI when the system is registered, it will create a group check (or use the existing group check if one has already been created from another system registration with the same --group). Additional systems which use the same --group parameter when COSI registers them will also send group metrics to the same group check. This allows application metrics to go to either the host, the group, or both - providing more flexibility in viewing, aggregating and analytics. If an HTTPTrap group check is manually created using the UI, set group_check_id in the nad-statsd configuration file. Additionally, if an HTTPTrap check is created manually it must have asynchronous set to disabled, in the Advanced Configuration section, in order for metrics submitted by systems in the group to be handled correctly.

host_key and group_key

The host_key and group_key are metric name prefixes which determine the disposition of a given metric. The host and group key prefix is removed from the metric name when it is submitted to Circonus.

metric name host_key group_key disposition
foo null null all metrics go to host
preference group
host.foo host. null foo goes to host
blah host. null metrics not prefixed with host. go to group
DEFAULT preference host
group.foo null group. foo goes to group
bar.yadda null group. metrics not prefixed with group. go to host
explicit only
host.foo host. group. foo goes to host
group.foo host. group. foo goes to group
drop_me host. group. all other metrics are ignored

Note: If a group check is not enabled and a group_key is configured -- all metrics destined for group, prefixed with the group_key, will be ignored.

how group metrics are handled

type default option
c sum group_counter_op ('sum' or 'average')
g average group_gauge_op ('sum' or 'average')
ms n/a all samples received are represented
h n/a all samples received are represented
s sum group_set_op ('sum' or 'average')
t n/a note: with text metrics the last one received is used

Plugins

NAD plugins are located in the plugin directory (default: /opt/circonus/nad/etc/node-agent.d, configurable with --plugin-dir option). If the automated or manual install were used, platform specific plugins for the current OS are already built. If the source installation method was used - change to the appropriate directory for the current OS and run make or gmake to build the platform specific plugins for the OS. (e.g. cd /opt/circonus/nad/etc/node-agent.d/linux && make)

When NAD starts it scans the plugin directory for plugins to enable. Rudimentary filters are used to determine what is a plugin and what is not. e.g. entry is not a directory, entry has a name in the format name.ext, entry is executable, entry is not a configuration file (extension of .json or .conf), etc. It is recommended that plugins be stored in subdirectories of the plugin directory. Subdirectories are not scanned, those plugins will not be loaded and enabled without an additional step.

To enable a plugin, create a symlink in the plugin directory. For example:

cd /opt/circonus/nad/etc/node-agent.d  # change to plugin directory
ln -s linux/vm.sh .                    # create symlink

The plugin will be automatically found and loaded if file watching is enabled (the default). If file watching is disabled (--no-watch), send a SIGHUP to the NAD process to trigger scanning for plugins.

To disable a plugin, delete the symlink in the plugin directory. For example:

cd /opt/circonus/nad/etc/node-agent.d  # change to plugin directory
rm vm.sh                               # delete symlink

The plugin will automatically be purged from the loaded plugins if file watching is enabled (the default). If file watching is disabled (--no-watch), send a SIGHUP to the NAD process to trigger scanning for plugins.

The output from a plugin can be verified/inspected at any time by making a request for that specific plugin:

curl http://localhost:2609/run/name

where name is the name of the plugin without the extension. NAD will respond with the metrics from that plugin in JSON format.

Inventory

The currently loaded plugin inventory can be seen by making a request to the inventory endpoint.

curl http://localhost:2609/inventory

NAD will respond with a list of the currently loaded plugins. The inventory endpoint supports one argument, ?full, which includes additional details on each plugin. The output of the inventory endpoint is JSON, enabling it to be used by orchestration and monitoring tooling.

Installation will create a run-state directory in the application directory that should be writable by the non-privileged user that NAD runs as. Plugins can use this directory as scratch space to save local state, such as caching the output of an expensive command or query.

The default location is $PREFIX/nad/var/run.

Custom

For information on creating custom plugins see the Plugin section of DEVELOPMENT.md.

nad's People

Contributors

2shortplanks avatar esproul avatar gschlossnagle avatar heinrichhartmann avatar keithf4 avatar maier avatar melcabel avatar mranney avatar neophenix avatar pamaddox avatar postwait avatar redhotpenguin avatar sax avatar tp avatar vynjo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nad's Issues

Compiling on SmartOS fails

To reproduce, on a SmartOS 16.4 instance:

git://github.com/circonus-labs/nad.git into /var/tmp/nad
cd /var/tmp/nad && make install
cd /opt/circonus/etc/node-agent.d/illumos && test -f Makefile && make PREFIX=/opt/circonus

Error produced:

(cd src && gmake)
gmake[1]: Entering directory '/opt/circonus/etc/node-agent.d/illumos/src'
gcc -m64 -m64 -O3 -g -Wall -D_LARGEFILE64_SOURCE -DHAVE_LOGICAL_USED -o ../fs.elf fs.c -lzfs
fs.c: In function 'main':
fs.c:39:23: error: 'ZFS_MAXNAMELEN' undeclared (first use in this function)
           char source[ZFS_MAXNAMELEN];
                       ^
fs.c:39:23: note: each undeclared identifier is reported only once for each function it appears in
fs.c:54:13: warning: format '%llu' expects argument of type 'long long unsigned int', but argument 3 has type 'uint64_t' [-Wformat=]
             printf("zfs`%s`used\tL\t%llu\n", mnt.mnt_mountp, used);
             ^
fs.c:59:13: warning: format '%llu' expects argument of type 'long long unsigned int', but argument 3 has type 'uint64_t' [-Wformat=]
             printf("zfs`%s`avail\tL\t%llu\n", mnt.mnt_mountp, avail);
             ^
fs.c:65:11: warning: format '%llu' expects argument of type 'long long unsigned int', but argument 3 has type 'uint64_t' [-Wformat=]
           ZFS_PULL_N_PRINT(ZFS_PROP_USEDCHILD, "used_children", "L", "%llu", datum);
           ^
fs.c:66:11: warning: format '%llu' expects argument of type 'long long unsigned int', but argument 3 has type 'uint64_t' [-Wformat=]
           ZFS_PULL_N_PRINT(ZFS_PROP_USEDSNAP, "used_snapshot", "L", "%llu", datum);
           ^
fs.c:67:11: warning: format '%llu' expects argument of type 'long long unsigned int', but argument 3 has type 'uint64_t' [-Wformat=]
           ZFS_PULL_N_PRINT(ZFS_PROP_REFERENCED, "referenced", "L", "%llu", datum);
           ^
fs.c:68:11: warning: format '%llu' expects argument of type 'long long unsigned int', but argument 3 has type 'uint64_t' [-Wformat=]
           ZFS_PULL_N_PRINT(ZFS_PROP_RECORDSIZE, "record_size", "L", "%llu", datum);
           ^
fs.c:69:11: warning: format '%llu' expects argument of type 'long long unsigned int', but argument 3 has type 'uint64_t' [-Wformat=]
           ZFS_PULL_N_PRINT(ZFS_PROP_QUOTA, "quota", "L", "%llu", datum);
           ^
fs.c:70:11: warning: format '%llu' expects argument of type 'long long unsigned int', but argument 3 has type 'uint64_t' [-Wformat=]
           ZFS_PULL_N_PRINT(ZFS_PROP_RESERVATION, "reservation", "L", "%llu", datum);
           ^
fs.c:71:11: warning: format '%llu' expects argument of type 'long long unsigned int', but argument 3 has type 'uint64_t' [-Wformat=]
           ZFS_PULL_N_PRINT(ZFS_PROP_REFRESERVATION, "ref_reservation", "L", "%llu", datum);
           ^
fs.c:72:11: warning: format '%llu' expects argument of type 'long long unsigned int', but argument 3 has type 'uint64_t' [-Wformat=]
           ZFS_PULL_N_PRINT(ZFS_PROP_USEDREFRESERV, "ref_reservation_used", "L", "%llu", datum);
           ^
fs.c:74:3: warning: format '%llu' expects argument of type 'long long unsigned int', but argument 3 has type 'uint64_t' [-Wformat=]
   ZFS_PULL_N_PRINT(ZFS_PROP_LOGICALUSED, "logical_used", "L", "%llu", datum);
   ^
fs.c:75:3: warning: format '%llu' expects argument of type 'long long unsigned int', but argument 3 has type 'uint64_t' [-Wformat=]
   ZFS_PULL_N_PRINT(ZFS_PROP_LOGICALREFERENCED, "logical_referenced", "L", "%llu", datum);
   ^
fs.c:41:15: warning: unused variable 'rv' [-Wunused-variable]
           int rv;
               ^
fs.c:39:16: warning: unused variable 'source' [-Wunused-variable]
           char source[ZFS_MAXNAMELEN];
                ^
fs.c:35:39: warning: unused variable 'space_avail' [-Wunused-variable]
         uint64_t *space_used = NULL, *space_avail = NULL;
                                       ^
fs.c:35:19: warning: unused variable 'space_used' [-Wunused-variable]
         uint64_t *space_used = NULL, *space_avail = NULL;
                   ^
fs.c:34:24: warning: unused variable 'avail' [-Wunused-variable]
         uint64_t used, avail;
                        ^
fs.c:34:18: warning: unused variable 'used' [-Wunused-variable]
         uint64_t used, avail;
                  ^
fs.c:83:9: warning: format '%llu' expects argument of type 'long long unsigned int', but argument 3 has type 'long unsigned int' [-Wformat=]
         printf("fs`%s`f_bsize\tL\t%llu\n", mnt.mnt_mountp, buf.f_bsize);
         ^
fs.c:84:9: warning: format '%llu' expects argument of type 'long long unsigned int', but argument 3 has type 'long unsigned int' [-Wformat=]
         printf("fs`%s`f_frsize\tL\t%llu\n", mnt.mnt_mountp, buf.f_frsize);
         ^
fs.c:85:9: warning: format '%llu' expects argument of type 'long long unsigned int', but argument 3 has type 'fsblkcnt_t' [-Wformat=]
         printf("fs`%s`f_blocks\tL\t%llu\n", mnt.mnt_mountp, buf.f_blocks);
         ^
fs.c:86:9: warning: format '%llu' expects argument of type 'long long unsigned int', but argument 3 has type 'fsblkcnt_t' [-Wformat=]
         printf("fs`%s`f_bfree\tL\t%llu\n", mnt.mnt_mountp, buf.f_bfree);
         ^
fs.c:87:9: warning: format '%llu' expects argument of type 'long long unsigned int', but argument 3 has type 'fsblkcnt_t' [-Wformat=]
         printf("fs`%s`f_bavail\tL\t%llu\n", mnt.mnt_mountp, buf.f_bavail);
         ^
fs.c:88:9: warning: format '%llu' expects argument of type 'long long unsigned int', but argument 3 has type 'fsblkcnt_t' [-Wformat=]
         printf("fs`%s`f_files\tL\t%llu\n", mnt.mnt_mountp, buf.f_blocks);
         ^
fs.c:89:9: warning: format '%llu' expects argument of type 'long long unsigned int', but argument 3 has type 'fsfilcnt_t' [-Wformat=]
         printf("fs`%s`f_ffree\tL\t%llu\n", mnt.mnt_mountp, buf.f_ffree);
         ^
fs.c:90:9: warning: format '%llu' expects argument of type 'long long unsigned int', but argument 3 has type 'fsfilcnt_t' [-Wformat=]
         printf("fs`%s`f_favail\tL\t%llu\n", mnt.mnt_mountp, buf.f_favail);
         ^
Makefile:19: recipe for target '../fs.elf' failed
gmake[1]: *** [../fs.elf] Error 1
gmake[1]: Leaving directory '/opt/circonus/etc/node-agent.d/illumos/src'
Makefile:2: recipe for target 'all' failed
make: *** [all] Error 2

To be honest, I don't know where the heck ZFS_MAXNAMELEN is supposed to come from, but changing this to ZFS_MAXPROPLEN fixes it.

Fix was proposed here for another piece of software: https://jira.hpdd.intel.com/browse/LU-8386

Documentation tab/whitespace mismash

The documentation says:

 Alternatively, the may produce simple tab-separated metric output
 that...

Where the code allows any whitespace separated values

/^\s*(metric\s+)?(\S+)\s+(string|int|float|[iIlLns])(\s*)(.*)$/

Incomplete lines from scripts are ignored

nad currently ignores any script output that isn't terminated by a newline.

This means that printing JSON without a new line after it causes data loss (the whole JSON document), and the same for the last tab-separated format line if that's not terminated with a new line (the last data line is ignored)

if.sh on newer SmartOS kernel returns empty data

In a non-global SmartOS zone, the if.sh check returns no data.

Assuming an interface net0, it appears to run the following command:

> /usr/bin/kstat -p -m z14_net0

The working command to collect this data (on platform image joyent_20131105T084235Z) would be:

> kstat -p -n net0

Documentation out of date?

Just ran through a COSI install and poking around the installation on my agent host. I noticed that the /opt/circonus/nad is not present and it looks like it's been renamed to /opt/circonus/agent. Similarly, the agent process is not called nad, but circonus-agentd. Can this please be updated? Thanks!

nad does not handle Python scripts in config dir on Windows

Wrote a custom stand-alone python script using twill to do synthetic login testing of a web application. This works successfully when run manually or with python script.py via CLI. I print out standard tab-separated data to stdout. When nad calls the script in the config directory, I get the following error, and nad dies.

child_process.js:1155
throw errnoException(err, 'spawn');
^
Error: spawn UNKNOWN
at exports._errnoException (util.js:746:11)
at ChildProcess.spawn (child_process.js:1155:11
at exports.spawn (child_process.js:988:9)
at run_script (E:\webmd\nad-master\nad:587:13)
at E:\webmd\nad-master\nad:532:7
at FSReqWrap.cb as oncomplete

Is there a custom module needed to run a python script, or will there be support for py scripts in the future?

readlink -e does not work on FreeBSD

Installed the latest nad on my FreeBSD system and all the postgres functions broke. Seems that the -e option does not exist for readlink on FreeBSD.

$ sudo -u nobody ./pg_isready.sh
readlink: illegal option -- e
usage: readlink [-fn] [file ...]
usage: dirname string [...]
Unable to find pg functions /pg_functions.s

-f does exist on both linux and bsd and appears to give equivalent output, just doesn't do as much checking I guess?

  -f, --canonicalize            canonicalize by following every symlink in
                                every component of the given name recursively;
                                all but the last component must exist
  -e, --canonicalize-existing   canonicalize by following every symlink in
                                every component of the given name recursively,
                                all components must exist
$ readlink -f pg_isready.sh                                                                                 
/usr/local/etc/node-agent.d/postgresql/pg_isready.sh

Changed -e to -f and now it runs

$ sudo -u nobody ./pg_isready.sh
isready_status  l       0

I can do a push request to fix them all, but wanted to be sure this works as intended

Blank line in JSON output from script causes problems

nad uses the blank line to separate various "runs" of a long running script. However, this means that any blank lines in JSON output causes errors since nad attempts to parse both halves of the JSON as individual chunks of JSON / tab separated output.

node error on 'nad_circapi" with latest version of nad

When installing the latest version of nad, I get the following error when starting it up or running any command-line options:

module.js:340
    throw err;
          ^
Error: Cannot find module 'nad_circapi'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (/opt/circonus/sbin/nad:17:14)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)

This is on SmartOS base64 images.

Race condition with global generation number

There's a race condition in nad to do with the global generation number and the watching of files for updates.

Callbacks that are executed when a file is updated are assigned to files inside the stat callback in rescan_modules (i.e. watches are enabled after each stat on that file has completed.)

When all stats have been returned sweep is executed, and anything that has the old generation number is removed from the scripts list. However: If someone touches one of the just watched file before all the stats return then rescan_modules could be re-entered before the sweep() executes. If this happens then the generation number will be incremented, and the sweep from the first execution will now be comparing the generation number in each object in the script object against the global generation from the second execution of rescan_modules, not the first, and could remove some of the script object by mistake. Worse, if the second execution of rescan_modules hasn't completed executing fs.readdir by this point it's possible that these scripts won't be re-added and will won't run at all till someone makes another change on disk.

This could be fixed with a per-closure copy of the generation number used for comparison purposes.

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.