#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright (C) 2019 tribe29 GmbH - License: GNU General Public License v2
# This file is part of Checkmk (https://checkmk.com). It is subject to the terms and
# conditions defined in the file COPYING, which is part of this source code package.


def inventory_pfsense_status(info):
    if info:
        return [(None, None)]


def check_pfsense_status(_no_item, params, info):
    statusvar = info[0][0]
    if statusvar == "1":
        return 0, "Running"
    elif statusvar == "2":
        return 2, "Not running"
    else:
        raise Exception("Unknown status value %s" % statusvar)


check_info["pfsense_status"] = {
    "inventory_function": inventory_pfsense_status,
    "check_function": check_pfsense_status,
    "service_description": "pfSense Status",
    "snmp_info": (
        ".1.3.6.1.4.1.12325.1.200.1",
        [
            "1.1",  # pfStatusRunning
            #  "1.2", # pfStatusRuntime
            #  "1.3", # pfStatusDebug
            #  "1.4", # pfStatusHostId
        ],
    ),
    "snmp_scan_function": lambda oid: "pfsense" in oid(".1.3.6.1.2.1.1.1.0").lower(),
}
