-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add monitor.pl metrics exporters to web servers
This implements everything except the http check, which I believe we are only using for fulcrum. Everything that can has a 1-second timeout, so slow services will be considered down.
- Loading branch information
Showing
18 changed files
with
402 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Copyright (c) 2024 The Regents of the University of Michigan. | ||
# All Rights Reserved. Licensed according to the terms of the Revised | ||
# BSD License. See LICENSE.txt for details. | ||
|
||
class nebula::profile::prometheus::exporter::webserver::base ( | ||
Hash[String, Hash[String, String]] $mariadb_connect = {}, | ||
Hash[String, Array[String]] $nfs_mounts = {}, | ||
Hash[String, Array[String]] $solr_instances = {}, | ||
Hash[String, Boolean] $check_shibd = {}, | ||
String $target, | ||
) { | ||
include stdlib | ||
$target_mariadb = pick_default($mariadb_connect[$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", | ||
content => template("nebula/profile/prometheus/exporter/webserver/metrics.sh.erb"), | ||
require => File["/usr/local/lib/prom_web_exporter"], | ||
} | ||
|
||
file { "/usr/local/lib/prom_web_exporter": | ||
ensure => "directory", | ||
} | ||
|
||
if $target_mariadb != {} { | ||
package { "mariadb-client": } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Copyright (c) 2024 The Regents of the University of Michigan. | ||
# All Rights Reserved. Licensed according to the terms of the Revised | ||
# BSD License. See LICENSE.txt for details. | ||
|
||
class nebula::profile::prometheus::exporter::webserver::fulcrum { | ||
class { "nebula::profile::prometheus::exporter::webserver::base": | ||
target => "fulcrum" | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
manifests/profile/prometheus/exporter/webserver/hathitrust.pp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Copyright (c) 2024 The Regents of the University of Michigan. | ||
# All Rights Reserved. Licensed according to the terms of the Revised | ||
# BSD License. See LICENSE.txt for details. | ||
|
||
class nebula::profile::prometheus::exporter::webserver::hathitrust { | ||
class { "nebula::profile::prometheus::exporter::webserver::base": | ||
target => "hathitrust" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Copyright (c) 2024 The Regents of the University of Michigan. | ||
# All Rights Reserved. Licensed according to the terms of the Revised | ||
# BSD License. See LICENSE.txt for details. | ||
|
||
class nebula::profile::prometheus::exporter::webserver::quod { | ||
class { "nebula::profile::prometheus::exporter::webserver::base": | ||
target => "quod" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Copyright (c) 2024 The Regents of the University of Michigan. | ||
# All Rights Reserved. Licensed according to the terms of the Revised | ||
# BSD License. See LICENSE.txt for details. | ||
|
||
class nebula::profile::prometheus::exporter::webserver::vhost ( | ||
Boolean $testing = false | ||
) { | ||
if $testing { | ||
include apache | ||
} | ||
|
||
apache::vhost { "prometheus-webserver-exporter": | ||
port => "9180", | ||
docroot => "/usr/local/lib/prom_web_exporter", | ||
aliases => [{ scriptalias => "/", path => "/usr/local/lib/prom_web_exporter/" }], | ||
rewrites => [{ rewrite_rule => ["^/$ /metrics [last,redirect=permanent]"]}], | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Copyright (c) 2024 The Regents of the University of Michigan. | ||
# All Rights Reserved. Licensed according to the terms of the Revised | ||
# BSD License. See LICENSE.txt for details. | ||
|
||
class nebula::profile::prometheus::exporter::webserver::www_lib { | ||
class { "nebula::profile::prometheus::exporter::webserver::base": | ||
target => "www_lib" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
spec/classes/profile/prometheus/exporter/webserver/base_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# frozen_string_literal: true | ||
|
||
# Copyright (c) 2024 The Regents of the University of Michigan. | ||
# All Rights Reserved. Licensed according to the terms of the Revised | ||
# BSD License. See LICENSE.txt for details. | ||
require 'spec_helper' | ||
|
||
describe 'nebula::profile::prometheus::exporter::webserver::base' do | ||
on_supported_os.each do |os, os_facts| | ||
context "on #{os}" do | ||
let(:facts) { os_facts } | ||
|
||
it { is_expected.not_to compile } | ||
|
||
context "with target set to abcd" do | ||
let(:params) { { target: "abcd" } } | ||
|
||
def have_script | ||
contain_file("/usr/local/lib/prom_web_exporter/metrics") | ||
end | ||
|
||
it { is_expected.to compile } | ||
it { is_expected.not_to contain_package("mariadb-client") } | ||
it { is_expected.to contain_file("/usr/local/lib/prom_web_exporter").with_ensure("directory") } | ||
it { is_expected.to have_script.with_mode("0755") } | ||
it { is_expected.to have_script.with_content(/^#!\/usr\/bin\/env bash$/) } | ||
it { is_expected.to have_script.with_content(/^ENABLE_MARIADB_CHECK="false"$/) } | ||
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 mariadb credentials set" do | ||
let(:params) do | ||
super().merge({ mariadb_connect: { "abcd" => { | ||
"hostname" => "abcd-db-host", | ||
"database" => "abcd-database", | ||
"username" => "abcd-db-monitor", | ||
"password" => "random-password", | ||
}}}) | ||
end | ||
|
||
it { is_expected.to contain_package("mariadb-client") } | ||
it { is_expected.to have_script.with_content(/^ENABLE_MARIADB_CHECK="true"$/) } | ||
end | ||
|
||
context "with nfs mounts set" do | ||
let(:params) do | ||
super().merge({ nfs_mounts: { "abcd" => %w[/abc /def /ghi] } }) | ||
end | ||
|
||
it { is_expected.to have_script.with_content(/^NFS_MOUNTS=\("\/abc" "\/def" "\/ghi"\)$/) } | ||
end | ||
|
||
context "with solr instances set" do | ||
let(:params) do | ||
super().merge({ solr_instances: { "abcd" => ["http://solr/solr/core"] } }) | ||
end | ||
|
||
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 | ||
end |
18 changes: 18 additions & 0 deletions
18
spec/classes/profile/prometheus/exporter/webserver/fulcrum_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# frozen_string_literal: true | ||
|
||
# Copyright (c) 2024 The Regents of the University of Michigan. | ||
# All Rights Reserved. Licensed according to the terms of the Revised | ||
# BSD License. See LICENSE.txt for details. | ||
require 'spec_helper' | ||
|
||
describe 'nebula::profile::prometheus::exporter::webserver::fulcrum' do | ||
on_supported_os.each do |os, os_facts| | ||
context "on #{os}" do | ||
let(:facts) { os_facts } | ||
let(:base) { "nebula::profile::prometheus::exporter::webserver::base" } | ||
|
||
it { is_expected.to compile } | ||
it { is_expected.to contain_class(base).with_target("fulcrum") } | ||
end | ||
end | ||
end |
18 changes: 18 additions & 0 deletions
18
spec/classes/profile/prometheus/exporter/webserver/hathitrust_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# frozen_string_literal: true | ||
|
||
# Copyright (c) 2024 The Regents of the University of Michigan. | ||
# All Rights Reserved. Licensed according to the terms of the Revised | ||
# BSD License. See LICENSE.txt for details. | ||
require 'spec_helper' | ||
|
||
describe 'nebula::profile::prometheus::exporter::webserver::hathitrust' do | ||
on_supported_os.each do |os, os_facts| | ||
context "on #{os}" do | ||
let(:facts) { os_facts } | ||
let(:base) { "nebula::profile::prometheus::exporter::webserver::base" } | ||
|
||
it { is_expected.to compile } | ||
it { is_expected.to contain_class(base).with_target("hathitrust") } | ||
end | ||
end | ||
end |
18 changes: 18 additions & 0 deletions
18
spec/classes/profile/prometheus/exporter/webserver/quod_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# frozen_string_literal: true | ||
|
||
# Copyright (c) 2024 The Regents of the University of Michigan. | ||
# All Rights Reserved. Licensed according to the terms of the Revised | ||
# BSD License. See LICENSE.txt for details. | ||
require 'spec_helper' | ||
|
||
describe 'nebula::profile::prometheus::exporter::webserver::quod' do | ||
on_supported_os.each do |os, os_facts| | ||
context "on #{os}" do | ||
let(:facts) { os_facts } | ||
let(:base) { "nebula::profile::prometheus::exporter::webserver::base" } | ||
|
||
it { is_expected.to compile } | ||
it { is_expected.to contain_class(base).with_target("quod") } | ||
end | ||
end | ||
end |
27 changes: 27 additions & 0 deletions
27
spec/classes/profile/prometheus/exporter/webserver/vhost_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# frozen_string_literal: true | ||
|
||
# Copyright (c) 2024 The Regents of the University of Michigan. | ||
# All Rights Reserved. Licensed according to the terms of the Revised | ||
# BSD License. See LICENSE.txt for details. | ||
require 'spec_helper' | ||
|
||
describe 'nebula::profile::prometheus::exporter::webserver::vhost' do | ||
on_supported_os.each do |os, os_facts| | ||
context "on #{os}" do | ||
let(:facts) { os_facts } | ||
|
||
it { is_expected.not_to compile } | ||
|
||
context "with apache configured for testing" do | ||
let(:params) { { testing: true } } | ||
|
||
def have_vhost | ||
contain_apache__vhost("prometheus-webserver-exporter") | ||
end | ||
|
||
it { is_expected.to compile } | ||
it { is_expected.to have_vhost.with_port(9180) } | ||
end | ||
end | ||
end | ||
end |
18 changes: 18 additions & 0 deletions
18
spec/classes/profile/prometheus/exporter/webserver/www_lib_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# frozen_string_literal: true | ||
|
||
# Copyright (c) 2024 The Regents of the University of Michigan. | ||
# All Rights Reserved. Licensed according to the terms of the Revised | ||
# BSD License. See LICENSE.txt for details. | ||
require 'spec_helper' | ||
|
||
describe 'nebula::profile::prometheus::exporter::webserver::www_lib' do | ||
on_supported_os.each do |os, os_facts| | ||
context "on #{os}" do | ||
let(:facts) { os_facts } | ||
let(:base) { "nebula::profile::prometheus::exporter::webserver::base" } | ||
|
||
it { is_expected.to compile } | ||
it { is_expected.to contain_class(base).with_target("www_lib") } | ||
end | ||
end | ||
end |
Oops, something went wrong.