Ad Widget

Collapse

Изменить таблицу Host Inventory

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Belfigor
    Member
    • Jul 2016
    • 69

    #1

    Изменить таблицу Host Inventory

    Inventory => Hosts
    Открывает таблицу с хостами находящимися в выбранной группе. Там несколько предустановленных колонок в таблице:
    Host, Group, Name, Type, OS, Serial Number A, TAG, Mac address A

    Хочу заменить на другие все колонки кроме Host и Group, как это можно сделать?
  • Aksel
    Senior Member
    • Aug 2014
    • 101

    #2
    1. Сделать бэкапы файлов!!!
    usr/share/zabbix/include/views/inventory.host.list.php
    usr/share/zabbix/hostinventories.php

    2. Править файлы:

    usr/share/zabbix/include/views/inventory.host.list.php
    править нужно секцию:

    $table = (new CTableInfo())
    <------>->setHeader([
    <------><------>make_sorting_header(_('Host'), 'name', $this->data['sort'], $this->data['sortorder']),
    <------><------>_('Group'),
    <------><------>make_sorting_header(_('Name'), 'pr_name', $this->data['sort'], $this->data['sortorder']),
    <------><------>make_sorting_header(_('Type'), 'pr_type', $this->data['sort'], $this->data['sortorder']),
    <------><------>make_sorting_header(_('OS'), 'pr_os', $this->data['sort'], $this->data['sortorder']),
    <------><------>make_sorting_header(_('Serial number A'), 'pr_serialno_a', $this->data['sort'], $this->data['sortorder']),
    <------><------>make_sorting_header(_('Tag'), 'pr_tag', $this->data['sort'], $this->data['sortorder']),
    <------><------>make_sorting_header(_('MAC address A'), 'pr_macaddress_a', $this->data['sort'], $this->data['sortorder'])
    <------>]);


    например на:

    $table = (new CTableInfo())
    <------>->setHeader([
    <------><------>make_sorting_header(_('Host'), 'name', $this->data['sort'], $this->data['sortorder']),
    <------><------>_('Group'),
    <------><------>make_sorting_header(_('Secondary POC notes'), 'poc_2_notes', $this->data['sort'], $this->data['sortorder']),
    <------><------>make_sorting_header(_('Secondary POC screen name'), 'poc_2_screen', $this->data['sort'], $this->data['sortorder']),
    <------><------>make_sorting_header(_('Secondary POC cell'), 'poc_2_cell', $this->data['sort'], $this->data['sortorder']),
    <------><------>make_sorting_header(_('Serial number A'), 'pr_serialno_a', $this->data['sort'], $this->data['sortorder']),
    <------><------>make_sorting_header(_('MAC address A'), 'pr_macaddress_a', $this->data['sort'], $this->data['sortorder']),
    <------><------>make_sorting_header(_('Primary POC phone A'), 'poc_1_phone_a', $this->data['sort'], $this->data['sortorder']),
    <------><------>make_sorting_header(_('Primary POC phone B'), 'poc_1_phone_b', $this->data['sort'], $this->data['sortorder']),
    <------><------>make_sorting_header(_('Primary POC name'), 'poc_1_name', $this->data['sort'], $this->data['sortorder']),
    <------><------>make_sorting_header(_('Primary POC email'), 'poc_1_email', $this->data['sort'], $this->data['sortorder']),
    <------><------>make_sorting_header(_('Secondary POC phone A'), 'poc_2_phone_a', $this->data['sort'], $this->data['sortorder']),
    <------><------>make_sorting_header(_('Secondary POC phone B'), 'poc_2_phone_b', $this->data['sort'], $this->data['sortorder']),
    <------><------>make_sorting_header(_('Secondary POC name'), 'poc_2_name', $this->data['sort'], $this->data['sortorder']),
    <------><------>make_sorting_header(_('Secondary POC email'), 'poc_2_email', $this->data['sort'], $this->data['sortorder'])
    <------><------>


    далее,

    <------>$row = [
    <------><------>(new CLink($host['name'], '?hostid='.$host['hostid'].url_param('groupid')))
    <------><------><------>->addClass($host['status'] == HOST_STATUS_NOT_MONITORED ? ZBX_STYLE_RED : null),
    <------><------>$hostGroups,
    <------><------>zbx_str2links($host['inventory']['name']),
    <------><------>zbx_str2links($host['inventory']['type']),
    <------><------>zbx_str2links($host['inventory']['os']),
    <------><------>zbx_str2links($host['inventory']['serialno_a']),
    <------><------>zbx_str2links($host['inventory']['tag']),
    <------><------>zbx_str2links($host['inventory']['macaddress_a'])
    <------>];

    на


    <------>$row = [
    <------><------>(new CLink($host['name'], '?hostid='.$host['hostid'].url_param('groupid')))
    <------><------><------>->addClass($host['status'] == HOST_STATUS_NOT_MONITORED ? ZBX_STYLE_RED : null),
    <------><------>$hostGroups,
    <------><------>zbx_str2links($host['inventory']['poc_2_notes']),
    <------><------>zbx_str2links($host['inventory']['poc_2_screen']),
    <------><------>zbx_str2links($host['inventory']['poc_2_cell']),
    <------><------>zbx_str2links($host['inventory']['serialno_a']),
    <------><------>zbx_str2links($host['inventory']['macaddress_a']),
    <------><------>zbx_str2links($host['inventory']['poc_1_phone_a']),
    <------><------>zbx_str2links($host['inventory']['poc_1_phone_b']),
    <------><------>zbx_str2links($host['inventory']['poc_1_name']),
    <------><------>zbx_str2links($host['inventory']['poc_1_email']),
    <------><------>zbx_str2links($host['inventory']['poc_2_phone_a']),
    <------><------>zbx_str2links($host['inventory']['poc_2_phone_b']),
    <------><------>zbx_str2links($host['inventory']['poc_2_name']),
    <------><------>zbx_str2links($host['inventory']['poc_2_email'])
    <------>];


    После того как добавите, нужные вам столбцы нужно править еще:


    usr/share/zabbix/hostinventories.php


    <------>'sort' =><-----><------><------><------>[T_ZBX_STR, O_OPT, P_SYS,
    <------><------><------><------><------><------><------><------>IN('"name","pr_macaddress_a","pr_name","pr_os","p r_serialno_a","pr_tag","pr_type"'),
    <------><------><------><------><------><------><------><------>null


    на:

    <------>'sort' =><-----><------><------><------>[T_ZBX_STR, O_OPT, P_SYS,
    <------><------><------><------><------><------><------><------>IN('"poc_2_notes","poc_2_screen","poc_2_cell","se rialno_a","macaddress_a","poc_1_phone_a","poc_1_ph one_b","poc_1_name","poc_1_email","poc_2_phone_a", "poc_2_phone_b","poc_2_n
    <------><------><------><------><------><------><------><------>null





    и еще



    <------>if ($data['pageFilter']->groupsSelected) {
    <------><------>// which inventory fields we will need for displaying
    <------><------>$requiredInventoryFields = [
    <------><------><------>'name',
    <------><------><------>'type',
    <------><------><------>'os',
    <------><------><------>'serialno_a',
    <------><------><------>'tag',
    <------><------><------>'macaddress_a'
    <------><------>];



    на


    <------>if ($data['pageFilter']->groupsSelected) {
    <------><------>// which inventory fields we will need for displaying
    <------><------>$requiredInventoryFields = [
    <------><------><------>'poc_2_notes',
    <------><------><------>'poc_2_screen',
    <------><------><------>'poc_2_cell',
    <------><------><------>'serialno_a',
    <------><------><------>'macaddress_a',
    <------><------><------>'poc_1_phone_a',
    <------><------><------>'poc_1_phone_b',
    <------><------><------>'poc_1_name',
    <------><------><------>'poc_1_email',
    <------><------><------>'poc_2_phone_a',
    <------><------><------>'poc_2_phone_b',
    <------><------><------>'poc_2_name',
    <------><------><------>'poc_2_email',
    <------><------><------>'name',
    <------><------><------>'type',
    <------><------><------>'os',
    <------><------><------>'tag'
    <------><------>];


    Если уж совсем не разберетесь, пишите. Напишу все совсем подробно.
    Last edited by Aksel; 23-08-2016, 16:52.

    Comment

    • Aksel
      Senior Member
      • Aug 2014
      • 101

      #3
      Вот как у меня отображается.
      s015.radikal.********ru/i331/1608/29/a4b40b96b31a.png

      (звездочки надо убрать)

      Comment

      • Belfigor
        Member
        • Jul 2016
        • 69

        #4
        Огромное спасибо!

        Comment

        Working...