diff --git a/README.md b/README.md index 8a1f388..c26164f 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,19 @@ FreeBSD systems via `pkg`: FreeNAS 9.10 includes `sg_ses` as part of the standard image. +Solaris/OmniOS/OpenIndiana/SmartOS based systems: + +Native Solaris should have sg3_utils installed. If executing `sg_ses` doesn't exist, it's necessary to install it from source. Installing napp-it, for the ZFS GUI, also installed all the requisite development tools. + +On OmniOS CE, the steps involved were: + + * Download the package[the `sg3_utils` package](http://sg.danny.cz/sg/ sg3_utils.html). Move to somewhere like `/root` and extract. + * Change into the directory, configure with `./configure --prefix=/root/sg3_utils`. + * `make` && `make install` + * Run the fan script and set the path in the environment `sg_sess_path=/root/sg3_utils/bin/sg_ses python fancontrol.py 2` + + + ## Usage Finds the ThinkServer Enclosure automatically. Works when the devices are either `/dev/sg*`, `/dev/ses*`, or `/dev/bsg/*` diff --git a/fancontrol.py b/fancontrol.py index d448cc4..317368a 100755 --- a/fancontrol.py +++ b/fancontrol.py @@ -6,11 +6,17 @@ import sys import time import glob import stat +import os.path from io import BytesIO from subprocess import check_output, Popen, PIPE, STDOUT, CalledProcessError -devices_to_check = ['/dev/sg*', '/dev/ses*', '/dev/bsg/*'] +devices_to_check = ['/dev/sg*', '/dev/ses*', '/dev/bsg/*', '/dev/es/ses*'] + +sg_ses_binary = "sg_ses" + +if "sg_ses_path" in os.environ: + sg_ses_binary = os.getenv("sg_ses_path") def usage(): @@ -33,7 +39,7 @@ def get_requested_fan_speed(): def print_speeds(device): for i in range(0, 6): print('Fan {} speed: {}'.format(i, check_output( - ['sg_ses', '--maxlen=32768', '--index=coo,{}'.format(i), '--get=1:2:11', device]) + [sg_ses_binary, '--maxlen=32768', '--index=coo,{}'.format(i), '--get=1:2:11', device]) .decode('utf-8').split('\n')[0])) @@ -42,7 +48,10 @@ def find_sa120_devices(): seen_devices = set() for device_glob in devices_to_check: for device in glob.glob(device_glob): - stats = os.stat(device) + try: + stats = os.stat(device) + except OSError: + continue if not stat.S_ISCHR(stats.st_mode): print('Enclosure not found on ' + device) continue @@ -52,7 +61,7 @@ def find_sa120_devices(): continue seen_devices.add(device_id) try: - output = check_output(['sg_ses', '--maxlen=32768', device], stderr=STDOUT) + output = check_output([sg_ses_binary, '--maxlen=32768', device], stderr=STDOUT) if b'ThinkServerSA120' in output: print('Enclosure found on ' + device) devices.append(device)