check_ncpa get wrong alert from CPUs

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
sacom01
Posts: 194
Joined: Wed Dec 23, 2020 10:15 pm

Re: check_ncpa get wrong alert from CPUs

Post by sacom01 »

check_cpu_log_clientsrv.txt.txt
hi Vinh,
the issue happen in both aix and linux, so you can test on any system.

i tried your commands and send you attach files.
easy to see when i write a new plugin with sar command inside, the result the same with check on client server.

i assume that ncpa's plugin do not work exact.

thanks.
You do not have the required permissions to view the files attached to this post.
User avatar
vtrac
Posts: 903
Joined: Tue Oct 27, 2020 1:35 pm

Re: check_ncpa get wrong alert from CPUs

Post by vtrac »

Hi Hang,
How are you doing?
Sorry, but I'm a bit confuse.
Based on the pictures provided, "sar" gave "Idle %", where as NCPA gave "CPU %" per each CPU (total 16).

"%idle" means CPU is not being used .... it is opposite to "CPU %"
"CPU %" means CPU is being used by users and all those processes in your system.
w1.png
Have you try writing your own script using either "sar" or "top"? .... since you are thinking they give more accurate results.

Please share your script, when you have it completed.

Also, have you had a chance to try the below script for AIX which I found on Nagios Exchange:
https://exchange.nagios.org/directory/P ... IX/details

Please let me know.


Best Regards,
Vinh
You do not have the required permissions to view the files attached to this post.
sacom01
Posts: 194
Joined: Wed Dec 23, 2020 10:15 pm

Re: check_ncpa get wrong alert from CPUs

Post by sacom01 »

hi Vinh,
Have you ever try the lastest command you sent me?
It will show very details on every cpu, not average, so we can not compare with the last previous (without "sleep5").Don't understand "sleep5" for what?

you can see the result :

