Skip to content

Commit

Permalink
Add shibd check
Browse files Browse the repository at this point in the history
  • Loading branch information
daaang committed Mar 15, 2024
1 parent d42ee18 commit 2f8dc63
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
2 changes: 2 additions & 0 deletions manifests/profile/prometheus/exporter/webserver/base.pp
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
class nebula::profile::prometheus::exporter::webserver::base (
Hash[String, Array[String]] $nfs_mounts = {},
Hash[String, Array[String]] $solr_instances = {},
Hash[String, Boolean] $check_shibd = {},
String $target,
) {
$target_nfs = pick_default($nfs_mounts[$target], [])
$target_solr = pick_default($solr_instances[$target], [])
$target_shibd = pick_default($check_shibd[$target], false)

file { "/usr/local/lib/prom_web_exporter/metrics":
mode => "0755",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def have_script
it { is_expected.to have_script.with_content(/^#!\/usr\/bin\/env bash$/) }
it { is_expected.to have_script.with_content(/^NFS_MOUNTS=\(\)$/) }
it { is_expected.to have_script.with_content(/^SOLR_INSTANCES=\(\)$/) }
it { is_expected.to have_script.with_content(/^ENABLE_SHIBD_CHECK="false"$/) }

context "with nfs mounts set" do
let(:params) do
Expand All @@ -41,6 +42,14 @@ def have_script

it { is_expected.to have_script.with_content(/^SOLR_INSTANCES=\("http:\/\/solr\/solr\/core"\)$/) }
end

context "with shibd check enabled" do
let(:params) do
super().merge({ check_shibd: { "abcd" => true } })
end

it { is_expected.to have_script.with_content(/^ENABLE_SHIBD_CHECK="true"$/) }
end
end
end
end
Expand Down
16 changes: 16 additions & 0 deletions templates/profile/prometheus/exporter/webserver/metrics.sh.erb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ SOLR_INSTANCES=()
<% else -%>
SOLR_INSTANCES=("<%= @target_solr.join('" "') %>")
<% end -%>
ENABLE_SHIBD_CHECK="<%= @target_shibd %>"

errorout() {
echo "usage: $PROG $USAGE" >&2
Expand Down Expand Up @@ -53,6 +54,7 @@ main() {
print_headers
[ -n "${NFS_MOUNTS[0]}" ] && check_nfs_mounts
[ -n "${SOLR_INSTANCES[0]}" ] && check_solr_instances
$ENABLE_SHIBD_CHECK && check_shibd
}

print_headers() {
Expand Down Expand Up @@ -92,4 +94,18 @@ solr_instance_is_ok() {
wget -q -T 1 -t 5 -O - "$1/admin/ping" > /dev/null 2> /dev/null
}

check_shibd() {
echo "# HELP mlibrary_webserver_shibd_up Check whether shibd is up"
echo "# TYPE mlibrary_webserver_shibd_up gauge"
if shibd_is_ok; then
echo "mlibrary_webserver_shibd_up 1"
else
echo "mlibrary_webserver_shibd_up 0"
fi
}

shibd_is_ok() {
pgrep -x "shibd" > /dev/null 2> /dev/null
}

main "$@"

0 comments on commit 2f8dc63

Please sign in to comment.