Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 25 additions & 19 deletions thold_functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -3390,7 +3390,7 @@ function thold_check_threshold(&$thold_data) {
'host_id' => $thold_data['host_id'],
'local_graph_id' => $thold_data['local_graph_id'],
'threshold_id' => $thold_data['id'],
'threshold_value' => ($breach_up ? $thold_data['time_hi'] : $thold_data['time_low']),
'threshold_value' => ($warning_breach_up ? $thold_data['time_warning_hi'] : $thold_data['time_warning_low']),
'current' => $thold_data['lastread'],
'status' => ($ra ? ST_NOTIFYRAW : ST_NOTIFYWA),
'description' => ($maint_dev ? $subject . '. ' . __('Only logging, maint device', 'thold') : $subject),
Expand All @@ -3406,7 +3406,7 @@ function thold_check_threshold(&$thold_data) {
'host_id' => $thold_data['host_id'],
'local_graph_id' => $thold_data['local_graph_id'],
'threshold_id' => $thold_data['id'],
'threshold_value' => ($warning_breach_up ? $thold_data['time_hi'] : $thold_data['time_low']),
'threshold_value' => ($warning_breach_up ? $thold_data['time_warning_hi'] : $thold_data['time_warning_low']),
'current' => $thold_data['lastread'],
'status' => ST_NOTIFYRAW,
'description' => ($maint_dev ? $subject . '. ' . __('Only logging, maint device', 'thold') : $subject),
Expand All @@ -3420,7 +3420,7 @@ function thold_check_threshold(&$thold_data) {
'host_id' => $thold_data['host_id'],
'local_graph_id' => $thold_data['local_graph_id'],
'threshold_id' => $thold_data['id'],
'threshold_value' => ($warning_breach_up ? $thold_data['time_hi'] : $thold_data['time_low']),
'threshold_value' => ($warning_breach_up ? $thold_data['time_warning_hi'] : $thold_data['time_warning_low']),
'current' => $thold_data['lastread'],
'status' => ST_TRIGGERW,
'description' => ($maint_dev ? $subject . '. ' . __('Only logging, maint device', 'thold') : $subject),
Expand Down Expand Up @@ -4317,22 +4317,28 @@ function get_thold_restoral_text($data_source_name, $thold, $h, $currentval, $lo
function thold_modify_values_by_cdef(&$thold_data) {
$cdef = false;

if ($thold_data['data_type'] != 1 || empty($thold_data['cdef'])) {
// Check is the graph item has a cdef
$cdef = db_fetch_cell_prepared('SELECT MAX(cdef_id)
FROM graph_templates_item AS gti
INNER JOIN data_template_rrd AS dtr
ON gti.task_item_id = dtr.id
WHERE local_graph_id = ?
AND dtr.id = ?
AND gti.graph_type_id IN (4, 5, 6, 7, 8, 20)
AND dtr.data_source_name = ?',
[$thold_data['local_graph_id'], $thold_data['data_template_rrd_id'], $thold_data['data_source_name']]);
}

if ($cdef !== false && $cdef > 0 && $thold_data['data_type'] == 1) {
$thold_data['lastread'] = thold_build_cdef($cdef, $thold_data['lastread'], $thold_data['local_data_id'], $thold_data['data_template_rrd_id']);

if ($thold_data['data_type'] == 1) {
if (!empty($thold_data['cdef'])) {
// Use the CDEF explicitly configured on the threshold
$cdef = $thold_data['cdef'];
} else {
// Auto-detect a CDEF from the graph item for this data source
$cdef = db_fetch_cell_prepared('SELECT MAX(cdef_id)
FROM graph_templates_item AS gti
INNER JOIN data_template_rrd AS dtr
ON gti.task_item_id = dtr.id
WHERE local_graph_id = ?
AND dtr.id = ?
AND gti.graph_type_id IN (4, 5, 6, 7, 8, 20)
AND dtr.data_source_name = ?',
[$thold_data['local_graph_id'], $thold_data['data_template_rrd_id'], $thold_data['data_source_name']]);
}
}

if ($cdef !== false && $cdef > 0) {
// Note: lastread is already CDEF-transformed by thold_poller_output before
// being stored, so we must not apply the CDEF to it again here. We only
// transform the threshold values so the comparison is consistent.
if ($thold_data['thold_type'] == 0) {
$thold_data['thold_hi'] = thold_build_cdef($cdef, $thold_data['thold_hi'], $thold_data['local_data_id'], $thold_data['data_template_rrd_id']);
$thold_data['thold_low'] = thold_build_cdef($cdef, $thold_data['thold_low'], $thold_data['local_data_id'], $thold_data['data_template_rrd_id']);
Expand Down
Loading