check ncpa with &SLEEP=5
[root@dc-nagiosxi01 libexec]# ./check_ncpa.py -H 192.168.xxx.xx -t token -P 5693 -M cpu/percent -w '20' -c '40' -q 'aggregate=avg&sleep=5'
CRITICAL: Percent was 8.00 %, 0.00 %, 0.00 %, 20.00 %, 30.00 %, 0.00 %, 0.00 %, 0.00 %, 60.00 %, 0.00 %, 0.00 %, 0.00 %, 52.00 %, 0.00 %, 0.00 %, 0.00 %, 8.00 %, 0.00 %, 0.00 %, 0.00 %, 12.00 %, 0.00 %, 0.00 %, 0.00 %, 16.00 %, 0.00 %, 0.00 %, 0.00 %, 34.00 %, 0.00 %, 0.00 %, 0.00 %, 24.00 %, 0.00 %, 0.00 %, 0.00 %, 78.00 %, 0.00 %, 0.00 %, 0.00 %, 26.00 %, 0.00 %, 0.00 %, 0.00 %, 6.00 %, 0.00 %, 0.00 %, 0.00 %, 24.00 %, 0.00 %, 0.00 %, 0.00 %, 8.00 %, 0.00 %, 0.00 %, 0.00 %, 6.00 %, 0.00 %, 0.00 %, 0.00 %, 30.00 %, 0.00 %, 0.00 %, 0.00 %, 72.00 %, 0.00 %, 0.00 %, 0.00 %, 44.00 %, 0.00 %, 0.00 %, 0.00 %, 26.00 %, 0.00 %, 0.00 %, 0.00 %, 48.00 %, 0.00 %, 0.00 %, 0.00 %, 28.00 %, 0.00 %, 0.00 %, 0.00 %, 22.00 %, 0.00 %, 0.00 %, 0.00 %, 26.00 %, 0.00 %, 0.00 %, 0.00 %, 32.00 %, 0.00 %, 0.00 %, 0.00 %, 32.00 %, 0.00 %, 0.00 %, 0.00 %, 32.00 %, 0.00 %, 0.00 %, 0.00 %, 28.00 %, 0.00 %, 0.00 %, 0.00 %, 16.00 %, 0.00 %, 0.00 %, 0.00 %, 22.00 %, 0.00 %, 0.00 %, 0.00 %, 20.00 %, 0.00 %, 0.00 %, 0.00 %, 26.00 %, 0.00 %, 0.00 %, 0.00 %, 22.00 %, 0.00 %, 0.00 %, 0.00 %, 40.00 %, 0.00 %, 0.00 %, 0.00 %, 10.00 %, 0.00 %, 0.00 %, 0.00 %, 24.00 %, 0.00 %, 0.00 %, 0.00 %, 36.00 %, 0.00 %, 0.00 %, 0.00 %, 58.00 %, 0.00 %, 0.00 %, 0.00 %, 80.00 %, 0.00 %, 0.00 %, 0.00 %, 32.00 %, 0.00 %, 0.00 %, 0.00 %, 30.00 %, 0.00 %, 0.00 %, 0.00 %, 38.00 %, 0.00 %, 0.00 %, 0.00 %, 10.00 %, 0.00 %, 0.00 %, 0.00 %, 78.00 %, 0.00 %, 0.00 %, 0.00 %, 36.00 %, 0.00 %, 0.00 %, 0.00 %, 12.00 %, 0.00 %, 0.00 %, 0.00 %, 20.00 %, 0.00 %, 0.00 %, 0.00 %, 20.00 %, 0.00 %, 0.00 %, 0.00 %, 0.00 %, 0.00 %, 0.00 %, 0.00 %, 54.00 %, 0.00 %, 0.00 %, 0.00 %, 66.00 %, 0.00 %, 0.00 %, 0.00 %, 26.00 %, 0.00 %, 0.00 %, 0.00 %, 68.00 %, 0.00 %, 0.00 %, 0.00 %, 40.00 %, 0.00 %, 0.00 %, 0.00 %, 54.00 %, 0.00 %, 0.00 %, 0.00 % | 'percent_0'=8.00%;20;40; 'percent_1'=0.00%;20;40; 'percent_2'=0.00%;20;40; 'percent_3'=20.00%;20;40; 'percent_4'=30.00%;20;40; 'percent_5'=0.00%;20;40; 'percent_6'=0.00%;20;40; 'percent_7'=0.00%;20;40; 'percent_8'=60.00%;20;40; 'percent_9'=0.00%;20;40; 'percent_10'=0.00%;20;40; 'percent_11'=0.00%;20;40; 'percent_12'=52.00%;20;40; 'percent_13'=0.00%;20;40; 'percent_14'=0.00%;20;40; 'percent_15'=0.00%;20;40; 'percent_16'=8.00%;20;40; 'percent_17'=0.00%;20;40; 'percent_18'=0.00%;20;40; 'percent_19'=0.00%;20;40; 'percent_20'=12.00%;20;40; 'percent_21'=0.00%;20;40; 'percent_22'=0.00%;20;40; 'percent_23'=0.00%;20;40; 'percent_24'=16.00%;20;40; 'percent_25'=0.00%;20;40; 'percent_26'=0.00%;20;40; 'percent_27'=0.00%;20;40; 'percent_28'=34.00%;20;40; 'percent_29'=0.00%;20;40; 'percent_30'=0.00%;20;40; 'percent_31'=0.00%;20;40; 'percent_32'=24.00%;20;40; 'percent_33'=0.00%;20;40; 'percent_34'=0.00%;20;40; 'percent_35'=0.00%;20;40; 'percent_36'=78.00%;20;40; 'percent_37'=0.00%;20;40; 'percent_38'=0.00%;20;40; 'percent_39'=0.00%;20;40; 'percent_40'=26.00%;20;40; 'percent_41'=0.00%;20;40; 'percent_42'=0.00%;20;40; 'percent_43'=0.00%;20;40; 'percent_44'=6.00%;20;40; 'percent_45'=0.00%;20;40; 'percent_46'=0.00%;20;40; 'percent_47'=0.00%;20;40; 'percent_48'=24.00%;20;40; 'percent_49'=0.00%;20;40; 'percent_50'=0.00%;20;40; 'percent_51'=0.00%;20;40; 'percent_52'=8.00%;20;40; 'percent_53'=0.00%;20;40; 'percent_54'=0.00%;20;40; 'percent_55'=0.00%;20;40; 'percent_56'=6.00%;20;40; 'percent_57'=0.00%;20;40; 'percent_58'=0.00%;20;40; 'percent_59'=0.00%;20;40; 'percent_60'=30.00%;20;40; 'percent_61'=0.00%;20;40; 'percent_62'=0.00%;20;40; 'percent_63'=0.00%;20;40; 'percent_64'=72.00%;20;40; 'percent_65'=0.00%;20;40; 'percent_66'=0.00%;20;40; 'percent_67'=0.00%;20;40; 'percent_68'=44.00%;20;40; 'percent_69'=0.00%;20;40; 'percent_70'=0.00%;20;40; 'percent_71'=0.00%;20;40; 'percent_72'=26.00%;20;40; 'percent_73'=0.00%;20;40; 'percent_74'=0.00%;20;40; 'percent_75'=0.00%;20;40; 'percent_76'=48.00%;20;40; 'percent_77'=0.00%;20;40; 'percent_78'=0.00%;20;40; 'percent_79'=0.00%;20;40; 'percent_80'=28.00%;20;40; 'percent_81'=0.00%;20;40; 'percent_82'=0.00%;20;40; 'percent_83'=0.00%;20;40; 'percent_84'=22.00%;20;40; 'percent_85'=0.00%;20;40; 'percent_86'=0.00%;20;40; 'percent_87'=0.00%;20;40; 'percent_88'=26.00%;20;40; 'percent_89'=0.00%;20;40; 'percent_90'=0.00%;20;40; 'percent_91'=0.00%;20;40; 'percent_92'=32.00%;20;40; 'percent_93'=0.00%;20;40; 'percent_94'=0.00%;20;40; 'percent_95'=0.00%;20;40; 'percent_96'=32.00%;20;40; 'percent_97'=0.00%;20;40; 'percent_98'=0.00%;20;40; 'percent_99'=0.00%;20;40; 'percent_100'=32.00%;20;40; 'percent_101'=0.00%;20;40; 'percent_102'=0.00%;20;40; 'percent_103'=0.00%;20;40; 'percent_104'=28.00%;20;40; 'percent_105'=0.00%;20;40; 'percent_106'=0.00%;20;40; 'percent_107'=0.00%;20;40; 'percent_108'=16.00%;20;40; 'percent_109'=0.00%;20;40; 'percent_110'=0.00%;20;40; 'percent_111'=0.00%;20;40; 'percent_112'=22.00%;20;40; 'percent_113'=0.00%;20;40; 'percent_114'=0.00%;20;40; 'percent_115'=0.00%;20;40; 'percent_116'=20.00%;20;40; 'percent_117'=0.00%;20;40; 'percent_118'=0.00%;20;40; 'percent_119'=0.00%;20;40; 'percent_120'=26.00%;20;40; 'percent_121'=0.00%;20;40; 'percent_122'=0.00%;20;40; 'percent_123'=0.00%;20;40; 'percent_124'=22.00%;20;40; 'percent_125'=0.00%;20;40; 'percent_126'=0.00%;20;40; 'percent_127'=0.00%;20;40; 'percent_128'=40.00%;20;40; 'percent_129'=0.00%;20;40; 'percent_130'=0.00%;20;40; 'percent_131'=0.00%;20;40; 'percent_132'=10.00%;20;40; 'percent_133'=0.00%;20;40; 'percent_134'=0.00%;20;40; 'percent_135'=0.00%;20;40; 'percent_136'=24.00%;20;40; 'percent_137'=0.00%;20;40; 'percent_138'=0.00%;20;40; 'percent_139'=0.00%;20;40; 'percent_140'=36.00%;20;40; 'percent_141'=0.00%;20;40; 'percent_142'=0.00%;20;40; 'percent_143'=0.00%;20;40; 'percent_144'=58.00%;20;40; 'percent_145'=0.00%;20;40; 'percent_146'=0.00%;20;40; 'percent_147'=0.00%;20;40; 'percent_148'=80.00%;20;40; 'percent_149'=0.00%;20;40; 'percent_150'=0.00%;20;40; 'percent_151'=0.00%;20;40; 'percent_152'=32.00%;20;40; 'percent_153'=0.00%;20;40; 'percent_154'=0.00%;20;40; 'percent_155'=0.00%;20;40; 'percent_156'=30.00%;20;40; 'percent_157'=0.00%;20;40; 'percent_158'=0.00%;20;40; 'percent_159'=0.00%;20;40; 'percent_160'=38.00%;20;40; 'percent_161'=0.00%;20;40; 'percent_162'=0.00%;20;40; 'percent_163'=0.00%;20;40; 'percent_164'=10.00%;20;40; 'percent_165'=0.00%;20;40; 'percent_166'=0.00%;20;40; 'percent_167'=0.00%;20;40; 'percent_168'=78.00%;20;40; 'percent_169'=0.00%;20;40; 'percent_170'=0.00%;20;40; 'percent_171'=0.00%;20;40; 'percent_172'=36.00%;20;40; 'percent_173'=0.00%;20;40; 'percent_174'=0.00%;20;40; 'percent_175'=0.00%;20;40; 'percent_176'=12.00%;20;40; 'percent_177'=0.00%;20;40; 'percent_178'=0.00%;20;40; 'percent_179'=0.00%;20;40; 'percent_180'=20.00%;20;40; 'percent_181'=0.00%;20;40; 'percent_182'=0.00%;20;40; 'percent_183'=0.00%;20;40; 'percent_184'=20.00%;20;40; 'percent_185'=0.00%;20;40; 'percent_186'=0.00%;20;40; 'percent_187'=0.00%;20;40; 'percent_188'=0.00%;20;40; 'percent_189'=0.00%;20;40; 'percent_190'=0.00%;20;40; 'percent_191'=0.00%;20;40; 'percent_192'=54.00%;20;40; 'percent_193'=0.00%;20;40; 'percent_194'=0.00%;20;40; 'percent_195'=0.00%;20;40; 'percent_196'=66.00%;20;40; 'percent_197'=0.00%;20;40; 'percent_198'=0.00%;20;40; 'percent_199'=0.00%;20;40; 'percent_200'=26.00%;20;40; 'percent_201'=0.00%;20;40; 'percent_202'=0.00%;20;40; 'percent_203'=0.00%;20;40; 'percent_204'=68.00%;20;40; 'percent_205'=0.00%;20;40; 'percent_206'=0.00%;20;40; 'percent_207'=0.00%;20;40; 'percent_208'=40.00%;20;40; 'percent_209'=0.00%;20;40; 'percent_210'=0.00%;20;40; 'percent_211'=0.00%;20;40; 'percent_212'=54.00%;20;40; 'percent_213'=0.00%;20;40; 'percent_214'=0.00%;20;40; 'percent_215'=0.00%;20;40;



