host info updates
[distro-setup] / disabled / nagios
1 #!/bin/bash
2 # I, Ian Kelling, follow the GNU license recommendations at
3 # https://www.gnu.org/licenses/license-recommendations.en.html. They
4 # recommend that small programs, < 300 lines, be licensed under the
5 # Apache License 2.0. This file contains or is part of one or more small
6 # programs. If a small program grows beyond 300 lines, I plan to switch
7 # its license to GPL.
8
9 # Copyright 2024 Ian Kelling
10
11 # Licensed under the Apache License, Version 2.0 (the "License");
12 # you may not use this file except in compliance with the License.
13 # You may obtain a copy of the License at
14
15 # http://www.apache.org/licenses/LICENSE-2.0
16
17 # Unless required by applicable law or agreed to in writing, software
18 # distributed under the License is distributed on an "AS IS" BASIS,
19 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20 # See the License for the specific language governing permissions and
21 # limitations under the License.
22
23
24 # this was part of distro-end
25
26 ### begin nagios ###
27
28 pi nagios-nrpe-server
29
30 case $HOSTNAME in
31 kd)
32 # the backport is for this bug: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=800345
33 pi nagios4 nagios-nrpe-plugin monitoring-plugins-basic/bullseye-backports
34 s rm -fv /etc/apache2/conf-enabled/nagios4-cgi.conf
35
36 # to add a password for admin:
37 # htdigest /etc/nagios4/htdigest.users Nagios4 iank
38 # now using the same pass as prometheus
39
40 # nagstamon auth settings, set to digest instead of basic.
41
42 web-conf -p 3005 - apache2 i.b8.nz <<'EOF'
43 # adapted from /etc/apache2/conf-enabled/nagios4-cgi.conf
44
45 ScriptAlias /cgi-bin/nagios4 /usr/lib/cgi-bin/nagios4
46 ScriptAlias /nagios4/cgi-bin /usr/lib/cgi-bin/nagios4
47
48 # Where the stylesheets (config files) reside
49 Alias /nagios4/stylesheets /etc/nagios4/stylesheets
50
51 # Where the HTML pages live
52 Alias /nagios4 /usr/share/nagios4/htdocs
53
54 <DirectoryMatch (/usr/share/nagios4/htdocs|/usr/lib/cgi-bin/nagios4|/etc/nagios4/stylesheets)>
55 Options FollowSymLinks
56 DirectoryIndex index.php index.html
57 AllowOverride AuthConfig
58 #
59 # The default Debian nagios4 install sets use_authentication=0 in
60 # /etc/nagios4/cgi.cfg, which turns off nagos's internal authentication.
61 # This is insecure. As a compromise this default apache2 configuration
62 # only allows private IP addresses access.
63 #
64 # The <Files>...</Files> below shows how you can secure the nagios4
65 # web site so anybody can view it, but only authenticated users can issue
66 # commands (such as silence notifications). To do that replace the
67 # "Require all granted" with "Require valid-user", and use htdigest
68 # program from the apache2-utils package to add users to
69 # /etc/nagios4/htdigest.users.
70 #
71 # A step up is to insist all users validate themselves by moving
72 # the stanza's in the <Files>..<Files> into the <DirectoryMatch>.
73 # Then by setting use_authentication=1 in /etc/nagios4/cgi.cfg you
74 # can configure which people get to see a particular service from
75 # within the nagios configuration.
76 #
77 AuthDigestDomain "Nagios4"
78 AuthDigestProvider file
79 AuthUserFile "/etc/nagios4-htdigest.users"
80 AuthGroupFile "/etc/group"
81 AuthName "Nagios4"
82 AuthType Digest
83 Require valid-user
84 </DirectoryMatch>
85
86 <Directory /usr/share/nagios4/htdocs>
87 Options +ExecCGI
88 </Directory>
89 EOF
90 ;;
91 esac
92
93 # when you alter a service through the web, it changes vars in /var/lib/nagios4/status.dat. for example:
94 # notifications_enabled=1
95 # note, the same variable exists in the correspdonding "define service {"
96
97 # in the default config, we have these definitions
98
99 # 11 define command {
100 # 2 define contact {
101 # 1 define contactgroup {
102 # 9 define host {
103 # 4 define hostgroup {
104 # 23 define service {
105 # 5 define timeperiod {
106
107
108 # on klaxon
109
110 # klaxon:/etc/nagios3 # grep -rho '^ *define [^{ ]*' | sort | uniq -c
111 # 76 define command
112 # 11 define contact
113 # 6 define contactgroup
114 # 162 define host
115 # 1 define hostextinfo
116 # 16 define hostgroup
117 # 3040 define service
118 # 2 define servicedependency
119 # 6 define timeperiod
120
121
122
123
124 ### end nagios ###