Madhuvishy has uploaded a new change for review. https://gerrit.wikimedia.org/r/320930
Change subject: labstore: Add cluster ip assignment monitoring to drbd cluster ...................................................................... labstore: Add cluster ip assignment monitoring to drbd cluster Change-Id: I26614670413637508fd941971977b69a31c02c1c --- A modules/labstore/files/monitor/check_drbd_cluster_ip M modules/labstore/manifests/monitoring/drbd.pp M modules/role/manifests/labs/nfs/secondary.pp 3 files changed, 58 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/operations/puppet refs/changes/30/320930/1 diff --git a/modules/labstore/files/monitor/check_drbd_cluster_ip b/modules/labstore/files/monitor/check_drbd_cluster_ip new file mode 100644 index 0000000..47b4f5f --- /dev/null +++ b/modules/labstore/files/monitor/check_drbd_cluster_ip @@ -0,0 +1,43 @@ +#!/usr/bin/python3 +import argparse +import subprocess +import sys + + +def check_cluster_ip(node, role, ip): + """ + If role is primary, check that cluster ip is assigned to the eth0 interface, + else make sure it is not. + :param node: string + :param role: string + :param ip: string + :returns: boolean + """ + # Check if the ip string is present in the list of ipv4 IPs assigned to the + # eth0 interface + ip_assigned = ip in str(subprocess.check_output(['/bin/ip', '-4', 'a', 'list', 'eth0'])) + if (role == 'primary' and ip_assigned) or \ + (role == 'secondary' and not ip_assigned): + print('Cluster IP assignment OK') + return True + + print('{}: Unexpected cluster ip assignment for role {}'.format( + node, role)) + return False + + +def main(): + + parser = argparse.ArgumentParser('Check if cluster ip is assigned \ + to DRBD primary') + parser.add_argument('node', help='Hostname of node being checked') + parser.add_argument('role', help='Expected drbd role, primary|secondary') + parser.add_argument('ip', help='Cluster IP assigned to primary node') + args = parser.parse_args() + + if not check_cluster_ip(args.node, args.role, args.ip): + sys.exit(1) + + +if __name__ == '__main__': + main() diff --git a/modules/labstore/manifests/monitoring/drbd.pp b/modules/labstore/manifests/monitoring/drbd.pp index bdc39bb..9e7c060 100644 --- a/modules/labstore/manifests/monitoring/drbd.pp +++ b/modules/labstore/manifests/monitoring/drbd.pp @@ -3,7 +3,7 @@ # Installs icinga checks to make sure resource status on a drbd node is OK, # and to check that the nodes conform to the expected drbd roles. -class labstore::monitoring::drbd($drbd_role, $resource = 'all') { +class labstore::monitoring::drbd($drbd_role, $cluster_ip, $resource = 'all') { sudo::user { 'nagios_check_drbd': user => 'nagios', @@ -39,4 +39,17 @@ require => File['/usr/local/sbin/check_drbd_role'], } + file { '/usr/local/sbin/check_drbd_cluster_ip': + source => 'puppet:///modules/labstore/monitor/check_drbd_cluster_ip', + mode => '0755', + owner => 'root', + group => 'root', + } + + nrpe::monitor_service { 'check_drbd_cluster_ip': + description => 'Check DRBD Cluster IP assignment', + nrpe_command => "/usr/bin/sudo /usr/local/sbin/check_drbd_cluster_ip ${::hostname} ${drbd_role} ${cluster_ip}", + require => File['/usr/local/sbin/check_drbd_role'], + } + } diff --git a/modules/role/manifests/labs/nfs/secondary.pp b/modules/role/manifests/labs/nfs/secondary.pp index 87bb9e8..79a0c25 100644 --- a/modules/role/manifests/labs/nfs/secondary.pp +++ b/modules/role/manifests/labs/nfs/secondary.pp @@ -81,6 +81,7 @@ class { 'labstore::monitoring::drbd': drbd_role => $drbd_role, + cluster_ip => $cluster_ip, } # state via nfs-manage -- To view, visit https://gerrit.wikimedia.org/r/320930 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I26614670413637508fd941971977b69a31c02c1c Gerrit-PatchSet: 1 Gerrit-Project: operations/puppet Gerrit-Branch: production Gerrit-Owner: Madhuvishy <mviswanat...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits