Skip to content

Commit

Permalink
Merge pull request #1074 from NagiosEnterprises/dev-v3.0.1
Browse files Browse the repository at this point in the history
Release Dev v3.0.1
  • Loading branch information
ne-bbahn committed Dec 13, 2023
2 parents 47901ea + f3be766 commit dddd4e8
Show file tree
Hide file tree
Showing 17 changed files with 208 additions and 312 deletions.
10 changes: 5 additions & 5 deletions BUILDING.rst
Expand Up @@ -62,23 +62,23 @@ the system and build the ncpa binary.
**Install on the target Linux server**
--------------------------------

Copy the resulting ~/ncpa/build/ncpa-3.0.0-latest.x86_64.rpm or ncpa_3.0.0-latest_amd64.deb to the desired server and install using the appropriate package system:
Copy the resulting ~/ncpa/build/ncpa-3.X.X-latest.x86_64.rpm or ncpa_3.X.X-latest_amd64.deb to the desired server and install using the appropriate package system:

On CentOS/RHEL/Oracle/Amazon/Rocky::

yum install ./ncpa-3.0.0-latest.x86_64.rpm
yum install ./ncpa-3.X.X-latest.x86_64.rpm

On Ubuntu 18+/Debian 10+::

dpkg -i ./ncpa_3.0.0-latest._amd64.deb
dpkg -i ./ncpa_3.X.X-latest._amd64.deb

On Ubuntu 14-16/Debian 8-9 (not supported, but may work)::

dpkg --force-depends -i ./ncpa_3.0.0-latest._amd64.deb
dpkg --force-depends -i ./ncpa_3.X.X-latest._amd64.deb

On OpenSuSE/SLES::

zypper install ./ncpa-3.0.0-latest.x86_64.rpm
zypper install ./ncpa-3.X.X-latest.x86_64.rpm


Building on MacOS
Expand Down
17 changes: 17 additions & 0 deletions CHANGES.rst
@@ -1,6 +1,23 @@
Changelog
+++++++++

3.0.1 - 12/13/2023
==================
**Updates**

- Updated more documentation to reflect changes in NCPA 3.0.0 (Michael Bellerue)

**Bug Fixes**

- Fixed an issue where the API ordering varied from NCPA 2, breaking historical data. (Blake Bahner)
- Fixed an issue where NCPA would fail to start if IPv6 was disabled. (Blake Bahner)
- Corrected several issues with NCPA 2 file removal during Debian system upgrades. (Blake Bahner, Jason Michaelson)
- Disabled config interpolation to match the behavior of NCPA 2 and allow the `%` character to be unescaped in configuration files. (Blake Bahner)
- Resolved errors appearing in Linux installs where the installation was actually successful. (Blake Bahner, Jason Michaelson)
- Enhanced build process to support building on Oracle Linux 8 & 9. (Blake Bahner)
- Added a check for NCPA 2 processes in Linux builds on distributions utilizing chkconfig. (Jason Michaelson)
- Added various checks for NCPA services before attempting to interact with them. (Blake Bahner)

3.0.0 - 11/17/2023
==================
**Updates**
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Expand Up @@ -12,7 +12,7 @@ Downloads
Current versions:

+---------+-------------+-------------------------------------------------------+
| Current | **3.0.0** | `Downloads <https://www.nagios.org/ncpa/#downloads>`_ |
| Current | **3.0.1** | `Downloads <https://www.nagios.org/ncpa/#downloads>`_ |
+---------+-------------+-------------------------------------------------------+

Note: If your nagios repo is outdated when installing NCPA, you must first update your GPG key using the following:
Expand Down
2 changes: 1 addition & 1 deletion VERSION
@@ -1 +1 @@
3.0.0
3.0.1
12 changes: 6 additions & 6 deletions agent/listener/processes.py
Expand Up @@ -269,15 +269,15 @@ def standard_form(self, process, ps_procs, units="", sleep=None):
mem_rss, mem_vms = (0, "B"), (0, "B")

return {
"pid": int(pid),
"name": name,
"exe": exe,
"cmd": cmd,
"username": username,
"cpu_percent": (cpu_percent, "%"),
"mem_percent": (mem_percent, "%"),
"mem_rss": mem_rss,
"exe": exe,
"name": name,
"cpu_percent": (cpu_percent, "%"),
"mem_vms": mem_vms,
"cmd": cmd,
"pid": int(pid),
"mem_rss": mem_rss,
}

