### Handle Log Example Clicks Source: https://github.com/nagiosenterprises/ncpa/blob/master/agent/listener/templates/gui/api.html Initializes the log name selector when a log example is clicked. ```javascript $('.log-example').click(function() { $('.log-name-selector .list ``` -------------------------------- ### Run NCPA Installer Source: https://github.com/nagiosenterprises/ncpa/blob/master/build/resources/macosreadme.txt Execute the installer script from the mounted volume using sudo privileges. ```bash sudo zsh /Volumes/NCPA-/install.sh ``` -------------------------------- ### Handle Counter Example Clicks Source: https://github.com/nagiosenterprises/ncpa/blob/master/agent/listener/templates/gui/api.html Updates the UI fields when a user selects a predefined counter example. ```javascript $('.example').click(function() { var counter = $(this).data('counter'); var sleep = $(this).data('sleep'); $('.windows-counter').val(counter); if (sleep == 0) { $('.sleep').val(''); } else { $('.sleep').val(sleep); } reload\_api\_browser(); }); ``` -------------------------------- ### Build NCPA on Windows Source: https://github.com/nagiosenterprises/ncpa/blob/master/BUILDING.rst Execute the Windows build script to install prerequisites and build the NCPA installer. This script requires administrative privileges and may necessitate system reboots. ```batch cd /path/to/ncpa/build/ build_windows.bat ``` -------------------------------- ### Build NCPA on Linux Source: https://github.com/nagiosenterprises/ncpa/blob/master/BUILDING.rst Run the Linux build script as root to install requirements and compile the NCPA binary. Ensure Python 3.11+ and git are installed beforehand. ```bash cd ncpa/build ./build.sh ``` -------------------------------- ### Install Homebrew on macOS Source: https://github.com/nagiosenterprises/ncpa/blob/master/BUILDING.rst Install the Homebrew package manager, which is required for installing Python and other dependencies on macOS. ```bash /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" ``` -------------------------------- ### Install Xcode Command Line Tools on macOS Source: https://github.com/nagiosenterprises/ncpa/blob/master/BUILDING.rst Install the necessary Xcode command line tools for building NCPA on macOS. ```bash xcode-select --install ``` -------------------------------- ### Start NCPA Service on AIX Source: https://github.com/nagiosenterprises/ncpa/blob/master/BUILDING.rst Use this command to start the NCPA service managed by AIX SRC. ```bash startsrc -s ncpa ``` -------------------------------- ### Install Python Requirements on Windows Source: https://github.com/nagiosenterprises/ncpa/blob/master/CONTRIBUTING.rst Installs the necessary Python packages for NCPA development on Windows using pip. ```bash python -m pip install -r resources/requires.txt ``` -------------------------------- ### Install New NCPA Package on Solaris Source: https://github.com/nagiosenterprises/ncpa/blob/master/BUILDING.rst Upgrade NCPA by installing the new package using 'pkgadd'. The process automatically handles stopping existing processes, installing new files, and starting a fresh instance while preserving configuration and logs. ```bash pkgadd -a ./admin_file -d ./ncpa-3.X.X..pkg ``` -------------------------------- ### Install NCPA RPM on OpenSuSE/SLES Source: https://github.com/nagiosenterprises/ncpa/blob/master/BUILDING.rst Install the NCPA RPM package on OpenSuSE or SLES systems. ```bash zypper install ./ncpa-3.X.X-latest.x86_64.rpm ``` -------------------------------- ### Define Passive Checks for Multiple Hosts Source: https://github.com/nagiosenterprises/ncpa/blob/master/agent/listener/static/help/passive.html Configuration example demonstrating how to report checks for multiple distinct hostnames. ```text server1.local|CPU Usage = plugins/check_cpu/-H server1.local/-w 60/-c 80 server2.local|CPU Usage = plugins/check_cpu/-H server2.local/-w 60/-c 80 %HOSTNAME%|CPU Usage = cpu/percent --warning 60 --critical 80 --aggregate avg ``` -------------------------------- ### Install NCPA Package Source: https://github.com/nagiosenterprises/ncpa/blob/master/BUILDING.rst Install the generated NCPA Solaris package on the target server using the pkgadd command. Replace with the appropriate architecture (sparc or i386). ```bash pkgadd -d ./ncpa-3.X.X..pkg ``` -------------------------------- ### Install NCPA DEB on Ubuntu/Debian Source: https://github.com/nagiosenterprises/ncpa/blob/master/BUILDING.rst Install the NCPA DEB package on Ubuntu or Debian systems. Use the force-depends option for older, unsupported versions. ```bash dpkg -i ./ncpa_3.X.X-latest._amd64.deb ``` ```bash dpkg --force-depends -i ./ncpa_3.X.X-latest._amd64.deb ``` -------------------------------- ### Configure NCPA Checks Source: https://github.com/nagiosenterprises/ncpa/blob/master/agent/listener/static/help/index.html Examples of check configurations that omit the /api/ endpoint prefix. ```text ./check_ncpa.py -H -t '' -M 'disk/logical/C:|' --units G %HOSTNAME%| = disk/logical/C:| --units G ``` -------------------------------- ### Run NCPA in Development Mode Source: https://github.com/nagiosenterprises/ncpa/blob/master/CONTRIBUTING.rst Starts a development instance of NCPA. This command should be run from the NCPA git working directory. ```bash cd agent python3.9 ncpa.py -d ``` -------------------------------- ### Install Python 3.13 on macOS with Homebrew Source: https://github.com/nagiosenterprises/ncpa/blob/master/BUILDING.rst Install Python version 3.13 using Homebrew. This is a prerequisite for building NCPA v3.x on macOS. ```bash brew install python@3.13 ``` -------------------------------- ### Embedding a Graph in HTML Source: https://github.com/nagiosenterprises/ncpa/blob/master/agent/listener/static/help/graphs.html A complete example showing how to load a CPU percentage graph into a div element using jQuery. ```html Embedded Graph
``` -------------------------------- ### Troubleshoot NCPA Auto-Startup (Service Script) Source: https://github.com/nagiosenterprises/ncpa/blob/master/BUILDING.rst Force NCPA startup using the service script if SMF or init script methods fail. This is a fallback mechanism to ensure NCPA starts. ```bash sudo /usr/local/bin/ncpa-service start ``` -------------------------------- ### GET /api/plugins/{plugin_name} Source: https://github.com/nagiosenterprises/ncpa/blob/master/agent/listener/static/help/api.html Executes a custom plugin script. Arguments are passed as URL parameters. ```APIDOC ## GET /api/plugins/{plugin_name} ### Description Executes a plugin script located on the NCPA agent. Arguments should be passed as URL parameters. ### Method GET ### Endpoint /api/plugins/{plugin_name} ### Parameters #### Path Parameters - **plugin_name** (string) - Required - The name of the plugin file to execute. #### Query Parameters - **args** (string) - Optional - Arguments to pass to the plugin. Can be specified multiple times. - **token** (string) - Required - The authentication token. ### Response #### Success Response (200) - **returncode** (integer) - The exit code of the plugin. - **stdout** (string) - The standard output from the plugin execution. ### Response Example { "returncode": 0, "stdout": "Arg1: -u local - Arg2: -p one,two" } ``` -------------------------------- ### Install NCPA RPM Package on AIX Source: https://github.com/nagiosenterprises/ncpa/blob/master/BUILDING.rst Install the generated NCPA RPM package on the target AIX server using the 'dnf' package manager. Ensure the package file is copied to the server first. ```bash dnf localinstall ncpa-3.X.X-latest.ppc.rpm ``` -------------------------------- ### Migrate NSClient++ to NCPA Source: https://github.com/nagiosenterprises/ncpa/blob/master/dist/README.rst Navigate to the nsclient_migration directory and execute the NSC2NCPA.py script to convert your NSClient++ installation to NCPA. ```bash cd nsclient_migration python NSC2NCPA.py ``` -------------------------------- ### Troubleshoot NCPA Auto-Startup (SMF) Source: https://github.com/nagiosenterprises/ncpa/blob/master/BUILDING.rst Steps to troubleshoot NCPA not starting automatically after a reboot, focusing on SMF service status and manual enablement. Also includes checking init script links and testing manually. ```bash svcs application/ncpa svcs -xv application/ncpa sudo svcadm enable application/ncpa ls -la /etc/rc2.d/S99ncpa /etc/rc3.d/S99ncpa sudo /etc/init.d/ncpa start sudo /etc/init.d/ncpa status ls -la /etc/init.d/ncpa sudo sh -n /etc/init.d/ncpa ``` -------------------------------- ### GET /api/disk/logical/{mount_point} Source: https://github.com/nagiosenterprises/ncpa/blob/master/agent/listener/static/help/api.html Retrieves statistics for a specific logical disk partition. ```APIDOC ## GET /api/disk/logical/{mount_point} ### Description Returns information on a specific mounted disk partition. Note: All \ and / characters in the mount point must be represented as |. ### Method GET ### Endpoint /api/disk/logical/{mount_point} ### Parameters #### Path Parameters - **mount_point** (string) - Required - The disk partition identifier (e.g., C:|). #### Query Parameters - **token** (string) - Required - The authentication token. - **units** (string) - Optional - Unit conversion: k, Ki, M, Mi, G, Gi, T, Ti. - **check** (boolean) - Optional - Enables check mode. - **warning** (string) - Optional - Warning threshold. - **critical** (string) - Optional - Critical threshold. - **delta** (integer) - Optional - Change in value over time in seconds. - **unit** (string) - Optional - Overrides the returned unit. ### Response #### Success Response (200) - **used_percent** (array) - Percentage of disk used. - **used** (array) - Amount of disk used with unit. - **total_size** (array) - Total disk size with unit. - **free** (array) - Free disk space with unit. ### Response Example { "C:|": { "used_percent": [76.8, "%"], "used": [356.94, "GiB"], "total_size": [464.87, "GiB"], "free": [107.93, "GiB"] } } ``` -------------------------------- ### Define Passive Check with Custom Interval Source: https://github.com/nagiosenterprises/ncpa/blob/master/agent/listener/static/help/passive.html Example of a CPU usage check configured to run every 30 seconds. ```text %HOSTNAME%|CPU Usage|30 = cpu/percent --warning 60 --critical 80 --aggregate avg ``` -------------------------------- ### Retrieve disk usage data without parameters Source: https://github.com/nagiosenterprises/ncpa/blob/master/agent/listener/static/help/api.html Example of a standard API request to retrieve disk usage in bytes. ```json { "total_size": [ 379222138880, "B" ] } ``` -------------------------------- ### Build NCPA on macOS Source: https://github.com/nagiosenterprises/ncpa/blob/master/BUILDING.rst Execute the macOS build script with sudo privileges after installing prerequisites. This script builds the NCPA binary. ```bash cd ~/ncpa/build sudo ./build.sh ``` -------------------------------- ### Retrieve disk usage data with units parameter Source: https://github.com/nagiosenterprises/ncpa/blob/master/agent/listener/static/help/api.html Example of an API request using the units parameter to convert bytes to GiB. ```json { "total_size": [ 353.09, "GiB" ] } ``` -------------------------------- ### Basic API Check via Curl Source: https://github.com/nagiosenterprises/ncpa/blob/master/agent/listener/static/help/active.html This example shows how to perform a basic active check by directly querying the NCPA API using curl. It checks the memory usage percentage. Replace and mytoken with your actual server address and token. ```bash curl -k "https://:5693/memory/virtual/percent?token=mytoken" ``` -------------------------------- ### Get User Count and List Source: https://github.com/nagiosenterprises/ncpa/blob/master/agent/listener/static/help/api.html Retrieves the number of logged-in users and a list of user sessions. Use the 'check' parameter to convert the output to a checkable format. ```json { "user": { "count": [ 2, "users" ], "list": [ [ "root", "root" ], "users" ] } } ``` -------------------------------- ### Building NCPA on Windows Source: https://github.com/nagiosenterprises/ncpa/blob/master/README.rst Link to detailed instructions for building NCPA from source on Windows systems. ```markdown `Building for Windows `_ ``` -------------------------------- ### Silent NCPA Installation Source: https://github.com/nagiosenterprises/ncpa/blob/master/BUILDING.rst Perform a silent installation of NCPA using an admin file for automated deployments. A sample admin file is included in the NCPA installation directory or repository. ```bash pkgadd -a ./admin_file -d ./ncpa-3.X.X..pkg ncpa ``` -------------------------------- ### Building NCPA on Linux Source: https://github.com/nagiosenterprises/ncpa/blob/master/README.rst Link to detailed instructions for building NCPA from source on Linux systems. ```markdown `Building for Linux `_ ``` -------------------------------- ### Document Ready and Initialization Source: https://github.com/nagiosenterprises/ncpa/blob/master/agent/listener/templates/gui/stats.html Initializes the live stats page by setting the active navigation link and calling functions to load CPU, disk, and interface statistics. It also sets up a window resize handler for graphs. ```javascript $(document).ready(function() { $('#live-nav').addClass('active'); load_cmu(); load_disk(); load_interface(); $(window).resize(function() { resize_graphs(); }); $('a[data-toggle="tab"]').on('shown.bs.tab', function (e) { resize_graphs(); }); }); ``` -------------------------------- ### Initialize WebSocket Log Tailer Source: https://github.com/nagiosenterprises/ncpa/blob/master/agent/listener/templates/tail.html Sets up the WebSocket connection and event handlers for log streaming. Requires jQuery and a valid WebSocket endpoint at /ws/tail. ```javascript var ws; var ws_loc; var logbody = $('.table tbody') var query_string = '{{ query_string }}' $(document).ready(function() { var get_ws_address = function() { var loc = window.location; if (loc.protocol === 'https:') { var ws_proto = 'wss'; } else { var ws_proto = 'ws'; } var ws_loc = ws_proto + '://' + loc.hostname + ':' + loc.port + '/ws/tail'; return ws_loc; } var get_ws_args = function() { var decoded = decodeURIComponent(query_string); return decoded; } var get_ws_total = function() { var ws_address = get_ws_address(); var ws_args = get_ws_args(); if (ws_args) { ws_address += '?' + ws_args; } return ws_address; } var add_log = function(log) { var tr = $(''); $('', {text: log.time_generated}).appendTo(tr); $('', {text: log.application}).appendTo(tr); $('', {text: log.computer_name}).appendTo(tr); $('', {text: log.category}).appendTo(tr); $('', {text: log.severity}).appendTo(tr); $('', {text: log.event_id}).appendTo(tr); $('', {text: log.message}).appendTo(tr); logbody.append(tr) }; var start_websocket = function() { ws_loc = get_ws_total(); ws = new WebSocket(ws_loc); // Set up what to do when websocket receives data ws.onmessage = function(d) { if ($('.tbl-message').length > 0) { $('.tbl-message').remove(); } logs = $.parseJSON(d.data); $.each(logs, function(i, log) { add_log(log); }) }; // Set websocket close on page change window.onbeforeunload = function() { ws.onclose = function () {}; ws.close() }; }; start_websocket(); $('.btn-apply').click(function() { var name = $('input[name="name"]').val(); query_string = "name=" + name; $('.name').text(name); // Restart the websocket ws.close(); logbody.html('No logs have came in yet.'); start_websocket(); }); $('#log-name').keypress(function(e) { if (e.which == 13) { $('.btn-apply').trigger('click'); } }); }); ``` -------------------------------- ### Initialize Top Processes View Source: https://github.com/nagiosenterprises/ncpa/blob/master/agent/listener/templates/gui/top.html Uses jQuery to set the active navigation state and load process data into the main container upon document readiness. ```html {% extends 'base.html' %} {% block title %}Top Processes{% endblock %} {% block headerjs %} $(document).ready(function() { $('#live-nav').addClass('active'); $('#main-content-container').load('/top'); }) {% endblock headerjs %} ``` -------------------------------- ### Identify NCPA Installer Volume Source: https://github.com/nagiosenterprises/ncpa/blob/master/build/resources/macosreadme.txt List mounted volumes to locate the NCPA installer disk image. ```bash ls /Volumes ``` -------------------------------- ### Initialize API documentation interface Source: https://github.com/nagiosenterprises/ncpa/blob/master/agent/listener/static/help/api.html jQuery script to initialize the API documentation page, bind tooltips, and fetch initial API data. ```javascript $(document).ready(function() { $('.api-output').css('height', $('.api-output').parents('.row').height()); $('.tt-bind').tooltip(); // Get the API data var json_url = 'https://' + location.hostname+(location.port ? ':' + location.port : '') + '/api'; $.get(json_url, { }, function(json) { $('.api-output').html(JSON.stringify(json, null, 4)); }, 'json'); }); ``` -------------------------------- ### Initialize NCPA API Browser UI Source: https://github.com/nagiosenterprises/ncpa/blob/master/agent/listener/templates/gui/api.html Sets up the initial state, event listeners for window resizing, and navigation active states. ```javascript var TMP_JSON = { }; var SERVICES = [ ]; $(document).ready(function() { // Set nav header active link and resize API window $('#api-nav').addClass('active'); resize_api_window(); reload_api_browser(); $(window).resize(function() { resize_api_window(); // Resize log timeframe if visible set_log_timeframe_size(); }); ``` -------------------------------- ### Initialize and Manage Top Processes View Source: https://github.com/nagiosenterprises/ncpa/blob/master/agent/listener/templates/top.html This JavaScript code initializes the top processes view, sets up event listeners for input fields (highlight, warning, critical), and establishes a WebSocket connection to receive process data. It handles dynamic updates to the displayed process list and system statistics. ```javascript $(document).ready(function() { var display = {{ display }}; var critical = {{ critical }}; var warning = {{ warning }}; var highlight = '{{ highlight }}'; var plbody = $('table.processes tbody'); var plhead = $('table.processes thead tr#titles') var order = ['pid', 'name', 'username', 'cpu_percent', 'mem_percent']; var current_pl = []; $('#highlight-input').on('keyup', function(e) { var raw_highlight = $(e.target).val(); if (raw_highlight === '') { highlight = null; } else { highlight = raw_highlight; } }) $('#warning-input').on('keyup', function(e) { var test = $(e.target).val(); var parsed_test = parseFloat(test); if (test === '') { warning = 0; } else if (isNaN(parsed_test)) { return; } else if (parsed_test < 0 || test > 100) { return; } else { warning = parsed_test; } }); $('#critical-input').on('keyup', function(e) { var test = $(e.target).val(); var parsed_test = parseFloat(test); if (test === '') { critical = 0; } else if (isNaN(parsed_test)) { return; } else if (parsed_test < 0 || test > 100) { return; } else { critical = parsed_test; } }); var get_ws_address = function() { var loc = window.location; if (loc.protocol === 'https:') { var ws_proto = 'wss'; } else { var ws_proto = 'ws'; } var ws_loc = ws_proto + '://' + loc.hostname + ':' + loc.port + '/ws/top'; return ws_loc; } var create_header = function(pl) { plhead.empty(); $.each(order, function(i) { var th = $('', { id: order[i], text: order[i].replace(/_/g, ' ') }); var s = $('', { class: 'signia', html: ' '}); if (order[i] == 'cpu_percent') { th.append(s); th.css('width', '12%'); th.click(function() { $('.signia').hide(); s.show(); comparator = cpu_compare; current_pl.sort(cpu_compare); create_plbody(current_pl); }); } if (order[i] == 'mem_percent') { th.append(s); th.css('width', '12%'); th.click(function() { $('.signia').hide(); s.show(); comparator = mem_compare; current_pl.sort(mem_compare); create_plbody(current_pl); }); s.hide(); } if (order[i] == 'pid') { th.css('width', '8%'); } plhead.append(th); }); } var cpu_compare = function(a, b) { if (a.cpu_percent[0] < b.cpu_percent[0]) { return 1 } if (a.cpu_percent[0] > b.cpu_percent[0]) { return -1 } return 0; } var mem_compare = function(a, b) { if (a.mem_percent[0] < b.mem_percent[0]) { return 1 } if (a.mem_percent[0] > b.mem_percent[0]) { return -1 } return 0; } var comparator = cpu_compare; var update_stats = function(cpu, virtual, swap) { var fcpu = parseFloat(cpu).toFixed(2) + '%'; var fvirtual = parseFloat(virtual).toFixed(2) + '%'; var fswap = parseFloat(swap).toFixed(2) + '%'; $('#load .current').text(fcpu); $('#virtual .current').text(fvirtual); $('#swap .current').text(fswap); } var create_plbody = function(pl) { plbody.empty(); $.each(pl, function(i) { if (display > 0 && display <= i) { return false; } var p = pl[i]; var tr = $('', {id: p.pid}); $.each(order, function(j) { var data = p[order[j]]; if (data.constructor === Array) { data = data[0]; } var td = $('', { text: data }); if (highlight != null && order[j] == 'name' && p[order[j]].indexOf(highlight) > -1) { tr.addClass('highlight'); } if ((order[j] == 'cpu_percent' || order[j] == 'mem_percent') && critical > 0 && p[order[j]][0] > critical) { td.addClass('critical'); } else if ((order[j] == 'cpu_percent' || order[j] == 'mem_percent') && warning > 0 && p[order[j]][0] > warning) { td.addClass('warning'); } tr.append(td); }) plbody.append(tr); }) } var ws_loc = get_ws_address(); var ws = new WebSocket(ws_loc); ws.onmessage = function(d) { info = $.parseJSON(d.data); var load = info.load var vir = info.vir var swap = info.swap var pl = info.process current_pl = pl; update_stats(load, vir, swap); if (plbody.children().length == 0) { create_header(pl); } pl.sort(comparator); create_plbody(pl); } }) ``` -------------------------------- ### List All Base Modules Available in API Source: https://github.com/nagiosenterprises/ncpa/blob/master/agent/listener/static/help/active.html Running check_ncpa.py with --list and no specified module will list all top-level API modules available for monitoring. ```bash ./check_ncpa.py -H -t mytoken --list ``` -------------------------------- ### Install NCPA RPM on CentOS/RHEL Source: https://github.com/nagiosenterprises/ncpa/blob/master/BUILDING.rst Install the NCPA RPM package on CentOS, RHEL, Oracle Linux, Amazon Linux, or Rocky Linux systems. ```bash yum install ./ncpa-3.X.X-latest.x86_64.rpm ``` -------------------------------- ### Toggle Automatic Startup Source: https://github.com/nagiosenterprises/ncpa/blob/master/build/resources/macosreadme.txt Enable or disable the automatic startup of the NCPA service at boot. ```bash sudo launchctl enable system/com.nagios.ncpa # Enable auto-start sudo launchctl disable system/com.nagios.ncpa # Disable auto-start ``` -------------------------------- ### Debug Boot Environment Issues Source: https://github.com/nagiosenterprises/ncpa/blob/master/BUILDING.rst Debug boot environment issues by testing the init script manually and checking environment variables like PATH and LD_LIBRARY_PATH during boot. ```bash # Check if environment variables are available during boot sudo /etc/init.d/ncpa start 2>&1 | tee /tmp/ncpa_boot_test.log # Verify PATH and library paths env | grep -E "PATH|LD_LIBRARY_PATH" ``` -------------------------------- ### List Available Nagios Plugins Source: https://github.com/nagiosenterprises/ncpa/blob/master/agent/listener/static/help/api.html Retrieve a list of all available Nagios plugins that can be executed via the NCPA API. Ensure plugins are placed in the configured plugins directory and have correct permissions. ```bash https://localhost:5693/api/plugins?token=mytoken ``` -------------------------------- ### GET /api/logs Source: https://github.com/nagiosenterprises/ncpa/blob/master/agent/listener/static/help/api.html Retrieves Windows event logs based on specified filters. ```APIDOC ## GET /api/logs ### Description Retrieves Windows event logs. Requires the 'name' parameter to specify which event logs to retrieve. ### Method GET ### Endpoint /api/logs ### Parameters #### Query Parameters - **token** (string) - Required - Authentication token - **name** (string) - Required - Name of the Windows event logs (e.g., System, Application) - **logged_after** (string) - Optional - Lookback period (e.g., 30m, 24h, 1w) - **severity** (string) - Optional - Exact match for EventType - **event_id** (string) - Optional - Exact match for EventID - **application** (string) - Optional - Exact match for SourceName - **computer_name** (string) - Optional - Exact match for ComputerName - **category** (string) - Optional - Exact match for EventCategory - **message** (string) - Optional - Search or regex match for Message field - **check** (boolean) - Optional - Turn the call into check results output - **warning** (string) - Optional - Warning threshold - **critical** (string) - Optional - Critical threshold - **type** (string) - Optional - Select if thresholds apply to 'all' or 'individual' logs ### Response #### Success Response (200) - **logs** (array) - List of event logs matching the criteria #### Response Example { "logs": [ { "Application": [ { "category": "0", "severity": "INFORMATION", "event_id": "0", "application": "Service1", "computer_name": "Win10-PC", "message": "PowerEvent handled successfully.", "time_generated": "12/04/16 01:15:37" } ] }, "logs" ] } ``` -------------------------------- ### GET /api/user Source: https://github.com/nagiosenterprises/ncpa/blob/master/agent/listener/static/help/api.html Retrieves the number of logged-in users and a list of active users. ```APIDOC ## GET /api/user ### Description Retrieves the count and list of users currently logged into the system. ### Method GET ### Endpoint /api/user ### Parameters #### Query Parameters - **token** (string) - Required - Authentication token - **check** (string) - Optional - Overrides the unit given but does not change the value - **warning** (string) - Optional - Warning threshold for check - **critical** (string) - Optional - Critical threshold for check ### Response #### Success Response (200) - **user** (object) - Contains count and list of users #### Response Example { "user": { "count": [2, "users"], "list": [["root", "root"], "users"] } } ``` -------------------------------- ### Building NCPA on Mac OS X Source: https://github.com/nagiosenterprises/ncpa/blob/master/README.rst Link to detailed instructions for building NCPA from source on Mac OS X systems. ```markdown `Building for Mac OS X `_ ``` -------------------------------- ### List Available Nodes in Disk Module Source: https://github.com/nagiosenterprises/ncpa/blob/master/agent/listener/static/help/active.html Use the --list or -l flag with a specific module (e.g., 'disk') to view all available monitoring metrics within that module without running a check. ```bash ./check_ncpa.py -H -t mytoken -M 'disk' --list ``` -------------------------------- ### GET /api/windowscounters/{category}/{counter} Source: https://github.com/nagiosenterprises/ncpa/blob/master/agent/listener/static/help/api.html Retrieves values for specific Windows performance counters. ```APIDOC ## GET /api/windowscounters/{category}/{counter} ### Description Accesses Windows performance counters. Note: Per-second counters require a 'sleep' parameter to return non-zero values. ### Method GET ### Endpoint /api/windowscounters/{category}/{counter} ### Parameters #### Path Parameters - **category** (string) - Required - The counter category - **counter** (string) - Required - The specific counter name #### Query Parameters - **token** (string) - Required - Authentication token - **sleep** (integer) - Optional - Sleep duration for per-second counters ### Response #### Success Response (200) - **windowscounters** (array) - The counter value and name #### Response Example { "windowscounters": [1421, "Connections Active"] } ``` -------------------------------- ### GET /api/cpu/percent Source: https://github.com/nagiosenterprises/ncpa/blob/master/agent/listener/static/help/api.html Retrieves CPU usage information, including per-core percentages and aggregated values. ```APIDOC ## GET /api/cpu/percent ### Description Returns the current system-wide CPU usage percentage. Supports aggregation across multiple cores. ### Method GET ### Endpoint /api/cpu/percent ### Parameters #### Query Parameters - **token** (string) - Required - The authentication token. - **aggregate** (string) - Optional - Aggregation type: avg, min, max, sum. - **check** (boolean) - Optional - Enables check mode. - **warning** (string) - Optional - Warning threshold. - **critical** (string) - Optional - Critical threshold. - **delta** (integer) - Optional - Change in value over time in seconds. - **unit** (string) - Optional - Overrides the returned unit. ### Response #### Success Response (200) - **percent** (array) - An array containing the usage values and the unit. ### Response Example { "percent": [ [18.8, 0.0, 1.5, 0.0, 13.8, 0.0, 3.2, 0.0], "%" ] } ``` -------------------------------- ### Configure NRDP Server Details Source: https://github.com/nagiosenterprises/ncpa/blob/master/agent/listener/static/help/configuration.html Set the NRDP server URL in the 'parent' option and the authentication token in the 'token' option. The 'hostname' option defines the value for the %HOSTNAME% macro. ```ini parent = http://your_nrdp_server/nrdp/ token = YOUR_TOKEN hostname = NCPA ``` -------------------------------- ### Build NCPA Prerequisites on Linux/macOS Source: https://github.com/nagiosenterprises/ncpa/blob/master/CONTRIBUTING.rst Builds the necessary prerequisites for NCPA development on Linux and macOS systems. ```bash cd build ./build.sh ``` -------------------------------- ### Manage NCPA Service on Mac OS X Source: https://github.com/nagiosenterprises/ncpa/blob/master/agent/listener/static/help/index.html Commands to stop and start the NCPA service on macOS using launchctl. ```bash sudo launchctl stop com.nagios.ncpa sudo launchctl start com.nagios.ncpa ``` -------------------------------- ### Search Processes with Multiple Names Source: https://github.com/nagiosenterprises/ncpa/blob/master/agent/listener/static/help/api.html Demonstrates searching for multiple process names using the 'or' combiner. ```http https://localhost:5693/api/processes?token=mytoken&name=steam&name=chrome&combiner=or&match=search&check=true ``` ```json { "returncode": 0, "stdout": "OK: Process count for processes named steam,chrome was 15 | 'process_count'=15;;;" } ``` -------------------------------- ### Run Memory Check with Warning and Critical Thresholds Source: https://github.com/nagiosenterprises/ncpa/blob/master/agent/listener/static/help/api.html Execute a check on the virtual memory usage percentage, specifying warning and critical thresholds. This returns Nagios plugin-style check results. ```bash https://localhost:5693/api/memory/virtual/percent?token=mytoken&warning=50&critical=60&check=1 ``` -------------------------------- ### Define Passive Checks in NCPA Configuration Source: https://github.com/nagiosenterprises/ncpa/blob/master/agent/listener/static/help/passive.html Standard examples of passive check definitions using the [passive checks] configuration syntax. ```text %HOSTNAME%|__HOST__ = system/agent_version %HOSTNAME%|CPU Usage = cpu/percent --warning 60 --critical 80 --aggregate avg %HOSTNAME%|Swap Usage = memory/swap --warning 60 --critical 80 --units Gi %HOSTNAME%|Memory Usage = memory/virtual --warning 80 --critical 90 --units Gi %HOSTNAME%|Process Count = processes --warning 300 --critical 400 ``` -------------------------------- ### Configure Plugin Execution for WSF Files Source: https://github.com/nagiosenterprises/ncpa/blob/master/agent/listener/static/help/configuration.html Define how WSF files (.wsf) are executed by NCPA using 'cscript $plugin_name $plugin_args //NoLogo'. The '$plugin_name' and '$plugin_args' macros are replaced with the script name and its arguments. ```ini .wsf = cscript $plugin_name $plugin_args //NoLogo ``` -------------------------------- ### Restart NCPA Service on Windows via CMD Source: https://github.com/nagiosenterprises/ncpa/blob/master/agent/listener/static/help/index.html Use these commands in a Windows command prompt to stop and start the NCPA service. ```batch net stop ncpa net start ncpa ```