/usr/share/zabbix/hostprofiles.php is in zabbix-frontend-php 1:1.8.11-1.
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 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 | <?php
/*
** ZABBIX
** Copyright (C) 2000-2010 SIA Zabbix
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
**/
?>
<?php
require_once('include/config.inc.php');
require_once('include/hosts.inc.php');
require_once('include/forms.inc.php');
$page['title'] = 'S_HOST_PROFILES';
$page['file'] = 'hostprofiles.php';
$page['hist_arg'] = array('groupid', 'hostid');
include_once('include/page_header.php');
?>
<?php
// VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION
$fields=array(
'groupid'=> array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, NULL),
'hostid'=> array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, NULL),
'prof_type'=> array(T_ZBX_INT, O_OPT, P_SYS, NULL, NULL),
);
check_fields($fields);
validate_sort_and_sortorder('host', ZBX_SORT_UP);
?>
<?php
$options = array(
'groups' => array(
'real_hosts' => 1,
),
'groupid' => get_request('groupid', null),
);
$pageFilter = new CPageFilter($options);
$_REQUEST['groupid'] = $pageFilter->groupid;
$_REQUEST['hostid'] = get_request('hostid', 0);
// permission check, imo should be remuved in future.
if($_REQUEST['hostid'] > 0){
$res = CHost::get(array('real_hosts' => 1, 'hostids' => $_REQUEST['hostid']));
if(empty($res)) access_deny();
}
$_REQUEST['prof_type'] = get_request('prof_type', 0);
$hostprof_wdgt = new CWidget();
$profile_form = new CForm(null, 'get');
$cmbProf = new CComboBox('prof_type', $_REQUEST['prof_type'], 'javascript: submit();');
$cmbProf->additem(0, S_NORMAL);
$cmbProf->additem(1, S_EXTENDED);
$profile_form->addItem(array(SPACE.S_HOST_PROFILES.SPACE, $cmbProf));
$hostprof_wdgt->addPageHeader(S_HOST_PROFILES_BIG, $profile_form);
if($_REQUEST['hostid'] > 0){
if($_REQUEST['prof_type']){
$hostprof_wdgt->addItem(insert_host_profile_ext_form());
}
else{
$hostprof_wdgt->addItem(insert_host_profile_form());
}
}
else{
$sortfield = getPageSortField('host');
$sortorder = getPageSortOrder();
$options = array(
'extendoutput' => 1,
'sortfield' => $sortfield,
'sortorder' => $sortorder,
'select_profile' => 1,
'select_groups' => 1,
'limit' => ($config['search_limit']+1)
);
if($pageFilter->groupsSelected){
if($pageFilter->groupid > 0)
$options['groupids'] = $pageFilter->groupid;
}
else{
$options['groupids'] = array();
}
$hosts = CHost::get($options);
// unset hosts without profiles, and copy some profile fileds to the uppers array level for sorting
$pr = ($_REQUEST['prof_type'] == 0) ? 'profile' : 'profile_ext';
$profile = array();
foreach($hosts as $num => $host){
if(empty($host[$pr])){
unset($hosts[$num]);
}
else{
if($_REQUEST['prof_type'] == 0){
$hosts[$num]['pr_name'] = $host['profile']['name'];
$hosts[$num]['pr_os'] = $host['profile']['os'];
$hosts[$num]['pr_serialno'] = $host['profile']['serialno'];
$hosts[$num]['pr_tag'] = $host['profile']['tag'];
$hosts[$num]['pr_macaddress'] = $host['profile']['macaddress'];
}
else{
$hosts[$num]['pre_device_os_short'] = $host['profile_ext']['device_os_short'];
$hosts[$num]['pre_device_hw_arch'] = $host['profile_ext']['device_hw_arch'];
$hosts[$num]['pre_device_type'] = $host['profile_ext']['device_type'];
$hosts[$num]['pre_device_status'] = $host['profile_ext']['device_status'];
}
}
}
$r_form = new CForm(null, 'get');
$r_form->addVar('prof_type', $_REQUEST['prof_type']);
$r_form->addItem(array(S_GROUP.SPACE, $pageFilter->getGroupsCB(true)));
$hostprof_wdgt->addHeader(S_HOSTS_BIG, $r_form);
$numrows = new CDiv();
$numrows->setAttribute('name', 'numrows');
$hostprof_wdgt->addHeader($numrows);
order_result($hosts, $sortfield, $sortorder);
$paging = getPagingLine($hosts);
$table = new CTableInfo();
if(0 == $_REQUEST['prof_type']){
$table->setHeader(array(
is_show_all_nodes() ? make_sorting_header(S_NODE, 'hostid') : null,
make_sorting_header(S_HOST, 'host'),
S_GROUP,
make_sorting_header(S_NAME, 'pr_name'),
make_sorting_header(S_OS, 'pr_os'),
make_sorting_header(S_SERIALNO, 'pr_serialno'),
make_sorting_header(S_TAG, 'pr_tag'),
make_sorting_header(S_MACADDRESS, 'pr_macaddress'))
);
}
else{
$table->setHeader(array(
is_show_all_nodes() ? make_sorting_header(S_NODE, 'hostid') : null,
make_sorting_header(S_HOST, 'host'),
S_GROUP,
make_sorting_header(S_DEVICE_OS_SHORT, 'pre_device_os_short'),
make_sorting_header(S_DEVICE_HW_ARCH, 'pre_device_hw_arch'),
make_sorting_header(S_DEVICE_TYPE, 'pre_device_type'),
make_sorting_header(S_DEVICE_STATUS, 'pre_device_status'))
);
}
foreach($hosts as $host){
$host_groups = array();
foreach($host['groups'] as $group){
$host_groups[] = $group['name'];
}
natcasesort($host_groups);
$host_groups = implode(', ', $host_groups);
$row = array(
get_node_name_by_elid($host['hostid']),
new CLink($host['host'],'?hostid='.$host['hostid'].url_param('groupid').'&prof_type='.$_REQUEST['prof_type']),
$host_groups);
if(0 == $_REQUEST['prof_type']){
$row[] = zbx_str2links($host['profile']['name']);
$row[] = zbx_str2links($host['profile']['os']);
$row[] = zbx_str2links($host['profile']['serialno']);
$row[] = zbx_str2links($host['profile']['tag']);
$row[] = zbx_str2links($host['profile']['macaddress']);
}
else{
$row[] = zbx_str2links($host['profile_ext']['device_os_short']);
$row[] = zbx_str2links($host['profile_ext']['device_hw_arch']);
$row[] = zbx_str2links($host['profile_ext']['device_type']);
$row[] = zbx_str2links($host['profile_ext']['device_status']);
}
$table->addRow($row);
}
$table = array($paging, $table, $paging);
$hostprof_wdgt->addItem($table);
}
$hostprof_wdgt->show();
include_once('include/page_footer.php');
?>
|