def get_process_dict(self, *args, **kwargs):
Expand Down
86 changes: 51 additions & 35 deletions agent/listener/psapi.py
Expand Up @@ -52,11 +52,11 @@ def make_disk_nodes(disk_name):
disk_name,
children=[
read_time,
write_time,
read_count,
write_count,
read_bytes,
write_count,
write_time,
write_bytes,
read_count,
],
)

Expand All @@ -83,17 +83,6 @@ def make_mountpoint_nodes(partition_name):
)
safe_mountpoint = re.sub(r"[\\/]+", "|", mountpoint)

node_children = [
total,
used,
free,
used_percent,
device_name,
fstype,
opts,
maxfile,
maxpath,
]

# Unix specific inode counter ~ sorry Windows! :'(
if __SYSTEM__ != "nt":
Expand All @@ -111,15 +100,40 @@ def make_mountpoint_nodes(partition_name):
inodes_used_percent = RunnableNode(
"inodes_used_percent", method=lambda: (iup, "%")
)
node_children.append(inodes)
node_children.append(inodes_used)
node_children.append(inodes_free)
node_children.append(inodes_used_percent)

node_children = [
used_percent,
used,
maxfile,
inodes_used,
free,
device_name,
inodes_free,
inodes,
fstype,
total,
maxpath,
opts,
inodes_used_percent
]
except OSError as ex:
# Log this error as debug only, normally means could not count inodes because
# of some permissions or access related issues
logging.exception(ex)

else:
node_children = [
used_percent,
used,
maxfile,
free,
device_name,
fstype,
total,
maxpath,
opts,
]

# Make and return the full parent node
return RunnableParentNode(
safe_mountpoint,
Expand Down Expand Up @@ -159,14 +173,14 @@ def make_if_nodes(if_name):
if_name,
primary="bytes_sent",
children=[
bytes_sent,
bytes_recv,
packets_sent,
dropin,
bytes_recv,
packets_recv,
errin,
errout,
dropin,
dropout,
bytes_sent,
errout,
],
)

Expand All @@ -192,16 +206,16 @@ def get_system_node():
return ParentNode(
"system",
children=[
sys_system,
sys_node,
sys_release,
sys_version,
sys_machine,
sys_processor,
sys_uptime,
sys_agent,
sys_timezone,
sys_version,
sys_time,
sys_release,
sys_timezone,
sys_agent,
sys_system,
sys_processor,
],
)

Expand All @@ -223,7 +237,7 @@ def get_cpu_node():
"idle", method=lambda: ([x.idle for x in ps.cpu_times(percpu=True)], "ms")
)
return ParentNode(
"cpu", children=[cpu_count, cpu_system, cpu_percent, cpu_user, cpu_idle]
"cpu", children=[cpu_count, cpu_idle, cpu_percent, cpu_system, cpu_user]
)


Expand All @@ -244,10 +258,10 @@ def get_memory_node():
primary="percent",
primary_unit="%",
children=(
mem_virt_total,
mem_virt_available,
mem_virt_free,
mem_virt_total,
mem_virt_percent,
mem_virt_free,
mem_virt_used,
),
custom_output="Memory usage was",
Expand All @@ -260,7 +274,6 @@ def get_memory_node():
)
mem_swap_used = RunnableNode("used", method=lambda: (ps.swap_memory().used, "B"))
mem_swap_free = RunnableNode("free", method=lambda: (ps.swap_memory().free, "B"))
node_children = [mem_swap_total, mem_swap_free, mem_swap_percent, mem_swap_used]

# sin and sout on Windows are always set to 0 ~ sorry Windows! :'(
if environment.SYSTEM != "Windows":
Expand All @@ -270,8 +283,11 @@ def get_memory_node():
mem_swap_out = RunnableNode(
"swapped_out", method=lambda: (ps.swap_memory().sout, "B")
)
node_children.append(mem_swap_in)
node_children.append(mem_swap_out)

node_children = [mem_swap_used, mem_swap_out, mem_swap_in, mem_swap_total, mem_swap_percent, mem_swap_free]
else:
node_children = [mem_swap_used, mem_swap_total, mem_swap_percent, mem_swap_free]


