/usr/share/zabbix/include/discovery.inc.php is in zabbix-frontend-php 1:2.4.7+dfsg-2ubuntu2.
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 | <?php
/*
** Zabbix
** Copyright (C) 2001-2015 Zabbix SIA
**
** 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
require_once dirname(__FILE__).'/perm.inc.php';
/**
* Returns true if the user has the permissions to network discovery.
*
* @return bool
*/
function check_right_on_discovery() {
return (CWebUser::getType() >= USER_TYPE_ZABBIX_ADMIN);
}
function svc_default_port($type_int) {
$typePort = array(
SVC_SSH => '22',
SVC_LDAP => '389',
SVC_SMTP => '25',
SVC_FTP => '21',
SVC_HTTP => '80',
SVC_POP => '110',
SVC_NNTP => '119',
SVC_IMAP => '143',
SVC_AGENT => '10050',
SVC_SNMPv1 => '161',
SVC_SNMPv2c => '161',
SVC_SNMPv3 => '161',
SVC_HTTPS => '443',
SVC_TELNET => '23'
);
return isset($typePort[$type_int]) ? $typePort[$type_int] : 0;
}
function discovery_check_type2str($type = null) {
$discoveryTypes = array(
SVC_SSH => _('SSH'),
SVC_LDAP => _('LDAP'),
SVC_SMTP => _('SMTP'),
SVC_FTP => _('FTP'),
SVC_HTTP => _('HTTP'),
SVC_POP => _('POP'),
SVC_NNTP => _('NNTP'),
SVC_IMAP => _('IMAP'),
SVC_TCP => _('TCP'),
SVC_AGENT => _('Zabbix agent'),
SVC_SNMPv1 => _('SNMPv1 agent'),
SVC_SNMPv2c => _('SNMPv2 agent'),
SVC_SNMPv3 => _('SNMPv3 agent'),
SVC_ICMPPING => _('ICMP ping'),
SVC_TELNET => _('Telnet'),
SVC_HTTPS => _('HTTPS')
);
if ($type === null) {
return $discoveryTypes;
}
elseif (isset($discoveryTypes[$type])) {
return $discoveryTypes[$type];
}
else {
return false;
}
}
function discovery_check2str($type, $key, $port) {
$externalParam = '';
if ($key !== '') {
switch ($type) {
case SVC_SNMPv1:
case SVC_SNMPv2c:
case SVC_SNMPv3:
case SVC_AGENT:
$externalParam = ' "'.$key.'"';
break;
}
}
$result = discovery_check_type2str($type);
if ($port && (svc_default_port($type) !== $port || $type === SVC_TCP)) {
$result .= ' ('.$port.')';
}
return $result.$externalParam;
}
function discovery_port2str($type_int, $port) {
$port_def = svc_default_port($type_int);
if ($port != $port_def) {
return ' ('.$port.')';
}
return '';
}
function discovery_status2str($status = null) {
$discoveryStatus = array(
DRULE_STATUS_ACTIVE => _('Enabled'),
DRULE_STATUS_DISABLED => _('Disabled')
);
if (is_null($status)) {
return $discoveryStatus;
}
elseif (isset($discoveryStatus[$status])) {
return $discoveryStatus[$status];
}
else {
return _('Unknown');
}
}
function discovery_status2style($status) {
switch ($status) {
case DRULE_STATUS_ACTIVE:
$status = 'off';
break;
case DRULE_STATUS_DISABLED:
$status = 'on';
break;
default:
$status = 'unknown';
break;
}
return $status;
}
function discovery_object_status2str($status = null) {
$discoveryStatus = array(
DOBJECT_STATUS_UP => _x('Up', 'discovery status'),
DOBJECT_STATUS_DOWN => _x('Down', 'discovery status'),
DOBJECT_STATUS_DISCOVER => _('Discovered'),
DOBJECT_STATUS_LOST => _('Lost')
);
if (is_null($status)) {
order_result($discoveryStatus);
return $discoveryStatus;
}
elseif (isset($discoveryStatus[$status])) {
return $discoveryStatus[$status];
}
else {
return _('Unknown');
}
}
function get_discovery_rule_by_druleid($druleid) {
return DBfetch(DBselect('SELECT d.* FROM drules d WHERE d.druleid='.zbx_dbstr($druleid)));
}
|