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 #ifndef ZABBIX_ACTIVE_H 21 #define ZABBIX_ACTIVE_H 22 23 #include "threads.h" 24 25 extern char *CONFIG_SOURCE_IP; 26 extern char *CONFIG_HOSTNAME; 27 extern char *CONFIG_HOST_METADATA; 28 extern char *CONFIG_HOST_METADATA_ITEM; 29 extern int CONFIG_REFRESH_ACTIVE_CHECKS; 30 extern int CONFIG_BUFFER_SEND; 31 extern int CONFIG_BUFFER_SIZE; 32 extern int CONFIG_MAX_LINES_PER_SECOND; 33 extern char *CONFIG_LISTEN_IP; 34 extern int CONFIG_LISTEN_PORT; 35 36 /* define minimal and maximal values of lines to send by agent */ 37 /* per second for checks `log' and `eventlog', used to parse key parameters */ 38 #define MIN_VALUE_LINES 1 39 #define MAX_VALUE_LINES 1000 40 41 #define HOST_METADATA_LEN 255 /* UTF-8 characters, not bytes */ 42 43 /* Windows event types for `eventlog' check */ 44 #ifdef _WINDOWS 45 # ifndef INFORMATION_TYPE 46 # define INFORMATION_TYPE "Information" 47 # endif 48 # ifndef WARNING_TYPE 49 # define WARNING_TYPE "Warning" 50 # endif 51 # ifndef ERROR_TYPE 52 # define ERROR_TYPE "Error" 53 # endif 54 # ifndef AUDIT_FAILURE 55 # define AUDIT_FAILURE "Failure Audit" 56 # endif 57 # ifndef AUDIT_SUCCESS 58 # define AUDIT_SUCCESS "Success Audit" 59 # endif 60 # ifndef CRITICAL_TYPE 61 # define CRITICAL_TYPE "Critical" 62 # endif 63 # ifndef VERBOSE_TYPE 64 # define VERBOSE_TYPE "Verbose" 65 # endif 66 #endif /* _WINDOWS */ 67 68 /* NB! Next list must fit in unsigned char (see ZBX_ACTIVE_METRIC "flags" field below). */ 69 #define ZBX_METRIC_FLAG_PERSISTENT 0x01 /* do not overwrite old values when adding to the buffer */ 70 #define ZBX_METRIC_FLAG_NEW 0x02 /* new metric, just added */ 71 #define ZBX_METRIC_FLAG_LOG_LOG 0x04 /* log[ */ 72 #define ZBX_METRIC_FLAG_LOG_LOGRT 0x08 /* logrt[ */ 73 #define ZBX_METRIC_FLAG_LOG_EVENTLOG 0x10 /* eventlog[ */ 74 #define ZBX_METRIC_FLAG_LOG /* item for log file monitoring, one of the above */ \ 75 (ZBX_METRIC_FLAG_LOG_LOG | ZBX_METRIC_FLAG_LOG_LOGRT | ZBX_METRIC_FLAG_LOG_EVENTLOG) 76 77 typedef struct 78 { 79 char *key; 80 char *key_orig; 81 zbx_uint64_t lastlogsize; 82 int refresh; 83 int nextcheck; 84 int mtime; 85 unsigned char skip_old_data; /* for processing [event]log metrics */ 86 unsigned char flags; 87 unsigned char state; 88 unsigned char refresh_unsupported; /* re-check notsupported item */ 89 int big_rec; /* for logfile reading: 0 - normal record, 1 - long unfinished record */ 90 int use_ino; /* 0 - do not use inodes (on FAT, FAT32) */ 91 /* 1 - use inodes (up to 64-bit) (various UNIX file systems, NTFS) */ 92 /* 2 - use 128-bit FileID (currently only on ReFS) to identify files */ 93 /* on a file system */ 94 int error_count; /* number of file reading errors in consecutive checks */ 95 int logfiles_num; 96 struct st_logfile *logfiles; /* for handling of logfile rotation for logrt[] items */ 97 } 98 ZBX_ACTIVE_METRIC; 99 100 typedef struct 101 { 102 char *host; 103 unsigned short port; 104 } 105 ZBX_THREAD_ACTIVECHK_ARGS; 106 107 typedef struct 108 { 109 char *host; 110 char *key; 111 char *value; 112 unsigned char state; 113 zbx_uint64_t lastlogsize; 114 int timestamp; 115 char *source; 116 int severity; 117 zbx_timespec_t ts; 118 int logeventid; 119 int mtime; 120 unsigned char flags; 121 } 122 ZBX_ACTIVE_BUFFER_ELEMENT; 123 124 typedef struct 125 { 126 ZBX_ACTIVE_BUFFER_ELEMENT *data; 127 int count; 128 int pcount; 129 int lastsent; 130 int first_error; 131 } 132 ZBX_ACTIVE_BUFFER; 133 134 ZBX_THREAD_ENTRY(active_checks_thread, args); 135 136 #endif /* ZABBIX_ACTIVE_H */ 137