def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('dev', nargs='*', help='devices to check (default: autodetect)')
    parser.add_argument('-H', '--hostname', type=str, help='override hostname provided by collectd', default=os.environ.get('COLLECTD_HOSTNAME'))
    parser.add_argument('-i', '--interval', type=int, help='override interval provided by collectd', default=int(float(os.environ.get('COLLECTD_INTERVAL', 300))))
    parser.add_argument('-c', '--dont-check-devs', action='store_true', default=False, help='do not check devices existence at startup')
    args = parser.parse_args()
    hostname = (args.hostname or subprocess.check_output(['hostname', '-f']).strip())
    if (len(hostname) == 0):
        parser.error('unable to detect hostname')
    interval = max(args.interval, 5)
    if (len(args.dev) == 0):
        devices = expand_devices(['autodetect'])
    else:
        devices = expand_devices(args.dev)
    if (not args.dont_check_devs):
        for dev in devices:
            if (not dev_exists(dev)):
                parser.error('device "/dev/{0}" does not exist'.format(dev))
    try:
        smartmon_loop(devices, hostname, interval)
    except KeyboardInterrupt:
        pass
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('dev', nargs='*', help='devices to check (default: autodetect)')
    parser.add_argument('-H', '--hostname', type=str, help='override hostname provided by collectd', default=os.environ.get('COLLECTD_HOSTNAME'))
    parser.add_argument('-i', '--interval', type=int, help='override interval provided by collectd', default=int(float(os.environ.get('COLLECTD_INTERVAL', 300))))
    parser.add_argument('-c', '--dont-check-devs', action='store_true', default=False, help='do not check devices existence at startup')
    args = parser.parse_args()
    hostname = (args.hostname or subprocess.check_output(['hostname', '-f']).strip())
    if (len(hostname) == 0):
        parser.error('unable to detect hostname')
    interval = max(args.interval, 5)
    if (len(args.dev) == 0):
        devices = expand_devices(['autodetect'])
    else:
        devices = expand_devices(args.dev)
    if (not args.dont_check_devs):
        for dev in devices:
            if (not dev_exists(dev)):
                parser.error('device "/dev/{0}" does not exist'.format(dev))
    try:
        smartmon_loop(devices, hostname, interval)
    except KeyboardInterrupt:
        pass