#!python
# -*- coding: utf-8 -*-
#
# Copyright 2015 wywy GmbH
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Author: Christian Becker <christian.becker@wywy.com>
import sys

from check_puppet_agent import MonitoringStatus, main

status = MonitoringStatus()

# this try statement contains all of the code below on purpose
# this is to ensure we have a critical state in the monitoring, in case anything goes wrong in here
# noinspection PyBroadException
try:
    main(status)
# catch all exceptions to create an error in the monitoring in case anything goes wrong in this script
except:
    e = sys.exc_info()
    status.add_status(MonitoringStatus.CRITICAL, str(e[1]))
finally:
    status.exit()
