gogagum

hdfs1

Jan 8th, 2021
924
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.42 KB | None | 0 0
  1. import sys
  2. import subprocess
  3. import re
  4.  
  5. if __name__ == "__main__":
  6.     file_name = sys.argv[1]
  7.     out = subprocess.check_output("hdfs fsck {} -files -blocks -locations".format(file_name).split(), stderr=subprocess.DEVNULL).decode("utf-8")
  8.    
  9.     for line in out.split('\n')[2:]:
  10.         ips = re.findall(r'\[[0-9]+(?:\.[0-9]+){3}', line)
  11.         if len(ips) > 0:
  12.             print(ips[0][1:])
  13.             break    
  14.  
Advertisement
Add Comment
Please, Sign In to add comment