check ncpa WITHOUT &SLEEP=5
[root@dc-nagiosxi01 libexec]# ./check_ncpa.py -H 192.168.xxx.xx -t token -P 5693 -M cpu/percent -w '20' -c '40' -q 'aggregate=avg'
OK: Percent was 11.02 % | 'percent'=11.02%;20;40;

And how about the TESTCASE2 i sent you? what do you think about it. I guess ncpa's plugin have wrong.

pls find attach file for scripts's details
You do not have the required permissions to view the files attached to this post.
User avatar
vtrac
Posts: 903
Joined: Tue Oct 27, 2020 1:35 pm

Re: check_ncpa get wrong alert from CPUs

Post by vtrac »

Hi Hang,
Hope you are having a good day!! ... :-)

I brought this issue up in today group meeting, and here's what their suggestion:
The next step would be to have him create a BR here so he can work with development on it: https://github.com/NagiosEnterprises/ncpa/issues
I'm very sorry, if you think this is a bug, please open a bug report (url above) and work with developer.

As I said before, you can write your own script, then put that under "/usr/local/ncpa/plugins", then use:
./check_ncpa -H x.x.x.x -t 'yourToken' -p 5693 -M 'plugins/yourScript'

Example (oneline) script:

Code: Select all

sar 1 1 | grep Average | awk '{print $3,$4,$5,$6,$7 " = " $3+$4+$5+$6+$7"%";}'

or

sar 1 1 | grep Average | awk '{print "CPU Average: " $3+$4+$5+$6+$7"%";}'
If you strongly want to use "sar", you could try the above command.
Please note that the above command was just for you to test out "sar". If you want to use it, you will need to add more condition checking into the script.

Also, if your system have Python's "psutil" installed, you can try this:

Code: Select all

python  -c "import psutil; print psutil.cpu_percent(interval=1, percpu=True)"
You can use "pip install psutil" to install "psutil", if you want to try .... just a suggestion ... :-)


Best Regards,
Vinh
sacom01
Posts: 194
Joined: Wed Dec 23, 2020 10:15 pm

Re: check_ncpa get wrong alert from CPUs

Post by sacom01 »

ok done.
pls close the topic.
User avatar
vtrac
Posts: 903
Joined: Tue Oct 27, 2020 1:35 pm

Re: check_ncpa get wrong alert from CPUs

Post by vtrac »

Great!! .... closing thread!! ... :-)
Locked