Skip to content

Instantly share code, notes, and snippets.

@2510
Created January 11, 2016 07:42
Show Gist options
  • Save 2510/ef6f0717cf65903868b8 to your computer and use it in GitHub Desktop.
Save 2510/ef6f0717cf65903868b8 to your computer and use it in GitHub Desktop.
Test Script for ucarp+nfs
#!/usr/local/bin/python2.7
import os
import subprocess
import sys
import time
path = '/glusterfs/test.dat'
addresses = [ '10.0.0.1', '10.0.0.2', '10.0.0.127' ]
null = open('/dev/null', 'w')
pinger = {}
for address in addresses:
pinger[address] = subprocess.Popen(['ping', address], stdout=null, stderr=null)
index = 0
try:
f = open(path, 'w')
while True:
subprocess.call(['clear'])
subprocess.call(['date'])
for address in addresses:
subprocess.call(['arp', address])
f.write("data %d\n" % index)
index = index + 1
f.flush()
os.fsync(f)
time.sleep(0.5)
finally:
for process in pinger.values():
process.terminate()
f.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment