def configuration_check(config):
    """Perform a sanity check on configuration.

    First it performs a sanity check against settings for daemon
    and then against settings for each service check.

    Arguments:
        config (obj): A configparser object which holds our configuration.

    Returns:
        None if all checks are successfully passed otherwise raises a
        ValueError exception.

    """
    log_level = config.get('daemon', 'loglevel')
    num_level = getattr(logging, log_level.upper(), None)
    pidfile = config.get('daemon', 'pidfile')

    # Catch the case where the directory, under which we store the pid file, is
    # missing.
    if not os.path.isdir(os.path.dirname(pidfile)):
        raise ValueError("{d} doesn't exit".format(d=os.path.dirname(pidfile)))

    if not isinstance(num_level, int):
        raise ValueError('Invalid log level: {}'.format(log_level))

    for _file in 'log_file', 'stderr_file':
        if config.has_option('daemon', _file):
            try:
                touch(config.get('daemon', _file))
            except OSError as exc:
                raise ValueError(exc)

    for option, getter in DAEMON_OPTIONS_TYPE.items():
        try:
            getattr(config, getter)('daemon', option)
        except configparser.NoOptionError as error:
            if option not in DAEMON_OPTIONAL_OPTIONS:
                raise ValueError(error)
        except configparser.Error as error:
            raise ValueError(error)
        except ValueError as exc:
            msg = ("invalid data for '{opt}' option in daemon section: {err}"
                   .format(opt=option, err=exc))
            raise ValueError(msg)

    service_configuration_check(config)
Perform a sanity check on configuration.

    First it performs a sanity check against settings for daemon
    and then against settings for each service check.

    Arguments:
        config (obj): A configparser object which holds our configuration.

    Returns:
        None if all checks are successfully passed otherwise raises a
        ValueError exception.