def determine_state(value, warning='', critical=''):
    """Based on `value`, calculate if it is greater or equal either `critical`
    or `warning` and return the corresponding state as an integer of either
    2 (CRITICAL), 1 (WARNING) or 0 (OK)."""
    if isinstance(critical, int) and value >= critical:
        return 2
    if isinstance(warning, int) and value >= warning:
        return 1
    return 0
