Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
HPCasCode
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
hpc-team
HPCasCode
Commits
f6039b69
Commit
f6039b69
authored
3 years ago
by
Simon Michnowicz
Browse files
Options
Downloads
Patches
Plain Diff
First checkin of python testing script
parent
d753b2c8
No related branches found
No related tags found
1 merge request
!449
Glustermonitor
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
roles/gluster-monitor/templates/detect-gluster-problems.py.j2
+87
-0
87 additions, 0 deletions
...s/gluster-monitor/templates/detect-gluster-problems.py.j2
with
87 additions
and
0 deletions
roles/gluster-monitor/templates/detect-gluster-problems.py.j2
0 → 100644
+
87
−
0
View file @
f6039b69
# detect-gluster-problems.py
# Authors simon michnowicz 13 April 2021
COMMAND="sudo gluster volume heal gv info"
#COMMAND="sudo gluster volume heal gv info split-brain"
#also gluster volume heal gv info split-brain
#myOutput=`$COMMAND`
#myOutput=" a split brain that heals"
#echo "Output is $myOutput"
#
#
#sudo gluster volume heal gv info split-brain
#Brick 172.16.227.169:/gbrick/brick
#Status: Connected
#Number of entries in split-brain:
import os
import sys
import subprocess
def error(e):
'''
we have an error. Send an email
e=error string
'''
hostname = os.uname()[1]
#print("Error is:\n{}".format(e))
HEADER="Error Message from {}".format(hostname)
MAILTO="{{ EMAIL_DEST }}"
command="echo -e \"{}\" | mail -s \"{}\" \"{}\" ".format(e,HEADER,MAILTO)
#print("Command is:\n{}".format(command))
os.system(command)
def Test1():
'''
This tests looks for the word "split brain" in a general query
'''
COMMAND="sudo gluster volume heal gv info"
try:
result = subprocess.check_output(COMMAND.split()).decode('UTF-8')
#print("Test1 Output is {}".format(result))
outList=result.splitlines()
for line in outList:
#print("Test1 line is {}".format(line))
if 'split' in line:
error(COMMAND+"\n"+outlist)
except subprocess.CalledProcessError as error:
error("Test1: \nPlease contact mcc-help@monash.edu \n error code", error.returncode, error.output)
sys.exit(1)
def Test2():
'''
This test checks for number of split brain entries
sudo gluster volume heal gv info split-brain
Brick 172.16.227.169:/gbrick/brick
Status: Connected
Number of entries in split-brain: 0
'''
COMMAND="sudo gluster volume heal gv info split-brain"
try:
result = subprocess.check_output(COMMAND.split()).decode('UTF-8')
#print("Test2 Output is {}".format(result))
outList=result.splitlines()
for line in outList:
#print("Line is {}".format(line))
if 'Number of entries in split-brain' in line:
split=line.split(':')
if len(split)!=2:
error("Logic error in Test2: split is {}".format(split))
sys.exit(1)
NoOfSplitBrains=int(split[1])
#print("Number of Split Brains is {}".format(NoOfSplitBrains))
if (NoOfSplitBrains!=0):
error("Number of Split Brains is {}".format(NoOfSplitBrains))
except subprocess.CalledProcessError as error:
error("Test1: \nPlease contact mcc-help@monash.edu \n error code", error.returncode, error.output)
sys.exit(1)
def main():
#error("Simon test")
#sys.exit(0)
Test1()
Test2()
if __name__ == "__main__":
main()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment