class profiles::postgresql { | |
# Устанавливаем Postgres | |
class {'::postgresql::globals': | |
version => '9.6', | |
} -> | |
class {'::postgresql::server': } | |
# ... Конфигурация Postgres-сервера | |
# В реальной жизни конфигурация не захардкожена | |
$mon_user = 'sensu' | |
$mon_password = 'sensu' | |
# Добавляем юзера для мониторинга | |
::postgresql::server::db {'sensu', | |
user => $mon_user, | |
password => $mon_password, | |
} | |
# Добавляем subscription в sensu | |
# Через subscription назначаются проверки | |
@sensu::subscription{'postgresql-server': | |
custom => { | |
postgres => { | |
user => $mon_user, | |
pass => $mon_password, | |
} | |
} | |
} | |
# Добавляем мониторинг доступности Postgres | |
@@sensu::check{ "check_postgres@${::fqdn}": | |
command => "check-postgres -H ${::fqdn} -d sensu -u ${mon_user} -p ${mon_password}", | |
# Проверка будет выполняться с серверов, выделенных под проверки доступности | |
subscription => 'roundrobin:healthchecks', | |
# У результатов будет подменяться source (в UI они будут привязаны к хосту с БД) | |
source => $::fqdn, | |
# Конфигурация хранится на master-серверах sensu | |
standalone => false, | |
} | |
# Добавляем мониторинг метрик Postgres | |
sensu::check{ "postgres_metrics": | |
command => "check-postgres-metrics -H localhost -d sensu -u :::postgres.user::: -p :::postgres.pass:::", | |
subscription => 'postgresql-server', | |
# Конфигурация будет храниться на сервере БД | |
# Это самый простой способ, можно делать по-другому | |
standalone => true, | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment