1 /* GKrellM
2 |  Copyright (C) 1999-2019 Bill Wilson
3 |
4 |  Author:  Bill Wilson    billw@gkrellm.net
5 |  Latest versions might be found at:  http://gkrellm.net
6 |
7 |
8 |  GKrellM is free software: you can redistribute it and/or modify it
9 |  under the terms of the GNU General Public License as published by
10 |  the Free Software Foundation, either version 3 of the License, or
11 |  (at your option) any later version.
12 |
13 |  GKrellM is distributed in the hope that it will be useful, but WITHOUT
14 |  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 |  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
16 |  License for more details.
17 |
18 |  You should have received a copy of the GNU General Public License
19 |  along with this program. If not, see http://www.gnu.org/licenses/
20 |
21 |
22 |  Additional permission under GNU GPL version 3 section 7
23 |
24 |  If you modify this program, or any covered work, by linking or
25 |  combining it with the OpenSSL project's OpenSSL library (or a
26 |  modified version of that library), containing parts covered by
27 |  the terms of the OpenSSL or SSLeay licenses, you are granted
28 |  additional permission to convey the resulting work.
29 |  Corresponding Source for a non-source form of such a combination
30 |  shall include the source code for the parts of OpenSSL used as well
31 |  as that of the covered work.
32 */
33 
34 #include "configure.h"
35 
36 #include "../src/gkrellm-sysdeps.h"
37 
38 #if defined(WIN32)
39 // Enable getaddrinfo on win32 if we target win xp or newer
40 #if _WIN32_WINNT > 0x0500
41 #define HAVE_GETADDRINFO	1
42 #endif
43 #endif
44 
45 #if defined(__linux__)
46 #define HAVE_GETADDRINFO	1
47 #endif
48 
49 #if defined(__DragonFly__)
50 #define HAVE_GETADDRINFO	1
51 #endif
52 
53 #if defined(__FreeBSD__)
54 #include <sys/param.h>
55 #if __FreeBSD_version >= 400000
56 #define HAVE_GETADDRINFO	1
57 #endif
58 #endif
59 
60 #if defined(__OpenBSD__)
61 #define HAVE_GETADDRINFO	1
62 #endif
63 
64 #if defined(__NetBSD__)
65 #define HAVE_GETADDRINFO	1
66 #include <sys/param.h>
67 #  if __NetBSD_Version__ <= 105010000
68 #    define sa_family_t unsigned char
69 #  endif
70 #endif
71 
72 #if defined(__solaris__)
73 # include <netconfig.h>
74 # if defined(NC_INET6)
75 #  define HAVE_GETADDRINFO	1
76 # endif
77 #endif
78 
79 #if defined(__APPLE__)
80 # ifndef socklen_t
81 #  define socklen_t int
82 # endif
83 #define HAVE_GETADDRINFO   1
84 #endif
85 
86 #ifndef	NI_WITHSCOPEID
87 #define	NI_WITHSCOPEID	0
88 #endif
89 
90 #if !defined(__FreeBSD__) && !defined(__linux__) && !defined(__NetBSD__) \
91     && !defined(__OpenBSD__) && !defined(__solaris__) && !defined(WIN32) \
92     && !defined(__APPLE__) && !defined(__DragonFly__)
93 #define  USE_LIBGTOP
94 #endif
95 
96 #define DEBUG_SYSDEP		0x1
97 #define DEBUG_SERVER		0x2
98 #define DEBUG_MAIL			0x10
99 #define DEBUG_NET			0x20
100 #define DEBUG_TIMER			0x40
101 #define DEBUG_SENSORS		0x80
102 #define DEBUG_NO_LIBSENSORS	0x100
103 #define DEBUG_INET          0x800
104 #define	DEBUG_BATTERY		0x8000
105 
106 
107 #define SENSOR_TEMPERATURE  0
108 #define SENSOR_FAN          1
109 #define SENSOR_VOLTAGE      2
110 
111 #define	SENSOR_GROUP_MAINBOARD	0
112 #define	SENSOR_GROUP_DISK		1
113 
114 #include <errno.h>
115 
116 struct GkrellmdConfig
117 	{
118 	gint		update_HZ;
119 	gint		debug_level;
120 	gint		*server_fd;
121 	gint		max_clients;
122 	gint		server_port;
123 	gchar		*server_address;
124 	gint		verbose;
125 	time_t		start_time;
126 	time_t		time_now;
127 	gint		io_timeout;
128 	gint		reconnect_timeout;
129 	gint		mbmon_port;
130 
131 	gint		fs_interval,
132 				nfs_interval,
133 				inet_interval;
134 
135 	gboolean	without_libsensors;
136 	gboolean	use_acpi_battery;
137 
138 	gboolean	list_plugins,
139 				log_plugins;
140 	gchar		*command_line_plugin;
141 
142 	gchar		*pidfile;
143 	gchar		*homedir;
144 
145 	gchar		*net_timer;
146 	};
147 
148 typedef struct
149 	{
150 	gchar	*name,
151 			*line;
152 	}
153 	PluginConfigRec;
154 
155 extern struct GkrellmdConfig	_GK;
156 
157 extern gchar	*plugin_install_log;
158 
159 typedef	void (*GkrellmdFunc)();
160 
161 extern GList	*gkrellmd_client_list,
162 				*gkrellmd_plugin_enable_list,
163 				*gkrellmd_plugin_config_list;
164 
165 void			gkrellmd_client_read(gint client_fd, gint nbytes);
166 void			gkrellmd_load_monitors(void);
167 GList			*gkrellmd_plugins_load(void);
168 gint			gkrellmd_update_monitors(void);
169 void			gkrellmd_serve_setup(GkrellmdClient *client);
170 
171 GkrellmdMonitor *gkrellmd_init_mail_monitor(void);
172 
173 gint		gkrellm_connect_to(gchar *, gint);
174