--- /dev/null
+#!/bin/bash
+
+STATE_OK=0
+STATE_WARNING=1
+STATE_CRITICAL=2
+STATE_UNKNOWN=3
+
+run_command="$1"
+hours="$2"
+as_user="$3"
+
+if [ -z "$as_user" ]; then
+ last_date=$($run_command 2>/dev/null | sort | tail -n 1)
+else
+ last_date=$(sudo -u "$as_user" $run_command 2>/dev/null | sort | tail -n 1)
+fi
+
+if [ -z "$last_date" ]; then
+ echo "UNKNOWN: Could not read date"
+ exit $STATE_UNKNOWN
+else
+ last_date=$(date -d "$last_date" "+%s")
+ LC_ALL=C last_date=$(printf "%.*f" 0 $last_date)
+ min_date=$(date -d "$hours hours ago" "+%s")
+ if [ "$min_date" -lt "$last_date" ]; then
+ echo "OK: Last date $(date -d @$last_date)"
+ exit $STATE_OK
+ else
+ echo "CRITICAL: Last date $(date -d @$last_date)"
+ exit $STATE_CRITICAL
+ fi
+fi
LC_ALL=C last_date=$(printf "%.*f" 0 $last_date)
min_date=$(date -d "$hours hours ago" "+%s")
if [ "$min_date" -lt "$last_date" ]; then
- echo "OK: Last backup $(date -d @$last_date)"
+ echo "OK: Last file $(date -d @$last_date)"
exit $STATE_OK
else
- echo "CRITICAL: Last backup $(date -d @$last_date)"
+ echo "CRITICAL: Last file $(date -d @$last_date)"
exit $STATE_CRITICAL
fi
fi
"check_command",
"check_md_raid",
"check_postgres_replication",
+ "check_date",
"check_last_file_date",
].each |$file| {
file { "$plugins/$file":
require => File["$plugins/check_postgres_replication"];
"check_last_file_date":
command_line => '$USER2$/check_last_file_date "$ARG1$" "$ARG2$" "$ARG3$"',
- require => File["$plugins/check_last_file_date"],
+ require => File["$plugins/check_last_file_date"];
+ "check_date":
+ command_line => '$USER2$/check_date "$ARG1$" "$ARG2$" "$ARG3$"',
+ require => File["$plugins/check_date"];
}
unless empty($naemon_url) {
],
}
+ if ($environment == "production") {
+ $monitored_key = 3
+ @profile::monitoring::local_service { "Last redis report is less than 2 hours old":
+ local => {
+ check_command => "check_date!redis-cli -s $redis_host GET /cryptoportfolio/$monitored_key/latest/date!2"
+ }
+ }
+
+ @profile::monitoring::local_service { "Last bot report is less than one week old":
+ sudos => {
+ "naemon-cryptoportfolio-bot" => "naemon ALL=($user) NOPASSWD: /usr/bin/find $cf_bot_app_reports -mindepth 1 -maxdepth 1 -printf %T@?n",
+ },
+ local => {
+ check_command => "check_last_file_date!$cf_bot_app_reports!168!$user",
+ },
+ }
+ }
+
if versioncmp($trader_version, "v1.3") >= 0 {
file { $cf_bot_app_conf_hourly:
owner => $user,
}
}
+ @profile::monitoring::external_service { "Cryptoportfolio website is running on $web_host":
+ type => "web",
+ master => {
+ check_command => "check_https!$web_host!/!<title>Cryptoportfolio"
+ }
+ }
+ @profile::monitoring::external_service { "$web_host ssl certificate is up to date":
+ type => "web",
+ master => {
+ check_command => "check_https_certificate!$web_host"
+ }
+ }
}
- modules/profile/manifests/postgresql/backup\_pgbouncer.pp (check pgbouncer works)
- modules/profile/manifests/mail.pp (check e-mails are going through)
- modules/profile/manifests/redis.pp (check redis is running)
- - modules/role/manifests/cryptoportfolio (role-specific checks)
+ - LASTSAVE
- Add redis replication and dumps
- Restore backups for cryptoportfolio
- Ensure latest by default for packages