I want to make a handle script that send me a notification with the top processes everytime to the CPU changes the status.
I have a script to saves the top cpu processes in a /temp/ file and shows it:
Code: Select all
#!/bin/bash
rm /tmp/checktopcpu.txt
date=$(date)
echo -e "$date" >> /tmp/checktopcpu.txt
ps -eo pcpu,args --sort=-%cpu|head >> /tmp/checktopcpu.txt
echo -e "\n" >> /tmp/checktopcpu.txt
cat /tmp/checktopcpu.txt
Code: Select all
command[check_topcpu_linux]=/usr/local/nagios/libexec/check_topcpu_linuxCode: Select all
[root@localhost libexec]# ./check_nrpe -H XXX.XXX.XXX.XXX -t 60 -p 5666 -c check_topcpu_linux
Thu Nov 23 15:37:50 CET 2017
%CPU COMMAND
0.0 /sbin/init
0.0 [kthreadd]
0.0 [ksoftirqd/0]
0.0 [kworker/0:0]
0.0 [kworker/0:0H]
0.0 [rcu_sched]
0.0 [rcu_bh]
0.0 [migration/0]
0.0 [watchdog/0]
Code: Select all
define command {
command_name check_topcpu_linux
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -t 60 -p 5666 -c check_toprcpu_linux
}
Code: Select all
define service {
host_name XXX.XXX.XXX.XXX
service_description CPU Stats
use xiwizard_nrpe_service
check_command check_nrpe!check_cpu_stats!-a '-w 85 -c 90'!!!!!!
max_check_attempts 1
check_interval 5
retry_interval 1
check_period xi_timeperiod_24x7
event_handler check_topcpu_linux
event_handler_enabled 1
notification_interval 60
notification_period xi_timeperiod_24x7
notifications_enabled 1
contacts nagiosadmin
_xiwizard linux-server
register 1
}
So, what is what i'm doing wrong?
Thank you so much!