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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>KISS server monitoring with Gogios</title>
<link rel="shortcut icon" type="image/gif" href="/favicon.ico" />
<link rel="stylesheet" href="../style.css" />
<link rel="stylesheet" href="style-override.css" />
</head>
<body class="rfx-boot">
<div class="rfx-overlay-grid"></div>
<div class="rfx-overlay-scanlines"></div>
<div id="rfx-stars"></div>
<div class="rfx-vignette"></div>
<p class="header">
<a href="https://foo.zone">Home</a> | <a href="https://codeberg.org/snonux/foo.zone/src/branch/content-md/gemfeed/2023-06-01-kiss-server-monitoring-with-gogios.md">Markdown</a> | <a href="gemini://foo.zone/gemfeed/2023-06-01-kiss-server-monitoring-with-gogios.gmi">Gemini</a>
</p>
<h1 style='display: inline' id='kiss-server-monitoring-with-gogios'>KISS server monitoring with Gogios</h1><br />
<br />
<span class='quote'>Published at 2023-06-01T21:10:17+03:00</span><br />
<br />
<span>Gogios is a minimalistic and easy-to-use monitoring tool I programmed in Google Go designed specifically for small-scale self-hosted servers and virtual machines. The primary purpose of Gogios is to monitor my personal server infrastructure for <span class='inlinecode'>foo.zone</span>, my MTAs, my authoritative DNS servers, my NextCloud, Wallabag and Anki sync server installations, etc.</span><br />
<br />
<span>With compatibility with the Nagios Check API, Gogios offers a simple yet effective solution to monitor a limited number of resources. In theory, Gogios scales to a couple of thousand checks, though. You can clone it from Codeberg here:</span><br />
<br />
<a class='textlink' href='https://codeberg.org/snonux/gogios'>https://codeberg.org/snonux/gogios</a><br />
<br />
<a href='./kiss-server-monitoring-with-gogios/gogios-small.png'><img alt='Gogios logo' title='Gogios logo' src='./kiss-server-monitoring-with-gogios/gogios-small.png' /></a><br />
<br />
<h2 style='display: inline' id='table-of-contents'>Table of Contents</h2><br />
<br />
<ul>
<li><a href='#kiss-server-monitoring-with-gogios'>KISS server monitoring with Gogios</a></li>
<li>⇢ <a href='#motivation'>Motivation</a></li>
<li>⇢ <a href='#features'>Features</a></li>
<li>⇢ <a href='#example-alert'>Example alert</a></li>
<li>⇢ <a href='#installation'>Installation</a></li>
<li>⇢ ⇢ <a href='#compiling-and-installing-gogios'>Compiling and installing Gogios</a></li>
<li>⇢ ⇢ <a href='#setting-up-user-group-and-directories'>Setting up user, group and directories</a></li>
<li>⇢ ⇢ <a href='#installing-monitoring-plugins'>Installing monitoring plugins</a></li>
<li>⇢ <a href='#configuration'>Configuration</a></li>
<li>⇢ ⇢ <a href='#mta'>MTA</a></li>
<li>⇢ ⇢ <a href='#configuring-gogios'>Configuring Gogios</a></li>
<li>⇢ <a href='#running-gogios'>Running Gogios</a></li>
<li>⇢ ⇢ <a href='#high-availability'>High-availability</a></li>
<li>⇢ <a href='#conclusion'>Conclusion:</a></li>
</ul><br />
<pre>
_____________________________ ____________________________
/ \ / \
| _______________________ || ______________________ |
| / \ || / \ |
| | # Alerts with status c| || | # Unhandled alerts: | |
| | hanged: | || | | |
| | | || | CRITICAL: Check Pizza| |
| | OK->CRITICAL: Check Pi| || | : Late delivery | |
| | zza: Late delivery | || | | |
| | | || | WARNING: Check Thirst| |
| | | || | : OutofKombuchaExcept| |
| \_______________________/ || \______________________/ |
| /|\ GOGIOS MONITOR 1 _ || /|\ GOGIOS MONITOR 2 _ |
\_____________________________/ \____________________________/
!_________________________! !________________________!
------------------------------------------------
ASCII art was modified by Paul Buetow
The original can be found at
https://asciiart.website/index.php?art=objects/computers
</pre>
<br />
<h2 style='display: inline' id='motivation'>Motivation</h2><br />
<br />
<span>With experience in monitoring solutions like Nagios, Icinga, Prometheus and OpsGenie, these tools often came with many features that I didn't necessarily need for personal use. Contact groups, host groups, check clustering, and the requirement of operating a DBMS and a WebUI added complexity and bloat to my monitoring setup.</span><br />
<br />
<span>My primary goal was to have a single email address for notifications and a simple mechanism to periodically execute standard Nagios check scripts and notify me of any state changes. I wanted the most minimalistic monitoring solution possible but wasn't satisfied with the available options.</span><br />
<br />
<span>This led me to create Gogios, a lightweight monitoring tool tailored to my specific needs. I chose the Go programming language for this project as it comes, in my opinion, with the best balance of ease to use and performance.</span><br />
<br />
<h2 style='display: inline' id='features'>Features</h2><br />
<br />
<ul>
<li>Compatible with Nagios Check scripts: Gogios leverages the widely-used Nagios Check API, allowing to use existing Nagios plugins.</li>
<li>Lightweight and Minimalistic: Gogios is designed to be simple and fairly easy to set up.</li>
<li>Configurable Check Timeout and Concurrency: Gogios allows you to set a timeout for checks and configure the number of concurrent checks, offering flexibility in monitoring your resources.</li>
<li>Configurable check dependency: A check can depend on another check, which enables scenarios like not executing an HTTP check when the server isn't pingable.</li>
<li>Retries: Check retry and retry intervals are configurable per check.</li>
<li>Email Notifications: Gogios can send email notifications regarding the status of monitored services, ensuring you stay informed about potential issues.</li>
<li>CRON-based Execution: Gogios can be quickly scheduled to run periodically via CRON, allowing you to automate monitoring without needing a complex setup.</li>
</ul><br />
<h2 style='display: inline' id='example-alert'>Example alert</h2><br />
<br />
<span>This is an example alert report received via E-Mail. Whereas, <span class='inlinecode'>[C:2 W:0 U:0 OK:51]</span> means that we've got two alerts in status critical, 0 warnings, 0 unknowns and 51 OKs.</span><br />
<br />
<pre>
Subject: GOGIOS Report [C:2 W:0 U:0 OK:51]
This is the recent Gogios report!
# Alerts with status changed:
OK->CRITICAL: Check ICMP4 vulcan.buetow.org: Check command timed out
OK->CRITICAL: Check ICMP6 vulcan.buetow.org: Check command timed out
# Unhandled alerts:
CRITICAL: Check ICMP4 vulcan.buetow.org: Check command timed out
CRITICAL: Check ICMP6 vulcan.buetow.org: Check command timed out
Have a nice day!
</pre>
<br />
<h2 style='display: inline' id='installation'>Installation</h2><br />
<br />
<h3 style='display: inline' id='compiling-and-installing-gogios'>Compiling and installing Gogios</h3><br />
<br />
<span>This document is primarily written for OpenBSD, but applying the corresponding steps to any Unix-like (e.g. Linux-based) operating system should be easy. On systems other than OpenBSD, you may always have to replace <span class='inlinecode'>does</span> with the <span class='inlinecode'>sudo</span> command and replace the <span class='inlinecode'>/usr/local/bin</span> path with <span class='inlinecode'>/usr/bin</span>.</span><br />
<br />
<span>To compile and install Gogios on OpenBSD, follow these steps:</span><br />
<br />
<!-- Generator: GNU source-highlight 3.1.9
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><font color="#ff0000">git clone https</font><font color="#F3E651">:</font><font color="#ff0000">//codeberg</font><font color="#F3E651">.</font><font color="#ff0000">org/snonux/gogios</font><font color="#F3E651">.</font><font color="#ff0000">git</font>
<font color="#ff0000">cd gogios</font>
<font color="#ff0000">go build -o gogios cmd/gogios/main</font><font color="#F3E651">.</font><font color="#ff0000">go</font>
<font color="#ff0000">doas cp gogios /usr/local/bin/gogios</font>
<font color="#ff0000">doas chmod </font><font color="#bb00ff">755</font><font color="#ff0000"> /usr/local/bin/gogios</font>
</pre>
<br />
<span>You can use cross-compilation if you want to compile Gogios for OpenBSD on a Linux system without installing the Go compiler on OpenBSD. Follow these steps:</span><br />
<br />
<!-- Generator: GNU source-highlight 3.1.9
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><b><font color="#ffffff">export</font></b><font color="#ff0000"> </font><font color="#ff0000">GOOS</font><font color="#F3E651">=</font><font color="#ff0000">openbsd</font>
<b><font color="#ffffff">export</font></b><font color="#ff0000"> </font><font color="#ff0000">GOARCH</font><font color="#F3E651">=</font><font color="#ff0000">amd64</font>
<font color="#ff0000">go build -o gogios cmd/gogios/main</font><font color="#F3E651">.</font><font color="#ff0000">go</font>
</pre>
<br />
<span>On your OpenBSD system, copy the binary to <span class='inlinecode'>/usr/local/bin/gogios</span> and set the correct permissions as described in the previous section. All steps described here you could automate with your configuration management system of choice. I use Rexify, the friendly configuration management system, to automate the installation, but that is out of the scope of this document.</span><br />
<br />
<a class='textlink' href='https://www.rexify.org'>https://www.rexify.org</a><br />
<br />
<h3 style='display: inline' id='setting-up-user-group-and-directories'>Setting up user, group and directories</h3><br />
<br />
<span>It is best to create a dedicated system user and group for Gogios to ensure proper isolation and security. Here are the steps to create the <span class='inlinecode'>_gogios</span> user and group under OpenBSD:</span><br />
<br />
<!-- Generator: GNU source-highlight 3.1.9
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><font color="#ff0000">doas adduser -group _gogios -batch _gogios</font>
<font color="#ff0000">doas usermod -d /var/run/gogios _gogios</font>
<font color="#ff0000">doas mkdir -p /var/run/gogios</font>
<font color="#ff0000">doas chown _gogios</font><font color="#F3E651">:</font><font color="#ff0000">_gogios /var/run/gogios</font>
<font color="#ff0000">doas chmod </font><font color="#bb00ff">750</font><font color="#ff0000"> /var/run/gogios</font>
</pre>
<br />
<span>Please note that creating a user and group might differ depending on your operating system. For other operating systems, consult their documentation for creating system users and groups.</span><br />
<br />
<h3 style='display: inline' id='installing-monitoring-plugins'>Installing monitoring plugins</h3><br />
<br />
<span>Gogios relies on external Nagios or Icinga monitoring plugin scripts. On OpenBSD, you can install the <span class='inlinecode'>monitoring-plugins</span> package with Gogios. The monitoring-plugins package is a collection of monitoring plugins, similar to Nagios plugins, that can be used to monitor various services and resources:</span><br />
<br />
<!-- Generator: GNU source-highlight 3.1.9
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><font color="#ff0000">doas pkg_add monitoring-plugins</font>
<font color="#ff0000">doas pkg_add nrpe </font><i><font color="#ababab"># If you want to execute checks remotely via NRPE.</font></i>
</pre>
<br />
<span>Once the installation is complete, you can find the monitoring plugins in the <span class='inlinecode'>/usr/local/libexec/nagios</span> directory, which then can be configured to be used in <span class='inlinecode'>gogios.json</span>.</span><br />
<br />
<h2 style='display: inline' id='configuration'>Configuration</h2><br />
<br />
<h3 style='display: inline' id='mta'>MTA</h3><br />
<br />
<span>Gogios requires a local Mail Transfer Agent (MTA) such as Postfix or OpenBSD SMTPD running on the same server where the CRON job (see about the CRON job further below) is executed. The local MTA handles email delivery, allowing Gogios to send email notifications to monitor status changes. Before using Gogios, ensure that you have a properly configured MTA installed and running on your server to facilitate the sending of emails. Once the MTA is set up and functioning correctly, Gogios can leverage it to send email notifications.</span><br />
<br />
<span>You can use the mail command to send an email via the command line on OpenBSD. Here's an example of how to send a test email to ensure that your email server is working correctly:</span><br />
<br />
<pre>
echo 'This is a test email from OpenBSD.' | mail -s 'Test Email' your-email@example.com
</pre>
<br />
<span>Check the recipient's inbox to confirm the delivery of the test email. If the email is delivered successfully, it indicates that your email server is configured correctly and functioning. Please check your MTA logs in case of issues.</span><br />
<br />
<h3 style='display: inline' id='configuring-gogios'>Configuring Gogios</h3><br />
<br />
<span>To configure Gogios, create a JSON configuration file (e.g., <span class='inlinecode'>/etc/gogios.json</span>). Here's an example configuration:</span><br />
<br />
<!-- Generator: GNU source-highlight 3.1.9
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><font color="#F3E651">{</font>
<font color="#ff0000"> </font><font color="#ff0000">"</font><font color="#ff0000">EmailTo</font><font color="#ff0000">"</font><font color="#ff0000">:</font><font color="#ff0000"> "</font><font color="#bb00ff">paul@dev.buetow.org</font><font color="#ff0000">"</font><font color="#F3E651">,</font>
<font color="#ff0000"> </font><font color="#ff0000">"</font><font color="#ff0000">EmailFrom</font><font color="#ff0000">"</font><font color="#ff0000">:</font><font color="#ff0000"> "</font><font color="#bb00ff">gogios@buetow.org</font><font color="#ff0000">"</font><font color="#F3E651">,</font>
<font color="#ff0000"> </font><font color="#ff0000">"</font><font color="#ff0000">CheckTimeoutS</font><font color="#ff0000">"</font><font color="#ff0000">: </font><font color="#bb00ff">10</font><font color="#F3E651">,</font>
<font color="#ff0000"> </font><font color="#ff0000">"</font><font color="#ff0000">CheckConcurrency</font><font color="#ff0000">"</font><font color="#ff0000">: </font><font color="#bb00ff">2</font><font color="#F3E651">,</font>
<font color="#ff0000"> </font><font color="#ff0000">"</font><font color="#ff0000">StateDir</font><font color="#ff0000">"</font><font color="#ff0000">:</font><font color="#ff0000"> "</font><font color="#bb00ff">/var/run/gogios</font><font color="#ff0000">"</font><font color="#F3E651">,</font>
<font color="#ff0000"> </font><font color="#ff0000">"</font><font color="#ff0000">Checks</font><font color="#ff0000">"</font><font color="#ff0000">: </font><font color="#F3E651">{</font>
<font color="#ff0000"> </font><font color="#ff0000">"</font><font color="#ff0000">Check ICMP4 www.foo.zone</font><font color="#ff0000">"</font><font color="#ff0000">: </font><font color="#F3E651">{</font>
<font color="#ff0000"> </font><font color="#ff0000">"</font><font color="#ff0000">Plugin</font><font color="#ff0000">"</font><font color="#ff0000">:</font><font color="#ff0000"> "</font><font color="#bb00ff">/usr/local/libexec/nagios/check_ping</font><font color="#ff0000">"</font><font color="#F3E651">,</font>
<font color="#ff0000"> </font><font color="#ff0000">"</font><font color="#ff0000">Args</font><font color="#ff0000">"</font><font color="#ff0000">: </font><font color="#F3E651">[</font><font color="#ff0000"> </font><font color="#ff0000">"</font><font color="#ff0000">-H</font><font color="#ff0000">"</font><font color="#F3E651">,</font><font color="#ff0000"> </font><font color="#ff0000">"</font><font color="#ff0000">www.foo.zone</font><font color="#ff0000">"</font><font color="#F3E651">,</font><font color="#ff0000"> </font><font color="#ff0000">"</font><font color="#ff0000">-4</font><font color="#ff0000">"</font><font color="#F3E651">,</font><font color="#ff0000"> </font><font color="#ff0000">"</font><font color="#ff0000">-w</font><font color="#ff0000">"</font><font color="#F3E651">,</font><font color="#ff0000"> </font><font color="#ff0000">"</font><font color="#ff0000">50,10%</font><font color="#ff0000">"</font><font color="#F3E651">,</font><font color="#ff0000"> </font><font color="#ff0000">"</font><font color="#ff0000">-c</font><font color="#ff0000">"</font><font color="#F3E651">,</font><font color="#ff0000"> </font><font color="#ff0000">"</font><font color="#ff0000">100,15%</font><font color="#ff0000">"</font><font color="#ff0000"> </font><font color="#F3E651">],</font>
<font color="#ff0000"> </font><font color="#ff0000">"</font><font color="#ff0000">Retries</font><font color="#ff0000">"</font><font color="#ff0000">: </font><font color="#bb00ff">3</font><font color="#F3E651">,</font>
<font color="#ff0000"> </font><font color="#ff0000">"</font><font color="#ff0000">RetryInterval</font><font color="#ff0000">"</font><font color="#ff0000">: </font><font color="#bb00ff">10</font>
<font color="#ff0000"> </font><font color="#F3E651">},</font>
<font color="#ff0000"> </font><font color="#ff0000">"</font><font color="#ff0000">Check ICMP6 www.foo.zone</font><font color="#ff0000">"</font><font color="#ff0000">: </font><font color="#F3E651">{</font>
<font color="#ff0000"> </font><font color="#ff0000">"</font><font color="#ff0000">Plugin</font><font color="#ff0000">"</font><font color="#ff0000">:</font><font color="#ff0000"> "</font><font color="#bb00ff">/usr/local/libexec/nagios/check_ping</font><font color="#ff0000">"</font><font color="#F3E651">,</font>
<font color="#ff0000"> </font><font color="#ff0000">"</font><font color="#ff0000">Args</font><font color="#ff0000">"</font><font color="#ff0000">: </font><font color="#F3E651">[</font><font color="#ff0000"> </font><font color="#ff0000">"</font><font color="#ff0000">-H</font><font color="#ff0000">"</font><font color="#F3E651">,</font><font color="#ff0000"> </font><font color="#ff0000">"</font><font color="#ff0000">www.foo.zone</font><font color="#ff0000">"</font><font color="#F3E651">,</font><font color="#ff0000"> </font><font color="#ff0000">"</font><font color="#ff0000">-6</font><font color="#ff0000">"</font><font color="#F3E651">,</font><font color="#ff0000"> </font><font color="#ff0000">"</font><font color="#ff0000">-w</font><font color="#ff0000">"</font><font color="#F3E651">,</font><font color="#ff0000"> </font><font color="#ff0000">"</font><font color="#ff0000">50,10%</font><font color="#ff0000">"</font><font color="#F3E651">,</font><font color="#ff0000"> </font><font color="#ff0000">"</font><font color="#ff0000">-c</font><font color="#ff0000">"</font><font color="#F3E651">,</font><font color="#ff0000"> </font><font color="#ff0000">"</font><font color="#ff0000">100,15%</font><font color="#ff0000">"</font><font color="#ff0000"> </font><font color="#F3E651">],</font>
<font color="#ff0000"> </font><font color="#ff0000">"</font><font color="#ff0000">Retries</font><font color="#ff0000">"</font><font color="#ff0000">: </font><font color="#bb00ff">3</font><font color="#F3E651">,</font>
<font color="#ff0000"> </font><font color="#ff0000">"</font><font color="#ff0000">RetryInterval</font><font color="#ff0000">"</font><font color="#ff0000">: </font><font color="#bb00ff">10</font>
<font color="#ff0000"> </font><font color="#F3E651">},</font>
<font color="#ff0000"> </font><font color="#ff0000">"</font><font color="#ff0000">www.foo.zone HTTP IPv4</font><font color="#ff0000">"</font><font color="#ff0000">: </font><font color="#F3E651">{</font>
<font color="#ff0000"> </font><font color="#ff0000">"</font><font color="#ff0000">Plugin</font><font color="#ff0000">"</font><font color="#ff0000">:</font><font color="#ff0000"> "</font><font color="#bb00ff">/usr/local/libexec/nagios/check_http</font><font color="#ff0000">"</font><font color="#F3E651">,</font>
<font color="#ff0000"> </font><font color="#ff0000">"</font><font color="#ff0000">Args</font><font color="#ff0000">"</font><font color="#ff0000">: </font><font color="#F3E651">[</font><font color="#ff0000">"</font><font color="#ff0000">www.foo.zone</font><font color="#ff0000">"</font><font color="#F3E651">,</font><font color="#ff0000"> </font><font color="#ff0000">"</font><font color="#ff0000">-4</font><font color="#ff0000">"</font><font color="#F3E651">],</font>
<font color="#ff0000"> </font><font color="#ff0000">"</font><font color="#ff0000">DependsOn</font><font color="#ff0000">"</font><font color="#ff0000">: </font><font color="#F3E651">[</font><font color="#ff0000">"</font><font color="#ff0000">Check ICMP4 www.foo.zone</font><font color="#ff0000">"</font><font color="#F3E651">]</font>
<font color="#ff0000"> </font><font color="#F3E651">},</font>
<font color="#ff0000"> </font><font color="#ff0000">"</font><font color="#ff0000">www.foo.zone HTTP IPv6</font><font color="#ff0000">"</font><font color="#ff0000">: </font><font color="#F3E651">{</font>
<font color="#ff0000"> </font><font color="#ff0000">"</font><font color="#ff0000">Plugin</font><font color="#ff0000">"</font><font color="#ff0000">:</font><font color="#ff0000"> "</font><font color="#bb00ff">/usr/local/libexec/nagios/check_http</font><font color="#ff0000">"</font><font color="#F3E651">,</font>
<font color="#ff0000"> </font><font color="#ff0000">"</font><font color="#ff0000">Args</font><font color="#ff0000">"</font><font color="#ff0000">: </font><font color="#F3E651">[</font><font color="#ff0000">"</font><font color="#ff0000">www.foo.zone</font><font color="#ff0000">"</font><font color="#F3E651">,</font><font color="#ff0000"> </font><font color="#ff0000">"</font><font color="#ff0000">-6</font><font color="#ff0000">"</font><font color="#F3E651">],</font>
<font color="#ff0000"> </font><font color="#ff0000">"</font><font color="#ff0000">DependsOn</font><font color="#ff0000">"</font><font color="#ff0000">: </font><font color="#F3E651">[</font><font color="#ff0000">"</font><font color="#ff0000">Check ICMP6 www.foo.zone</font><font color="#ff0000">"</font><font color="#F3E651">]</font>
<font color="#ff0000"> </font><font color="#F3E651">}</font>
<font color="#ff0000"> </font><font color="#ff0000">"</font><font color="#ff0000">Check NRPE Disk Usage foo.zone</font><font color="#ff0000">"</font><font color="#ff0000">: </font><font color="#F3E651">{</font>
<font color="#ff0000"> </font><font color="#ff0000">"</font><font color="#ff0000">Plugin</font><font color="#ff0000">"</font><font color="#ff0000">:</font><font color="#ff0000"> "</font><font color="#bb00ff">/usr/local/libexec/nagios/check_nrpe</font><font color="#ff0000">"</font><font color="#F3E651">,</font>
<font color="#ff0000"> </font><font color="#ff0000">"</font><font color="#ff0000">Args</font><font color="#ff0000">"</font><font color="#ff0000">: </font><font color="#F3E651">[</font><font color="#ff0000">"</font><font color="#ff0000">-H</font><font color="#ff0000">"</font><font color="#F3E651">,</font><font color="#ff0000"> </font><font color="#ff0000">"</font><font color="#ff0000">foo.zone</font><font color="#ff0000">"</font><font color="#F3E651">,</font><font color="#ff0000"> </font><font color="#ff0000">"</font><font color="#ff0000">-c</font><font color="#ff0000">"</font><font color="#F3E651">,</font><font color="#ff0000"> </font><font color="#ff0000">"</font><font color="#ff0000">check_disk</font><font color="#ff0000">"</font><font color="#F3E651">,</font><font color="#ff0000"> </font><font color="#ff0000">"</font><font color="#ff0000">-p</font><font color="#ff0000">"</font><font color="#F3E651">,</font><font color="#ff0000"> </font><font color="#ff0000">"</font><font color="#ff0000">5666</font><font color="#ff0000">"</font><font color="#F3E651">,</font><font color="#ff0000"> </font><font color="#ff0000">"</font><font color="#ff0000">-4</font><font color="#ff0000">"</font><font color="#F3E651">]</font>
<font color="#ff0000"> </font><font color="#F3E651">}</font>
<font color="#ff0000"> </font><font color="#F3E651">}</font>
<font color="#F3E651">}</font>
</pre>
<br />
<ul>
<li><span class='inlinecode'>EmailTo</span>: Specifies the recipient of the email notifications.</li>
<li><span class='inlinecode'>EmailFrom</span>: Indicates the sender's email address for email notifications.</li>
<li><span class='inlinecode'>CheckTimeoutS</span>: Sets the timeout for checks in seconds.</li>
<li><span class='inlinecode'>CheckConcurrency</span>: Determines the number of concurrent checks that can run simultaneously.</li>
<li><span class='inlinecode'>StateDir</span>: Specifies the directory where Gogios stores its persistent state in a <span class='inlinecode'>state.json</span> file. </li>
<li><span class='inlinecode'>Checks</span>: Defines a list of checks to be performed, each with a unique name, plugin path, and arguments.</li>
</ul><br />
<span>Adjust the configuration file according to your needs, specifying the checks you want Gogios to perform.</span><br />
<br />
<span>If you want to execute checks only when another check succeeded (status OK), use <span class='inlinecode'>DependsOn</span>. In the example above, the HTTP checks won't run when the hosts aren't pingable. They will show up as <span class='inlinecode'>UNKNOWN</span> in the report.</span><br />
<br />
<span><span class='inlinecode'>Retries</span> and <span class='inlinecode'>RetryInterval</span> are optional check configuration parameters. In case of failure, Gogios will retry <span class='inlinecode'>Retries</span> times each <span class='inlinecode'>RetryInterval</span> seconds.</span><br />
<br />
<span>For remote checks, use the <span class='inlinecode'>check_nrpe</span> plugin. You also need to have the NRPE server set up correctly on the target host (out of scope for this document).</span><br />
<br />
<span>The <span class='inlinecode'>state.json</span> file mentioned above keeps track of the monitoring state and check results between Gogios runs, enabling Gogios only to send email notifications when there are changes in the check status.</span><br />
<br />
<h2 style='display: inline' id='running-gogios'>Running Gogios</h2><br />
<br />
<span>Now it is time to give it a first run. On OpenBSD, do:</span><br />
<br />
<!-- Generator: GNU source-highlight 3.1.9
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><font color="#ff0000">doas -u _gogios /usr/local/bin/gogios -cfg /etc/gogios</font><font color="#F3E651">.</font><font color="#ff0000">json</font>
</pre>
<br />
<span>To run Gogios via CRON on OpenBSD as the <span class='inlinecode'>gogios</span> user and check all services once per minute, follow these steps:</span><br />
<br />
<span>Type <span class='inlinecode'>doas crontab -e -u _gogios</span> and press Enter to open the crontab file for the <span class='inlinecode'>_gogios</span> user for editing and add the following lines to the crontab file:</span><br />
<br />
<pre>
*/5 8-22 * * * /usr/local/bin/gogios -cfg /etc/gogios.json
0 7 * * * /usr/local/bin/gogios -renotify -cfg /etc/gogios.json
</pre>
<br />
<span>Gogios is now configured to run every five minutes from 8 am to 10 pm via CRON as the <span class='inlinecode'>_gogios</span> user. It will execute the checks and send monitoring status whenever a check status changes via email according to your configuration. Also, Gogios will run once at 7 am every morning and re-notify all unhandled alerts as a reminder.</span><br />
<br />
<h3 style='display: inline' id='high-availability'>High-availability</h3><br />
<br />
<span>To create a high-availability Gogios setup, you can install Gogios on two servers that will monitor each other using the NRPE (Nagios Remote Plugin Executor) plugin. By running Gogios in alternate CRON intervals on both servers, you can ensure that even if one server goes down, the other will continue monitoring your infrastructure and sending notifications.</span><br />
<br />
<ul>
<li>Install Gogios on both servers following the compilation and installation instructions provided earlier.</li>
<li>Install the NRPE server (out of scope for this document) and plugin on both servers. This plugin allows you to execute Nagios check scripts on remote hosts.</li>
<li>Configure Gogios on both servers to monitor each other using the NRPE plugin. Add a check to the Gogios configuration file (<span class='inlinecode'>/etc/gogios.json</span>) on both servers that uses the NRPE plugin to execute a check script on the other server. For example, if you have Server A and Server B, the configuration on Server A should include a check for Server B, and vice versa.</li>
<li>Set up alternate CRON intervals on both servers. Configure the CRON job on Server A to run Gogios at minutes 0, 10, 20, ..., and on Server B to run at minutes 5, 15, 25, ... This will ensure that if one server goes down, the other server will continue monitoring and sending notifications. </li>
<li>Gogios doesn't support clustering. So it means when both servers are up, unhandled alerts will be notified via E-Mail twice; from each server once. That's the trade-off for simplicity.</li>
</ul><br />
<span>There are plans to make it possible to execute certain checks only on certain nodes (e.g. on elected leader or master nodes). This is still in progress (check out my Gorum Git project).</span><br />
<br />
<h2 style='display: inline' id='conclusion'>Conclusion:</h2><br />
<br />
<span>Gogios is a lightweight and straightforward monitoring tool that is perfect for small-scale environments. With its compatibility with the Nagios Check API, email notifications, and CRON-based scheduling, Gogios offers an easy-to-use solution for those looking to monitor a limited number of resources. I personally use it to execute around 500 checks on my personal server infrastructure. I am very happy with this solution.</span><br />
<br />
<span>E-Mail your comments to <span class='inlinecode'>paul@nospam.buetow.org</span> :-)</span><br />
<br />
<span>Other KISS-related posts are:</span><br />
<br />
<a class='textlink' href='./2024-04-01-KISS-high-availability-with-OpenBSD.html'>2024-04-01 KISS high-availability with OpenBSD</a><br />
<a class='textlink' href='./2023-10-29-kiss-static-web-photo-albums-with-photoalbum.sh.html'>2023-10-29 KISS static web photo albums with <span class='inlinecode'>photoalbum.sh</span></a><br />
<a class='textlink' href='./2023-06-01-kiss-server-monitoring-with-gogios.html'>2023-06-01 KISS server monitoring with Gogios (You are currently reading this)</a><br />
<a class='textlink' href='./2021-09-12-keep-it-simple-and-stupid.html'>2021-09-12 Keep it simple and stupid</a><br />
<br />
<a class='textlink' href='../'>Back to the main site</a><br />
<p class="footer">
Generated with <a href="https://codeberg.org/snonux/gemtexter">Gemtexter 3.0.1-develop</a> |
served by <a href="https://www.OpenBSD.org">OpenBSD</a>/<a href="https://man.openbsd.org/relayd.8">relayd(8)</a>+<a href="https://man.openbsd.org/httpd.8">httpd(8)</a> |
<a href="https://foo.zone/site-mirrors.html">Site Mirrors</a>
<br />
Webring: <a href="https://shring.sh/foo.zone/previous">previous</a> | <a href="https://shring.sh">shring</a> | <a href="https://shring.sh/foo.zone/next">next</a>
</p>
<script type="text/javascript" src="../retrofuturistic.js"></script>
</body>
</html>
|