/usr/lib/python2.7/dist-packages/shinken/check.py is in shinken-common 1.4-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (C) 2009-2012:
# Gabes Jean, naparuba@gmail.com
# Gerhard Lausser, Gerhard.Lausser@consol.de
# Gregory Starck, g.starck@gmail.com
# Hartmut Goebel, h.goebel@goebel-consult.de
#
# This file is part of Shinken.
#
# Shinken is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Shinken is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with Shinken. If not, see <http://www.gnu.org/licenses/>.
from shinken.action import Action
from shinken.property import UnusedProp, BoolProp, IntegerProp, FloatProp
from shinken.property import CharProp, StringProp, ListProp
from shinken.autoslots import AutoSlots
class Check(Action):
""" ODO: Add some comment about this class for the doc"""
# AutoSlots create the __slots__ with properties and
# running_properties names
__metaclass__ = AutoSlots
my_type = 'check'
properties = {
'is_a': StringProp(default='check'),
'type': StringProp(default=''),
'_in_timeout': BoolProp(default=False),
'status': StringProp(default=''),
'exit_status': IntegerProp(default=3),
'state': IntegerProp(default=0),
'output': StringProp(default=''),
'long_output': StringProp(default=''),
'ref': IntegerProp(default=-1),
't_to_go': IntegerProp(default=0),
'depend_on': StringProp(default=[]),
'dep_check': StringProp(default=[]),
'check_time': IntegerProp(default=0),
'execution_time': FloatProp(default=0.0),
'u_time': FloatProp(default=0.0),
's_time': FloatProp(default=0.0),
'perf_data': StringProp(default=''),
'check_type': IntegerProp(default=0),
'poller_tag': StringProp(default='None'),
'reactionner_tag': StringProp(default='None'),
'env': StringProp(default={}),
'internal': BoolProp(default=False),
'module_type': StringProp(default='fork'),
'worker': StringProp(default='none'),
'from_trigger': BoolProp(default=False),
}
def __init__(self, status, command, ref, t_to_go, dep_check=None, id=None,
timeout=10, poller_tag='None', reactionner_tag='None',
env={}, module_type='fork', from_trigger=False):
self.is_a = 'check'
self.type = ''
if id is None: # id != None is for copy call only
self.id = Action.id
Action.id += 1
self._in_timeout = False
self.timeout = timeout
self.status = status
self.exit_status = 3
self.command = command
self.output = ''
self.long_output = ''
self.ref = ref
#self.ref_type = ref_type
self.t_to_go = t_to_go
self.depend_on = []
if dep_check is None:
self.depend_on_me = []
else:
self.depend_on_me = [dep_check]
self.check_time = 0
self.execution_time = 0
self.u_time = 0 # user executon time
self.s_time = 0 # system execution time
self.perf_data = ''
self.check_type = 0 # which kind of check result? 0=active 1=passive
self.poller_tag = poller_tag
self.reactionner_tag = reactionner_tag
self.module_type = module_type
self.env = env
# we keep the reference of the poller that will take us
self.worker = 'none'
# If it's a business rule, manage it as a special check
if ref and ref.got_business_rule or command.startswith('_internal'):
self.internal = True
else:
self.internal = False
self.from_trigger = from_trigger
def copy_shell(self):
"""return a copy of the check but just what is important for execution
So we remove the ref and all
"""
# We create a dummy check with nothing in it, just defaults values
return self.copy_shell__(Check('', '', '', '', '', id=self.id))
def get_return_from(self, c):
self.exit_status = c.exit_status
self.output = c.output
self.long_output = c.long_output
self.check_time = c.check_time
self.execution_time = c.execution_time
self.perf_data = c.perf_data
def is_launchable(self, t):
return t > self.t_to_go
def __str__(self):
return "Check %d status:%s command:%s ref:%s" % \
(self.id, self.status, self.command, self.ref)
def get_id(self):
return self.id
def set_type_active(self):
self.check_type = 0
def set_type_passive(self):
self.check_type = 1
|