Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F9347362
D5709.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
4 KB
Subscribers
None
D5709.diff
View Options
diff --git a/site-modules/profile/files/icinga2/plugins/check_logstash_errors.sh b/site-modules/profile/files/icinga2/plugins/check_logstash_errors.sh
new file mode 100644
--- /dev/null
+++ b/site-modules/profile/files/icinga2/plugins/check_logstash_errors.sh
@@ -0,0 +1,54 @@
+#!/bin/bash
+
+CODE_CRITICAL=2
+CODE_OK=0
+
+STATE_CRITICAL=false
+
+LOGSTASH_STATS_URL=http://localhost:9600/_node/stats
+
+ERROR_CODE=0
+
+# JPATH_FAILURE_COUNT=".pipelines.main.plugins.outputs[].bulk_requests.failures"
+JPATH_ERROR_COUNT=".pipelines.main.plugins.outputs[].bulk_requests.with_errors"
+JPATH_NON_RETRYABLE_FAILURE_COUNT=".pipelines.main.plugins.outputs[].documents.non_retryable_failures"
+
+get_value_from_json() {
+ json=$1
+ jpath=$2
+
+ if ! jq -r "${jpath}" "${json}"; then
+ echo "CRITICAL: unable to parse json file"
+ exit ${CODE_CRITICAL}
+ fi
+}
+
+TMP_FILE=$(mktemp)
+
+trap "rm -f ${TMP_FILE}" EXIT
+
+if ! curl -f -s -o ${TMP_FILE} ${LOGSTASH_STATS_URL}; then
+ echo "CRITICAL - Unable to retrieve logstash statistics"
+ exit ${CODE_CRITICAL}
+fi
+
+NON_RETRYABLE_FAILURES="$(get_value_from_json ${TMP_FILE} ${JPATH_NON_RETRYABLE_FAILURE_COUNT})"
+ERRORS="$(get_value_from_json ${TMP_FILE} ${JPATH_ERROR_COUNT})"
+
+if [ "${NON_RETRYABLE_FAILURES}" != "null" ]; then
+ STATE_CRITICAL=true
+fi
+
+if [ "${ERRORS}" != null ]; then
+ STATE_CRITICAL=true
+fi
+
+if ${STATE_CRITICAL}; then
+ echo "CRITICAL - Logstash has detected some errors in outputs errors=${ERRORS} non_retryable_errors=${NON_RETRYABLE_FAILURES}"
+ ERROR_CODE=${CODE_CRITICAL}
+else
+ echo "OK - No errors detected"
+ ERROR_CODE=${CODE_OK}
+fi
+
+exit ${ERROR_CODE}
diff --git a/site-modules/profile/manifests/icinga2/objects/common_checks.pp b/site-modules/profile/manifests/icinga2/objects/common_checks.pp
--- a/site-modules/profile/manifests/icinga2/objects/common_checks.pp
+++ b/site-modules/profile/manifests/icinga2/objects/common_checks.pp
@@ -108,4 +108,15 @@
ignore => ['host.vars.noagent'],
target => '/etc/icinga2/zones.d/global-templates/services.conf',
}
+
+ ::icinga2::object::service {'logstash_errors':
+ import => ['generic-service'],
+ apply => true,
+ check_command => 'check_logstash_errors.sh',
+ command_endpoint => 'host.name',
+ assign => ['"check_logstash_errors.sh" in host.vars.plugins'],
+ ignore => ['host.vars.noagent'],
+ target => '/etc/icinga2/zones.d/global-templates/services.conf',
+ }
+
}
diff --git a/site-modules/profile/manifests/icinga2/objects/logstash_checks.pp b/site-modules/profile/manifests/icinga2/objects/logstash_checks.pp
new file mode 100644
--- /dev/null
+++ b/site-modules/profile/manifests/icinga2/objects/logstash_checks.pp
@@ -0,0 +1,27 @@
+# Check the status of logstash service
+# this is an agent check
+class profile::icinga2::objects::logstash_checks {
+ $swh_plugin_dir = '/usr/lib/nagios/plugins/swh'
+ $check_command = 'check_logstash_errors.sh'
+ $check_command_path = "${swh_plugin_dir}/${check_command}"
+
+ $swh_plugin_configfile = '/etc/icinga2/conf.d/swh-plugins.conf'
+
+ file {$check_command_path:
+ ensure => present,
+ owner => 'root',
+ group => 'root',
+ mode => '0755',
+ source => "puppet:///modules/profile/icinga2/plugins/${check_command}",
+ require => File[$swh_plugin_dir]
+ }
+
+
+ ::icinga2::object::checkcommand {$check_command:
+ import => ['plugin-check-command'],
+ command => $check_command_path,
+ target => $swh_plugin_configfile,
+ require => File[$check_command_path]
+ }
+
+}
diff --git a/site-modules/profile/manifests/icinga2/objects/static_checks.pp b/site-modules/profile/manifests/icinga2/objects/static_checks.pp
--- a/site-modules/profile/manifests/icinga2/objects/static_checks.pp
+++ b/site-modules/profile/manifests/icinga2/objects/static_checks.pp
@@ -74,6 +74,12 @@
target => $checks_file,
}
+ ::icinga2::object::checkcommand {'check_logstash_errors.sh':
+ import => ['plugin-check-command'],
+ command => '/usr/lib/nagios/plugins/icinga_check_logstash.sh',
+ target => $checks_file,
+ }
+
::icinga2::object::host {'DNS resolvers':
check_command => 'dummy',
address => '127.0.0.1',
diff --git a/site-modules/profile/manifests/logstash.pp b/site-modules/profile/manifests/logstash.pp
--- a/site-modules/profile/manifests/logstash.pp
+++ b/site-modules/profile/manifests/logstash.pp
@@ -50,4 +50,6 @@
],
}
+ include profile::icinga2::objects::logstash_checks
+
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Jul 3, 5:29 PM (3 w, 4 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3225049
Attached To
D5709: Add a monitoring alert when logstash is failing to send logs to ES
Event Timeline
Log In to Comment