Bug 239168 - net-mgmt/nagios-plugins: freebsd-patch breaks long ps output
Summary: net-mgmt/nagios-plugins: freebsd-patch breaks long ps output
Status: New
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: freebsd-ports-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-07-12 16:27 UTC by Johan Ström
Modified: 2023-01-30 07:58 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Johan Ström 2019-07-12 16:27:25 UTC
With nagios-plugins 2.2.1_8,1 the check_procs plugin fails to match arguments on processes with long titles, when executed by ngios.

When running the plugin manually from terminal, it works, but when nagios runs it the check fails.

I was able to reproduce it in terminal when giving /dev/null as stdin:

$ /usr/local/libexec/nagios//check_procs -w 1: -c 1: -a'python -m pyowmaster owmaster-dev.yaml' -vv
CMD: /bin/ps -axwo 'stat uid pid ppid jid vsz rss pcpu comm args'
Matched: uid=1001 vsz=18364 rss=5272 pid=4700 ppid=4680 jid=0 pcpu=0.00 stat=I+ etime= prog=python3.6 args=/home/johan/dev/pyowmaster/venv/bin/python -m pyowmaster owmaster-dev.yaml (python3.6)

PROCS OK: 1 process with args 'python -m pyowmaster owmaster-dev.yaml' | procs=1;1:;1:;0;
$ /usr/local/libexec/nagios//check_procs -w 1: -c 1: -a'python -m pyowmaster owmaster-dev.yaml' < /dev/null
CMD: /bin/ps -axwo 'stat uid pid ppid jid vsz rss pcpu comm args'
PROCS CRITICAL: 0 processes with args 'python -m pyowmaster owmaster-dev.yaml' | procs=0;1:;1:;0;
$

I believe the problem is this patch:
https://svnweb.freebsd.org/ports/head/net-mgmt/nagios-plugins/files/patch-configure?view=markup
It uses "-axwo" but it should be "-axwwo" to ensure ps does not care about terminal width. Altering the patch to use use -axwwo resolves the issue.

(In HEAD version of ps this has actually been altered, but this is not in 11.x or even 12.x it seem): https://svnweb.freebsd.org/base?view=revision&revision=330712
Comment 1 Johan Ström 2019-07-12 16:30:25 UTC
Here is the actual output with -axwo:

$ /usr/local/libexec/nagios//check_procs -a'python -m pyowmaster' -w 1: -c 1:  -vv < /dev/null
CMD: /bin/ps -axwo 'stat uid pid ppid jid vsz rss pcpu comm args'
Matched: uid=1001 vsz=53116 rss=11996 pid=4696 ppid=4678 jid=0 pcpu=0.00 stat=S+ etime= prog=python3.6 args=/home/johan/dev/pyowmaster/venv/bin/python -m pyowmaster owmast

Matched: uid=1001 vsz=18364 rss=5272 pid=4700 ppid=4680 jid=0 pcpu=0.00 stat=I+ etime= prog=python3.6 args=/home/johan/dev/pyowmaster/venv/bin/python -m pyowmaster owmast

PROCS OK: 2 processes with args 'python -m pyowmaster' | procs=2;1:;1:;0;
$

Note how the ps output is chopped.