Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- #
- # FreeNAS drive identification
- # based on a shell script by @Bidule0hm
- import subprocess
- print '''\
- +========+============================================+====================+
- | Device | GPTID | Serial Number |
- +========+============================================+====================+'''
- drives = subprocess.check_output(['sysctl', '-n', 'kern.disks']).split()
- drives.sort()
- for drive in drives:
- try:
- gptid = subprocess.check_output(['glabel', 'status', '-s', drive+'p2']).split()[0]
- # not partitioned?
- except subprocess.CalledProcessError:
- gptid = 'N/A'
- try:
- serial = filter(
- lambda line: 'umber' in line,
- subprocess.check_output(['smartctl', '-i', '/dev/'+drive]).splitlines()
- )[0]
- serial = serial.split()[2]
- # SMART not supported?
- except subprocess.CalledProcessError:
- serial = 'N/A'
- print '|{0:^8}|{1:^44}|{2:^20}|'.format(drive, gptid, serial)
- print '+--------+--------------------------------------------+--------------------+'
Add Comment
Please, Sign In to add comment