mem_swap = RunnableParentNode(
"swap",
Expand Down Expand Up @@ -338,7 +354,7 @@ def get_disk_node(config):
disk_physical = ParentNode("physical", children=disk_counters)
disk_mount = ParentNode("mount", children=disk_parts)

return ParentNode("disk", children=[disk_physical, disk_logical, disk_mount])
return ParentNode("disk", children=[disk_mount, disk_logical, disk_physical])


def get_interface_node():
Expand Down
15 changes: 0 additions & 15 deletions agent/listener/static/help/api.html
Expand Up @@ -750,16 +750,6 @@ <h6>Basic Parameters</h6>
<a name="api-modules-services"></a>
<h4>services</h4>
<div class="container-fluid">
<div class="row" style="margin: 0 -30px;">
<div class="col-sm-12">
<p>
<div class="alert alert-warning">
<i class="fa fa-exclamation-triangle fa-14 fa-l"></i> <b>Warning!</b> In NCPA 2 the API endpoint for checking services was <em><b>deprecated</b></em> and will be removed in NCPA 3 and above. Example deprecated version: <b>service/&lt;servicename&gt;/&lt;status&gt;</b>
</div>
</p>
<p>This node is different than most of the standard nodes. When using just the <code>services</code> endpoint you will see a list of all services NCPA can find and their current state. You can select a single service by adding the <code>service=&lt;servicename&gt;</code> parameter. You can also turn the <code>service</code> parameter into a search by adding the <code>match=search</code> parameter to the query.</p>
</div>
</div>
<div class="row" style="margin: 0 -30px;">
<div class="col-sm-6">
<h6 style="margin-top: 1rem;">Example of Service Filtering</h6>
Expand Down Expand Up @@ -840,11 +830,6 @@ <h4>system</h4>

<a name="api-modules-plugins"></a>
<h4>plugins</h4>
<p>
<div class="alert alert-warning">
<i class="fa fa-exclamation-triangle fa-14 fa-l"></i> <b>Warning!</b> In NCPA 2 the API endpoint for <b>agent/plugin</b> was <em><b>deprecated</b></em> in favor of <b>plugins</b> and will be removed in NCPA 3 and above. Example deprecated version: <b>agent/plugin/&lt;plugin name&gt;</b>
</div>
</p>
<p>This module will show you a list of all available plugins (that are in the directory defined <code>plugin_path</code>) and let's you run them.</p>
<p>You can run a custom plugin by following this format in the URL:</p>
<pre>https://localhost:5693/api/plugins/&lt;plugin name&gt;/&lt;arg1&gt;/&lt;arg2&gt;/?token=mytoken</pre>
Expand Down
2 changes: 1 addition & 1 deletion agent/listener/static/help/configuration.html
Expand Up @@ -42,7 +42,7 @@ <h2>Config Locations</h2>
<div role="tabpanel" class="tab-pane" id="linux"><pre>/usr/local/ncpa/etc/</pre></div>
<div role="tabpanel" class="tab-pane" id="mac"><pre>/usr/local/ncpa/etc/</pre></div>
</div>
<p>As of NCPA 2, there is also an <code>ncpa.cfg.d</code> folder which includes all <b>.cfg</b> files inside of it into the main <code>nagios.cfg</code> when parsing the configuration. Another change to the way configuration works in NCPA 2 is that changing the passive check configuration <em>requires a restart of the NCPA Passive service</em>. By default NCPA 2 will have an <code>ncpa.cfg.d/example.cfg</code> file in the config directory on all operating systems. On Windows, you are able to select whether or not you are going to enable NRDP during the install - including setting up your basic default checks - placed in <code>nrdp.cfg.d/nrdp.cfg</code>.</p>
<p>As of NCPA 2, there is also an <code>ncpa.cfg.d</code> folder which includes all <b>.cfg</b> files inside of it into the main <code>ncpa.cfg</code> when parsing the configuration. After any changes you make to either <code>nagios.cfg</code>, or any other files in <code>ncpa.cfg.d</code>, you will need to restart the NCPA service.</p>
</div>

<a name="config-option-reference"></a>
Expand Down
4 changes: 2 additions & 2 deletions agent/listener/static/help/index.html
Expand Up @@ -22,9 +22,9 @@
<h1>Overview</h1>

<p>This help documentation explains the inner workings of NCPA as well as providing a reference for configuring and setting up NCPA instances. If you've never used NCPA before, and have not yet installed it on a machine - you can take a look at the <a target="_new" href="https://nagios.org/ncpa/getting-started.php">getting started guide</a> <i class="fa fa-external-link"></i> available on the NCPA website, which will go through the initial installation admin setup, and show you how start monitoring with passive or active checks using either Nagios XI or Nagios Core.</p>
<p>This help documentation is geared towards those who have already installed NCPA and are looking at more advanced configuration and setup using this help as a reference. To start off, below is a brief overview of the parts of NCPA and what they are responsible for. More guides and documentation can be found on the <a target="_new" href="https://nagios.org/ncpa/">NCPA website</a> <i class="fa fa-external-link"></i>.</p>
<p>This help documentation is geared towards those who have already installed NCPA and are looking at more advanced configuration and setup using this help as a reference. More guides and documentation can be found on the <a target="_new" href="https://nagios.org/ncpa/">NCPA website</a> <i class="fa fa-external-link"></i>.</p>

<a name="two-parts-of-ncpa"></a>
<a name="ncpa-single-service"></a>
<div class="section">

<h2>NCPA 3.x Single Service</h2>
Expand Down
4 changes: 2 additions & 2 deletions agent/listener/templates/gui/help.html
Expand Up @@ -42,8 +42,8 @@ <h4>Help Documentation</h4>
<li>
<a target="help-frame" href="../static/help/index.html">Overview</a>
<ul class="npb">
<li><a target="help-frame" href="../static/help/index.html#two-parts-of-ncpa">The Two Parts of NCPA</a></li>
<li><a target="help-frame" href="../static/help/index.html#restarting-ncpa">Restarting the NCPA Services</a></li>
<li><a target="help-frame" href="../static/help/index.html#ncpa-single-service">NCPA 3.x Single Service</a></li>
<li><a target="help-frame" href="../static/help/index.html#restarting-ncpa">Restarting the NCPA Service</a></li>
<li><a target="help-frame" href="../static/help/index.html#changes-in-30">Change Log</a></li>
<li><a target="help-frame" href="../static/help/index.html#troubleshooting">Troubleshooting</a></li>
</ul>
Expand Down
40 changes: 26 additions & 14 deletions agent/ncpa.py
Expand Up @@ -40,6 +40,7 @@
from gevent.pool import Pool
from gevent.pywsgi import WSGIServer
from geventwebsocket.handler import WebSocketHandler
from socket import error as SocketError
from io import open
from logging.handlers import RotatingFileHandler
from multiprocessing import Process, Value, freeze_support
Expand Down Expand Up @@ -69,7 +70,7 @@

# Set some global variables for later
__FROZEN__ = getattr(sys, 'frozen', False)
__VERSION__ = '3.0.0'
__VERSION__ = '3.0.1'
__DEBUG__ = False
__SYSTEM__ = os.name
__STARTED__ = datetime.datetime.now()
Expand Down Expand Up @@ -280,6 +281,22 @@ def run(self):
http_server.serve_forever()
logger.debug("run() - http_server running")

# If we fail to start in dual stack mode, try IPv4 only
except SocketError as e:
if address == '::':
logging.info("Failed to start in dual stack mode: %s", e)
logging.info("Trying IPv4 only")
else:
logging.exception("run() - exception: %s", e)
address = '0.0.0.0'
http_server = WSGIServer(listener=(address, port),
application=listener.server.listener,
handler_class=WebSocketHandler,
log=listener_logger,
spawn=Pool(max_connections),
**ssl_context)
http_server.serve_forever()

except Exception as e:
logger.exception("exception: %s", e)
self.send_error()
Expand Down Expand Up @@ -876,22 +893,17 @@ def get_configuration(config=None, configdir=None):
"""Get the configuration options and return the config parser for them"""
parent_logger.debug("get_configuration()")

# Use default config/directory if none is given to us
if config is None:
config = os.path.join('etc', 'ncpa.cfg')
configdir = os.path.join('etc', 'ncpa.cfg.d', '*.cfg')

# Get the configuration
config_filenames = [get_filename(config)]

# Add config directory if it is defined
if configdir is not None:
config_filenames.extend(sorted(glob.glob(get_filename(configdir))))
config = os.path.join('etc', 'ncpa.cfg')
configdir = os.path.join('etc', 'ncpa.cfg.d', '*.cfg')

cp = ConfigParser()
cp = ConfigParser(interpolation=None)
cp.optionxform = str
cp.read_dict(cfg_defaults)
cp.read(config_filenames)
cp.read(get_filename(config))

if configdir is not None:
for config_file in sorted(glob.glob(get_filename(configdir))):
cp.read(config_file)
return cp

def chown(user_uid, user_gid, fn):
Expand Down

0 comments on commit dddd4e8

Please sign in to comment.