Dzahn has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/366310 )
Change subject: librenms: active_server param, don't pull data from multi
servers
......................................................................
librenms: active_server param, don't pull data from multi servers
Add an active_server parameter, just like it was done for rancid.
The same Hiera setting can switch between netmon servers for both
services.
Only run crons on the active server, remove them on inactive server,
as requested by Arzhel we should not pull data for librenms
from multiple netmon servers at the same time.
Bug: T159756
Change-Id: I7f77a255b8feeba4e8b638ffffad565efa651631
---
M modules/librenms/manifests/init.pp
M modules/role/manifests/librenms.pp
2 files changed, 30 insertions(+), 14 deletions(-)
Approvals:
jenkins-bot: Verified
Dzahn: Looks good to me, approved
diff --git a/modules/librenms/manifests/init.pp
b/modules/librenms/manifests/init.pp
index 58859fa..1068252 100644
--- a/modules/librenms/manifests/init.pp
+++ b/modules/librenms/manifests/init.pp
@@ -12,9 +12,13 @@
#
# [*rrd_dir*]
# Location where RRD files are going to be placed. Defaults to "rrd" under
-# *install_dir*.
+#
+# [*active_server*]
+# FQDN of the server that should have active cronjobs pulling data.
+# To avoid pulling multiple times when role is applied on muliple nodes for
a standby-scenario.
#
class librenms(
+ $active_server,
$config={},
$install_dir='/srv/librenms',
$rrd_dir="${install_dir}/rrd",
@@ -110,8 +114,14 @@
include ::imagemagick::install
+ if $active_server == $::fqdn {
+ $cron_ensure = 'present'
+ } else {
+ $cron_ensure = 'absent'
+ }
+
cron { 'librenms-discovery-all':
- ensure => present,
+ ensure => $cron_ensure,
user => 'librenms',
command => "${install_dir}/discovery.php -h all >/dev/null 2>&1",
hour => '*/6',
@@ -119,49 +129,49 @@
require => User['librenms'],
}
cron { 'librenms-discovery-new':
- ensure => present,
+ ensure => $cron_ensure,
user => 'librenms',
command => "${install_dir}/discovery.php -h new >/dev/null 2>&1",
minute => '*/5',
require => User['librenms'],
}
cron { 'librenms-poller-all':
- ensure => present,
+ ensure => $cron_ensure,
user => 'librenms',
command => "python ${install_dir}/poller-wrapper.py 16 >/dev/null
2>&1",
minute => '*/5',
require => User['librenms'],
}
cron { 'librenms-check-services':
- ensure => present,
+ ensure => $cron_ensure,
user => 'librenms',
command => "${install_dir}/check-services.php >/dev/null 2>&1",
minute => '*/5',
require => User['librenms'],
}
cron { 'librenms-alerts':
- ensure => present,
+ ensure => $cron_ensure,
user => 'librenms',
command => "${install_dir}/alerts.php >/dev/null 2>&1",
minute => '*',
require => User['librenms'],
}
cron { 'librenms-poll-billing':
- ensure => present,
+ ensure => $cron_ensure,
user => 'librenms',
command => "${install_dir}/poll-billing.php >/dev/null 2>&1",
minute => '*/5',
require => User['librenms'],
}
cron { 'librenms-billing-calculate':
- ensure => present,
+ ensure => $cron_ensure,
user => 'librenms',
command => "${install_dir}/billing-calculate.php >/dev/null 2>&1",
minute => '01',
require => User['librenms'],
}
cron { 'librenms-daily':
- ensure => present,
+ ensure => $cron_ensure,
user => 'librenms',
command => "${install_dir}/daily.sh >/dev/null 2>&1",
hour => '0',
@@ -183,7 +193,7 @@
source => 'puppet:///modules/librenms/purge.py',
}
cron { 'purge-syslog-eventlog':
- ensure => present,
+ ensure => $cron_ensure,
user => 'librenms',
command => "python ${install_dir}/purge.py --syslog --eventlog
--perftimes '1 month' >/dev/null 2>&1",
hour => '0',
diff --git a/modules/role/manifests/librenms.pp
b/modules/role/manifests/librenms.pp
index d394d20..065fa0c 100644
--- a/modules/role/manifests/librenms.pp
+++ b/modules/role/manifests/librenms.pp
@@ -9,6 +9,11 @@
$sitename = 'librenms.wikimedia.org'
$install_dir = '/srv/deployment/librenms/librenms'
+ # Which of the netmon servers should actually poll data and
+ # have active cron jobs. We don't want both to do it at the same time.
+ # Switch it in hieradata/common.yaml, the default is just a fallback.
+ $active_server = hiera('netmon_server', 'netmon1002.wikimedia.org')
+
# NOTE: scap will manage the deploy user
scap::target { 'librenms/librenms':
deploy_user => 'deploy-librenms',
@@ -111,10 +116,11 @@
}
class { '::librenms':
- install_dir => $install_dir,
- rrd_dir => '/srv/librenms/rrd',
- config => $config,
- require => Package['librenms/librenms'],
+ install_dir => $install_dir,
+ rrd_dir => '/srv/librenms/rrd',
+ config => $config,
+ require => Package['librenms/librenms'],
+ active_server => $active_server,
}
class { '::librenms::syslog':
require => Class['::librenms']
--
To view, visit https://gerrit.wikimedia.org/r/366310
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I7f77a255b8feeba4e8b638ffffad565efa651631
Gerrit-PatchSet: 3
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Dzahn <[email protected]>
Gerrit-Reviewer: Alexandros Kosiaris <[email protected]>
Gerrit-Reviewer: Ayounsi <[email protected]>
Gerrit-Reviewer: Dzahn <[email protected]>
Gerrit-Reviewer: Giuseppe Lavagetto <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits