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_METRICS_H
21 #define ZABBIX_METRICS_H
22 
23 #include "zbxtypes.h"
24 
25 /* define minimal and maximal values of lines to send by agent */
26 /* per second for checks `log' and `eventlog', used to parse key parameters */
27 #define	MIN_VALUE_LINES			1
28 #define	MAX_VALUE_LINES			1000
29 #define	MAX_VALUE_LINES_MULTIPLIER	10
30 
31 /* NB! Next list must fit in unsigned char (see ZBX_ACTIVE_METRIC "flags" field below). */
32 #define ZBX_METRIC_FLAG_PERSISTENT	0x01	/* do not overwrite old values when adding to the buffer */
33 #define ZBX_METRIC_FLAG_NEW		0x02	/* new metric, just added */
34 #define ZBX_METRIC_FLAG_LOG_LOG		0x04	/* log[ or log.count[, depending on ZBX_METRIC_FLAG_LOG_COUNT */
35 #define ZBX_METRIC_FLAG_LOG_LOGRT	0x08	/* logrt[ or logrt.count[, depending on ZBX_METRIC_FLAG_LOG_COUNT */
36 #define ZBX_METRIC_FLAG_LOG_EVENTLOG	0x10	/* eventlog[ */
37 #define ZBX_METRIC_FLAG_LOG_COUNT	0x20	/* log.count[ or logrt.count[ */
38 #define ZBX_METRIC_FLAG_LOG			/* item for log file monitoring, one of the above */	\
39 		(ZBX_METRIC_FLAG_LOG_LOG | ZBX_METRIC_FLAG_LOG_LOGRT | ZBX_METRIC_FLAG_LOG_EVENTLOG)
40 
41 typedef struct
42 {
43 	char			*key;
44 	char			*key_orig;
45 	zbx_uint64_t		lastlogsize;
46 	int			refresh;
47 	int			nextcheck;
48 	int			mtime;
49 	unsigned char		skip_old_data;	/* for processing [event]log metrics */
50 	unsigned char		flags;
51 	unsigned char		state;
52 	int			big_rec;	/* for logfile reading: 0 - normal record, 1 - long unfinished record */
53 	int			use_ino;	/* 0 - do not use inodes (on FAT, FAT32) */
54 						/* 1 - use inodes (up to 64-bit) (various UNIX file systems, NTFS) */
55 						/* 2 - use 128-bit FileID (currently only on ReFS) to identify files */
56 						/* on a file system */
57 	int			error_count;	/* number of file reading errors in consecutive checks */
58 	int			logfiles_num;
59 	struct st_logfile	*logfiles;	/* for handling of logfile rotation for logrt[], logrt.count[] items */
60 	double			start_time;	/* Start time of check for log[], log.count[], logrt[], logrt.count[] */
61 						/* items. Used for measuring duration of checks. */
62 	zbx_uint64_t		processed_bytes;	/* number of processed bytes for log[], log.count[], logrt[], */
63 							/* logrt.count[] items */
64 	char			*persistent_file_name;	/* not used on Microsoft Windows */
65 }
66 ZBX_ACTIVE_METRIC;
67 
68 #endif
69