Created
June 10, 2022 20:07
-
-
Save tryfail/f452bfef102fa89590b1c26db3940f4b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff ./app/views/monitoring.widget.hostavail.view.php-20220610-1352 ./app/views/monitoring.widget.hostavail.view.php | |
| --- ./app/views/monitoring.widget.hostavail.view.php-20220610-1352 | |
| +++ ./app/views/monitoring.widget.hostavail.view.php | |
| @@ -18,7 +18,9 @@ | |
| ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
| **/ | |
| +require_once dirname(__FILE__).'../../../include/classes/api/services/CHost.php'; | |
| + | |
| /** | |
| * @var CView $this | |
| */ | |
| @@ -61,12 +63,25 @@ | |
| $table->addItem((new CDiv([ | |
| (new CSpan($counts[INTERFACE_AVAILABLE_FALSE]))->addClass(ZBX_STYLE_TOTALS_LIST_COUNT), _('Not available') | |
| ]))->addClass(ZBX_STYLE_HOST_AVAIL_FALSE)); | |
| - | |
| + | |
| + | |
| + if (in_array(INTERFACE_TYPE_AGENT, $data['hosts_types'])) { | |
| + | |
| + $matchedHosts = new CHost(); | |
| + $nHostsFound = 0; | |
| + $nHostsFound = count($matchedHosts->get(array('tags' => array(array('tag' => 'AVAILABILITY', 'value' => 'ICMP',))))); | |
| + $nHostsFound += count($matchedHosts->get(array('tags' => array(array('tag' => 'AVAILABILITY', 'value' => 'WEB',))))); | |
| + | |
| + $table->addItem((new CDiv([ | |
| + (new CSpan($counts[INTERFACE_AVAILABLE_UNKNOWN]-$nHostsFound))->addClass(ZBX_STYLE_TOTALS_LIST_COUNT), _('Unknown') | |
| + ]))->addClass(ZBX_STYLE_HOST_AVAIL_UNKNOWN)); | |
| + } | |
| + else { | |
| + $table->addItem((new CDiv([ | |
| + (new CSpan($counts[INTERFACE_AVAILABLE_UNKNOWN]))->addClass(ZBX_STYLE_TOTALS_LIST_COUNT), _('Unknown') | |
| + ]))->addClass(ZBX_STYLE_HOST_AVAIL_UNKNOWN)); | |
| + } | |
| $table->addItem((new CDiv([ | |
| - (new CSpan($counts[INTERFACE_AVAILABLE_UNKNOWN]))->addClass(ZBX_STYLE_TOTALS_LIST_COUNT), _('Unknown') | |
| - ]))->addClass(ZBX_STYLE_HOST_AVAIL_UNKNOWN)); | |
| - | |
| - $table->addItem((new CDiv([ | |
| (new CSpan($data['hosts_total'][$data['hosts_types'][0]]))->addClass(ZBX_STYLE_TOTALS_LIST_COUNT), _('Total') | |
| ]))->addClass(ZBX_STYLE_HOST_AVAIL_TOTAL)); | |
| } | |
| @@ -80,20 +95,46 @@ | |
| if (in_array($key, $data['hosts_types'])) { | |
| $counts = $data['hosts_count'][$key]; | |
| - $available_row = (new CCol($counts[INTERFACE_AVAILABLE_TRUE]))->addClass(ZBX_STYLE_HOST_AVAIL_TRUE); | |
| - $not_available_row = (new CCol($counts[INTERFACE_AVAILABLE_FALSE]))->addClass(ZBX_STYLE_HOST_AVAIL_FALSE); | |
| - $unknown_row = (new CCol($counts[INTERFACE_AVAILABLE_UNKNOWN]))->addClass(ZBX_STYLE_HOST_AVAIL_UNKNOWN); | |
| - $total_row = (new CCol($data['hosts_total'][$key]))->addClass(ZBX_STYLE_HOST_AVAIL_TOTAL); | |
| + if ($key == INTERFACE_TYPE_AGENT ) { | |
| + | |
| + $matchedHosts = new CHost(); | |
| + $nHostsFound = 0; | |
| + $nHostsFound = count($matchedHosts->get(array('tags' => array(array('tag' => 'AVAILABILITY', 'value' => 'ICMP',))))); | |
| + $nHostsFound += count($matchedHosts->get(array('tags' => array(array('tag' => 'AVAILABILITY', 'value' => 'WEB',))))); | |
| - if ($data['layout'] == STYLE_HORIZONTAL) { | |
| - $table->addRow([$value, $available_row, $not_available_row, $unknown_row, $total_row]); | |
| + $available_row = (new CCol($counts[INTERFACE_AVAILABLE_TRUE]))->addClass(ZBX_STYLE_HOST_AVAIL_TRUE); | |
| + $not_available_row = (new CCol($counts[INTERFACE_AVAILABLE_FALSE]))->addClass(ZBX_STYLE_HOST_AVAIL_FALSE); | |
| + $unknown_row = (new CCol($counts[INTERFACE_AVAILABLE_UNKNOWN]-$nHostsFound))->addClass(ZBX_STYLE_HOST_AVAIL_UNKNOWN); | |
| + $total_row = (new CCol($data['hosts_total'][$key]))->addClass(ZBX_STYLE_HOST_AVAIL_TOTAL); | |
| + | |
| + if ($data['layout'] == STYLE_HORIZONTAL) { | |
| + $table->addRow([$value, $available_row, $not_available_row, $unknown_row, $total_row]); | |
| + } | |
| + else { | |
| + $rows[INTERFACE_AVAILABLE_TRUE][] = $available_row; | |
| + $rows[INTERFACE_AVAILABLE_FALSE][] = $not_available_row; | |
| + $rows[INTERFACE_AVAILABLE_UNKNOWN][] = $unknown_row; | |
| + $rows['hosts_total'][] = $total_row; | |
| + } | |
| } | |
| else { | |
| - $rows[INTERFACE_AVAILABLE_TRUE][] = $available_row; | |
| - $rows[INTERFACE_AVAILABLE_FALSE][] = $not_available_row; | |
| - $rows[INTERFACE_AVAILABLE_UNKNOWN][] = $unknown_row; | |
| - $rows['hosts_total'][] = $total_row; | |
| + | |
| + $available_row = (new CCol($counts[INTERFACE_AVAILABLE_TRUE]))->addClass(ZBX_STYLE_HOST_AVAIL_TRUE); | |
| + $not_available_row = (new CCol($counts[INTERFACE_AVAILABLE_FALSE]))->addClass(ZBX_STYLE_HOST_AVAIL_FALSE); | |
| + $unknown_row = (new CCol($counts[INTERFACE_AVAILABLE_UNKNOWN]))->addClass(ZBX_STYLE_HOST_AVAIL_UNKNOWN); | |
| + $total_row = (new CCol($data['hosts_total'][$key]))->addClass(ZBX_STYLE_HOST_AVAIL_TOTAL); | |
| + | |
| + if ($data['layout'] == STYLE_HORIZONTAL) { | |
| + $table->addRow([$value, $available_row, $not_available_row, $unknown_row, $total_row]); | |
| + } | |
| + else { | |
| + $rows[INTERFACE_AVAILABLE_TRUE][] = $available_row; | |
| + $rows[INTERFACE_AVAILABLE_FALSE][] = $not_available_row; | |
| + $rows[INTERFACE_AVAILABLE_UNKNOWN][] = $unknown_row; | |
| + $rows['hosts_total'][] = $total_row; | |
| + } | |
| } | |
| + | |
| } | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment