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_DISKDEVICES_H
21 #define ZABBIX_DISKDEVICES_H
22 
23 #ifdef _WINDOWS
24 #	error "This module allowed only for Unix OS"
25 #endif
26 
27 #include "sysinfo.h"
28 
29 #define	MAX_DISKDEVICES	1024
30 
31 /* Disk device time to live: if disk statistics is being collected but not polled (using passive  */
32 /* or active check) DISKDEVICE_TTL or more seconds then delete this disk from collector.          */
33 /* Update interval for vfs.dev.read[] and vfs.dev.write[] items must be less than DISKDEVICE_TTL. */
34 #define	DISKDEVICE_TTL	(3 * SEC_PER_HOUR)
35 
36 typedef struct c_single_diskdevice_data
37 {
38 	char		name[32];
39 	int		index;
40 	/* Counter used to detect devices no longer polled and to delete them from collector. It is set */
41 	/* to 0 when disk statistics is polled and incremented when disk statistics is updated. For     */
42 	/* example, value 3600 means that approximately 1 hour statistics was not polled for this disk. */
43 	int 		ticks_since_polled;
44 	time_t		clock[MAX_COLLECTOR_HISTORY];
45 	zbx_uint64_t	r_sect[MAX_COLLECTOR_HISTORY];
46 	zbx_uint64_t	r_oper[MAX_COLLECTOR_HISTORY];
47 	zbx_uint64_t	r_byte[MAX_COLLECTOR_HISTORY];
48 	zbx_uint64_t	w_sect[MAX_COLLECTOR_HISTORY];
49 	zbx_uint64_t	w_oper[MAX_COLLECTOR_HISTORY];
50 	zbx_uint64_t	w_byte[MAX_COLLECTOR_HISTORY];
51 	double		r_sps[ZBX_AVG_COUNT];
52 	double		r_ops[ZBX_AVG_COUNT];
53 	double		r_bps[ZBX_AVG_COUNT];
54 	double		w_sps[ZBX_AVG_COUNT];
55 	double		w_ops[ZBX_AVG_COUNT];
56 	double		w_bps[ZBX_AVG_COUNT];
57 } ZBX_SINGLE_DISKDEVICE_DATA;
58 
59 typedef struct c_diskdevices_data
60 {
61 	int				count;		/* number of disks to collect statistics for */
62 	int				max_diskdev;	/* number of "slots" for disk statistics */
63 	ZBX_SINGLE_DISKDEVICE_DATA	device[1];	/* more "slots" for disk statistics added dynamically */
64 } ZBX_DISKDEVICES_DATA;
65 
66 #define DISKDEVICE_COLLECTOR_STARTED(collector)	((collector) && (collector)->diskstat_shmid != ZBX_NONEXISTENT_SHMID)
67 
68 ZBX_SINGLE_DISKDEVICE_DATA	*collector_diskdevice_get(const char *devname);
69 ZBX_SINGLE_DISKDEVICE_DATA	*collector_diskdevice_add(const char *devname);
70 void				collect_stats_diskdevices(void);
71 
72 #endif
73