1 /*
2 ** Zabbix
3 ** Copyright (C) 2001-2021 Zabbix SIA
4 **
5 ** This program is free software; you can redistribute it and/or modify
6 ** it under the terms of the GNU General Public License as published by
7 ** the Free Software Foundation; either version 2 of the License, or
8 ** (at your option) any later version.
9 **
10 ** This program is distributed in the hope that it will be useful,
11 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 ** GNU General Public License for more details.
14 **
15 ** You should have received a copy of the GNU General Public License
16 ** along with this program; if not, write to the Free Software
17 ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 **/
19
20 #include "common.h"
21 #include "sysinfo.h"
22
23 extern char *CONFIG_HOSTNAME;
24
25 static int AGENT_HOSTNAME(AGENT_REQUEST *request, AGENT_RESULT *result);
26 static int AGENT_PING(AGENT_REQUEST *request, AGENT_RESULT *result);
27 static int AGENT_VERSION(AGENT_REQUEST *request, AGENT_RESULT *result);
28 static int AGENT_VARIANT(AGENT_REQUEST *request, AGENT_RESULT *result);
29
30 ZBX_METRIC parameters_agent[] =
31 /* KEY FLAG FUNCTION TEST PARAMETERS */
32 {
33 {"agent.hostname", 0, AGENT_HOSTNAME, NULL},
34 {"agent.ping", 0, AGENT_PING, NULL},
35 {"agent.variant", 0, AGENT_VARIANT, NULL},
36 {"agent.version", 0, AGENT_VERSION, NULL},
37 {NULL}
38 };
39
AGENT_HOSTNAME(AGENT_REQUEST * request,AGENT_RESULT * result)40 static int AGENT_HOSTNAME(AGENT_REQUEST *request, AGENT_RESULT *result)
41 {
42 ZBX_UNUSED(request);
43
44 SET_STR_RESULT(result, zbx_strdup(NULL, CONFIG_HOSTNAME));
45
46 return SYSINFO_RET_OK;
47 }
48
AGENT_PING(AGENT_REQUEST * request,AGENT_RESULT * result)49 static int AGENT_PING(AGENT_REQUEST *request, AGENT_RESULT *result)
50 {
51 ZBX_UNUSED(request);
52
53 SET_UI64_RESULT(result, 1);
54
55 return SYSINFO_RET_OK;
56 }
57
AGENT_VERSION(AGENT_REQUEST * request,AGENT_RESULT * result)58 static int AGENT_VERSION(AGENT_REQUEST *request, AGENT_RESULT *result)
59 {
60 ZBX_UNUSED(request);
61
62 SET_STR_RESULT(result, zbx_strdup(NULL, ZABBIX_VERSION));
63
64 return SYSINFO_RET_OK;
65 }
66
AGENT_VARIANT(AGENT_REQUEST * request,AGENT_RESULT * result)67 static int AGENT_VARIANT(AGENT_REQUEST *request, AGENT_RESULT *result)
68 {
69 ZBX_UNUSED(request);
70
71 SET_UI64_RESULT(result, 1);
72
73 return SYSINFO_RET_OK;
74 }
75