Madhuvishy has submitted this change and it was merged.

Change subject: drbd monitoring: Improve status and error messages
......................................................................


drbd monitoring: Improve status and error messages

Change-Id: I5832dba418e6a0f291dd0de129a8e16b45a7a2ab
---
M modules/labstore/files/monitor/check_drbd_role
M modules/labstore/files/monitor/check_drbd_status
2 files changed, 15 insertions(+), 2 deletions(-)

Approvals:
  Madhuvishy: Verified; Looks good to me, approved



diff --git a/modules/labstore/files/monitor/check_drbd_role 
b/modules/labstore/files/monitor/check_drbd_role
index abea821..e8ec4c8 100644
--- a/modules/labstore/files/monitor/check_drbd_role
+++ b/modules/labstore/files/monitor/check_drbd_role
@@ -1,5 +1,6 @@
 #!/usr/bin/python3
 import argparse
+import os
 import subprocess
 import sys
 
@@ -11,7 +12,7 @@
     :returns: boolean
     """
     drbd_res_roles = str(
-        subprocess.check_output(['drbdadm', 'role', 'all']), 'utf-8')\
+        subprocess.check_output(['/sbin/drbdadm', 'role', 'all']), 'utf-8')\
         .rstrip('\n').split('\n')
     if expected_role == 'primary':
         role_ok = all([role == 'Primary/Secondary' for role in drbd_res_roles])
@@ -26,6 +27,10 @@
 
 
 def main():
+    if not os.geteuid() == 0:
+        print('Script not run as root')
+        sys.exit(1)
+
     parser = argparse.ArgumentParser('Check DRBD node role')
     parser.add_argument('node', help='Hostname of node being checked')
     parser.add_argument('role', help='Expected drbd role, primary|secondary')
@@ -34,5 +39,7 @@
     if not check_role(args.node, args.role):
         sys.exit(1)
 
+    print('DRBD role OK')
+
 if __name__ == '__main__':
     main()
diff --git a/modules/labstore/files/monitor/check_drbd_status 
b/modules/labstore/files/monitor/check_drbd_status
index 3d7edb0..4286ea2 100644
--- a/modules/labstore/files/monitor/check_drbd_status
+++ b/modules/labstore/files/monitor/check_drbd_status
@@ -1,5 +1,6 @@
 #!/usr/bin/python3
 import argparse
+import os
 import re
 import subprocess
 import sys
@@ -22,7 +23,7 @@
 
     # Read contents of drbd-overview and split by new lines
     drbd_overview_raw = str(subprocess.check_output(
-        ['drbd-overview']), 'utf-8').rstrip('\n').split('\n')
+        ['/usr/sbin/drbd-overview']), 'utf-8').rstrip('\n').split('\n')
 
     # Split each line into a list - making a nested list, remove empty elements
     # and strip whitespaces in the rest
@@ -67,6 +68,10 @@
 
 
 def main():
+    if not os.geteuid() == 0:
+        print('Script not run as root')
+        sys.exit(1)
+
     parser = argparse.ArgumentParser('Check DRBD Status')
     parser.add_argument('resource',
                         help='Name of resource or \'all\'')
@@ -82,6 +87,7 @@
             args.resource, resource_status_map[args.resource]):
         sys.exit(1)
 
+    print('DRBD Status OK')
 
 if __name__ == '__main__':
     main()

-- 
To view, visit https://gerrit.wikimedia.org/r/315874
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I5832dba418e6a0f291dd0de129a8e16b45a7a2ab
Gerrit-PatchSet: 2
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Madhuvishy <mviswanat...@wikimedia.org>
Gerrit-Reviewer: Madhuvishy <mviswanat...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to