aboutsummaryrefslogtreecommitdiff
path: root/modules/private
diff options
context:
space:
mode:
Diffstat (limited to 'modules/private')
-rw-r--r--modules/private/default.nix2
-rw-r--r--modules/private/environment.nix9
-rw-r--r--modules/private/monitoring/default.nix4
-rw-r--r--modules/private/monitoring/objects_common.nix2
-rwxr-xr-xmodules/private/monitoring/plugins/check_command14
-rwxr-xr-xmodules/private/monitoring/plugins/check_emails6
-rwxr-xr-xmodules/private/monitoring/plugins/check_eriomem16
-rwxr-xr-xmodules/private/monitoring/plugins/check_ftp_database4
-rwxr-xr-xmodules/private/monitoring/plugins/check_git17
-rwxr-xr-xmodules/private/monitoring/plugins/check_imap_connection4
-rwxr-xr-xmodules/private/monitoring/plugins/check_last_file_date6
-rwxr-xr-xmodules/private/monitoring/plugins/check_mysql_replication6
-rwxr-xr-xmodules/private/monitoring/plugins/check_openldap_replication6
-rwxr-xr-xmodules/private/monitoring/plugins/check_ovh_sms4
-rwxr-xr-xmodules/private/monitoring/plugins/check_postgres_replication6
-rwxr-xr-xmodules/private/monitoring/plugins/check_redis_replication6
-rw-r--r--modules/private/monitoring/status_engine.nix109
-rw-r--r--modules/private/websites/default.nix1
-rw-r--r--modules/private/websites/tools/performance/default.nix89
19 files changed, 270 insertions, 41 deletions
diff --git a/modules/private/default.nix b/modules/private/default.nix
index 17dedd4..cf9dc85 100644
--- a/modules/private/default.nix
+++ b/modules/private/default.nix
@@ -84,6 +84,7 @@ set = {
84 mastodonTool = ./websites/tools/mastodon; 84 mastodonTool = ./websites/tools/mastodon;
85 mgoblinTool = ./websites/tools/mgoblin; 85 mgoblinTool = ./websites/tools/mgoblin;
86 peertubeTool = ./websites/tools/peertube; 86 peertubeTool = ./websites/tools/peertube;
87 performanceTool = ./websites/tools/performance;
87 toolsTool = ./websites/tools/tools; 88 toolsTool = ./websites/tools/tools;
88 mailTool = ./websites/tools/mail; 89 mailTool = ./websites/tools/mail;
89 90
@@ -105,6 +106,7 @@ set = {
105 ssh = ./ssh; 106 ssh = ./ssh;
106 monitoring = ./monitoring; 107 monitoring = ./monitoring;
107 status = ./monitoring/status.nix; 108 status = ./monitoring/status.nix;
109 status_engine = ./monitoring/status_engine.nix;
108 vpn = ./vpn; 110 vpn = ./vpn;
109 111
110 environment = ./environment.nix; 112 environment = ./environment.nix;
diff --git a/modules/private/environment.nix b/modules/private/environment.nix
index 82e3981..3a805c6 100644
--- a/modules/private/environment.nix
+++ b/modules/private/environment.nix
@@ -1020,6 +1020,15 @@ in
1020 }; 1020 };
1021 }; 1021 };
1022 }; 1022 };
1023 status_engine = mkOption {
1024 description = "Status Engine configuration";
1025 type = submodule {
1026 options = {
1027 mysql = mkMysqlOptions "StatusEngine" {};
1028 ldap = mkLdapOptions "StatusEngine" {};
1029 };
1030 };
1031 };
1023 task = mkOption { 1032 task = mkOption {
1024 description = "Taskwarrior configuration"; 1033 description = "Taskwarrior configuration";
1025 type = submodule { 1034 type = submodule {
diff --git a/modules/private/monitoring/default.nix b/modules/private/monitoring/default.nix
index 349ba8a..8ae0b30 100644
--- a/modules/private/monitoring/default.nix
+++ b/modules/private/monitoring/default.nix
@@ -241,7 +241,6 @@ in
241 services.naemon = { 241 services.naemon = {
242 enable = true; 242 enable = true;
243 extraConfig = '' 243 extraConfig = ''
244 broker_module=${pkgs.naemon-livestatus}/lib/naemon-livestatus/livestatus.so ${config.services.naemon.runDir}/live
245 use_syslog=1 244 use_syslog=1
246 log_initial_states=1 245 log_initial_states=1
247 date_format=iso8601 246 date_format=iso8601
@@ -249,6 +248,9 @@ in
249 '' + lib.optionalString (!cfg.master) '' 248 '' + lib.optionalString (!cfg.master) ''
250 obsess_over_services=1 249 obsess_over_services=1
251 ocsp_command=notify-master 250 ocsp_command=notify-master
251 '' + lib.optionalString (cfg.master) ''
252 broker_module=${pkgs.naemon-livestatus}/lib/naemon-livestatus/livestatus.so ${config.services.naemon.runDir}/live
253 broker_module=${pkgs.status_engine.module}/lib/status-engine/naemon/statusengine-${pkgs.naemon.status_engine_version}.o use_service_perfdata=1 use_process_data=0 use_system_command_data=0 use_external_command_data=0 use_flapping_data=0 use_program_status_data=0 use_notification_data=0 use_contact_status_data=0 use_contact_notification_data=0 use_event_handler_data=0 use_object_data=0
252 ''; 254 '';
253 extraResource = '' 255 extraResource = ''
254 $USER2$=${myplugins} 256 $USER2$=${myplugins}
diff --git a/modules/private/monitoring/objects_common.nix b/modules/private/monitoring/objects_common.nix
index e9b1b51..2585c38 100644
--- a/modules/private/monitoring/objects_common.nix
+++ b/modules/private/monitoring/objects_common.nix
@@ -133,7 +133,7 @@ in
133 notify-service-by-email = "ADMINEMAIL=\"$ADMINEMAIL$\" SERVICENOTIFICATIONID=\"$SERVICENOTIFICATIONID$\" SERVICEDESC=\"$SERVICEDESC$\" SERVICESTATE=\"$SERVICESTATE$\" SERVICEOUTPUT=\"$SERVICEOUTPUT$\" $USER2$/notify_by_email service \"$NOTIFICATIONTYPE$\" \"$HOSTALIAS$\" \"$LONGDATETIME$\" \"$CONTACTEMAIL$\" $OVE"; 133 notify-service-by-email = "ADMINEMAIL=\"$ADMINEMAIL$\" SERVICENOTIFICATIONID=\"$SERVICENOTIFICATIONID$\" SERVICEDESC=\"$SERVICEDESC$\" SERVICESTATE=\"$SERVICESTATE$\" SERVICEOUTPUT=\"$SERVICEOUTPUT$\" $USER2$/notify_by_email service \"$NOTIFICATIONTYPE$\" \"$HOSTALIAS$\" \"$LONGDATETIME$\" \"$CONTACTEMAIL$\" $OVE";
134 notify-by-slack = "HOST=\"$HOSTALIAS$\" SERVICESTATE=\"$SERVICESTATE$\" SERVICEDESC=\"$SERVICEDESC$\" SERVICEOUTPUT=\"$SERVICEOUTPUT$\" $USER2$/notify_by_slack \"$ARG1$\" \"$ARG2$\""; 134 notify-by-slack = "HOST=\"$HOSTALIAS$\" SERVICESTATE=\"$SERVICESTATE$\" SERVICEDESC=\"$SERVICEDESC$\" SERVICEOUTPUT=\"$SERVICEOUTPUT$\" $USER2$/notify_by_slack \"$ARG1$\" \"$ARG2$\"";
135 135
136 notify-master = "$USER2$/send_nrdp.sh -u \"$USER200$\" -t \"$USER201$\" -H \"$HOSTADDRESS$\" -s \"$SERVICEDESC$\" -S \"$SERVICESTATEID$\" -o \"$SERVICEOUTPUT$\""; 136 notify-master = "$USER2$/send_nrdp.sh -u \"$USER200$\" -t \"$USER201$\" -H \"$HOSTADDRESS$\" -s \"$SERVICEDESC$\" -S \"$SERVICESTATEID$\" -o \"$SERVICEOUTPUT$ | $SERVICEPERFDATA$\"";
137 }; 137 };
138 timeperiod = { 138 timeperiod = {
139 "24x7" = { 139 "24x7" = {
diff --git a/modules/private/monitoring/plugins/check_command b/modules/private/monitoring/plugins/check_command
index 55779fd..2b546c1 100755
--- a/modules/private/monitoring/plugins/check_command
+++ b/modules/private/monitoring/plugins/check_command
@@ -57,30 +57,30 @@ if ($other_command ne '') {
57 57
58chomp($cmd_result); 58chomp($cmd_result);
59if ($cmd_result =~ /sudo/i) { 59if ($cmd_result =~ /sudo/i) {
60 print "$command CRITICAL - No sudo right to run the command\n"; 60 print "$command CRITICAL - No sudo right to run the command | result=1;;;;\n";
61 exit($STATE_UNKNOWN); 61 exit($STATE_UNKNOWN);
62} elsif ($expected_status ne '') { 62} elsif ($expected_status ne '') {
63 if ($? != $expected_status) { 63 if ($? != $expected_status) {
64 print "$command CRITICAL - Response status $?\n"; 64 print "$command CRITICAL - Response status $? | result=1;;;;\n";
65 exit($STATE_CRITICAL); 65 exit($STATE_CRITICAL);
66 } else { 66 } else {
67 print "$command OK - Response status $?\n"; 67 print "$command OK - Response status $? | result=0;;;;\n";
68 exit($STATE_OK); 68 exit($STATE_OK);
69 } 69 }
70} elsif ($other_command ne '') { 70} elsif ($other_command ne '') {
71 if ($cmd_result ne $other_cmd_result) { 71 if ($cmd_result ne $other_cmd_result) {
72 print "$command CRITICAL - Expected output not matching other command output\n"; 72 print "$command CRITICAL - Expected output not matching other command output | result=1;;;;\n";
73 exit($STATE_CRITICAL); 73 exit($STATE_CRITICAL);
74 } else { 74 } else {
75 print "$command OK - Expected output matching other command output\n"; 75 print "$command OK - Expected output matching other command output | result=0;;;;\n";
76 exit($STATE_OK); 76 exit($STATE_OK);
77 } 77 }
78} else { 78} else {
79 if ($cmd_result !~ /$expected_output/) { 79 if ($cmd_result !~ /$expected_output/) {
80 print "$command CRITICAL - Expected output not matching\n"; 80 print "$command CRITICAL - Expected output not matching | result=1;;;;\n";
81 exit($STATE_CRITICAL); 81 exit($STATE_CRITICAL);
82 } else { 82 } else {
83 print "$command OK - Expected output matching\n"; 83 print "$command OK - Expected output matching | result=0;;;;\n";
84 exit($STATE_OK); 84 exit($STATE_OK);
85 } 85 }
86} 86}
diff --git a/modules/private/monitoring/plugins/check_emails b/modules/private/monitoring/plugins/check_emails
index 5a8453e..534e5a5 100755
--- a/modules/private/monitoring/plugins/check_emails
+++ b/modules/private/monitoring/plugins/check_emails
@@ -61,6 +61,7 @@ foreach my $line (@lines) {
61} 61}
62 62
63my $output = ""; 63my $output = "";
64my $old = 0;
64foreach my $email_from (@emails_to_expect) { 65foreach my $email_from (@emails_to_expect) {
65 my @email_split = split(/:/, $email_from); 66 my @email_split = split(/:/, $email_from);
66 my $email = $email_split[0]; 67 my $email = $email_split[0];
@@ -73,16 +74,17 @@ foreach my $email_from (@emails_to_expect) {
73 if ($current_date - $email_date > 60*30) { 74 if ($current_date - $email_date > 60*30) {
74 $output = "$output$email ($found_emails{$email} from $from) "; 75 $output = "$output$email ($found_emails{$email} from $from) ";
75 } 76 }
77 $old = ($current_date - $email_date) > $old ? ($current_date - $email_date) : $old;
76 } else { 78 } else {
77 $output = "$output$email (missing) " 79 $output = "$output$email (missing) "
78 } 80 }
79} 81}
80 82
81if ($output ne '') { 83if ($output ne '') {
82 print "Emails $host CRITICAL - expecting emails: $output\n"; 84 print "Emails $host CRITICAL - expecting emails: $output | timestamp=${old}s;;;;\n";
83 exit($STATE_CRITICAL); 85 exit($STATE_CRITICAL);
84} else { 86} else {
85 print "Emails $host OK\n"; 87 print "Emails $host OK | timestamp=${old}s;;;;\n";
86 exit($STATE_OK); 88 exit($STATE_OK);
87} 89}
88 90
diff --git a/modules/private/monitoring/plugins/check_eriomem b/modules/private/monitoring/plugins/check_eriomem
index f91d1e4..880b88a 100755
--- a/modules/private/monitoring/plugins/check_eriomem
+++ b/modules/private/monitoring/plugins/check_eriomem
@@ -47,7 +47,7 @@ def main():
47 for p in ps: 47 for p in ps:
48 os.kill(p.pid, signal.SIGTERM) 48 os.kill(p.pid, signal.SIGTERM)
49 output(STATE_UNKNOWN, 49 output(STATE_UNKNOWN,
50 "eriomem UNKNOWN - Command timeout after 60 seconds!") 50 "Eriomem UNKNOWN - Command timeout after 60 seconds!")
51 51
52 signal.alarm(0) 52 signal.alarm(0)
53 53
@@ -57,20 +57,20 @@ def main():
57 use_percent = 100 * usage / max_size 57 use_percent = 100 * usage / max_size
58 if use_percent > critical_percent: 58 if use_percent > critical_percent:
59 output(STATE_CRITICAL, 59 output(STATE_CRITICAL,
60 "eriomem CRITICAL - bucket usage: %s (%s%%);| size=%s;;;;" % 60 "Eriomem CRITICAL - bucket usage: %s (%s%%);| size=%s;;;;" %
61 (sizeof_fmt(usage), use_percent, usage)) 61 (sizeof_fmt(usage), use_percent, sizeof_fmt(usage)))
62 elif use_percent > warning_percent: 62 elif use_percent > warning_percent:
63 output(STATE_WARNING, 63 output(STATE_WARNING,
64 "eriomem WARNING - bucket usage: %s (%s%%);| size=%s;;;;" % 64 "Eriomem WARNING - bucket usage: %s (%s%%);| size=%s;;;;" %
65 (sizeof_fmt(usage), use_percent, usage)) 65 (sizeof_fmt(usage), use_percent, sizeof_fmt(usage)))
66 else: 66 else:
67 output(STATE_OK, 67 output(STATE_OK,
68 "eriomem OK - bucket usage: %s (%d%%);| size=%s;;;;" % 68 "Eriomem OK - bucket usage: %s (%d%%);| size=%s;;;;" %
69 (sizeof_fmt(usage), use_percent, usage)) 69 (sizeof_fmt(usage), use_percent, sizeof_fmt(usage)))
70 else: 70 else:
71 messages = "\n".join([out[0].decode() + out[1].decode() for out in outs]) 71 messages = "\n".join([out[0].decode() + out[1].decode() for out in outs])
72 output(STATE_UNKNOWN, 72 output(STATE_UNKNOWN,
73 "eriomem Unknown - Error in command\n" + messages) 73 "Eriomem UNKNOWN - Error in command")
74 74
75def sizeof_fmt(num): 75def sizeof_fmt(num):
76 for unit in ['','ko','Mo','Go','To','Po','Eo','Zo']: 76 for unit in ['','ko','Mo','Go','To','Po','Eo','Zo']:
diff --git a/modules/private/monitoring/plugins/check_ftp_database b/modules/private/monitoring/plugins/check_ftp_database
index 9a41424..f9cf579 100755
--- a/modules/private/monitoring/plugins/check_ftp_database
+++ b/modules/private/monitoring/plugins/check_ftp_database
@@ -3,9 +3,9 @@
3OUT=$(echo "ls" | lftp -u test_ftp,test_ftp eldiron.immae.eu | grep it_works | wc -l) 3OUT=$(echo "ls" | lftp -u test_ftp,test_ftp eldiron.immae.eu | grep it_works | wc -l)
4 4
5if [ "$OUT" -eq 1 ]; then 5if [ "$OUT" -eq 1 ]; then
6 echo "ftp connection OK - access to ftp is working" 6 echo "ftp connection OK - access to ftp is working | ftp=1;;;;"
7 exit 0 7 exit 0
8else 8else
9 echo "ftp connection CRITICAL - no access to ftp" 9 echo "ftp connection CRITICAL - no access to ftp | ftp=0;;;;"
10 exit 2 10 exit 2
11fi 11fi
diff --git a/modules/private/monitoring/plugins/check_git b/modules/private/monitoring/plugins/check_git
index 8c09925..e8fbb29 100755
--- a/modules/private/monitoring/plugins/check_git
+++ b/modules/private/monitoring/plugins/check_git
@@ -13,6 +13,7 @@ trap "rm -rf $TMPDIR" EXIT
13 13
14ERRORS="" 14ERRORS=""
15OUTPUT="" 15OUTPUT=""
16PERFS=""
16 17
17cd "$TMPDIR" 18cd "$TMPDIR"
18OUT=$(git clone -q git://git.immae.eu/perso/Immae/Projets/Ruby/Monitor.git 2>&1) 19OUT=$(git clone -q git://git.immae.eu/perso/Immae/Projets/Ruby/Monitor.git 2>&1)
@@ -22,7 +23,10 @@ OUTPUT="$OUTPUT
22$OUT" 23$OUT"
23fi 24fi
24if [ "$ERR" != 0 ]; then 25if [ "$ERR" != 0 ]; then
26 PERFS="$PERFS git=0;;;;"
25 ERRORS="$ERRORS git://" 27 ERRORS="$ERRORS git://"
28else
29 PERFS="$PERFS git=1;;;;"
26fi 30fi
27rm -rf Monitor 31rm -rf Monitor
28 32
@@ -34,6 +38,9 @@ $OUT"
34fi 38fi
35if [ "$ERR" != 0 ]; then 39if [ "$ERR" != 0 ]; then
36 ERRORS="$ERRORS http://" 40 ERRORS="$ERRORS http://"
41 PERFS="$PERFS http=0;;;;"
42else
43 PERFS="$PERFS http=1;;;;"
37fi 44fi
38rm -rf Monitor 45rm -rf Monitor
39 46
@@ -45,6 +52,9 @@ $OUT"
45fi 52fi
46if [ "$ERR" != 0 ]; then 53if [ "$ERR" != 0 ]; then
47 ERRORS="$ERRORS https://" 54 ERRORS="$ERRORS https://"
55 PERFS="$PERFS https=0;;;;"
56else
57 PERFS="$PERFS https=1;;;;"
48fi 58fi
49rm -rf Monitor 59rm -rf Monitor
50 60
@@ -56,13 +66,16 @@ $OUT"
56fi 66fi
57if [ "$ERR" != 0 ]; then 67if [ "$ERR" != 0 ]; then
58 ERRORS="$ERRORS ssh" 68 ERRORS="$ERRORS ssh"
69 PERFS="$PERFS ssh=0;;;;"
70else
71 PERFS="$PERFS ssh=1;;;;"
59fi 72fi
60rm -rf Monitor 73rm -rf Monitor
61 74
62if [ -n "$ERRORS" ]; then 75if [ -n "$ERRORS" ]; then
63 echo "gitolite CRITICAL - impossible to clone via$ERRORS|$OUTPUT" 76 echo "gitolite CRITICAL - impossible to clone via$ERRORS | $PERFS"
64 exit 2 77 exit 2
65else 78else
66 echo "gitolite OK - ssh, git, http and https work|$OUTPUT" 79 echo "gitolite OK - ssh, git, http and https work | $PERFS"
67 exit 0 80 exit 0
68fi 81fi
diff --git a/modules/private/monitoring/plugins/check_imap_connection b/modules/private/monitoring/plugins/check_imap_connection
index 304eae6..c1ab0dd 100755
--- a/modules/private/monitoring/plugins/check_imap_connection
+++ b/modules/private/monitoring/plugins/check_imap_connection
@@ -26,10 +26,10 @@ my $expected_result = "a OK Logged in";
26 26
27chomp($cmd_result); 27chomp($cmd_result);
28if ($cmd_result !~ /$expected_result/) { 28if ($cmd_result !~ /$expected_result/) {
29 print "IMAP CRITICAL - Unable to connect via imaps\n"; 29 print "IMAP CRITICAL - Unable to connect via imaps | imap=0;;;;\n";
30 exit($STATE_CRITICAL); 30 exit($STATE_CRITICAL);
31} else { 31} else {
32 print "IMAP OK - imaps connected successfully\n"; 32 print "IMAP OK - imaps connected successfully | imap=1;;;;\n";
33 exit($STATE_OK); 33 exit($STATE_OK);
34} 34}
35 35
diff --git a/modules/private/monitoring/plugins/check_last_file_date b/modules/private/monitoring/plugins/check_last_file_date
index df45bbc..f51a258 100755
--- a/modules/private/monitoring/plugins/check_last_file_date
+++ b/modules/private/monitoring/plugins/check_last_file_date
@@ -15,12 +15,14 @@ if [ -z "$last_date" ]; then
15 exit $STATE_UNKNOWN 15 exit $STATE_UNKNOWN
16else 16else
17 LC_ALL=C last_date=$(printf "%.*f" 0 $last_date) 17 LC_ALL=C last_date=$(printf "%.*f" 0 $last_date)
18 LC_ALL=C age=$(( $(date "+%s") - $last_date))
19 max_age=$(( $hours * 60 * 60 ))
18 min_date=$(date -d "$hours hours ago" "+%s") 20 min_date=$(date -d "$hours hours ago" "+%s")
19 if [ "$min_date" -lt "$last_date" ]; then 21 if [ "$min_date" -lt "$last_date" ]; then
20 echo "OK: Last file $(date -d @$last_date)" 22 echo "OK: Last file $(date -d @$last_date) | age=${age}s;;$max_age;;"
21 exit $STATE_OK 23 exit $STATE_OK
22 else 24 else
23 echo "CRITICAL: Last file $(date -d @$last_date)" 25 echo "CRITICAL: Last file $(date -d @$last_date) | age=${age}s;;$max_age;;"
24 exit $STATE_CRITICAL 26 exit $STATE_CRITICAL
25 fi 27 fi
26fi 28fi
diff --git a/modules/private/monitoring/plugins/check_mysql_replication b/modules/private/monitoring/plugins/check_mysql_replication
index 8923928..4027f63 100755
--- a/modules/private/monitoring/plugins/check_mysql_replication
+++ b/modules/private/monitoring/plugins/check_mysql_replication
@@ -23,13 +23,13 @@ else
23 LC_ALL=C lag=$(printf "%.*f" 0 $lag) 23 LC_ALL=C lag=$(printf "%.*f" 0 $lag)
24 24
25 if [[ $lag -lt 5 ]]; then 25 if [[ $lag -lt 5 ]]; then
26 echo "OK - $output" 26 echo "OK - $output | time=${lag}s;5;10;;"
27 exit $STATE_OK 27 exit $STATE_OK
28 elif [[ $lag -lt 10 ]]; then 28 elif [[ $lag -lt 10 ]]; then
29 echo "WARNING - $output" 29 echo "WARNING - $output | time=${lag}s;5;10;;"
30 exit $STATE_WARNING 30 exit $STATE_WARNING
31 else 31 else
32 echo "CRITICAL - $output" 32 echo "CRITICAL - $output | time=${lag}s;5;10;;"
33 exit $STATE_CRITICAL 33 exit $STATE_CRITICAL
34 fi 34 fi
35fi 35fi
diff --git a/modules/private/monitoring/plugins/check_openldap_replication b/modules/private/monitoring/plugins/check_openldap_replication
index b511ff2..7136ad5 100755
--- a/modules/private/monitoring/plugins/check_openldap_replication
+++ b/modules/private/monitoring/plugins/check_openldap_replication
@@ -42,13 +42,13 @@ else
42 LC_ALL=C lag=$(printf "%.*f" 0 $lag) 42 LC_ALL=C lag=$(printf "%.*f" 0 $lag)
43 43
44 if [[ $offset -lt 5 ]]; then 44 if [[ $offset -lt 5 ]]; then
45 echo "OK - $output" 45 echo "OK - $output | time=${offset}s;5;10;;"
46 exit $STATE_OK 46 exit $STATE_OK
47 elif [[ $offset -lt 10 ]]; then 47 elif [[ $offset -lt 10 ]]; then
48 echo "WARNING - $output" 48 echo "WARNING - $output | time=${offset}s;5;10;;"
49 exit $STATE_WARNING 49 exit $STATE_WARNING
50 else 50 else
51 echo "CRITICAL - $output" 51 echo "CRITICAL - $output | time=${offset}s;5;10;;"
52 exit $STATE_CRITICAL 52 exit $STATE_CRITICAL
53 fi 53 fi
54fi 54fi
diff --git a/modules/private/monitoring/plugins/check_ovh_sms b/modules/private/monitoring/plugins/check_ovh_sms
index 141f82d..caf279c 100755
--- a/modules/private/monitoring/plugins/check_ovh_sms
+++ b/modules/private/monitoring/plugins/check_ovh_sms
@@ -15,10 +15,10 @@ try:
15 result = client.get('/sms/{}'.format(account))["creditsLeft"] 15 result = client.get('/sms/{}'.format(account))["creditsLeft"]
16 16
17 if result < 20: 17 if result < 20:
18 print("SMS OVH Critical - Not enough sms left ({})|SMS {}".format(result, result)) 18 print("SMS OVH Critical - Not enough sms left ({})|SMS={};;;;".format(result, result))
19 sys.exit(2) 19 sys.exit(2)
20 else: 20 else:
21 print("SMS OVH Ok - Enough sms left ({})|SMS {}".format(result, result)) 21 print("SMS OVH Ok - Enough sms left ({})|SMS={};;;;".format(result, result))
22 sys.exit(0) 22 sys.exit(0)
23except Exception: 23except Exception:
24 print("SMS OVH UNKNOWN - Error during script") 24 print("SMS OVH UNKNOWN - Error during script")
diff --git a/modules/private/monitoring/plugins/check_postgres_replication b/modules/private/monitoring/plugins/check_postgres_replication
index 009b4d5..ff257a3 100755
--- a/modules/private/monitoring/plugins/check_postgres_replication
+++ b/modules/private/monitoring/plugins/check_postgres_replication
@@ -23,13 +23,13 @@ else
23 LC_ALL=C lag=$(printf "%.*f" 0 $lag) 23 LC_ALL=C lag=$(printf "%.*f" 0 $lag)
24 24
25 if [[ $lag -lt 5 ]]; then 25 if [[ $lag -lt 5 ]]; then
26 echo "OK - $output" 26 echo "OK - $output | time=${lag}s;5;10;0;"
27 exit $STATE_OK 27 exit $STATE_OK
28 elif [[ $lag -lt 10 ]]; then 28 elif [[ $lag -lt 10 ]]; then
29 echo "WARNING - $output" 29 echo "WARNING - $output | time=${lag}s;5;10;0;"
30 exit $STATE_WARNING 30 exit $STATE_WARNING
31 else 31 else
32 echo "CRITICAL - $output" 32 echo "CRITICAL - $output | time=${lag}s;5;10;0;"
33 exit $STATE_CRITICAL 33 exit $STATE_CRITICAL
34 fi 34 fi
35fi 35fi
diff --git a/modules/private/monitoring/plugins/check_redis_replication b/modules/private/monitoring/plugins/check_redis_replication
index 7a884e1..6dbe4c4 100755
--- a/modules/private/monitoring/plugins/check_redis_replication
+++ b/modules/private/monitoring/plugins/check_redis_replication
@@ -26,13 +26,13 @@ else
26 LC_ALL=C lag=$(printf "%.*f" 0 $lag) 26 LC_ALL=C lag=$(printf "%.*f" 0 $lag)
27 27
28 if [[ $lag -lt 5 && $offset -lt 5 ]]; then 28 if [[ $lag -lt 5 && $offset -lt 5 ]]; then
29 echo "OK - $output" 29 echo "OK - $output | time=${lag}s;5;10;0; offset=${offset};5;10;0;"
30 exit $STATE_OK 30 exit $STATE_OK
31 elif [[ $lag -lt 10 && $offset -lt 10 ]]; then 31 elif [[ $lag -lt 10 && $offset -lt 10 ]]; then
32 echo "WARNING - $output" 32 echo "WARNING - $output | time=${lag}s;5;10;0; offset=${offset};5;10;0;"
33 exit $STATE_WARNING 33 exit $STATE_WARNING
34 else 34 else
35 echo "CRITICAL - $output" 35 echo "CRITICAL - $output | time=${lag}s;5;10;0; offset=${offset};5;10;0;"
36 exit $STATE_CRITICAL 36 exit $STATE_CRITICAL
37 fi 37 fi
38fi 38fi
diff --git a/modules/private/monitoring/status_engine.nix b/modules/private/monitoring/status_engine.nix
new file mode 100644
index 0000000..c74a44d
--- /dev/null
+++ b/modules/private/monitoring/status_engine.nix
@@ -0,0 +1,109 @@
1{ config, pkgs, lib, name, ... }:
2let
3 package = pkgs.status_engine.worker.override { config_file = config.secrets.fullPaths."status_engine"; };
4 env = config.myEnv.tools.status_engine;
5in
6{
7 config = lib.mkIf config.myServices.status.enable {
8 systemd.services.gearmand = {
9 description = "Gearman daemon";
10 after = [ "network.target" ];
11 wantedBy = [ "multi-user.target" ];
12 serviceConfig = {
13 DynamicUser = true;
14 User = "gearmand";
15 Type = "simple";
16 ExecStart = "${pkgs.gearmand}/bin/gearmand --syslog -L 127.0.0.1 -q libsqlite3 --libsqlite3-db /var/lib/gearmand/gearmand.db --store-queue-on-shutdown -l stderr -P /run/gearmand/gearmand.pid";
17 RuntimeDirectory = "gearmand";
18 StateDirectory = "gearmand";
19 };
20 };
21
22 secrets.keys = [{
23 dest = "status_engine";
24 permissions = "0400";
25 user = "naemon";
26 group = "naemon";
27 text = ''
28 node_name: ${name}
29 use_gearman: 1
30 gearman:
31 address: 127.0.0.1
32 port: 4730
33 timeout: 1000
34 use_rabbitmq: 0
35 use_redis: 1
36 redis:
37 address: 127.0.0.1
38 port: 6379
39 db: 0
40 store_live_data_in_archive_backend: 1
41 use_mysql: 1
42 mysql:
43 host: ${env.mysql.remoteHost}
44 port: ${env.mysql.port}
45 username: ${env.mysql.user}
46 password: ${env.mysql.password}
47 database: ${env.mysql.database}
48 use_crate: 0
49 number_of_bulk_records: 100
50 max_bulk_delay: 5
51 number_servicestatus_worker: 1
52 number_hoststatus_worker: 1
53 number_logentry_worker: 1
54 number_statechange_worker: 1
55 number_hostcheck_worker: 1
56 number_servicecheck_worker: 1
57 number_misc_worker: 1
58
59 process_perfdata: 1
60 number_perfdata_worker: 1
61 perfdata_backend:
62 - mysql
63
64 check_for_commands: 1
65 command_check_interval: 15
66 external_command_file: /run/naemon/naemon.cmd
67 query_handler: /run/naemon/naemon.qh
68 submit_method: qh
69
70 syslog_enabled: 1
71 syslog_tag: statusengine-worker
72
73 # Archive age
74 age_hostchecks: 5
75 age_host_acknowledgements: 60
76 age_host_notifications: 60
77 age_host_statehistory: 365
78 age_host_downtimes: 60
79 age_servicechecks: 5
80 age_service_acknowledgements: 60
81 age_service_notifications: 60
82 age_service_statehistory: 365
83 age_service_downtimes: 60
84 age_logentries: 5
85 age_tasks: 1
86 age_perfdata: 90
87
88 disable_http_proxy: 1
89 '';
90 }];
91
92 services.redis = rec {
93 enable = true;
94 bind = "127.0.0.1";
95 };
96
97 systemd.services.status_engine_worker = {
98 description = "Status engine worker";
99 after = [ "network.target" ];
100 wantedBy = [ "multi-user.target" ];
101 serviceConfig = {
102 Type = "simple";
103 Restart = "on-failure";
104 User = "naemon";
105 ExecStart = "${package}/bin/StatusengineWorker.php";
106 };
107 };
108 };
109}
diff --git a/modules/private/websites/default.nix b/modules/private/websites/default.nix
index 864d5d9..f84567e 100644
--- a/modules/private/websites/default.nix
+++ b/modules/private/websites/default.nix
@@ -295,6 +295,7 @@ in
295 tools.mastodon.enable = true; 295 tools.mastodon.enable = true;
296 tools.mediagoblin.enable = true; 296 tools.mediagoblin.enable = true;
297 tools.peertube.enable = true; 297 tools.peertube.enable = true;
298 tools.performance.enable = true;
298 tools.tools.enable = true; 299 tools.tools.enable = true;
299 tools.email.enable = true; 300 tools.email.enable = true;
300 301
diff --git a/modules/private/websites/tools/performance/default.nix b/modules/private/websites/tools/performance/default.nix
new file mode 100644
index 0000000..df2b58d
--- /dev/null
+++ b/modules/private/websites/tools/performance/default.nix
@@ -0,0 +1,89 @@
1{ pkgs, lib, config, ... }:
2let
3 env = config.myEnv.tools.status_engine;
4 package = pkgs.status_engine.interface.override({ config_file = config.secrets.fullPaths."status_engine_ui"; });
5 apacheRoot = "${package}/public";
6 cfg = config.myServices.websites.tools.performance;
7in
8{
9 options.myServices.websites.tools.performance = {
10 enable = lib.mkEnableOption "Enable performance website";
11 };
12
13 config = lib.mkIf cfg.enable {
14 secrets.keys = [
15 {
16 dest = "status_engine_ui";
17 permissions = "0400";
18 user = "wwwrun";
19 group = "wwwrun";
20 text = ''
21 allow_anonymous: 0
22 anonymous_can_submit_commands: 0
23 urls_without_login:
24 - login
25 - loginstate
26 auth_type: ldap
27 ldap_server: ${env.ldap.host}
28 ldap_use_ssl: 1
29 ldap_port: 636
30 ldap_bind_dn: ${env.ldap.dn}
31 ldap_bind_password: ${env.ldap.password}
32 ldap_base_dn: ${env.ldap.base}
33 ldap_filter: "${env.ldap.filter}"
34 ldap_attribute:
35 - memberOf
36 use_crate: 0
37 use_mysql: 1
38 mysql:
39 host: 127.0.0.1
40 port: ${env.mysql.port}
41 username: ${env.mysql.user}
42 password: ${env.mysql.password}
43 database: ${env.mysql.database}
44 display_perfdata: 1
45 perfdata_backend: mysql
46 '';
47 }
48 ];
49
50 services.websites.env.tools.modules = [ "proxy_fcgi" ];
51
52 services.websites.env.tools.vhostConfs.performance = {
53 certName = "eldiron";
54 addToCerts = true;
55 hosts = [ "performance.immae.eu" ];
56 root = apacheRoot;
57 extraConfig = [
58 ''
59 <Directory ${apacheRoot}>
60 DirectoryIndex index.html
61 AllowOverride None
62 Require all granted
63 <FilesMatch "\.php$">
64 SetHandler "proxy:unix:${config.services.phpfpm.pools.status_engine.socket}|fcgi://localhost"
65 </FilesMatch>
66 </Directory>
67 ''
68 ];
69 };
70
71 services.phpfpm.pools.status_engine = {
72 user = "wwwrun";
73 group = "wwwrun";
74 settings = {
75 "listen.owner" = "wwwrun";
76 "listen.group" = "wwwrun";
77 "pm" = "dynamic";
78 "pm.max_children" = "60";
79 "pm.start_servers" = "2";
80 "pm.min_spare_servers" = "1";
81 "pm.max_spare_servers" = "10";
82
83 "php_admin_value[open_basedir]" = "${package}:/tmp:/var/secrets/status_engine_ui";
84 };
85 phpPackage = pkgs.php74;
86 };
87
88 };
89}