Class that provides API/helpers for generating the state of a report based on a number of events. More...
Public Member Functions | |
get_data () | |
For hysterical reasons, we expect every single report type to return the report data in a brand new way. | |
add_event ($row) | |
Given an event (a database row), add it to the current report. | |
__construct (Report_options $options, $timeperiod) | |
Create a new state calculator. | |
initialize ($initial_state, $initial_depth, $is_running) | |
Prepare a state calculator for action Takes a number of initialization arguments, simply because they can be more efficiently retrieved in bulk somewhere else. | |
st_update ($end_time) | |
Update the raw uptime array. | |
convert_state_table ($state, $conv) | |
Calculate the time spent in different states as total and percentage. | |
finalize () | |
Finalize the report, calculating real uptime from our internal meta-format. | |
Protected Attributes | |
$st_text = array() | |
Mapping between state integers and state text. | |
$st_source = false | |
The source object. | |
$host_name = false | |
The source object's host name, if it's just one. | |
$service_description = false | |
The source object's service description, if it's just one. | |
$state_tpl_host | |
The state template for hosts. | |
$state_tpl_svc | |
The state template for services. | |
$st_is_service = false | |
Whether this is a service. | |
$st_running = false | |
Is nagios running? | |
$st_inactive = 0 | |
Time we have no information about. | |
$st_dt_depth = 0 | |
The downtime depth. | |
$st_obj_state = false | |
The calculated state of the object, taking such things as scheduled downtime counted as uptime into consideration. | |
$st_raw = array() | |
Mapping between the raw states and the time spent there. | |
$prev_row | |
The last db row, so we can get duration. | |
$options | |
A Report_options object for this report. |
Class that provides API/helpers for generating the state of a report based on a number of events.
StateCalculator::__construct | ( | Report_options $ | options, | |
$ | timeperiod | |||
) |
Create a new state calculator.
$options | A report_options object that describes the report | |
$timeperiod | A (resolved) timeperiod to use throughout calculations |
StateCalculator::convert_state_table | ( | $ | state, | |
$ | conv | |||
) |
Calculate the time spent in different states as total and percentage.
$state | State times. Has the format: array("X:Y:Z" => seconds, ...). Where X, Y and Z are numeric states and rhs argument is the number of seconds in that state | |
$conv | State translation table. E.g. for hostgroups: array(0 => 'UP', '1' => 'DOWN', '2' => 'UNREACHABLE', '-1' => 'UNDETERMINED') |
StateCalculator::get_data | ( | ) | [abstract] |
For hysterical reasons, we expect every single report type to return the report data in a brand new way.
Jay.
Reimplemented in SingleStateCalculator, and WorstStateCalculator.
StateCalculator::initialize | ( | $ | initial_state, | |
$ | initial_depth, | |||
$ | is_running | |||
) |
Prepare a state calculator for action Takes a number of initialization arguments, simply because they can be more efficiently retrieved in bulk somewhere else.
$initial_state | The state for the object when the report starts | |
$initial_depth | The downtime depth when the report starts - in practice a boolean | |
$is_running | Is nagios itself running when the report starts? |
Reimplemented in SingleStateCalculator, and WorstStateCalculator.
StateCalculator::st_update | ( | $ | end_time | ) |
Update the raw uptime array.
$end_time | When the event ends - start time is taken from prev_row |
StateCalculator::$host_name = false [protected] |
The source object's host name, if it's just one.
Set for services.
StateCalculator::$service_description = false [protected] |
The source object's service description, if it's just one.
Only description for services
StateCalculator::$st_source = false [protected] |
The source object.
Can be object array, can be host_name, can be host_name;service_description, can drive you mad.
StateCalculator::$state_tpl_host [protected] |
array( 'HOST_NAME' => '', 'TIME_UP_SCHEDULED' => 0, 'TIME_UP_UNSCHEDULED' => 0, 'TIME_DOWN_SCHEDULED' => 0, 'TIME_DOWN_UNSCHEDULED' => 0, 'TIME_UNREACHABLE_SCHEDULED' => 0, 'TIME_UNREACHABLE_UNSCHEDULED' => 0, 'TIME_UNDETERMINED_NOT_RUNNING' => 0, 'TIME_UNDETERMINED_NO_DATA' => 0, )
The state template for hosts.
StateCalculator::$state_tpl_svc [protected] |
array( 'HOST_NAME' => '', 'SERVICE_DESCRIPTION' => '', 'TIME_OK_SCHEDULED' => 0, 'TIME_OK_UNSCHEDULED' => 0, 'TIME_WARNING_SCHEDULED' => 0, 'TIME_WARNING_UNSCHEDULED' => 0, 'TIME_UNKNOWN_SCHEDULED' => 0, 'TIME_UNKNOWN_UNSCHEDULED' => 0, 'TIME_CRITICAL_SCHEDULED' => 0, 'TIME_CRITICAL_UNSCHEDULED' => 0, 'TIME_UNDETERMINED_NOT_RUNNING' => 0, 'TIME_UNDETERMINED_NO_DATA' => 0, )
The state template for services.