-
Notifications
You must be signed in to change notification settings - Fork 1
/
Check_Long_Procs_Plugin_Conf.txt
130 lines (98 loc) · 4.63 KB
/
Check_Long_Procs_Plugin_Conf.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
Nagios like plugin to check and alert for the long running processes
Plugin name: check_long_procs.pl
Testing the Plugin
printing the version
ajoy@debhost1:~/scripts$ ./check_long_procs.pl -v
check_long_procs : 1.0
ajoy@debhost1:~/scripts$ ./check_long_procs.pl --version
check_long_procs : 1.0
printing the help
ajoy@debhost1:~/scripts$ ./check_long_procs.pl -h
check_long_procs : 1.0
Usage: check_long_procs -p <search pattern> -n <search pattern to exclude> [-v] [-h]
-c <critcal count> = Count of process to send alert, but is optional as the value is hardcoded.
-p <search pattern> = Search pattern for command grep.
-n <search pattern to exclude> = Search pattern to exclude from grep.
-v = Version.
-h = This screen.
Eg:- check_long_procs -c 0 -p java -n oracle.
Eg:- check_long_procs -c 0 -p "http|ssh" -n "java|grep".
ajoy@debhost1:~/scripts$ ./check_long_procs.pl --help
check_long_procs : 1.0
Usage: check_long_procs -p <search pattern> -n <search pattern to exclude> [-v] [-h]
-c <critcal count> = Count of process to send alert, but is optional as the value is hardcoded.
-p <search pattern> = Search pattern for command grep.
-n <search pattern to exclude> = Search pattern to exclude from grep.
-v = Version.
-h = This screen.
Eg:- check_long_procs -c 0 -p java -n oracle.
Eg:- check_long_procs -c 0 -p "http|ssh" -n "java|grep".
Traping Invalid options
ajoy@debhost1:~/scripts$ ./check_long_procs.pl -s
Unknown option: s
Usage: check_long_procs -p <search pattern> -n <search pattern to exclude> [-v] [-h]
Eg:- check_long_procs -c 0 -p java -n oracle.
Eg:- check_long_procs -c 0 -p "http|ssh" -n "java|grep".
ajoy@debhost1:~/scripts$
ajoy@debhost1:~/scripts$ ./check_long_procs.pl -9
Unknown option: 9
Usage: check_long_procs -p <search pattern> -n <search pattern to exclude> [-v] [-h]
Eg:- check_long_procs -c 0 -p java -n oracle.
Eg:- check_long_procs -c 0 -p "http|ssh" -n "java|grep".
ajoy@debhost1:~/scripts$
Traping execution with out options
ajoy@debhost1:~/scripts$ ./check_long_procs.pl
Usage: check_long_procs -p <search pattern> -n <search pattern to exclude> [-v] [-h]
Eg:- check_long_procs -c 0 -p java -n oracle.
Eg:- check_long_procs -c 0 -p "http|ssh" -n "java|grep".
ajoy@debhost1:~/scripts$
Traping execution with incomplete options
ajoy@debhost1:~/scripts$ ./check_long_procs.pl -p java
You have to specify a negative pattern to search with the option -n or --negpattern
Usage: check_long_procs -p <search pattern> -n <search pattern to exclude> [-v] [-h]
Eg:- check_long_procs -c 0 -p java -n oracle.
Eg:- check_long_procs -c 0 -p "http|ssh" -n "java|grep".
ajoy@debhost1:~/scripts$ ./check_long_procs.pl -n java
You have to specify a pattern to search with the option -p or --pattern
Usage: check_long_procs -p <search pattern> -n <search pattern to exclude> [-v] [-h]
Eg:- check_long_procs -c 0 -p java -n oracle.
Eg:- check_long_procs -c 0 -p "http|ssh" -n "java|grep".
Execution with valid options and the output (in PROD servers)
tsaapp@appprod1:~/ajoy$ ./check_long_procs.pl -p "java" -n "http"
CRITICAL - 2 long running processes found: PIDS :- 26673 26671
tsaapp@appprod1:~/ajoy$ ./check_long_procs.pl -p "java" -n "ssh"
CRITICAL - 1 long running processes found: PIDS :- 5344
tsaapp@appprod1:~/ajoy$ ./check_long_procs.pl -p "java" -n "http|ssh"
OK - No long running processes
tsaapp@appdb:~/ajoy$ ./check_long_procs.pl -p dbreplicator -n "ps|grep"
OK - No long running processes
tsaapp@appdb:~/ajoy$ ./check_long_procs.pl -p nagios -n "ps|grep"
CRITICAL - 1 long running processes found: PIDS :- 30508
tsaapp@appweb:~/ajoy$ ./check_long_procs.pl -p listener -n "ps|grep"
OK - No long running processes
tsaapp@appweb:~/ajoy$ ./check_long_procs.pl -p sshd -n "ps|grep"
CRITICAL - 3 long running processes found: PIDS :- 2910 17255 17258
tsaapp@xml-07:~/ajoy$
Plugin in action in local test server and host
Adding the plugin to the nrpe
root@debhost1:~# vi /etc/nagios/nrpe.cfg
command[check_long_procs]=/usr/lib/nagios/plugins/check_long_procs -p http -n java
root@debhost1:~# /etc/init.d/nagios-nrpe-server reload
Configuring the plugin to work from nagios server.
[root@centserver ~]# /usr/local/nagios/libexec/check_nrpe -H 192.168.17.128 -c check_long_procs
OK - No long running processes
[root@centserver ~]#
Creating service definitions
[root@centserver ~]# cd /usr/local/nagios/etc/linux/
[root@centserver linux]# vi services.cfg
# Service definition
define service{
use nrpe-service
host_name debhost1
service_description Long Processes
contact_groups admins
check_command check_nrpe!check_long_procs
[root@centserver linux]# /etc/init.d/nagios reload
Running configuration check...done.
Reloading nagios configuration...done
[root@centserver linux]#