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 "daemon.h"
22 #include "zbxself.h"
23 #include "log.h"
24 #include "selfmon.h"
25
26 extern unsigned char process_type, program_type;
27 extern int server_num, process_num;
28
ZBX_THREAD_ENTRY(selfmon_thread,args)29 ZBX_THREAD_ENTRY(selfmon_thread, args)
30 {
31 double sec;
32
33 process_type = ((zbx_thread_args_t *)args)->process_type;
34 server_num = ((zbx_thread_args_t *)args)->server_num;
35 process_num = ((zbx_thread_args_t *)args)->process_num;
36
37 zabbix_log(LOG_LEVEL_INFORMATION, "%s #%d started [%s #%d]", get_program_type_string(program_type),
38 server_num, get_process_type_string(process_type), process_num);
39
40 for (;;)
41 {
42 zbx_handle_log();
43
44 zbx_setproctitle("%s [processing data]", get_process_type_string(process_type));
45
46 sec = zbx_time();
47 collect_selfmon_stats();
48 sec = zbx_time() - sec;
49
50 zbx_setproctitle("%s [processed data in " ZBX_FS_DBL " sec, idle 1 sec]",
51 get_process_type_string(process_type), sec);
52
53 zbx_sleep_loop(1);
54
55 #if !defined(_WINDOWS) && defined(HAVE_RESOLV_H)
56 zbx_update_resolver_conf(); /* handle /etc/resolv.conf update */
57 #endif
58 }
59 }
60