Skip to content

Commit

Permalink
Merge branch 'maint' into issue-757
Browse files Browse the repository at this point in the history
  • Loading branch information
jomann09 committed Oct 26, 2021
2 parents bd77a03 + d514007 commit 57d36d1
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 10 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ docs/_build
agent/plugins/*
ncpa.db
prereqs.installed
.python-version
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Changelog
- Fixed toggle long output doesnt work (#778) (ccztux)
- Fixed the filter Type gets lost on pages > 1 (#780) (ccztux)
- Fixed some configuration directives doesnt work, e.g. all_partitions and follow_symlinks (#757) (ccztux)
- Fixed issue with systemctl not showing services due to output (#791)

2.3.1 - 02/11/2021
==================
Expand Down
3 changes: 2 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ We currently build for the following operating systems:
- SLES 11, 12, 15
- Oracle 7, 8
- Amazon Linux 2
- Solaris 10, 11
- Solaris 11
- AIX 7
- Raspbian 10 (Buster)

Expand All @@ -46,6 +46,7 @@ Older systems that have been supported by NCPA in the past:
- Oracle 5 using NCPA 2.0.6
- Oracle 6 using NCPA 2.2.2
- Windows XP/Vista using NCPA 1.8.1
- Solaris 10

If you're looking for older builds you can find them `in the archives <https://www.nagios.org/ncpa/archive.php>`_.

Expand Down
18 changes: 13 additions & 5 deletions agent/listener/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,13 @@ def run_check(self, *args, **kwargs):
class RunnableParentNode(ParentNode):

def __init__(self, name, children, primary, primary_unit='',
custom_output=None, include=None, *args, **kwargs):
custom_output=None, include=None, add_primary_node_to_perfdata=False, *args, **kwargs):
super(RunnableParentNode, self).__init__(name, children)
self.primary = primary
self.primary_unit = primary_unit
self.custom_output = custom_output
# See https://github.com/NagiosEnterprises/ncpa/issues/783
self.add_primary_node_to_perfdata = add_primary_node_to_perfdata
if include is None:
self.include = [x for x in self.children]
else:
Expand All @@ -107,6 +109,12 @@ def run_check(self, *args, **kwargs):
custom_output=self.custom_output,
child_check=True,
*args, **kwargs)

# See https://github.com/NagiosEnterprises/ncpa/issues/783
if self.add_primary_node_to_perfdata:
perfdata = primary_info.get('perfdata')
if perfdata is not None:
secondary_perfdata.append(perfdata)
else:
result = child.run_check(use_prefix=False, use_perfdata=False,
primary=False, primary_total=total,
Expand Down Expand Up @@ -508,16 +516,16 @@ def adjust_scale(self, values, units):
elif units in ['TI', 'GI', 'MI', 'KI']:
if units == 'TI':
units = 'Ti'
factor = 1.1e12
factor = 1099511627776.0
elif units == 'GI':
units = 'Gi'
factor = 1.074e9
factor = 1073741824.0
elif units == 'MI':
units = 'Mi'
factor = 1.049e6
factor = 1048576.0
elif units == 'KI':
units = 'Ki'
factor = 1.024e3
factor = 1024.0

# Process the values and put them back into list, also check if
# the value is just a bytes value - keep as integer
Expand Down
4 changes: 3 additions & 1 deletion agent/listener/psapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,9 @@ def get_memory_node():
mem_virt = RunnableParentNode('virtual', primary='percent', primary_unit='%',
children=(mem_virt_total, mem_virt_available, mem_virt_free,
mem_virt_percent, mem_virt_used),
custom_output='Memory usage was')
custom_output='Memory usage was',
# See https://github.com/NagiosEnterprises/ncpa/issues/783
add_primary_node_to_perfdata=True)
mem_swap_total = RunnableNode('total', method=lambda: (ps.swap_memory().total, 'B'))
mem_swap_percent = RunnableNode('percent', method=lambda: (ps.swap_memory().percent, '%'))
mem_swap_used = RunnableNode('used', method=lambda: (ps.swap_memory().used, 'B'))
Expand Down
2 changes: 1 addition & 1 deletion agent/listener/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def get_services_via_launchctl(self, *args, **kwargs):
def get_services_via_systemctl(self, *args, **kwargs):
services = {}
status = tempfile.TemporaryFile()
service = subprocess.Popen(['systemctl', '--no-pager', '--no-legend', '--all', '--type=service', 'list-units'], stdout=status)
service = subprocess.Popen(['systemctl', '--no-pager', '--no-legend', '--all', '--type=service', 'list-units', '--plain'], stdout=status)
service.wait()
status.seek(0)

Expand Down
4 changes: 2 additions & 2 deletions client/check_ncpa.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@


class ConnectionError(Exception):
error_output_prefix = "UNKNOWN: An error occured connecting to API. "
error_output_prefix = "UNKNOWN: An error occurred connecting to API. "
pass

class URLError(ConnectionError):
Expand Down Expand Up @@ -203,7 +203,7 @@ def get_arguments_from_options(options, **kwargs):
# API call which can confuse people if they don't match
arguments = { 'token': options.token,
'units': options.units }

if not options.list:
arguments['warning'] = options.warning
arguments['critical'] = options.critical
Expand Down

0 comments on commit 57d36d1

Please sign in to comment.