-
Notifications
You must be signed in to change notification settings - Fork 0
/
nagios_troubleshooting
87 lines (77 loc) · 4.41 KB
/
nagios_troubleshooting
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
#!/bin/bash
##########NOTES for NAGIOS WEB GUI SERVICES THAT ARE NOT GREEN##########
#####HTTP#####
##IF ERROR: (No output on stdout) stderr: Could not resolve hostname $: Name or service not known##
##ON SERVER, most likely missing variables in last line that was echoed into cfg file during Nagios instal##
##https://support.nagios.com/forum/viewtopic.php?f=7&t=33850##
vim /etc/nagios/objects/commands.cfg
##CONFIRM LAST LINE HAST $HOSTADDRESS$ & $ARG1$
echo "########### NRPE CONFIG LINE #######################
define command{
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}" >> /etc/nagios/objects/commands.cfg
#####UNCOMMENT LINE TO ENABLE NAGIOS.CFG
sed -i '51 s/^#//' /etc/nagios/nagios.cfg
##IF ERROR: FORBIDDEN##
##ON SERVER: the file /etc/httpd/conf.d/welcome.conf tells Nagios to look for an index with user information##
##if that index does not exist, it forbids Nagios from accessing the client http for monitoring##
##need to create and execute an empty file for Nagios to fetch##
##https://stackoverflow.com/questions/23673549/nagios-http-warning-http-1-1-403-forbidden##
touch /var/www/html/index.html
chmod 755 /var/www/html/index.html
##IF ERROR: SWAP USAGE CRITICAL##
##ON SERVER: need to enable SWAP memory##
##https://rafishaikblog.wordpress.com/2017/08/14/nagios-plugins-functionality/##
dd if=/dev/zero of=/swap bs=1024 count=2097152
mkswap /swap && chown root. /swap && chmod 0600 /swap && swapon /swap
echo /swap swap swap defaults 0 0 >> /etc/fstab
echo vm.swappiness = 0 >> /etc/sysctl.conf && sysctl -p
##########TROUBLESHOOTING SERVER##########
###CONFIRM NAGIOS CONFIG on SERVER###
/usr/sbin/nagios -v /etc/nagios/nagios.cfg
##########TROUBLESHOOTING CLIENT##########
###SERVER CHECKS to be done on NAGIOS SERVER#####
##WANT OKS AS RESPONSE FROM FOLLOWING##
/usr/lib64/nagios/plugins/check_nrpe -H <client internal ip address> -c check_load
/usr/lib64/nagios/plugins/check_nrpe -H <client internal ip address> -c check_mem
##IF ANYTHING BUT OKS, NEED TO UPDATE COMMANDS IN NRPE.CFG FILE ON CLIENT##
##STARTING AT LINE 319, UNCOMMENTS AND MAKE CHANGES AS LISTED BELOW IN SED STATEMENTS
vim /etc/nagios/nrpe.cfg
##TO AUTOMATE##
sed -i 's|#command\[check_mem\]=/usr/lib64/nagios/plugins/custom_check_mem -n \$ARG1\$|command[check_mem]=/usr/lib64/nagios/plugins/check_mem.sh -w 80 -c 90|g' /etc/nagios/nrpe.cfg
sed -i 's|#command\[check_users\]=/usr/lib64/nagios/plugins/check_users \$ARG1\$|command\[check_users\]=/usr/lib64/nagios/plugins/check_users -w 5 -c 10|g' /etc/nagios/nrpe.cfg
sed -i 's|#command\[check_load\]=/usr/lib64/nagios/plugins/check_load \$ARG1\$|command\[check_load\]=/usr/lib64/nagios/plugins/check_load -w 15,10,5 -c 30,25,20|g' /etc/nagios/nrpe.cfg
sed -i 's|#command\[check_disk\]=/usr/lib64/nagios/plugins/check_disk \$ARG1\$|command\[check_disk\]=/usr/lib64/nagios/plugins/check_disk -w 20% -c 10%|g' /etc/nagios/nrpe.cfg
sed -i 's|#command\[check_swap\]=/usr/lib64/nagios/plugins/check_swap \$ARG1\$|command\[check_swap\]=/usr/lib64/nagios/plugins/check_swap -w 20% -c 10%|g' /etc/nagios/nrpe.cfg
sed -i 's|#command\[check_cpu_stats\]=/usr/lib64/nagios/plugins/check_cpu_stats.sh \$ARG1\$|command\[check_cpu_stats\]=/usr/lib64/nagios/plugins/check_cpu_stats.sh -w 70,40,30 -c 90,50,40|g' /etc/nagios.nrpe.cfg
##########SED STATEMENT CHEATSHEET##########
: # label
= # line_number
a # append_text_to_stdout_after_flush
b # branch_unconditional
c # range_change
d # pattern_delete_top/cycle
D # pattern_ltrunc(line+nl)_top/cycle
g # pattern=hold
G # pattern+=nl+hold
h # hold=pattern
H # hold+=nl+pattern
i # insert_text_to_stdout_now
l # pattern_list
n # pattern_flush=nextline_continue
N # pattern+=nl+nextline
p # pattern_print
P # pattern_first_line_print
q # flush_quit
r # append_file_to_stdout_after_flush
s # substitute
t # branch_on_substitute
w # append_pattern_to_file_now
x # swap_pattern_and_hold
y # transform_chars
, # seperator
| # seperator
/ # seperator
: # seperator
\ # escape symbol when / is also part of line--goes before: sed -i 's/some text path\/with a sub text path/new text to be replaced\/with new sub text/g' /file/path