View | Details | Raw Unified | Return to bug 194859 | Differences between
and this patch

Collapse All | Expand All

(-)b/net-mgmt/pandorafms_agent/Makefile (+1 lines)
Lines 40-45 post-patch: Link Here
40
40
41
post-install:
41
post-install:
42
	@${RM} -f ${STAGEDIR}${LOGDIR}/pandora_agent.log
42
	@${RM} -f ${STAGEDIR}${LOGDIR}/pandora_agent.log
43
	@${RM} -f ${STAGEDIR}${DATADIR}/collections/.empty
43
	@${MKDIR} ${STAGEDIR}${DOCSDIR}
44
	@${MKDIR} ${STAGEDIR}${DOCSDIR}
44
.for x in ${PORTDOCS}
45
.for x in ${PORTDOCS}
45
	${INSTALL_DATA} ${WRKSRC}/${x} ${STAGEDIR}${DOCSDIR}
46
	${INSTALL_DATA} ${WRKSRC}/${x} ${STAGEDIR}${DOCSDIR}
(-)b/net-mgmt/pandorafms_agent/distinfo (-2 / +2 lines)
Lines 1-2 Link Here
1
SHA256 (pandora/pandorafms_agent_unix-5.1.tar.gz) = 9d487573716c088a5121fbb89456000bd39226dbb317ed2d88970f46d4b2bc34
1
SHA256 (pandora/pandorafms_agent_unix-5.1SP1.tar.gz) = b4e4363784a133d4679bdab22c977177ccebc9758e9b6f051d15a7a6a81a7a95
2
SIZE (pandora/pandorafms_agent_unix-5.1.tar.gz) = 86100
2
SIZE (pandora/pandorafms_agent_unix-5.1SP1.tar.gz) = 80277
(-)a/net-mgmt/pandorafms_agent/files/patch-update (-1288 lines)
Removed Link Here
1
Index: ChangeLog
2
===================================================================
3
--- ChangeLog	(revision 10314)
4
+++ ChangeLog	(working copy)
5
@@ -1,3 +1,33 @@
6
+2014-08-14  Koichiro Kikuchi <koichiro@rworks.jp>
7
+
8
+	* pandora_agent_installer: Fixed symlink source path.
9
+
10
+2014-08-13  Koichiro Kikuchi <koichiro@rworks.jp>
11
+
12
+	* FreeBSD/pandora_agent: Small fixes: use proper rc variables,
13
+	 remove obsolete function "set_rcvar" call and use "daemon" command
14
+	 to start pandora_agent.
15
+
16
+	* pandora_agent_installer: Refactored implementation and added
17
+	 "fakeroot" installation support.
18
+
19
+	* plugins/who.sh: Converted to bourne shell script.
20
+
21
+	* pandora_agent_daemon: Small bug fixes and refactorings.
22
+
23
+2014-08-12  Ramon Novoa  <rnovoa@artica.es>
24
+
25
+	* pandora_agent: Fixed to make the 'Command Snapshot' feature work.
26
+
27
+2014-08-12  Ramon Novoa  <rnovoa@artica.es>
28
+
29
+	* pandora_agent: Trim leading and trailing whitespaces from module names
30
+	  (like policies and windows agents do).
31
+
32
+2014-08-07  Ramon Novoa  <rnovoa@artica.es>
33
+
34
+	* pandora_agent_daemon: Fixes the ps call on HP-UX.
35
+
36
 2014-06-04  Koichiro KIKUCHI <koichiro@rworks.jp>
37
 
38
 	* pandora_agent: Allow spaces in module group names.
39
Index: pandora_agent_installer
40
===================================================================
41
--- pandora_agent_installer	(revision 10314)
42
+++ pandora_agent_installer	(working copy)
43
@@ -15,49 +15,79 @@
44
 
45
 FORCE=0
46
 LOG_TIMESTAMP=`date +"%Y/%m/%d %H:%M:%S"`
47
-PANDORA_HOME=/usr/share/pandora_agent
48
-PANDORA_BIN=/usr/bin/pandora_agent
49
-PANDORA_EXEC_BIN=/usr/bin/pandora_agent_exec
50
-PANDORA_REVENT_BIN=/usr/bin/pandora_revent
51
+
52
+PREFIX=/usr
53
+if [ "$OS_NAME" = "FreeBSD" ] || [ "$OS_NAME" = "NetBSD" ]
54
+then
55
+	PREFIX=/usr/local
56
+fi
57
+PANDORA_HOME=$PREFIX/share/pandora_agent
58
+PANDORA_BIN=$PREFIX/bin/pandora_agent
59
+PANDORA_EXEC_BIN=$PREFIX/bin/pandora_agent_exec
60
+PANDORA_REVENT_BIN=$PREFIX/bin/pandora_revent
61
 PANDORA_TEMP=/var/spool/pandora
62
 PANDORA_CFG=/etc/pandora
63
 PANDORA_LOG_DIR=/var/log/pandora
64
 PANDORA_LOG=pandora_agent.log
65
-TENTACLE=/usr/bin/tentacle_client
66
-TENTACLE_SERVER=/usr/bin/tentacle_server
67
-PANDORA_MAN=/usr/share/man
68
+TENTACLE=$PREFIX/bin/tentacle_client
69
+TENTACLE_SERVER=$PREFIX/bin/tentacle_server
70
+PANDORA_MAN=$PREFIX/share/man
71
+PANDORA_STARTUP=/etc/init.d/pandora_agent_daemon
72
+DAEMON_SCRIPT=pandora_agent_daemon
73
+PANDORA_USER="root"
74
+PANDORA_PERL_PATH="perl"
75
+WITHOUT_TENTACLE_SERVER=0
76
+FAKEROOT=0
77
 
78
+# defaults for each platforms
79
+case $OS_NAME in
80
+AIX)
81
+    PANDORA_STARTUP=/etc/rc.pandora_agent_daemon
82
+	;;
83
+HP-UX)
84
+	PANDORA_STARTUP=/sbin/init.d/pandora_agent_daemon
85
+	;;
86
+FreeBSD)
87
+	PANDORA_CFG=$PREFIX/etc/pandora
88
+	PANDORA_MAN=$PREFIX/man
89
+	PANDORA_STARTUP=$PREFIX/etc/rc.d/pandora_agent
90
+	DAEMON_SCRIPT=$OS_NAME/pandora_agent
91
+	PANDORA_PERL_PATH=/usr/local/bin/perl
92
+	;;
93
+NetBSD)
94
+	PANDORA_CFG=/usr/local/etc/pandora
95
+	PANDORA_STARTUP=/etc/rc.d/pandora_agent
96
+	DAEMON_SCRIPT=$OS_NAME/pandora_agent
97
+	PANDORA_PERL_PATH=/usr/pkg/bin/perl
98
+	;;
99
+esac
100
+
101
 MODE=$1
102
-PANDORA_BASE=`echo $2 | sed -e 's/\/$//'`
103
+
104
+# options
105
+while :
106
+do
107
+	case "$2" in 
108
+	"--no-tentacle-server") WITHOUT_TENTACLE_SERVER=1;;
109
+	"--fakeroot") FAKEROOT=1;;
110
+	*) break;;
111
+	esac
112
+	shift
113
+done
114
+
115
+PANDORA_BASE=`echo $2 | sed -e 's|/$||'`
116
 if [ "$3" != "" ]
117
 then
118
 	PANDORA_USER=$3
119
-	if [ "$PANDORA_BASE" = "" ]
120
+	if [ -z "$PANDORA_BASE" ]
121
 	then
122
 		echo "When specifying a custom user the agent must be installed to a custom location where that user has write permissions!"
123
 		exit 1
124
 	fi
125
-else
126
-	PANDORA_USER="root"
127
 fi
128
 
129
-if [ "$4" != "" ]
130
-then
131
-	PANDORA_PERL_PATH=$4
132
-	echo $PANDORA_PERL_PATH > PANDORA_PERL_PATH.temp
133
-        sed 's/\//\\\//g' PANDORA_PERL_PATH.temp > PANDORA_PERL_PATH.temp2
134
+[ "$4" ] && PANDORA_PERL_PATH=$4
135
 
136
-        PANDORA_PERL_DECODED_PATH=`cat PANDORA_PERL_PATH.temp2`
137
-        rm PANDORA_PERL_PATH.temp PANDORA_PERL_PATH.temp2
138
-	#PANDORA_PERL_DECODED_PATH=`echo $PANDORA_PERL_PATH | sed -e "s.\/.\\\\\/.g"`
139
-else
140
-	PANDORA_PERL_PATH="perl"
141
-	if [ "$OS_NAME" = "NetBSD" ]
142
-	then
143
-		PANDORA_PERL_DECODED_PATH="/usr/pkg/bin/perl"
144
-	fi
145
-fi
146
-
147
 # Check for Perl 5.6.x or higher available
148
 PERL_VERSION=`$PANDORA_PERL_PATH -v | egrep 'v5.6|v5.7|v5.8|v5.9|v5.1[0-9]' | grep perl`
149
 
150
@@ -69,17 +99,16 @@
151
 	exit 2
152
 fi
153
 
154
-UNIX_KIND=`uname -s`
155
-if [ -z "`echo Linux HP-UX SunOS AIX Solaris Darwin BSD bsd FreeBSD NetBSD | grep \"$UNIX_KIND\"`" ]
156
+if [ -z "`echo Linux HP-UX SunOS AIX Solaris Darwin BSD bsd FreeBSD NetBSD | grep \"$OS_NAME\"`" ]
157
 then
158
-	echo "This system: '$UNIX_KIND' is not supported by this script"
159
+	echo "This system: '$OS_NAME' is not supported by this script"
160
 	echo "Please make the install yourself as it's described in documentation"
161
 	exit 1
162
 fi
163
 
164
 
165
 # check for root to do the install
166
-if [ -z "`id | grep \"uid=0(root)\"`" ]
167
+if [ $FAKEROOT -ne 1 ] && [ -z "`id | grep \"uid=0(root)\"`" ]
168
 then
169
 	echo "You need to be root to do the install. Please made a manual install"
170
 	echo "if you want to install Pandora FMS agent without root"
171
@@ -91,7 +120,7 @@
172
 help () {
173
 	echo "Syntax":
174
 	echo " "
175
-	echo "    ./pandora_agent_installer < --mode > [ destination_path ] [ user_to_run_as ] [custom_perl_path]"
176
+	echo "    ./pandora_agent_installer < --mode > [ --option ] [ destination_path ] [ user_to_run_as ] [custom_perl_path]"
177
 	echo " "
178
 	echo "Modes:"
179
 	echo " "
180
@@ -99,6 +128,11 @@
181
 	echo "  --install            To install Pandora FMS Agent on this system"
182
 	echo "  --uninstall          To uninstall/remove Pandora FMS Agent on this System"
183
 	echo " "	
184
+	echo "Option:"
185
+	echo " "
186
+	echo "  --no-tentacle-server  Skip tentacle server installation (by default tentalce server installed)"
187
+	echo "  --fakeroot            treate \"destination_path\" as root directory"
188
+	echo " "
189
 	echo "Some exaples of how to use the installer:"
190
 	echo " "
191
 	echo "   ./pandora_agent_installer --install"
192
@@ -110,38 +144,12 @@
193
 }
194
 
195
 uninstall () {
196
-	OS_NAME=`uname -s`
197
-
198
 	if [ "$OS_NAME" = "Darwin" ]
199
         then
200
 		launchctl remove com.pandorafms.pandorafms 
201
 		rm /Library/LaunchDaemons/com.pandorafms.pandorafms.plist 2> /dev/null
202
 	fi
203
 
204
-
205
-	if [ "$OS_NAME" = "FreeBSD" ]
206
-	then
207
-		PANDORA_HOME=/usr/local/share/pandora_agent
208
-		PANDORA_BIN=/usr/local/bin/pandora_agent
209
-		PANDORA_EXEC_BIN=/usr/local/bin/pandora_agent_exec
210
-		PANDORA_REVENT_BIN=/usr/local/bin/pandora_revent
211
-		PANDORA_CFG=/usr/local/etc/pandora
212
-		TENTACLE=/usr/local/bin/tentacle_client
213
-		TENTACLE_SERVER=/usr/local/bin/tentacle_server
214
-		PANDORA_MAN=/usr/local/man
215
-	fi
216
-	if [ "$OS_NAME" = "NetBSD" ]
217
-	then
218
-		PANDORA_HOME=/usr/local/share/pandora_agent
219
-		PANDORA_BIN=/usr/local/bin/pandora_agent
220
-		PANDORA_EXEC_BIN=/usr/local/bin/pandora_agent_exec
221
-		PANDORA_REVENT_BIN=/usr/local/bin/pandora_revent
222
-		PANDORA_CFG=/usr/local/etc/pandora
223
-		TENTACLE=/usr/local/bin/tentacle_client
224
-		TENTACLE_SERVER=/usr/local/bin/tentacle_server
225
-		PANDORA_MAN=/usr/share/man
226
-	fi
227
-
228
 	echo "Removing Pandora FMS Agent..."
229
 	rm -Rf $PANDORA_BASE$PANDORA_BIN 2> /dev/null
230
 	rm -Rf $PANDORA_BASE$PANDORA_EXEC_BIN 2> /dev/null
231
@@ -168,16 +176,19 @@
232
 	rm -Rf $PANDORA_BASE/etc/rc.d/rc?.d/S90pandora_agent_daemon 2> /dev/null
233
 	rm -Rf $PANDORA_BASE/etc/rc.d/rc?.d/S90pandora_agent 2> /dev/null
234
 	rm -Rf $PANDORA_BASE/usr/local/etc/rc.d/pandora_agent 2> /dev/null
235
-	rm -Rf /etc/init.d/pandora_agent_daemon 2> /dev/null
236
-	rm -Rf /sbin/init.d/pandora_agent_daemon 2> /dev/null
237
-	rm -Rf /etc/rc.pandora_agent_daemon 2> /dev/null
238
-	rm -Rf /etc/rc?.d/S90pandora_agent_daemon 2> /dev/null
239
-	rm -Rf /sbin/rc?.d/S90pandora_agent_daemon 2> /dev/null
240
-	rm -Rf /etc/rc?.d/S90pandora_agent 2> /dev/null
241
-	rm -Rf /sbin/rc?.d/S90pandora_agent 2> /dev/null
242
-	rm -Rf /etc/rc.d/rc?.d/S90pandora_agent_daemon 2> /dev/null
243
-	rm -Rf /etc/rc.d/rc?.d/S90pandora_agent 2> /dev/null
244
-	rm -Rf /usr/local/etc/rc.d/pandora_agent 2> /dev/null
245
+	if [ $FAKEROOT -ne 1 ]
246
+	then
247
+		rm -Rf /etc/init.d/pandora_agent_daemon 2> /dev/null
248
+		rm -Rf /sbin/init.d/pandora_agent_daemon 2> /dev/null
249
+		rm -Rf /etc/rc.pandora_agent_daemon 2> /dev/null
250
+		rm -Rf /etc/rc?.d/S90pandora_agent_daemon 2> /dev/null
251
+		rm -Rf /sbin/rc?.d/S90pandora_agent_daemon 2> /dev/null
252
+		rm -Rf /etc/rc?.d/S90pandora_agent 2> /dev/null
253
+		rm -Rf /sbin/rc?.d/S90pandora_agent 2> /dev/null
254
+		rm -Rf /etc/rc.d/rc?.d/S90pandora_agent_daemon 2> /dev/null
255
+		rm -Rf /etc/rc.d/rc?.d/S90pandora_agent 2> /dev/null
256
+		rm -Rf /usr/local/etc/rc.d/pandora_agent 2> /dev/null
257
+	fi
258
 	
259
 	rm -Rf $PANDORA_BASE$PANDORA_HOME 2> /dev/null
260
 	rm -Rf $PANDORA_BASE$PANDORA_LOG_DIR 2> /dev/null
261
@@ -201,36 +212,48 @@
262
 	echo "Done"
263
 }
264
 
265
-install () {
266
+#
267
+# install_perl_script [OPTIONS] SRCFILE DESTFILE
268
+#	Install perl script. If PANDORA_PERL_DECODED_PATH is set, path of the perl
269
+#	in shebang line is replaced with PANDORA_PERL_DECODED_PATH value.
270
+#	OPTIONS:
271
+#		-o OWNER  owner of the installed script
272
+#		-g GROUP  group of the installed script
273
+#		-m PREM   mode of the installed script
274
+#
275
+install_perl_script () {
276
+	OWNER=""; GROUP=""; PERM=""
277
+	while :
278
+	do
279
+		case $1 in
280
+		-o) OWNER=$2;;
281
+		-g) GROUP=$2;;
282
+		-m) PERM=$2;;
283
+		*)  break;;
284
+		esac
285
+		shift;shift
286
+	done
287
+	SRC="$1"
288
+	DEST="$2"
289
 
290
-	OS_VERSION=`uname -r`
291
-	OS_NAME=`uname -s`
292
-	OLDFILENAMETMP=`date +"%Y-%m-%d"`
293
-
294
-	if [ "$OS_NAME" = "FreeBSD" ]
295
+	# do install
296
+	if echo $PANDORA_PERL_PATH | grep "/" > /dev/null && [ "$PANDORA_PERL_PATH" != "/usr/bin/perl" ]
297
 	then
298
-		PANDORA_HOME=/usr/local/share/pandora_agent
299
-		PANDORA_BIN=/usr/local/bin/pandora_agent
300
-		PANDORA_EXEC_BIN=/usr/local/bin/pandora_agent_exec
301
-		PANDORA_REVENT_BIN=/usr/local/bin/pandora_revent
302
-		PANDORA_CFG=/usr/local/etc/pandora
303
-		TENTACLE=/usr/local/bin/tentacle_client
304
-		TENTACLE_SERVER=/usr/local/bin/tentacle_server
305
-		PANDORA_MAN=/usr/local/man
306
+		sed -e "s:^#\!.*:#\!$PANDORA_PERL_PATH:g" $SRC > $DEST
307
+	else
308
+		cp $SRC $DEST
309
 	fi
310
 
311
-	if [ "$OS_NAME" = "NetBSD" ]
312
-	then
313
-		PANDORA_HOME=/usr/local/share/pandora_agent
314
-		PANDORA_BIN=/usr/local/bin/pandora_agent
315
-		PANDORA_EXEC_BIN=/usr/local/bin/pandora_agent_exec
316
-		PANDORA_REVENT_BIN=/usr/local/bin/pandora_revent
317
-		PANDORA_CFG=/usr/local/etc/pandora
318
-		TENTACLE=/usr/local/bin/tentacle_client
319
-		TENTACLE_SERVER=/usr/local/bin/tentacle_server
320
-		PANDORA_MAN=/usr/share/man
321
-	fi
322
+	# set owner, group and permissions
323
+	[ "$OWNER" ] && chown $OWNER $DEST 2>/dev/null
324
+	[ "$GROUP" ] && chgrp $GROUP $DEST 2>/dev/null
325
+	[ "$PERM"  ] && chmod $PERM  $DEST
326
+}
327
 
328
+install () {
329
+	OS_VERSION=`uname -r`
330
+	OLDFILENAMETMP=`date +"%Y-%m-%d"`
331
+
332
 	echo "Detecting Unix distribution: $OS_NAME version $OS_VERSION"
333
 	if [ -f $PANDORA_BASE$PANDORA_HOME ] && [ "$FORCE" = "0" ]
334
 	then
335
@@ -253,87 +276,49 @@
336
 
337
 	# Alter dynamically the daemon launcher and setup the new path 
338
 	# if PANDORA_BASE is customized.
339
-	if [ ! -z "$PANDORA_BASE" ]
340
+	if [ "$PANDORA_BASE" ] && [ $FAKEROOT -ne 1 ]
341
 	then
342
-		if [ "$OS_NAME" = "FreeBSD" ]
343
-		then
344
-			DAEMON_SCRIPT=FreeBSD/pandora_agent
345
-			DAEMON_TEMP=pandora_agent_daemon_temp
346
-		elif [ "$OS_NAME" = "NetBSD" ]
347
-		then
348
-			DAEMON_SCRIPT=NetBSD/pandora_agent
349
-			DAEMON_TEMP=pandora_agent_daemon_temp
350
-		else
351
-			DAEMON_SCRIPT=pandora_agent_daemon
352
-			DAEMON_TEMP=pandora_agent_daemon_temp
353
-		fi
354
+		DAEMON_TEMP=pandora_agent_daemon_temp
355
 
356
 		# Backup the daemon script
357
-		cp -f "$DAEMON_SCRIPT" "$DAEMON_SCRIPT.bak"
358
+		cp -f "$DAEMON_SCRIPT" "${DAEMON_SCRIPT}.bak"
359
 		
360
 		AGENT_CFG=$OS_NAME/pandora_agent.conf
361
 		AGENT_CFG_TEMP=$OS_NAME/pandora_agent.conf.temp
362
 
363
 		# Backup the configuration file
364
-		cp -f "$AGENT_CFG" "$AGENT_CFG.bak"
365
+		cp -f "$AGENT_CFG" "${AGENT_CFG}.bak"
366
 
367
-		echo $PANDORA_BASE > PANDORA_BASE.temp
368
-		sed 's/\//\\\//g' PANDORA_BASE.temp > PANDORA_BASE.temp2
369
-
370
-		PANDORA_BASE_DECODED=`cat PANDORA_BASE.temp2`
371
-		rm PANDORA_BASE.temp PANDORA_BASE.temp2
372
-
373
-		if [ "$OS_NAME" = "FreeBSD" -o "$OS_NAME" = "NetBSD" ]
374
+		if [ "$OS_NAME" = "FreeBSD" ] || [ "$OS_NAME" = "NetBSD" ]
375
 		then
376
-			sed -e "s/^PATH\=[.]*/PATH\=$PANDORA_BASE_DECODED\/usr\/local\/bin\:/g" $DAEMON_SCRIPT > $DAEMON_TEMP
377
+			sed -e "\|^PATH=|s|=|=$PANDORA_BASE$PREFIX/bin:|" \
378
+				-e "s|/usr/local/etc/pandora|$PANDORA_BASE$PANDORA_CFG|g" \
379
+				-e "s|/usr/local/bin/pandora_agent|$PANDORA_BASE$PANDORA_BIN|g" \
380
+				$DAEMON_SCRIPT > $DAEMON_TEMP
381
 			mv $DAEMON_TEMP $DAEMON_SCRIPT
382
-
383
-			sed -e "s/^command\=[.]*/command\=$PANDORA_BASE_DECODED/g" $DAEMON_SCRIPT > $DAEMON_TEMP
384
-			mv $DAEMON_TEMP $DAEMON_SCRIPT
385
-
386
-			sed -e 's/^command_args\=\"[.]*/command_args\=\"$PANDORA_BASE_DECODED/g' $DAEMON_SCRIPT > $DAEMON_TEMP
387
-			mv $DAEMON_TEMP $DAEMON_SCRIPT
388
-
389
-			sed -e 's/^required_files\=\"[.]*/required_files\=\"$PANDORA_BASE_DECODED/g' $DAEMON_SCRIPT > $DAEMON_TEMP
390
-			mv $DAEMON_TEMP $DAEMON_SCRIPT
391
 		else
392
-			sed -e "s/^PATH\=[.]*/PATH\=$PANDORA_BASE_DECODED\/usr\/bin\:/g" $DAEMON_SCRIPT > $DAEMON_TEMP
393
+			sed -e "\|^PATH=|s|=|=$PANDORA_BASE/usr/bin:|" \
394
+				-e "\|^PANDORA_PATH=|s|=|=$PANDORA_BASE|" \
395
+				-e "\|^LOGFILE=|s|=|=$PANDORA_BASE|" \
396
+				-e "\|^DAEMON=|s|=|=$PANDORA_BASE|" \
397
+				-e "\|^DAEMON_TENTACLE=|s|=|=$PANDORA_BASE|" \
398
+				-e "s/^PANDORA_USER=.*/PANDORA_USER=$PANDORA_USER/"  \
399
+				$DAEMON_SCRIPT > $DAEMON_TEMP
400
 			mv  $DAEMON_TEMP $DAEMON_SCRIPT
401
-
402
-			sed -e "s/^PANDORA_PATH\=[.]*/PANDORA_PATH\=$PANDORA_BASE_DECODED/g"  $DAEMON_SCRIPT > $DAEMON_TEMP
403
-			mv  $DAEMON_TEMP $DAEMON_SCRIPT
404
-
405
-			sed -e "s/^LOGFILE\=[.]*/LOGFILE\=$PANDORA_BASE_DECODED/g"  $DAEMON_SCRIPT > $DAEMON_TEMP
406
-			mv  $DAEMON_TEMP $DAEMON_SCRIPT
407
-
408
-			sed -e "s/^DAEMON\=[.]*/DAEMON\=$PANDORA_BASE_DECODED/g"  $DAEMON_SCRIPT > $DAEMON_TEMP
409
-			mv  $DAEMON_TEMP $DAEMON_SCRIPT
410
-
411
-			sed -e "s/^DAEMON_TENTACLE\=[.]*/DAEMON_TENTACLE\=$PANDORA_BASE_DECODED/g"  $DAEMON_SCRIPT > $DAEMON_TEMP
412
-                        mv  $DAEMON_TEMP $DAEMON_SCRIPT
413
- 
414
-			sed -e "s/^PANDORA_USER\=.*/PANDORA_USER\=$PANDORA_USER/g"  $DAEMON_SCRIPT > $DAEMON_TEMP
415
-			mv  $DAEMON_TEMP $DAEMON_SCRIPT
416
 		fi
417
 
418
-		sed -e "s/^temporal [.]*/temporal $PANDORA_BASE_DECODED/g" $AGENT_CFG > $AGENT_CFG_TEMP
419
+		sed -e "s|^temporal[ 	]*|temporal $PANDORA_BASE|" \
420
+			-e "s|^logfile[ 	]*|logfile $PANDORA_BASE|" \
421
+			$AGENT_CFG > $AGENT_CFG_TEMP
422
 		mv $AGENT_CFG_TEMP $AGENT_CFG
423
-
424
-		sed -e "s/^logfile [.]*/logfile $PANDORA_BASE_DECODED/g" $AGENT_CFG > $AGENT_CFG_TEMP
425
-		mv $AGENT_CFG_TEMP $AGENT_CFG
426
 	fi
427
 	echo "Creating Pandora FMS Agent home directory at $PANDORA_BASE$PANDORA_HOME"
428
-	if [ ! -z "$PANDORA_BASE" ]
429
+	if [ "$PANDORA_BASE" ]
430
 	then
431
 		mkdir -p $PANDORA_BASE 2> /dev/null
432
 		mkdir -p $PANDORA_BASE/var/log 2> /dev/null
433
 		mkdir -p $PANDORA_BASE/$PANDORA_MAN/man1 2> /dev/null
434
-		if [ "$OS_NAME" = "FreeBSD" -o "$OS_NAME" = "NetBSD" ]
435
-		then
436
-			mkdir -p $PANDORA_BASE/usr/local/bin 2> /dev/null
437
-		else
438
-			mkdir -p $PANDORA_BASE/usr/bin 2> /dev/null
439
-		fi
440
+		mkdir -p $PANDORA_BASE$PREFIX/bin 2> /dev/null
441
 	fi
442
 
443
 	mkdir -p $PANDORA_BASE$PANDORA_HOME 2> /dev/null
444
@@ -344,14 +329,14 @@
445
 	mkdir -p $PANDORA_BASE$PANDORA_TEMP/data_out 2> /dev/null
446
 	mkdir -p $PANDORA_BASE$PANDORA_CFG 2> /dev/null
447
 	mkdir -p $PANDORA_BASE$PANDORA_LOG_DIR 2> /dev/null
448
-
449
+	
450
 	# Set the user the agent will run as
451
 	if [ "$PANDORA_USER" != "root" ]
452
 	then
453
 		sed -e "s/.*pandora_user .*/pandora_user $PANDORA_USER/" $AGENT_CFG > $AGENT_CFG_TEMP 2> /dev/null && \
454
-		mv $AGENT_CFG_TEMP $AGENT_CFG
455
+			mv $AGENT_CFG_TEMP $AGENT_CFG
456
 		chmod 755 pandora_agent_daemon
457
-		chown -R $PANDORA_USER $PANDORA_BASE
458
+		chown -R $PANDORA_USER $PANDORA_BASE 2>/dev/null
459
 	fi
460
 
461
 	# Create logfile
462
@@ -365,32 +350,10 @@
463
 
464
 	# Copying agent and securing it
465
 	echo "Copying Pandora FMS Agent to $PANDORA_BASE$PANDORA_BIN..."
466
+	install_perl_script -m 755 -o $PANDORA_USER -g 0 pandora_agent $PANDORA_BASE$PANDORA_BIN
467
+	install_perl_script -m 755 -o $PANDORA_USER -g 0 pandora_agent_exec $PANDORA_BASE$PANDORA_EXEC_BIN
468
+	install_perl_script -m 755 -o $PANDORA_USER -g 0 pandora_revent $PANDORA_BASE$PANDORA_REVENT_BIN
469
 
470
-	if [ "$PANDORA_PERL_DECODED_PATH" != "" ]
471
-	then
472
-        	sed -e "s:^#\!.*:#\!$PANDORA_PERL_DECODED_PATH:g" pandora_agent > $PANDORA_BASE$PANDORA_BIN
473
-	else
474
-        	cp pandora_agent $PANDORA_BASE$PANDORA_BIN
475
-	fi
476
-	chmod 755 $PANDORA_BASE$PANDORA_BIN
477
-	if [ "$PANDORA_PERL_DECODED_PATH" != "" ]
478
-        then
479
-                sed -e "s:^#\!.*:#\!$PANDORA_PERL_DECODED_PATH:g" pandora_agent_exec > $PANDORA_BASE$PANDORA_EXEC_BIN
480
-        else
481
-                cp pandora_agent_exec $PANDORA_BASE$PANDORA_EXEC_BIN
482
-        fi
483
-	chmod 755 $PANDORA_BASE$PANDORA_EXEC_BIN
484
-	if [ "$PANDORA_PERL_DECODED_PATH" != "" ]
485
-        then
486
-                sed -e "s:^#\!.*:#\!$PANDORA_PERL_DECODED_PATH:g" pandora_revent > $PANDORA_BASE$PANDORA_REVENT_BIN
487
-        else
488
-                cp pandora_revent $PANDORA_BASE$PANDORA_REVENT_BIN
489
-        fi
490
-	chmod 755 $PANDORA_BASE$PANDORA_REVENT_BIN
491
-	chown $PANDORA_USER:0 $PANDORA_BASE$PANDORA_BIN
492
-	chown $PANDORA_USER:0 $PANDORA_BASE$PANDORA_EXEC_BIN
493
-	chown $PANDORA_USER:0 $PANDORA_BASE$PANDORA_REVENT_BIN
494
-
495
 	echo "Copying Pandora FMS Agent configuration file to $PANDORA_BASE$PANDORA_CFG/pandora_agent.conf..."
496
 	if [ -f $PANDORA_BASE/$PANDORA_CFG/pandora_agent.conf ]
497
 	then
498
@@ -400,49 +363,36 @@
499
 
500
 	echo "Copying Pandora FMS Agent plugins to $PANDORA_BASE$PANDORA_HOME/plugins..."
501
 
502
-	if [ "$OS_NAME" = "NetBSD" ]
503
-	then
504
-		if [ ! -d $PANDORA_BASE$PANDORA_HOME/plugins ]
505
+	[ -d $PANDORA_BASE$PANDORA_HOME/plugins ] || mkdir -p $PANDORA_BASE$PANDORA_HOME/plugins >/dev/null 2>&1
506
+	for PLUGIN in plugins/*
507
+	do
508
+		if grep '^#!.*/perl' $PLUGIN >/dev/null 2>&1
509
 		then
510
-			mkdir -p $PANDORA_BASE$PANDORA_HOME/plugins
511
+			install_perl_script $PLUGIN $PANDORA_BASE$PANDORA_HOME/$PLUGIN
512
+		else
513
+			cp $PLUGIN $PANDORA_BASE$PANDORA_HOME/plugins
514
 		fi
515
-		for i in `ls -1 plugins`
516
-		do 
517
-			sed s:/usr/bin/perl:/usr/pkg/bin/perl: plugins/$i > plugins/$i.tmp
518
-			cp plugins/$i.tmp $PANDORA_BASE$PANDORA_HOME/plugins/$i
519
-			rm plugins/$i.tmp
520
-		done
521
-	else
522
-		cp -r plugins $PANDORA_BASE$PANDORA_HOME
523
-	fi
524
-
525
+	done
526
 	chmod -R 700 $PANDORA_BASE$PANDORA_HOME/plugins
527
-	ln -s $PANDORA_BASE$PANDORA_HOME/plugins $PANDORA_BASE$PANDORA_CFG
528
 
529
+	PANDORA_BASE_REAL="$PANDORA_BASE"
530
+	[ $FAKEROOT -eq 1 ] && PANDORA_BASE_REAL=""
531
+
532
+	ln -s $PANDORA_BASE_REAL$PANDORA_HOME/plugins $PANDORA_BASE$PANDORA_CFG
533
+
534
 	echo "Copying Pandora FMS Agent collections to $PANDORA_BASE$PANDORA_HOME/collections..."
535
 	cp -r collections $PANDORA_BASE$PANDORA_HOME
536
 	chmod -R 700 $PANDORA_BASE$PANDORA_HOME/collections
537
-	ln -s $PANDORA_BASE$PANDORA_HOME/collections $PANDORA_BASE$PANDORA_CFG
538
+	ln -s $PANDORA_BASE_REAL$PANDORA_HOME/collections $PANDORA_BASE$PANDORA_CFG
539
 	
540
-	echo "Copying tentacle server to $PANDORA_BASE$TENTACLE_SERVER"
541
-	if [ "$PANDORA_PERL_DECODED_PATH" != "" ]
542
-        then
543
-                sed -e "s:^#\!.*:#\!$PANDORA_PERL_DECODED_PATH:g" tentacle_server > $PANDORA_BASE$TENTACLE_SERVER
544
-        else
545
-                cp tentacle_server $PANDORA_BASE$TENTACLE_SERVER
546
-        fi
547
-	chmod 755 $PANDORA_BASE$TENTACLE_SERVER	
548
-	chown $PANDORA_USER:0 $PANDORA_BASE$TENTACLE_SERVER
549
+	if [ $WITHOUT_TENTACLE_SERVER -eq 0 ]
550
+	then
551
+		echo "Copying tentacle server to $PANDORA_BASE$TENTACLE_SERVER"
552
+		install_perl_script -m 755 -o $PANDORA_USER -g 0 tentacle_server $PANDORA_BASE$TENTACLE_SERVER
553
+	fi
554
 	
555
 	echo "Copying tentacle client to $PANDORA_BASE$TENTACLE"
556
-	if [ "$PANDORA_PERL_DECODED_PATH" != "" ]
557
-        then
558
-                sed -e "s:^#\!.*:#\!$PANDORA_PERL_DECODED_PATH:g" tentacle_client > $PANDORA_BASE$TENTACLE
559
-        else
560
-                cp tentacle_client $PANDORA_BASE$TENTACLE
561
-        fi
562
-	chmod 755 $PANDORA_BASE$TENTACLE
563
-	chown $PANDORA_USER:0 $PANDORA_BASE$TENTACLE	
564
+	install_perl_script -m 755 -o $PANDORA_USER -g 0 tentacle_client $PANDORA_BASE$TENTACLE	
565
 
566
 	echo "Installing the Pandora Agent and Tentacle Client manuals"
567
 	cp man/man1/tentacle_client.1.gz $PANDORA_BASE/$PANDORA_MAN/man1
568
@@ -451,14 +401,14 @@
569
 	chmod 644 $PANDORA_BASE/$PANDORA_MAN/man1/pandora_agent.1.gz
570
 
571
 	echo "Setting secure permissions and ownership for all Pandora FMS Agent files..."
572
-	chown -R $PANDORA_USER $PANDORA_BASE$PANDORA_HOME
573
+	chown -R $PANDORA_USER $PANDORA_BASE$PANDORA_HOME  2>/dev/null
574
 	chmod -R 700 $PANDORA_BASE$PANDORA_TEMP/data_out
575
 	chmod 711 $PANDORA_BASE$PANDORA_LOG_DIR
576
 	chmod 640 $PANDORA_BASE$PANDORA_LOG_DIR/$PANDORA_LOG
577
-	chown $PANDORA_USER:0 $PANDORA_BASE$PANDORA_LOG_DIR/$PANDORA_LOG
578
-	if [ "$OS_NAME" = "FreeBSD" -o "$OS_NAME" = "NetBSD" ]
579
+	chown $PANDORA_USER:0 $PANDORA_BASE$PANDORA_LOG_DIR/$PANDORA_LOG  2>/dev/null
580
+	if [ "$OS_NAME" = "FreeBSD" ] || [ "$OS_NAME" = "NetBSD" ]
581
 	then
582
-		chown $PANDORA_USER:daemon $PANDORA_BASE$PANDORA_TEMP
583
+		chown $PANDORA_USER:daemon $PANDORA_BASE$PANDORA_TEMP 2>/dev/null
584
 		chmod -R 770 $PANDORA_BASE$PANDORA_TEMP
585
 		chmod 775 $PANDORA_BASE$PANDORA_TEMP
586
 	fi
587
@@ -467,85 +417,55 @@
588
 
589
 	cp $OS_NAME/pandora_agent.conf $PANDORA_BASE$PANDORA_CFG/pandora_agent.conf
590
 	chmod 600 $PANDORA_BASE$PANDORA_CFG/pandora_agent.conf
591
-	chown $PANDORA_USER $PANDORA_BASE$PANDORA_CFG/pandora_agent.conf
592
+	chown $PANDORA_USER $PANDORA_BASE$PANDORA_CFG/pandora_agent.conf 2>/dev/null
593
 
594
-	if [ "$OS_NAME" = "FreeBSD" -o "$OS_NAME" = "NetBSD" ]
595
+	echo "Linking start-up daemon script '$DAEMON_SCRIPT' on $OS_NAME";
596
+
597
+	if [ "$OS_NAME" = "Darwin" ]
598
 	then
599
-		echo "Linking start-up daemon script 'pandora_agent' on $OS_NAME";
600
+		# Specific service install on Darwin/macOSX
601
+		launchctl load -F Darwin/com.pandorafms.pandorafms.plist
602
+		echo "Start Pandora FMS service with 'launchctl start com.pandorafms.pandorafms'"
603
+		echo "This service has been scheduled to launch on each system startup"
604
 	else
605
-		echo "Linking start-up daemon script 'pandora_agent_daemon' on $OS_NAME";
606
-	fi
607
+		DESTDIR=""
608
+		[ "$PANDORA_BASE" ] && [ $FAKEROOT -eq 1 ] && DESTDIR=$PANDORA_BASE
609
 
610
-	if [ "$OS_NAME" = "Darwin" ]
611
-        then
612
-        	# Specific service install on Darwin/macOSX
613
-                launchctl load -F Darwin/com.pandorafms.pandorafms.plist
614
-                echo "Start Pandora FMS service with 'launchctl start com.pandorafms.pandorafms'"
615
-                echo "This service has been scheduled to launch on each system startup"
616
-        fi
617
+		cp $DAEMON_SCRIPT $DESTDIR$PANDORA_STARTUP
618
+		chmod 755 $DESTDIR$PANDORA_STARTUP
619
+		chown root:0 $DESTDIR$PANDORA_STARTUP 2>/dev/null
620
 
621
-	if [ "$OS_NAME" = "AIX" ]
622
-	then
623
-		cp pandora_agent_daemon /etc/rc.pandora_agent_daemon		
624
-		ln -s /etc/rc.pandora_agent_daemon /etc/rc.d/rc2.d/S90pandora_agent_daemon
625
-		chmod 755 $PANDORA_STARTUP
626
-		chown root:0 $PANDORA_STARTUP
627
-		echo "Pandora FMS agent has been included in /etc/rc.d/rc2.d/S90pandora_agent_daemon"
628
-	fi
629
-	
630
-	if [ $OS_NAME = "HP-UX" ]
631
-	then
632
-		PANDORA_STARTUP=/sbin/init.d/pandora_agent_daemon
633
-		cp pandora_agent_daemon $PANDORA_STARTUP
634
-		ln -s /sbin/init.d/pandora_agent_daemon /sbin/rc3.d/S90pandora_agent_daemon 2> /dev/null
635
-		ln -s /sbin/init.d/pandora_agent_daemon /sbin/rc2.d/S90pandora_agent_daemon 2> /dev/null
636
-		chmod 755 $PANDORA_STARTUP
637
-		chown root:0 $PANDORA_STARTUP
638
-		echo "Pandora FMS agent has been included in /sbin/rcX.d/S90pandora_agent_daemon"
639
-	fi
640
-	
641
-	if [ $OS_NAME = "SunOS" ]
642
-	then
643
-		PANDORA_STARTUP=/etc/init.d/pandora_agent_daemon
644
-		cp pandora_agent_daemon $PANDORA_STARTUP 
645
-		ln -s /etc/init.d/pandora_agent_daemon /etc/rc2.d/S90pandora_agent_daemon 2> /dev/null
646
-		chmod 755 $PANDORA_STARTUP
647
-		chown root:0 $PANDORA_STARTUP
648
-		echo "Pandora FMS agent has been included in /etc/rc2.d/S90pandora_agent_daemon"
649
-	fi
650
-	
651
-	if [ $OS_NAME = "Linux" ]
652
-	then
653
-		PANDORA_STARTUP=/etc/init.d/pandora_agent_daemon
654
-		cp pandora_agent_daemon $PANDORA_STARTUP
655
-		if [ -d /etc/rc.d/ ]
656
+		RCDIRS=""
657
+		MSG=""
658
+		if [ "$OS_NAME" = "AIX" ]
659
 		then
660
-			ln -s /etc/init.d/pandora_agent_daemon /etc/rc.d/rc2.d/S90pandora_agent 2> /dev/null
661
-			ln -s /etc/init.d/pandora_agent_daemon /etc/rc.d/rc3.d/S90pandora_agent 2> /dev/null
662
-		else
663
-			ln -s /etc/init.d/pandora_agent_daemon /etc/rc2.d/S90pandora_agent 2> /dev/null
664
-			ln -s /etc/init.d/pandora_agent_daemon /etc/rc2.d/S90pandora_agent 2> /dev/null
665
+			RCDIRS=/etc/rc.d/rc2.d
666
+			MSG="Pandora FMS agent has been included in $DESTDIR/etc/rc.d/rc2.d/S90pandora_agent_daemon"
667
+		elif [ "$OS_NAME" = "HP-UX" ]
668
+		then
669
+			RCDIRS="/sbin/rc2.d /sbin/rc3.d"
670
+			MSG="Pandora FMS agent has been included in $DESTDIR/sbin/rcX.d/S90pandora_agent_daemon"
671
+		elif [ "$OS_NAME" = "SunOS" ]
672
+		then
673
+			RCDIRS=/etc/rc2.d
674
+			MSG="Pandora FMS agent has been included in $DESTDIR/etc/rc2.d/S90pandora_agent_daemon"
675
+		elif [ "$OS_NAME" = "Linux" ]
676
+		then
677
+			if [ -d /etc/rc.d/ ]
678
+			then
679
+				RCDIRS="/etc/rc.d/rc2.d /etc/rc.d/rc3.d"
680
+			else
681
+				RCDIRS="/etc/rc2.d /etc/rc3.d"
682
+			fi
683
 		fi
684
-		chmod 755 $PANDORA_STARTUP
685
-		chown root:0 $PANDORA_STARTUP
686
+		[ "$RCDIRS" ] && for RCDIR in $RCDIRS
687
+		do
688
+			[ $FAKEROOT -eq 1 ] && [ ! -d $DESTDIR$RCDIR ] && mkdir -p $DESTDIR$RCDIR >/dev/null 2>&1
689
+			ln -s $PANDORA_STARTUP $DESTDIR$RCDIR/S90pandora_agent 2> /dev/null
690
+		done
691
+		[ "$MSG" ] && echo "$MSG"
692
 	fi
693
 
694
-	if [ "$OS_NAME" = "FreeBSD" ]
695
-	then
696
-		PANDORA_STARTUP=/usr/local/etc/rc.d/pandora_agent
697
-		cp FreeBSD/pandora_agent $PANDORA_STARTUP
698
-		chmod 555 $PANDORA_STARTUP
699
-		chown root:wheel $PANDORA_STARTUP
700
-	fi
701
-
702
-	if [ "$OS_NAME" = "NetBSD" ]
703
-	then
704
-		PANDORA_STARTUP=/etc/rc.d/pandora_agent
705
-		cp NetBSD/pandora_agent $PANDORA_STARTUP
706
-		chmod 555 $PANDORA_STARTUP
707
-		chown root:wheel $PANDORA_STARTUP
708
-	fi
709
-
710
 	echo "Done."
711
 	echo " "
712
 	echo "You have your startup script ready at $PANDORA_STARTUP"
713
Index: plugins/who.sh
714
===================================================================
715
--- plugins/who.sh	(revision 10314)
716
+++ plugins/who.sh	(working copy)
717
@@ -1,10 +1,10 @@
718
-#!/bin/bash
719
+#!/bin/sh
720
 echo "<module>";
721
 echo "<name>who</name>";
722
 echo "<type>async_string</type>";
723
 echo "<data><![CDATA["
724
 WHO=`who`
725
-if [ "$WHO" == "" ]; then
726
+if [ "$WHO" = "" ]; then
727
 	echo "None"
728
 else
729
 	echo $WHO
730
Index: tentacle_server
731
===================================================================
732
--- tentacle_server	(revision 10314)
733
+++ tentacle_server	(working copy)
734
@@ -60,9 +60,15 @@
735
 use warnings;
736
 use Getopt::Std;
737
 use IO::Select;
738
+use threads;
739
 use Thread::Semaphore;
740
 use POSIX ":sys_wait_h";
741
+use Time::HiRes qw(usleep);
742
 
743
+# Constants for Win32 services.
744
+use constant WIN32_SERVICE_STOPPED => 0x01;
745
+use constant WIN32_SERVICE_RUNNING => 0x04;
746
+
747
 my $t_libwrap_installed = eval { require Authen::Libwrap } ? 1 : 0;
748
 
749
 if ($t_libwrap_installed) {
750
@@ -77,9 +83,8 @@
751
       : eval { require IO::Socket::INET }  ? 'IO::Socket::INET'
752
       : die $@;
753
 
754
-if ($SOCKET_MODULE eq 'IO::Socket::INET') {
755
-	print_log ("IO::Socket::INET6 is not found. IPv6 is disabled.");
756
-}
757
+# Service name for Win32.
758
+my $SERVICE_NAME="Tentacle Server";
759
 
760
 # Program version
761
 our $VERSION = '0.4.0';
762
@@ -130,7 +135,7 @@
763
 my $t_select;
764
 
765
 # Semaphore
766
-my $t_sem;
767
+my $t_sem :shared;
768
 
769
 # Server socket
770
 my @t_server_sockets;
771
@@ -197,6 +202,7 @@
772
 	print ("\t-p port\t\tPort to listen on (default $t_port).\n");
773
 	print ("\t-q\t\tQuiet. Do now print error messages.\n");
774
 	print ("\t-r number\tNumber of retries for network opertions (default $t_retries).\n");
775
+	print ("\t-S (install|uninstall|run) Manage the win32 service.\n");
776
 	print ("\t-t time\t\tTime-out for network operations in seconds (default ${t_timeout}s).\n");
777
 	print ("\t-v\t\tBe verbose.\n");
778
 	print ("\t-w\t\tPrompt for OpenSSL private key password.\n");
779
@@ -241,27 +247,6 @@
780
 }
781
 
782
 ################################################################################
783
-## SUB start_win_service
784
-## Turn the current process into a Windows service.
785
-################################################################################
786
-#sub start_win_service {
787
-#	require Win32::Daemon;
788
-#
789
-#	# Tell the OS to start the service
790
-#	Win32::Daemon::StartService ();
791
-#
792
-#	# Wait until the service manager is ready
793
-#	while (SERVICE_START_PENDING != Win32::Daemon::State()) {
794
-#		sleep (1);
795
-#	}
796
-#
797
-#	# Tell the service manager we are running
798
-#	Win32::Daemon::State (SERVICE_RUNNING);
799
-#
800
-#	# Call Win32::Daemon::StopService() when done
801
-#}
802
-
803
-################################################################################
804
 ## SUB parse_options
805
 ## Parse command line options and initialize global variables.
806
 ################################################################################
807
@@ -271,7 +256,7 @@
808
 	my @t_addresses_tmp;
809
 
810
 	# Get options
811
-	if (getopts ('a:c:de:f:hi:k:m:op:qr:s:t:vwx:b:g:T', \%opts) == 0 || defined ($opts{'h'})) {
812
+	if (getopts ('a:b:c:de:f:g:hi:k:m:op:qr:s:S:t:Tvwx:', \%opts) == 0 || defined ($opts{'h'})) {
813
 		print_help ();
814
 		exit 1;
815
 	}
816
@@ -467,19 +452,33 @@
817
 			error ("Authen::Libwrap is not installed.");
818
 		}
819
 	}
820
-}
821
 
822
-################################################################################
823
-## SUB sigchld_handler
824
-## Handle child process termination.
825
-################################################################################
826
-sub sigchld_handler {
827
+	# Win32 service management
828
+	if (defined ($opts{'S'})) {
829
+		my $service_action = $opts{'S'};
830
+		if ($^O ne 'MSWin32') {
831
+			error ("Windows services are only available on Win32.");
832
+		} else {
833
+			eval "use Win32::Daemon";
834
+			die($@) if ($@);
835
 
836
-	while (waitpid(-1, &WNOHANG) > 0) {
837
-		$t_sem->up ();
838
+			if ($service_action eq 'install') {
839
+				install_service();
840
+			} elsif ($service_action eq 'uninstall') {
841
+				uninstall_service();
842
+			} elsif ($service_action eq 'run') {
843
+				Win32::Daemon::RegisterCallbacks({
844
+			        start       =>  \&callback_start,
845
+			        running     =>  \&callback_running,
846
+			        stop        =>  \&callback_stop,
847
+				});
848
+				Win32::Daemon::StartService();
849
+				exit 0;
850
+			} else {
851
+				error("Unknown action: $service_action");
852
+			}
853
+		}
854
 	}
855
-
856
-	$SIG{CHLD} = \&sigchld_handler;
857
 }
858
 
859
 ################################################################################
860
@@ -660,87 +659,86 @@
861
 }
862
 
863
 ################################################################################
864
-## SUB accept_connection
865
-## Accept an incoming connection and fork.
866
+## SUB accept_connections
867
+## Manage incoming connections.
868
 ################################################################################
869
-sub accept_connection {
870
+sub accept_connections {
871
 	my $pid;
872
 	my $t_server_socket;
873
 
874
-	my @ready = $select->can_read;
875
+	# Start server
876
+	start_server ();
877
 
878
-	foreach $t_server_socket (@ready) {
879
+	# Initialize semaphore
880
+	$t_sem = Thread::Semaphore->new ($t_max_conn);
881
 
882
-		# Accept connection
883
-		$t_client_socket = $t_server_socket->accept ();
884
+	while (1) {
885
+		my @ready = $select->can_read;
886
+		foreach $t_server_socket (@ready) {
887
 
888
-		if (! defined ($t_client_socket)) {
889
+			# Accept connection
890
+			$t_client_socket = $t_server_socket->accept ();
891
 
892
-			# EINTR
893
-			if ($! ne '') {
894
-				next;
895
+			if (! defined ($t_client_socket)) {
896
+				next if ($! ne ''); # EINTR
897
+				error ("accept: $!.");
898
 			}
899
 
900
-			error ("accept: $!.");
901
-		}
902
+			print_log ("Client connected from " . $t_client_socket->sockhost ());
903
 
904
-		print_log ("Client connected from " . $t_client_socket->sockhost ());
905
-
906
-		# Fork and serve the client
907
-		$pid = fork ();
908
-		if (! defined ($pid)) {
909
-			error ("Cannot fork: $!.");
910
+			# Create a new thread and serve the client
911
+			$t_sem->down();
912
+			my $thr = threads->create(\&serve_client);
913
+			if (! defined ($thr)) {
914
+				error ("Error creating thread: $!.");
915
+			}
916
+			$thr->detach();
917
 		}
918
-	
919
-		# Child
920
-		if ($pid == 0) {
921
-		
922
-			# We do not need the server socket
923
-			$t_server_socket->close ();
924
 
925
-			if ($t_use_libwrap) {
926
-				if (! hosts_ctl($t_program_name, $t_client_socket)) {
927
-					print_log ("Connection from " . $t_client_socket->sockhost() . " is closed by tcpwrappers.");
928
-					$t_client_socket->close ();
929
+		usleep (1000);
930
+	}
931
+}
932
 
933
-					exit;
934
-				}
935
-			}
936
-		
937
-			# Add client socket to select queue
938
-			$t_select = IO::Select->new ();
939
-			$t_select->add ($t_client_socket);
940
-		
941
-			# Start SSL
942
-			if ($t_ssl == 1) {
943
-				start_ssl ();
944
-			}
945
+################################################################################
946
+## SUB serve_client
947
+## Serve a connected client.
948
+################################################################################
949
+sub serve_client() {
950
 
951
-			# Authenticate client
952
-			if ($t_pwd ne '') {
953
-				auth_pwd ();
954
-			}
955
+	if ($t_use_libwrap) {
956
+		if (! hosts_ctl($t_program_name, $t_client_socket)) {
957
+			print_log ("Connection from " . $t_client_socket->sockhost() . " is closed by tcpwrappers.");
958
+			$t_client_socket->close ();
959
+			$t_sem->up();
960
+			return;
961
+		}
962
+	}
963
 
964
-			# Check if proxy mode is enable
965
-			if (defined ($t_proxy_ip)) {
966
-
967
-				serve_proxy_connection ();	
968
+	eval {		
969
+		# Add client socket to select queue
970
+		$t_select = IO::Select->new ();
971
+		$t_select->add ($t_client_socket);
972
 			
973
-			} else {
974
-			
975
-				serve_connection ();
976
-			}
977
-
978
-			$t_client_socket->close ();
979
-
980
-			# Must exit now
981
-			exit;
982
+		# Start SSL
983
+		if ($t_ssl == 1) {
984
+			start_ssl ();
985
 		}
986
+	
987
+		# Authenticate client
988
+		if ($t_pwd ne '') {
989
+			auth_pwd ();
990
+		}
991
+	
992
+		# Check if proxy mode is enable
993
+		if (defined ($t_proxy_ip)) {
994
+			serve_proxy_connection ();	
995
+		} else {
996
+			serve_connection ();
997
+		}
998
+	};
999
 
1000
-		# Parent
1001
-		$t_client_socket->close ();
1002
-
1003
-	}
1004
+	$t_client_socket->close ();
1005
+	$t_sem->up();
1006
 }
1007
 
1008
 ################################################################################
1009
@@ -1045,10 +1043,8 @@
1010
 sub error {
1011
 
1012
 	if ($t_quiet == 0) {
1013
-		print (STDERR "[err] $_[0]\n");
1014
+		die("[err] $_[0]\n\n");
1015
 	}
1016
-
1017
-	exit 1;
1018
 }
1019
 
1020
 ################################################################################
1021
@@ -1414,6 +1410,91 @@
1022
 }
1023
 
1024
 ################################################################################
1025
+## SUB install_service
1026
+## Install the Windows service.
1027
+################################################################################
1028
+sub install_service() {
1029
+
1030
+	my $service_path = $0;
1031
+	my $service_params = "-s \"$t_directory\" -S run";
1032
+
1033
+	my %service_hash = (
1034
+		machine =>  '',
1035
+		name	=>  'TENTACLESRV',
1036
+		display =>  $SERVICE_NAME,
1037
+		path	=>  $service_path,
1038
+		user	=>  '',
1039
+		pwd	 =>  '',
1040
+		description => 'Tentacle Server http://sourceforge.net/projects/tentacled/',
1041
+		parameters => $service_params
1042
+	);
1043
+	
1044
+	if (Win32::Daemon::CreateService(\%service_hash)) {
1045
+		print "Successfully added.\n";
1046
+		exit 0;
1047
+	} else {
1048
+		print "Failed to add service: " . Win32::FormatMessage(Win32::Daemon::GetLastError()) . "\n";
1049
+		exit 1;
1050
+	}
1051
+}
1052
+
1053
+################################################################################
1054
+## SUB uninstall_service
1055
+## Install the Windows service.
1056
+################################################################################
1057
+sub uninstall_service() {
1058
+	if (Win32::Daemon::DeleteService('', 'TENTACLESRV')) {
1059
+		print "Successfully deleted.\n";
1060
+		exit 0;
1061
+	} else {
1062
+		print "Failed to delete service: " . Win32::FormatMessage(Win32::Daemon::GetLastError()) . "\n";
1063
+		exit 1;
1064
+	}
1065
+}
1066
+
1067
+################################################################################
1068
+## SUB callback_running
1069
+## Windows service callback function for the running event.
1070
+################################################################################
1071
+sub callback_running {
1072
+
1073
+	if (Win32::Daemon::State() == WIN32_SERVICE_RUNNING) {
1074
+	}
1075
+}
1076
+
1077
+################################################################################
1078
+## SUB callback_start
1079
+## Windows service callback function for the start event.
1080
+################################################################################
1081
+sub callback_start {
1082
+
1083
+	# Accept_connections ();
1084
+	my $thr = threads->create(\&accept_connections);
1085
+	if (!defined($thr)) {
1086
+		Win32::Daemon::State(WIN32_SERVICE_STOPPED);
1087
+		Win32::Daemon::StopService();
1088
+		return;
1089
+	}
1090
+	$thr->detach();
1091
+
1092
+	Win32::Daemon::State(WIN32_SERVICE_RUNNING);
1093
+}
1094
+
1095
+################################################################################
1096
+## SUB callback_stop
1097
+## Windows service callback function for the stop event.
1098
+################################################################################
1099
+sub callback_stop {
1100
+
1101
+	foreach my $t_server_socket (@t_server_sockets) {
1102
+		$t_server_socket->close ();
1103
+	}
1104
+
1105
+	Win32::Daemon::State(WIN32_SERVICE_STOPPED);
1106
+	Win32::Daemon::StopService();
1107
+}
1108
+
1109
+################################################################################
1110
 # Main
1111
 ################################################################################
1112
 
1113
@@ -1444,25 +1525,16 @@
1114
 
1115
 # Handle ctr-c
1116
 if ($^O eq 'MSWin32') {
1117
+	no warnings;
1118
 	$SIG{INT2} = \&stop_server;
1119
+	use warnings;
1120
 }
1121
 else {
1122
 	$SIG{INT} = \&stop_server;
1123
 }
1124
 
1125
-# Handle SIGCHLD
1126
-$SIG{CHLD} = \&sigchld_handler;
1127
-
1128
-start_server ();
1129
-
1130
-# Initialize semaphore
1131
-$t_sem = Thread::Semaphore->new ($t_max_conn);
1132
-
1133
 # Accept connections
1134
-while (1) {
1135
-	$t_sem->down ();
1136
-	accept_connection ();
1137
-}
1138
+accept_connections();
1139
 
1140
 __END__
1141
 
1142
Index: pandora_agent_daemon
1143
===================================================================
1144
--- pandora_agent_daemon	(revision 10314)
1145
+++ pandora_agent_daemon	(working copy)
1146
@@ -34,38 +34,39 @@
1147
 	OS_NAME=`uname -s`
1148
 	if [ $OS_NAME = "HP-UX" ]
1149
 	then
1150
-		PANDORA_PID=`ps -ex | grep "$DAEMON $PANDORA_PATH" | grep -v grep | head -1 | awk '{ print $1 }'`
1151
-	else
1152
-		if [ "$OS_NAME" = "SunOS" ]
1153
+		PANDORA_PID=`ps -ef | grep "/usr/bin/perl $DAEMON" | grep -v grep | awk '{print $2}'`
1154
+	elif [ "$OS_NAME" = "SunOS" ]
1155
+	then
1156
+		ZONENAME_CMD="/bin/zonename"
1157
+		TRUNCATED_DAEMON=`echo "$DAEMON $PANDORA_PATH" | cut -c1-20`
1158
+		if [ -x $ZONENAME_CMD ]
1159
 		then
1160
-			ZONENAME_CMD="/bin/zonename"
1161
-			TRUNCATED_DAEMON=`echo "$DAEMON $PANDORA_PATH" | cut -c1-20`
1162
-			if [ -x $ZONENAME_CMD ]
1163
-			then
1164
-				ZONE=`$ZONENAME_CMD`
1165
-			else
1166
-				ZONE=
1167
-			fi
1168
-			if [ "$ZONE" = "global" ]
1169
-			then
1170
-				PANDORA_PID=`ps -f -z global | grep "$TRUNCATED_DAEMON" | grep -v grep | head -1 | awk '{ print $2 }'`
1171
-			else
1172
-				PANDORA_PID=`ps -Af | grep "$TRUNCATED_DAEMON" | grep -v grep | head -1 | awk '{ print $2 }'`
1173
-			fi
1174
-		elif [ "$OS_NAME" = "Linux" -a -x /usr/sbin/vzpid ]
1175
+			ZONE=`$ZONENAME_CMD`
1176
+		else
1177
+			ZONE=
1178
+		fi
1179
+		if [ "$ZONE" = "global" ]
1180
 		then
1181
-			for _pid in `ps -Af | grep "$DAEMON $PANDORA_PATH" | grep -v grep | awk '{ print $2 }'`
1182
-			do
1183
-				_ctid=`/usr/sbin/vzpid $_pid | awk '$1 == '$_pid' { print $2 }'`
1184
-				if [ "X$_ctid" = "X0" ]
1185
-				then
1186
-					PANDORA_PID=$_pid
1187
-					break
1188
-				fi
1189
-			done
1190
+			PANDORA_PID=`ps -f -z global | grep "$TRUNCATED_DAEMON" | grep -v grep | head -1 | awk '{ print $2 }'`
1191
 		else
1192
-			PANDORA_PID=`ps -Af | grep "$DAEMON $PANDORA_PATH" | grep -v grep | head -1 | awk '{ print $2 }'`
1193
+			PANDORA_PID=`ps -Af | grep "$TRUNCATED_DAEMON" | grep -v grep | head -1 | awk '{ print $2 }'`
1194
 		fi
1195
+	elif [ "$OS_NAME" = "Linux" ] && [ -x /usr/sbin/vzpid ]
1196
+	then
1197
+		# Virtuozzo/OpenVZ
1198
+		local _pid _ctid _pids
1199
+		_pids=`ps -Af | grep "$DAEMON $PANDORA_PATH" | grep -v grep | awk '{ print $2 }'`
1200
+		[ "$_pids" ] && for _pid in $_pids
1201
+		do
1202
+			_ctid=`/usr/sbin/vzpid $_pid | awk '$1 == '$_pid' { print $2 }'`
1203
+			if [ "X$_ctid" = "X0" ]
1204
+			then
1205
+				PANDORA_PID=$_pid
1206
+				break
1207
+			fi
1208
+		done
1209
+	else
1210
+		PANDORA_PID=`ps -Af | grep "$DAEMON $PANDORA_PATH" | grep -v grep | head -1 | awk '{ print $2 }'`
1211
 	fi
1212
 	
1213
 	echo $PANDORA_PID
1214
Index: pandora_agent
1215
===================================================================
1216
--- pandora_agent	(revision 10314)
1217
+++ pandora_agent	(working copy)
1218
@@ -343,6 +343,8 @@
1219
 			init_module ($module);
1220
 		} elsif ($line =~ /^\s*module_name\s+(.+)$/) {
1221
 			$module->{'name'} = $1;
1222
+			$module->{'name'} =~ s/\s+$//g;
1223
+			$module->{'name'} =~ s/^\s+//g;
1224
 		} elsif ($line =~ /^\s*module_description\s+(.+)$/) {
1225
 			$module->{'description'} = $1;
1226
 		} elsif ($line =~ /^\s*module_type\s+(\S+)\s*$/) {
1227
@@ -1727,12 +1729,7 @@
1228
 		
1229
 	# Data list
1230
 	if ($#data > 0) {
1231
-		$Xml .= "	<datalist>\n";
1232
-		foreach my $data_item (@data) {
1233
-			chomp ($data_item);
1234
-			$Xml .= "	<data><value><![CDATA[$data_item]]></value></data>\n";
1235
-		}
1236
-		$Xml .= "	</datalist>\n";
1237
+		$Xml .= "	<data><![CDATA[" . join('', @data) . "]]></data>\n";
1238
 	# Single data
1239
 	} else {
1240
 		chomp ($data[0]);
1241
Index: FreeBSD/pandora_agent
1242
===================================================================
1243
--- FreeBSD/pandora_agent	(revision 10314)
1244
+++ FreeBSD/pandora_agent	(working copy)
1245
@@ -3,6 +3,7 @@
1246
 # **********************************************************************
1247
 # Pandora FMS Agent Daemon launcher for FreeBSD
1248
 # (c) 2010 Junichi Satoh <junichi@rworks.jp>
1249
+# (c) 2014 Koichiro Kikuchi <koichiro@rworks.jp>
1250
 #
1251
 # **********************************************************************
1252
 
1253
@@ -18,7 +19,7 @@
1254
 . "/etc/rc.subr"
1255
 
1256
 name="pandora_agent"
1257
-rcvar=`set_rcvar`
1258
+rcvar=pandora_agent_enable
1259
 
1260
 # read configuration and set defaults
1261
 pandora_agent_enable=${pandora_agent_enable:-"NO"}
1262
@@ -26,22 +27,15 @@
1263
 
1264
 PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin
1265
 
1266
-command=/usr/local/bin/pandora_agent
1267
-command_args="/usr/local/etc/pandora &"
1268
-
1269
 pidfile=/var/run/$name.pid
1270
 required_files="/usr/local/etc/pandora/pandora_agent.conf"
1271
-start_postcmd=start_postcmd
1272
 stop_postcmd=stop_postcmd
1273
 
1274
-procname="/usr/bin/perl"
1275
+command=/usr/sbin/daemon
1276
+command_interpreter=/usr/local/bin/perl
1277
+procname=/usr/local/bin/pandora_agent
1278
 
1279
-start_postcmd()
1280
-{
1281
-	sleep 1
1282
-	PANDORA_PID=`pgrep -f -j none $name`
1283
-	echo $PANDORA_PID > $pidfile
1284
-}
1285
+command_args="-cfp $pidfile $procname /usr/local/etc/pandora"
1286
 
1287
 stop_postcmd()
1288
 {
(-)b/net-mgmt/pandorafms_console/Makefile (-4 / +5 lines)
Lines 50-65 post-install: Link Here
50
		&& ${RM} -rf pandora_console_install* *.spec \
50
		&& ${RM} -rf pandora_console_install* *.spec \
51
			extras/check_other_languages.sh.bak \
51
			extras/check_other_languages.sh.bak \
52
			include/languages/extract_newlines.sh.bak \
52
			include/languages/extract_newlines.sh.bak \
53
			*.sql.bak COPYING ${PORTDOCS} DEBIAN/
53
			*.sql.bak COPYING ${PORTDOCS} DEBIAN/ \
54
			attachment/collections/.empty attachment/downloads/.gitignore
54
	@cd ${STAGEDIR}${WWWDIR} && ${MV} install.php install.done
55
	@cd ${STAGEDIR}${WWWDIR} && ${MV} install.php install.done
55
.if ${PORT_OPTIONS:MDOCS}
56
.if ${PORT_OPTIONS:MDOCS}
56
	@${MKDIR} ${STAGEDIR}${DOCSDIR}
57
	@${MKDIR} ${STAGEDIR}${DOCSDIR}
57
.for x in ${PORTDOCS}
58
.for x in ${PORTDOCS}
58
	@${INSTALL_DATA} ${WRKSRC}/${x} ${STAGEDIR}${DOCSDIR}
59
	${INSTALL_DATA} ${WRKSRC}/${x} ${STAGEDIR}${DOCSDIR}
59
.endfor
60
.endfor
60
.endif
61
.endif
61
	@${MKDIR} -p ${STAGEDIR}${PREFIX}/${APACHEETCDIR}/Includes
62
	@${MKDIR} ${STAGEDIR}${PREFIX}/${APACHEETCDIR}/Includes
62
	@${INSTALL_DATA} ${WRKDIR}/pandora_console.conf \
63
	${INSTALL_DATA} ${WRKDIR}/pandora_console.conf \
63
		${STAGEDIR}${PREFIX}/${APACHEETCDIR}/Includes/pandora_console.conf.sample
64
		${STAGEDIR}${PREFIX}/${APACHEETCDIR}/Includes/pandora_console.conf.sample
64
	@${LN} -sf ${_LICENSE_DIR}/${LICENSE} ${STAGEDIR}${WWWDIR}/COPYING
65
	@${LN} -sf ${_LICENSE_DIR}/${LICENSE} ${STAGEDIR}${WWWDIR}/COPYING
65
66
(-)b/net-mgmt/pandorafms_console/distinfo (-2 / +2 lines)
Lines 1-2 Link Here
1
SHA256 (pandora/pandorafms_console-5.1.tar.gz) = 4f9624f4ddbe416929b3ce47a737073da2ff319f6121454b66140fb2a70c4638
1
SHA256 (pandora/pandorafms_console-5.1SP1.tar.gz) = 5696fef415db22fd0eaffb3d8286eddfe3d123c86bae9a8a4044b7937efb8742
2
SIZE (pandora/pandorafms_console-5.1.tar.gz) = 28264905
2
SIZE (pandora/pandorafms_console-5.1SP1.tar.gz) = 27900949
(-)a/net-mgmt/pandorafms_console/files/patch-update (-9578 lines)
Removed Link Here
1
Index: pandoradb_data.sql
2
===================================================================
3
--- pandoradb_data.sql	(revision 10314)
4
+++ pandoradb_data.sql	(working copy)
5
@@ -283,7 +283,7 @@
6
 -- Dumping data for table `tnews`
7
 --
8
 
9
-INSERT INTO `tnews` (`id_news`, `author`, `subject`, `text`, `timestamp`) VALUES (1,'admin','Welcome to Pandora FMS 5.0!','This is the new Pandora FMS Console. A lot of new features have been added since last version. Please read the documentation about it, and feel free to test any option.\r\n\r\nThe Pandora FMS Team.',NOW());
10
+INSERT INTO `tnews` (`id_news`, `author`, `subject`, `text`, `timestamp`) VALUES (1,'admin','Welcome to Pandora FMS!','This is the Pandora FMS Console. A lot of new features have been added since last version. Please read the documentation about it, and feel free to test any option.\r\n\r\nThe Pandora FMS Team.',NOW());
11
 INSERT INTO `tnews` (`id_news`, `author`, `subject`, `text`, `timestamp`) VALUES (2,'admin','New Pandora FMS Agent Features','Feel free to test our new features for both Windows and Linux agents: Proxy and Broker modes.',NOW());
12
 
13
 INSERT INTO tmodule VALUES (1,'Agent&#x20;module');
14
Index: include/functions_clippy.php
15
===================================================================
16
--- include/functions_clippy.php	(revision 0)
17
+++ include/functions_clippy.php	(revision 10417)
18
@@ -0,0 +1,176 @@
19
+<?php
20
+
21
+// Pandora FMS - http://pandorafms.com
22
+// ==================================================
23
+// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
24
+// Please see http://pandorafms.org for full contribution list
25
+
26
+// This program is free software; you can redistribute it and/or
27
+// modify it under the terms of the  GNU Lesser General Public License
28
+// as published by the Free Software Foundation; version 2
29
+
30
+// This program is distributed in the hope that it will be useful,
31
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
32
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
33
+// GNU General Public License for more details.
34
+
35
+/**
36
+ * @package Include
37
+ * @subpackage Clippy
38
+ */
39
+
40
+function clippy_start($sec2) {
41
+	global $config;
42
+	
43
+	if ($sec2 === false) {
44
+		$sec2 = 'homepage';
45
+	}
46
+	
47
+	$sec2 = str_replace('/', '_', $sec2);
48
+	
49
+	if ($sec2 != 'homepage') {
50
+		if (is_file("include/help/clippy/" . $sec2 . ".php")) {
51
+			require("include/help/clippy/" . $sec2 . ".php");
52
+			
53
+			clippy_start_page();
54
+		}
55
+		
56
+		//Add homepage for all pages for to show the "task sugestions"
57
+		require("include/help/clippy/homepage.php");
58
+		clippy_start_page_homepage();
59
+	}
60
+	else {
61
+		require("include/help/clippy/homepage.php");
62
+		clippy_start_page_homepage();
63
+	}
64
+}
65
+
66
+function clippy_clean_help() {
67
+	set_cookie('clippy', null);
68
+}
69
+
70
+function clippy_write_javascript_helps_steps($helps,
71
+	$force_first_step_by_default = true) {
72
+	
73
+	global $config;
74
+	
75
+	$clippy = get_cookie('clippy', false);
76
+	set_cookie('clippy', null);
77
+	
78
+	
79
+	//Get the help steps from a task
80
+	$steps = $helps[$clippy]['steps'];
81
+	if ($force_first_step_by_default) {
82
+		if (empty($steps)) {
83
+			//Get the first by default
84
+			$temp = reset($helps);
85
+			$steps = $temp['steps'];
86
+		}
87
+	}
88
+	
89
+	$conf = $helps[$clippy]['conf'];
90
+	if ($force_first_step_by_default) {
91
+		if (empty($conf)) {
92
+			//Get the first by default
93
+			$temp = reset($helps);
94
+			$conf = $temp['conf'];
95
+		}
96
+	}
97
+	
98
+	if (!empty($steps)) {
99
+		$name_obj_tour = 'intro';
100
+		if (!empty($conf['name_obj_tour'])) {
101
+			$name_obj_tour = $conf['name_obj_tour'];
102
+		}
103
+		
104
+		$autostart = true;
105
+		if (!is_null($conf['autostart'])) {
106
+			$autostart = $conf['autostart'];
107
+		}
108
+		
109
+		$other_js = '';
110
+		if (!empty($conf['other_js'])) {
111
+			$other_js = $conf['other_js'];
112
+		}
113
+		
114
+		?>
115
+		<script type="text/javascript">
116
+			var <?php echo $name_obj_tour; ?> = null;
117
+			
118
+			$(document).ready(function() {
119
+				<?php echo $name_obj_tour; ?> = introJs();
120
+				
121
+				<?php echo $name_obj_tour; ?>.setOptions({
122
+					steps: <?php echo json_encode($steps); ?>,
123
+					showBullets: <?php echo json_encode($conf['showBullets']); ?>,
124
+					showStepNumbers: <?php echo json_encode($conf['showStepNumbers']); ?>,
125
+					nextLabel: "<?php echo __('Next &rarr;'); ?>",
126
+					prevLabel: "<?php echo __('&larr; Back'); ?>",
127
+					skipLabel: "<?php echo __('Skip'); ?>",
128
+					doneLabel: "<?php echo __('Done'); ?>",
129
+					exitOnOverlayClick: false,
130
+					exitOnEsc: true, //false,
131
+				})
132
+				.onexit(function(value) {
133
+						exit = confirm("<?php echo __("Do you want to exit the help tour?"); ?>");
134
+						return exit;
135
+					});
136
+				
137
+				<?php
138
+				if (!empty($conf['next_help'])) {
139
+				?>
140
+					clippy_set_help('<?php echo $conf['next_help']; ?>');
141
+				<?php
142
+				}
143
+				?>
144
+				
145
+				<?php
146
+				if ($autostart) {
147
+				?>
148
+					<?php echo $name_obj_tour; ?>.start();
149
+				<?php
150
+				}
151
+				?>
152
+			});
153
+			
154
+			<?php echo $other_js; ?>
155
+		</script>
156
+		<?php
157
+	}
158
+}
159
+
160
+function clippy_context_help($help = null) {
161
+	$id = uniqid("id_");
162
+	
163
+	$return = '';
164
+	
165
+	require_once("include/help/clippy/" . $help . ".php");
166
+	
167
+	ob_start();
168
+	$function = "clippy_" . $help;
169
+	$function();
170
+	$code = ob_get_clean();
171
+	
172
+	$code = str_replace('{clippy}', '#' . $id, $code); html_debug_print($code, true);
173
+	$code = str_replace('{clippy_obj}', 'intro_' . $id, $code); html_debug_print($code, true);
174
+	
175
+	$return = $code . 
176
+		'<div id="' . $id . '" style="display: inline;">' .
177
+		'<a onclick="intro_' .  $id . '.start();" href="javascript: return false;" >' .
178
+			html_print_image(
179
+				"images/clippy_icon.png",
180
+				true) .
181
+		'</a>' .
182
+		'</div>
183
+		<script type="text/javascript">
184
+		$(document).ready(function() {
185
+			$("#' . $id . ' img").pulsate ();
186
+		});
187
+		</script>
188
+		';
189
+	
190
+	
191
+	
192
+	return $return;
193
+}
194
+?>
195
\ No newline at end of file
196
Index: include/styles/menu.css
197
===================================================================
198
--- include/styles/menu.css	(revision 10314)
199
+++ include/styles/menu.css	(working copy)
200
@@ -81,7 +81,6 @@
201
 .submenu {
202
 	font-family: Georgia,"Times New Roman","Bitstream Charter",Times,serif;
203
 	margin: 0px 10px 0px 0;
204
-	width: 173px;
205
 }
206
 .submenu li a {
207
 	background-color: #222;
208
@@ -143,10 +142,6 @@
209
 	background-position: 4px 8px;
210
 }
211
 
212
-.menu {
213
-	width: 173px;
214
-
215
-}
216
 /* Icons specified here */
217
 #icon_oper-networkconsole {
218
  	background-image: url(../../images/op_network.png);
219
@@ -234,7 +229,6 @@
220
 #menu_container {
221
 	z-index: 3;
222
 	position: absolute;
223
-	left: -140px;
224
+	left: -80px;
225
 	background-color: #AAA;
226
-	height: 100%;
227
 }
228
Index: include/styles/pandora.css
229
===================================================================
230
--- include/styles/pandora.css	(revision 10314)
231
+++ include/styles/pandora.css	(working copy)
232
@@ -278,7 +278,7 @@
233
 }
234
 
235
 div#menu {
236
-	width: 165px;
237
+	width: 175px;
238
 	float: left;
239
 }
240
 
241
@@ -291,6 +291,14 @@
242
 	background-color: #274C00;
243
 }
244
 
245
+.fixed_header {
246
+	z-index: 9999;
247
+	position: fixed;
248
+	left: 0;
249
+	top: 0;
250
+	width: 100%;
251
+}
252
+
253
 div#foot {
254
 	font-size: 6pt !important;
255
 	border-top: solid 2px #222;
256
@@ -298,7 +306,6 @@
257
 	padding-bottom: 5px;
258
 	text-align: center;
259
 	background: #333333;
260
-	width: 960px;
261
 	height: 38px;
262
 	clear: both;
263
 	width: auto;
264
@@ -901,17 +908,10 @@
265
 	padding: 6px 0px;
266
 	height: 14px;
267
 }
268
-.titop {
269
-	-moz-border-top-right-radius: 6px;
270
-	-webkit-border-top-right-radius: 6px;
271
-	border-top-right-radius: 6px;
272
-	heigth: 100px;
273
-}
274
 .tit, .titb {
275
 	font-weight: bold;
276
 	color: #fff;
277
 	text-align: center;
278
-	width: 173px;
279
 }
280
 
281
 .suc * {
282
@@ -1863,12 +1863,10 @@
283
 div#main {
284
 	width: auto;
285
 	float: none;
286
-	padding-right: 0px;
287
-	padding-left: 0px;
288
-	padding-top: 0px;
289
-	padding-bottom: 20px;
290
-	margin-left: 182px;
291
-	margin-right: 20px;
292
+	margin-top: 10px;
293
+	margin-left: 185px;
294
+	margin-right: 10px;
295
+	padding-bottom: 10px;
296
 	background: #ECECEC;
297
 	min-width: 720px;
298
 }
299
@@ -2669,7 +2667,7 @@
300
 	margin: 0px !important;
301
 	bottom: 0px;
302
 	left: 0px;
303
-	z-index: 1020;
304
+	z-index: 9001;
305
 }
306
 
307
 #shortcut_bar {
308
@@ -2704,3 +2702,12 @@
309
 table#policy_modules td * {
310
 	display: inline;
311
 }
312
+
313
+
314
+.context_help_title {
315
+	font-weight: bolder;
316
+	text-align: left;
317
+}
318
+.context_help_body {
319
+	text-align: left;
320
+}
321
\ No newline at end of file
322
Index: include/functions_update_manager.php
323
===================================================================
324
--- include/functions_update_manager.php	(revision 10314)
325
+++ include/functions_update_manager.php	(working copy)
326
@@ -24,11 +24,17 @@
327
 	global $build_version;
328
 	global $pandora_version;
329
 	
330
-	$license = db_get_value('`value`', 'tupdate_settings', '`key`',
331
+	$license = db_get_value(
332
+		db_encapsule_fields_with_same_name_to_instructions('value'),
333
+		'tupdate_settings',
334
+		db_encapsule_fields_with_same_name_to_instructions('key'),
335
 		'customer_key');
336
 	
337
 	if (enterprise_installed()) {
338
-		$current_update = db_get_value('`value`', 'tupdate_settings', '`key`',
339
+		$current_update = db_get_value(
340
+			db_encapsule_fields_with_same_name_to_instructions('value'),
341
+			'tupdate_settings',
342
+			db_encapsule_fields_with_same_name_to_instructions('key'),
343
 			'current_package_enterprise');
344
 		
345
 		$current_update = 0;
346
@@ -36,7 +42,10 @@
347
 			$current_update = $config['current_package_enterprise'];
348
 	}
349
 	else {
350
-		$current_update = db_get_value('`value`', 'tupdate_settings', '`key`',
351
+		$current_update = db_get_value(
352
+			db_encapsule_fields_with_same_name_to_instructions('value'),
353
+			'tupdate_settings',
354
+			db_encapsule_fields_with_same_name_to_instructions('key'),
355
 			'current_package');
356
 		
357
 		$current_update = 0;
358
@@ -64,10 +73,12 @@
359
 function rrmdir($dir) {
360
 	if (is_dir($dir)) {
361
 		$objects = scandir($dir);
362
+		
363
 		foreach ($objects as $object) {
364
 			if ($object != "." && $object != "..") {
365
-				if (filetype($dir."/".$object) == "dir")
366
-					rrmdir($dir."/".$object); else unlink($dir."/".$object);
367
+				if (filetype($dir . "/" . $object) == "dir")
368
+					rrmdir($dir . "/" . $object);
369
+				else unlink($dir . "/" . $object);
370
 			}
371
 		}
372
 		reset($objects);
373
@@ -264,11 +275,13 @@
374
 		return false;
375
 	}
376
 	else {
377
-		if ($is_ajax) {
378
-			return true;
379
+		$result = json_decode($result, true);
380
+		
381
+		if (empty($result)) {
382
+			return false;
383
 		}
384
 		else {
385
-			return false;
386
+			return true;
387
 		}
388
 	}
389
 }
390
@@ -362,8 +375,10 @@
391
 		"/downloads/last_package.tgz";
392
 	
393
 	try {
394
+		rrmdir($config['attachment_store'] .
395
+			"/downloads/temp_update/pandora_console");
396
+		
397
 		$phar = new PharData($path_package);
398
-		rrmdir($config['attachment_store'] . "/downloads/temp_update/pandora_console");
399
 		$phar->extractTo($config['attachment_store'] . "/downloads/temp_update");
400
 	}
401
 	catch (Exception $e) {
402
@@ -384,7 +399,14 @@
403
 		array('value' => 50),
404
 		array('token' => 'progress_update'));
405
 	
406
-	$full_path = $config['attachment_store'] . "/downloads/temp_update/pandora_console";
407
+	$path_array = array('downloads', 'temp_update', 'pandora_console');
408
+	$full_path = $config['attachment_store'];
409
+	foreach ($path_array as $directory) {
410
+		$full_path = $full_path . '/' . $directory;
411
+		if (!is_dir($full_path)) {
412
+			mkdir($full_path);
413
+		}
414
+	}
415
 	
416
 	$homedir = $config['homedir'];
417
 	
418
Index: include/functions_groups.php
419
===================================================================
420
--- include/functions_groups.php	(revision 10314)
421
+++ include/functions_groups.php	(working copy)
422
@@ -236,7 +236,7 @@
423
  * @param integer $parent The id_group parent to search the childrens.
424
  * @param array $groups The groups, its for optimize the querys to DB.
425
  */
426
-function groups_get_childrens($parent, $groups = null) {
427
+function groups_get_childrens($parent, $groups = null, $onlyPropagate = false) {
428
 	if (empty($groups)) {
429
 		$groups = db_get_all_rows_in_table('tgrupo');
430
 	}
431
@@ -248,7 +248,7 @@
432
 			continue;
433
 		}
434
 		
435
-		if ($group['propagate']) {
436
+		if ($group['propagate'] || $onlyPropagate) {
437
 			if ($group['parent'] == $parent) {
438
 				$return = $return + array($group['id_grupo'] => $group) + groups_get_childrens($group['id_grupo'], $groups);
439
 			}
440
@@ -1531,4 +1531,42 @@
441
 		}
442
 	}
443
 }
444
+
445
+/**
446
+ * Return an array with the groups hierarchy (Recursive)
447
+ *
448
+ * @param array Groups array passed by reference
449
+ * @param mixed The id of the parent to search or false to begin the search from the first hierarchy level
450
+ * 
451
+ * @return array The groups reordered by its hierarchy
452
+ */
453
+function groups_get_tree(&$groups, $parent = false) {
454
+	$return = array();
455
+	
456
+	foreach ($groups as $id => $group) {
457
+		if ($parent === false && (!isset($group['parent']) || $group['parent'] == 0)) {
458
+			$return[$id] = $group;
459
+			unset($groups[$id]);
460
+			$children = groups_get_tree($groups, $id);
461
+
462
+			if (!empty($children)) {
463
+				$return[$id]['children'] = $children;
464
+			}
465
+		}
466
+		else if ($parent && isset($group['parent']) && $group['parent'] == $parent) {
467
+			$return[$id] = $group;
468
+			unset($groups[$id]);
469
+			$children = groups_get_tree($groups, $id);
470
+
471
+			if (!empty($children)) {
472
+				$return[$id]['children'] = $children;
473
+			}
474
+		}
475
+		else {
476
+			continue;
477
+		}
478
+	}
479
+	
480
+	return $return;
481
+}
482
 ?>
483
Index: include/functions_visual_map.php
484
===================================================================
485
--- include/functions_visual_map.php	(revision 10314)
486
+++ include/functions_visual_map.php	(working copy)
487
@@ -114,9 +114,11 @@
488
 			echo '<div id="' . $id . '" class="item static_graph" style="z-index: 1; text-align: center; color: ' . $color . '; position: absolute; display: inline-block; ' . $sizeStyle . ' top: ' . $top . 'px; left: ' . $left . 'px;">';
489
 			if ($layoutData['image'] != null) {
490
 				if (($width != 0) && ($height != 0)) 
491
-					echo html_print_image($img, true, array("class" => "image", "id" => "image_" . $id, "width" => "$width", "height" => "$height", "style" => $borderStyle));
492
+					echo html_print_image($img, true,
493
+						array("class" => "image", "id" => "image_" . $id, "width" => "$width", "height" => "$height", "style" => $borderStyle));
494
 				else
495
-					echo html_print_image($img, true, array("class" => "image", "id" => "image_" . $id, "style" => $borderStyle));
496
+					echo html_print_image($img, true,
497
+						array("class" => "image", "id" => "image_" . $id, "style" => $borderStyle));
498
 				echo '<br />';
499
 			}
500
 			echo io_safe_output($text);
501
@@ -1299,8 +1301,28 @@
502
 				}
503
 				
504
 				$img_style = array ();
505
+				
506
 				$img_style["title"] = strip_tags($layout_data["label"]);
507
+				if ($layout_data['type'] == STATIC_GRAPH) {
508
+					if ($layout_data['id_agente_modulo'] != 0) {
509
+						$unit_text = trim(io_safe_output(
510
+							modules_get_unit($layout_data['id_agente_modulo'])));
511
+						
512
+						$value = modules_get_last_value($layout_data['id_agente_modulo']);
513
+						
514
+						if (!is_string($value)) {
515
+							$value = format_for_graph($value, 2);
516
+						}
517
+						
518
+						if (!empty($unit_text))
519
+							$value .= " " . $unit_text;
520
+						
521
+						$img_style["title"] .= " <br>" . __("Last value: ") .
522
+							$value;
523
+					}
524
+				}
525
 				
526
+				
527
 				if (!empty ($layout_data["width"])) {
528
 					$img_style["width"] = $layout_data["width"];
529
 				} 
530
Index: include/ajax/events.php
531
===================================================================
532
--- include/ajax/events.php	(revision 10314)
533
+++ include/ajax/events.php	(working copy)
534
@@ -349,7 +349,13 @@
535
 	}
536
 	
537
 	$details = events_page_details($event, $server);
538
-	
539
+
540
+	// Juanma (09/05/2014) Fix: Needs to reconnect to node, in previous funct node connection was lost
541
+	if ($meta) {
542
+		$server = metaconsole_get_connection_by_id ($server_id);
543
+                metaconsole_connect($server);
544
+	}
545
+
546
 	$custom_fields = events_page_custom_fields($event);
547
 	
548
 	$custom_data = events_page_custom_data($event);
549
Index: include/ajax/module.php
550
===================================================================
551
--- include/ajax/module.php	(revision 10314)
552
+++ include/ajax/module.php	(working copy)
553
@@ -23,6 +23,14 @@
554
 enterprise_include_once ('include/functions_metaconsole.php');
555
 
556
 $get_plugin_macros = get_parameter('get_plugin_macros');
557
+$search_modules = get_parameter('search_modules');
558
+$get_module_detail = get_parameter ('get_module_detail', 0);
559
+$get_module_autocomplete_input = (bool) get_parameter('get_module_autocomplete_input');
560
+$add_module_relation = (bool) get_parameter('add_module_relation');
561
+$remove_module_relation = (bool) get_parameter('remove_module_relation');
562
+$change_module_relation_updates = (bool) get_parameter('change_module_relation_updates');
563
+$get_id_tag = (bool) get_parameter('get_id_tag', 0);
564
+
565
 if ($get_plugin_macros) {
566
 	$id_plugin = get_parameter('id_plugin', 0);
567
 	
568
@@ -37,7 +45,7 @@
569
 	return;
570
 }
571
 
572
-$search_modules = get_parameter('search_modules');
573
+
574
 if ($search_modules) {
575
 	$id_agents = json_decode(io_safe_output(get_parameter('id_agents')));
576
 	$filter = get_parameter('q', '') . '%';
577
@@ -56,10 +64,9 @@
578
 	return;
579
 }
580
 
581
-$get_module_detail = get_parameter ('get_module_detail', 0);
582
 
583
 if ($get_module_detail) {
584
-
585
+	
586
 	ui_include_time_picker();
587
 	
588
 	ui_require_jquery_file("ui.datepicker-" . get_user_language(), "include/javascript/i18n/");
589
@@ -82,6 +89,9 @@
590
 		$conexion = mysql_connect ($server['dbhost'], $server['dbuser'], $server['dbpass']);
591
 		$select_db = mysql_select_db ($server['dbname'], $conexion);
592
 	}
593
+	else {
594
+		$conexion = false;
595
+	}
596
 	
597
 	$selection_mode = get_parameter('selection_mode', 'fromnow');
598
 	$date_from = (string) get_parameter ('date_from', date ('Y-m-j'));
599
@@ -131,15 +141,16 @@
600
 	
601
 	html_print_table($formtable);
602
 	
603
-	$moduletype_name = modules_get_moduletype_name (modules_get_agentmodule_type ($module_id));
604
+	$moduletype_name = modules_get_moduletype_name(
605
+		modules_get_agentmodule_type($module_id));
606
 	
607
 	$offset = (int) get_parameter("offset");
608
 	$block_size = (int) $config["block_size"];
609
 	
610
 	$columns = array ();
611
 	
612
-	$datetime_from = strtotime ($date_from.' '.$time_from);
613
-	$datetime_to = strtotime ($date_to.' '.$time_to);
614
+	$datetime_from = strtotime ($date_from . ' ' . $time_from);
615
+	$datetime_to = strtotime ($date_to . ' ' . $time_to);
616
 	
617
 	if ($moduletype_name == "log4x") {
618
 		$table->width = "100%";
619
@@ -222,14 +233,30 @@
620
 		);
621
 	}
622
 	
623
+	
624
 	$sql_body = io_safe_output($sql_body);
625
 	// Clean all codification characters
626
 	
627
 	$sql = "SELECT * " . $sql_body;
628
-	$sql_count = "SELECT count(*) " . $sql_body;
629
 	
630
+	switch ($config['dbtype']) {
631
+		case "mysql":
632
+			$sql_count = "SELECT count(*) " . $sql_body;
633
+			break;
634
+		case "postgresql":
635
+			$sql_body = str_replace("ORDER BY utimestamp DESC",
636
+				"GROUP BY utimestamp ORDER BY utimestamp DESC",
637
+				$sql_body);
638
+			$sql_count = "SELECT count(DISTINCT utimestamp) " . $sql_body;
639
+			break;
640
+		case "oracle":
641
+			$sql_count = "SELECT count(*) " . $sql_body;
642
+			break;
643
+	}
644
+	
645
 	$count = db_get_value_sql ($sql_count, $conexion);
646
 	
647
+	
648
 	switch ($config["dbtype"]) {
649
 		case "mysql":
650
 			$sql .= " LIMIT " . $offset . "," . $block_size;
651
@@ -337,10 +364,10 @@
652
 	return;
653
 }
654
 
655
-$get_module_autocomplete_input = (bool) get_parameter('get_module_autocomplete_input');
656
+
657
 if ($get_module_autocomplete_input) {
658
 	$id_agent = (int) get_parameter("id_agent");
659
-
660
+	
661
 	ob_clean();
662
 	if ($id_agent > 0) {
663
 		html_print_autocomplete_modules(
664
@@ -350,7 +377,7 @@
665
 	return;
666
 }
667
 
668
-$add_module_relation = (bool) get_parameter('add_module_relation');
669
+
670
 if ($add_module_relation) {
671
 	$result = false;
672
 	$id_module_a = (int) get_parameter("id_module_a");
673
@@ -384,7 +411,7 @@
674
 	return;
675
 }
676
 
677
-$remove_module_relation = (bool) get_parameter('remove_module_relation');
678
+
679
 if ($remove_module_relation) {
680
 	$id_relation = (int) get_parameter("id_relation");
681
 	if ($id_relation > 0) {
682
@@ -395,23 +422,25 @@
683
 	return;
684
 }
685
 
686
-$change_module_relation_updates = (bool) get_parameter('change_module_relation_updates');
687
+
688
 if ($change_module_relation_updates) {
689
 	$id_relation = (int) get_parameter("id_relation");
690
 	if ($id_relation > 0) {
691
 		$result = (bool) modules_change_relation_lock($id_relation);
692
 	}
693
+	
694
 	echo json_encode($result);
695
 	return;
696
 }
697
 
698
-$get_id_tag = (bool) get_parameter('get_id_tag', 0);
699
+
700
 if ($get_id_tag) {
701
 	$tag_name = get_parameter('tag_name');
702
-
703
+	
704
 	if ($tag_name) {
705
 		$tag_id = db_get_value('id_tag', 'ttag', 'name', $tag_name);
706
-	} else {
707
+	}
708
+	else {
709
 		$tag_id = 0;
710
 	}
711
 	
712
Index: include/functions_api.php
713
===================================================================
714
--- include/functions_api.php	(revision 10314)
715
+++ include/functions_api.php	(working copy)
716
@@ -757,7 +757,7 @@
717
 	$cascadeProtection = $other['data'][4];
718
 	$intervalSeconds = $other['data'][5];
719
 	$idOS = $other['data'][6];
720
-	$idServer = $other['data'][7];
721
+	$nameServer = $other['data'][7];
722
 	$customId = $other['data'][8];
723
 	$learningMode = $other['data'][9];
724
 	$disabled = $other['data'][10];
725
@@ -806,7 +806,8 @@
726
 	$cascadeProtection = $other['data'][4];
727
 	$intervalSeconds = $other['data'][5];
728
 	$idOS = $other['data'][6];
729
-	$idServer = $other['data'][7];
730
+	//$idServer = $other['data'][7];
731
+	$nameServer = $other['data'][7];
732
 	$customId = $other['data'][8];
733
 	$learningMode = $other['data'][9];
734
 	$disabled = $other['data'][10];
735
@@ -815,12 +816,12 @@
736
 	switch ($config["dbtype"]) {
737
 		case "mysql":
738
 			$sql1 = 'SELECT name
739
-				FROM tserver WHERE id_server =' . $idServer;
740
+				FROM tserver WHERE name LIKE "' . $nameServer . '"';
741
 			break;
742
 		case "postgresql":
743
 		case "oracle":
744
 			$sql1 = 'SELECT name
745
-				FROM tserver WHERE id_server =' . $idServer;
746
+				FROM tserver WHERE name LIKE \'' . $nameServer . '\'';
747
 			break;
748
 	}
749
 	
750
@@ -2476,7 +2477,7 @@
751
 	if (!$module_values) {
752
 		returnError('error_get_module_value_all_agents', 'Error getting module values from all agents.');
753
 	}
754
-	else{
755
+	else {
756
 		$data = array('type' => 'array', 'data' => $module_values);
757
 		
758
 		returnData('csv', $data, ';');
759
@@ -4856,7 +4857,7 @@
760
 		else {
761
 			$return = true;
762
 		}
763
-
764
+		
765
 		$data['type'] = 'string';
766
 		if ($return === false) {
767
 			$data['data'] = 0;
768
@@ -4865,7 +4866,7 @@
769
 			$data['data'] = $return;
770
 		}
771
 		returnData('string', $data);
772
-		return;		
773
+		return;
774
 	}
775
 	else {
776
 		returnError('error_parameter', 'Error in the parameters.');
777
@@ -4900,20 +4901,20 @@
778
 						<data><![CDATA[%s]]></data>
779
 					</module>
780
 				</agent_data>";
781
-		
782
+			
783
 			$xml = sprintf($xmlTemplate, io_safe_output(get_os_name($agent['id_os'])),
784
 				io_safe_output($agent['os_version']), $agent['intervalo'],
785
 				io_safe_output($agent['agent_version']), date('Y/m/d H:i:s', $time),
786
 				io_safe_output($agent['nombre']), $agent['timezone_offset'],
787
 				io_safe_output($agentModule['nombre']), io_safe_output($agentModule['descripcion']), modules_get_type_name($agentModule['id_tipo_modulo']), $data);
788
-		
789
-				
790
+			
791
+			
792
 			if (false === @file_put_contents($config['remote_config'] . '/' . io_safe_output($agent['nombre']) . '.' . $time . '.data', $xml)) {
793
 				returnError('error_file', 'Can save agent data xml.');
794
 			}
795
 			else {
796
 				returnData('string', array('type' => 'string', 'data' => $xml));
797
-				return;		
798
+				return;
799
 			}
800
 		}
801
 	}
802
@@ -6064,7 +6065,7 @@
803
 	$id_agent = agents_get_agent_id($agent_name);
804
 	$id_agent_module = db_get_value_filter('id_agente_modulo', 'tagente_modulo', array('id_agente' => $id_agent, 'nombre' => $module_name));
805
 	
806
-	$result = modules_change_disabled($id_agent_module, 1);
807
+	$result = modules_change_disabled($id_agent_module, 0);
808
 	
809
 	if ($result === NOERR) {
810
 		returnData('string', array('type' => 'string', 'data' => __('Correct module enable')));
811
@@ -6665,7 +6666,8 @@
812
 			'module_lag' => $server["module_lag"],
813
 			'threads' => $server["threads"],
814
 			'queued_modules' => $server["queued_modules"],
815
-			'keepalive' => $server['keepalive']
816
+			'keepalive' => $server['keepalive'],
817
+			'id_server' => $server['id_server']
818
 		);
819
 		
820
 		// servers_get_info() returns "<a http:....>servername</a>" for recon server's name.
821
Index: include/functions_ui.php
822
===================================================================
823
--- include/functions_ui.php	(revision 10314)
824
+++ include/functions_ui.php	(working copy)
825
@@ -1245,7 +1245,13 @@
826
 	}
827
 	$output .= "\n\t";
828
 	
829
+	
830
+	
831
+	
832
+	
833
+	////////////////////////////////////////////////////////////////////
834
 	//Load CSS
835
+	////////////////////////////////////////////////////////////////////
836
 	if (empty ($config['css'])) {
837
 		$config['css'] = array ();
838
 	}
839
@@ -1270,7 +1276,8 @@
840
 		}
841
 	}
842
 	
843
-	//First, if user has assigned a skin then try to use css files of skin subdirectory
844
+	//First, if user has assigned a skin then try to use css files of
845
+	//skin subdirectory
846
 	$isFunctionSkins = enterprise_include_once ('include/functions_skins.php');
847
 	if (!$login_ok) {
848
 		if ($isFunctionSkins !== ENTERPRISE_NOT_HOOK) {
849
@@ -1278,6 +1285,7 @@
850
 		}
851
 	}
852
 	
853
+	
854
 	$exists_css = false;
855
 	if ($login_ok and $isFunctionSkins !== ENTERPRISE_NOT_HOOK) {
856
 		//Checks if user's skin is available 
857
@@ -1305,12 +1313,17 @@
858
 			$config['css']);
859
 	}
860
 	
861
+	
862
+	
863
 	// Add the jquery UI styles CSS
864
 	$config['css']['jquery-UI'] = "include/styles/jquery-ui-1.10.0.custom.css";
865
-	
866
 	// Add the dialog styles CSS
867
 	$config['css']['dialog'] = "include/styles/dialog.css";
868
+	// Add the dialog styles CSS
869
+	$config['css']['dialog'] = "include/javascript/introjs.css";
870
 	
871
+	
872
+	
873
 	//We can't load empty and we loaded (conditionally) ie
874
 	$loaded = array ('', 'ie');
875
 	
876
@@ -1333,25 +1346,34 @@
877
 			$output .= '<link rel="stylesheet" href="' . $url_css . '" type="text/css" />'."\n\t";
878
 		}
879
 	}
880
+	////////////////////////////////////////////////////////////////////
881
 	//End load CSS
882
+	////////////////////////////////////////////////////////////////////
883
 	
884
+	
885
+	
886
+	
887
+	////////////////////////////////////////////////////////////////////
888
 	//Load JS
889
+	////////////////////////////////////////////////////////////////////
890
 	if (empty ($config['js'])) {
891
 		$config['js'] = array (); //If it's empty, false or not init set array to empty just in case
892
 	}
893
 	
894
+	
895
 	//Pandora specific JavaScript should go first
896
 	$config['js'] = array_merge (array ("pandora" => "include/javascript/pandora.js"), $config['js']);
897
-	
898
 	//Load base64 javascript library
899
 	$config['js']['base64'] = "include/javascript/encode_decode_base64.js";
900
-	
901
 	//Load webchat javascript library
902
 	$config['js']['webchat'] = "include/javascript/webchat.js";
903
-	
904
 	//Load qrcode library
905
 	$config['js']['qrcode'] = "include/javascript/qrcode.js";
906
+	//Load intro.js library (for bubbles and clippy)
907
+	$config['js']['intro'] = "include/javascript/intro.js";
908
+	$config['js']['clippy'] = "include/javascript/clippy.js";
909
 	
910
+	
911
 	//Load other javascript
912
 	//We can't load empty
913
 	$loaded = array ('');
914
@@ -1370,9 +1392,15 @@
915
 			$output .= '<script type="text/javascript" src="' . $url_js . '"></script>'."\n\t";
916
 		}
917
 	}
918
+	////////////////////////////////////////////////////////////////////
919
 	//End load JS
920
+	////////////////////////////////////////////////////////////////////
921
 	
922
+	
923
+	
924
+	////////////////////////////////////////////////////////////////////
925
 	//Load jQuery
926
+	////////////////////////////////////////////////////////////////////
927
 	if (empty ($config['jquery'])) {
928
 		$config['jquery'] = array (); //If it's empty, false or not init set array to empty just in case
929
 	}
930
@@ -1422,8 +1450,13 @@
931
 			$output .= '<script type="text/javascript" src="' . $url_js . '"></script>'."\n\t";
932
 		}
933
 	}
934
+	////////////////////////////////////////////////////////////////////
935
+	//End load JQuery
936
+	////////////////////////////////////////////////////////////////////
937
 	
938
 	
939
+	
940
+	
941
 	if ($config['flash_charts']) {
942
 		//Include the javascript for the js charts library
943
 		include_once($config["homedir"] . '/include/graphs/functions_flot.php');
944
@@ -1576,9 +1609,9 @@
945
 	
946
 	// Show GOTO FIRST button
947
 	if ($other_class == '') {
948
-		$output .= '<a class="pagination go_first" href="'.$url.'&amp;'.$offset_name.'=0">'.html_print_image ("images/go_first.png", true, array ("class" => "bot")).'</a>&nbsp;';
949
+		$output .= '<a class="pagination offset_0" href="'.$url.'&amp;' .$offset_name.'=0">'.html_print_image ("images/go_first.png", true, array ("class" => "bot")).'</a>&nbsp;';
950
 	} else {
951
-		$output .= "<a class='pagination $other_class go_first' href='$url.&amp;$offset_name=0'>".html_print_image ("images/go_first.png", true, array ("class" => "bot"))."</a>&nbsp;";
952
+		$output .= "<a class='pagination $other_class offset_0' href='$url.&amp;$offset_name=0'>".html_print_image ("images/go_first.png", true, array ("class" => "bot"))."</a>&nbsp;";
953
 	}
954
 
955
 	// Show PREVIOUS button
956
@@ -1588,9 +1621,9 @@
957
 			$index_page_prev = 0;
958
 			
959
 		if ($other_class == '') {
960
-				$output .= '<a class="pagination go_rewind" href="'.$url.'&amp;'.$offset_name.'='.$index_page_prev.'">'.html_print_image ("images/go_previous.png", true, array ("class" => "bot")).'</a>';
961
+			$output .= '<a class="pagination offset_' . $index_page_prev . '" href="'.$url.'&amp;'.$offset_name.'='.$index_page_prev.'">'.html_print_image ("images/go_previous.png", true, array ("class" => "bot")).'</a>';
962
 		} else {
963
-			$output .= "<a class='pagination $other_class go_rewind' href='$url &amp;$offset_name = $index_page_prev'>".html_print_image ("images/go_previous.png", true, array ("class" => "bot"))."</a>";
964
+			$output .= "<a class='pagination $other_class offset_$index_page_prev' href='$url &amp;$offset_name = $index_page_prev'>".html_print_image ("images/go_previous.png", true, array ("class" => "bot"))."</a>";
965
 		}
966
 	}
967
 	
968
@@ -1629,13 +1662,12 @@
969
 	// Index_counter stores max of blocks
970
 	if (($paginacion_maxima == 1) AND (($index_counter - $i) > 0)) {
971
 		$prox_bloque = ($i + ceil ($block_limit / 2)) * $pagination;
972
-		if ($prox_bloque > $count)
973
-			$prox_bloque = ($count -1) - $pagination;
974
-			
975
+		if ($prox_bloque >= $count)
976
+			$prox_bloque = (int) (($count - 1) / $pagination) * $pagination;
977
 		if ($other_class == '') {
978
-				$output .= '<a class="pagination go_fastforward" href="'.$url.'&amp;'.$offset_name.'='.$prox_bloque.'">'.html_print_image ("images/go_next.png", true, array ("class" => "bot")).'</a>';
979
+			$output .= '<a class="pagination offset_' . $prox_bloque . '" href="'.$url.'&amp;'.$offset_name.'='.$prox_bloque.'">'.html_print_image ("images/go_next.png", true, array ("class" => "bot")).'</a>';
980
 		} else {
981
-			$output .= "<a class='pagination $other_class go_fastforward' href='$url&amp;$offset_name=$prox_bloque'>".html_print_image ("images/go_next.png", true, array ("class" => "bot"))."</a>";
982
+			$output .= "<a class='pagination $other_class offset_$prox_bloque' href='$url&amp;$offset_name=$prox_bloque'>".html_print_image ("images/go_next.png", true, array ("class" => "bot"))."</a>";
983
 		}
984
 		$i = $index_counter;
985
 	}
986
@@ -1647,9 +1679,9 @@
987
 		$myoffset = floor (($count - 1) / $pagination) * $pagination;
988
 		
989
 		if ($other_class == '') {
990
-			$output .= '<a class="pagination go_last" href="'.$url.'&amp;'.$offset_name.'='.$myoffset.'">'.html_print_image ("images/go_last.png", true, array ("class" => "bot")).'</a>';
991
+			$output .= '<a class="pagination offset_' . $myoffset . '" href="'.$url. '&amp;'.$offset_name.'='.$myoffset.'">'.html_print_image ("images/go_last.png", true, array ("class" => "bot")).'</a>';
992
 		} else {
993
-			$output .= "<a class='pagination $other_class go_last' href='$url&amp;$offset_name=$myoffset'>".html_print_image ("images/go_last.png", true, array ("class" => "bot"))."</a>";
994
+			$output .= "<a class='pagination $other_class offset_$myoffset' href='$url&amp;$offset_name=$myoffset'>".html_print_image ("images/go_last.png", true, array ("class" => "bot"))."</a>";
995
 		}
996
 	}
997
 	
998
@@ -2268,7 +2300,8 @@
999
 	$buffer .= '<span style="display: inline-block; vertical-align: top; margin-top: 2px;">' . 
1000
 		ui_print_truncate_text($title, 38);
1001
 	if ($help != "")
1002
-		$buffer .= "<div class='head_help' style='float: right; margin-top: -3px !important; margin-left: 2px !important;'>" . ui_print_help_icon ($help, true, '', 'images/help_w.png') . "</div>";
1003
+		$buffer .= "<div class='head_help' style='float: right; margin-top: -3px !important; margin-left: 2px !important;'>" .
1004
+			ui_print_help_icon ($help, true, '', 'images/help_w.png') . "</div>";
1005
 	$buffer .= '</span></li></ul></div>';
1006
 	
1007
 	if (is_array($options)) {
1008
Index: include/functions.php
1009
===================================================================
1010
--- include/functions.php	(revision 10314)
1011
+++ include/functions.php	(working copy)
1012
@@ -768,6 +768,23 @@
1013
 	return get_parameter($name, 0);
1014
 }
1015
 
1016
+function get_cookie($name, $default = '') {
1017
+	if (isset($_COOKIE[$name])) {
1018
+		return $_COOKIE[$name];
1019
+	}
1020
+	else {
1021
+		return $default;
1022
+	}
1023
+}
1024
+
1025
+function set_cookie($name, $value) {
1026
+	if (is_null($value)) {
1027
+		unset($_COOKIE[$value]);
1028
+		setcookie($value, null, -1, '/');
1029
+	}
1030
+	setcookie($name, $value);
1031
+}
1032
+
1033
 /** 
1034
  * Get a parameter from a request.
1035
  *
1036
@@ -1430,9 +1447,11 @@
1037
  * 
1038
  * @return array SNMP result.
1039
  */
1040
-function get_snmpwalk($ip_target, $snmp_version, $snmp_community = '', $snmp3_auth_user = '',
1041
-	$snmp3_security_level = '', $snmp3_auth_method = '', $snmp3_auth_pass = '',
1042
-	$snmp3_privacy_method = '', $snmp3_privacy_pass = '', $quick_print = 0, $base_oid = "", $snmp_port = '') {
1043
+function get_snmpwalk($ip_target, $snmp_version, $snmp_community = '',
1044
+	$snmp3_auth_user = '', $snmp3_security_level = '',
1045
+	$snmp3_auth_method = '', $snmp3_auth_pass = '',
1046
+	$snmp3_privacy_method = '', $snmp3_privacy_pass = '',
1047
+	$quick_print = 0, $base_oid = "", $snmp_port = '') {
1048
 	
1049
 	global $config;
1050
 	
1051
@@ -1464,7 +1483,7 @@
1052
 	else {
1053
 		$snmpwalk_bin = $config['snmpwalk'];
1054
 	}
1055
-
1056
+	
1057
 	switch (PHP_OS) {
1058
 		case "WIN32":
1059
 		case "WINNT":
1060
@@ -1480,16 +1499,54 @@
1061
 	$rc = 0;
1062
 	switch ($snmp_version) {
1063
 		case '3':
1064
-			exec ($snmpwalk_bin . ' -m ALL -v 3 -u ' . escapeshellarg($snmp3_auth_user) . ' -A ' . escapeshellarg($snmp3_auth_pass) . ' -l ' . escapeshellarg($snmp3_security_level) . ' -a ' . escapeshellarg($snmp3_auth_method) . ' -x ' . escapeshellarg($snmp3_privacy_method) . ' -X ' . escapeshellarg($snmp3_privacy_pass) . ' ' . escapeshellarg($ip_target)  . ' ' . $base_oid . ' 2> ' . $error_redir_dir, $output, $rc);
1065
+			switch ($snmp3_security_level) {
1066
+				case "authNoPriv":
1067
+					$command_str = $snmpwalk_bin .
1068
+						' -m ALL -v 3' .
1069
+						' -u ' . escapeshellarg($snmp3_auth_user) .
1070
+						' -A ' . escapeshellarg($snmp3_auth_pass) .
1071
+						' -l ' . escapeshellarg($snmp3_security_level) .
1072
+						' -a ' . escapeshellarg($snmp3_auth_method) .
1073
+						' ' . escapeshellarg($ip_target)  .
1074
+						' ' . $base_oid .
1075
+						' 2> ' . $error_redir_dir;
1076
+					break;
1077
+				case "noAuthNoPriv":
1078
+					$command_str = $snmpwalk_bin .
1079
+						' -m ALL -v 3' .
1080
+						' -u ' . escapeshellarg($snmp3_auth_user) .
1081
+						' -l ' . escapeshellarg($snmp3_security_level) .
1082
+						' ' . escapeshellarg($ip_target)  .
1083
+						' ' . $base_oid .
1084
+						' 2> ' . $error_redir_dir;
1085
+					break;
1086
+				default:
1087
+					$command_str = $snmpwalk_bin .
1088
+						' -m ALL -v 3' .
1089
+						' -u ' . escapeshellarg($snmp3_auth_user) .
1090
+						' -A ' . escapeshellarg($snmp3_auth_pass) .
1091
+						' -l ' . escapeshellarg($snmp3_security_level) .
1092
+						' -a ' . escapeshellarg($snmp3_auth_method) .
1093
+						' -x ' . escapeshellarg($snmp3_privacy_method) .
1094
+						' -X ' . escapeshellarg($snmp3_privacy_pass) .
1095
+						' ' . escapeshellarg($ip_target)  .
1096
+						' ' . $base_oid .
1097
+						' 2> ' . $error_redir_dir;
1098
+					break;
1099
+			}
1100
 			break;
1101
 		case '2':
1102
 		case '2c':
1103
 		case '1':
1104
 		default:
1105
-			exec ($snmpwalk_bin . ' -m ALL -v ' . escapeshellarg($snmp_version) . ' -c ' . escapeshellarg($snmp_community) . ' ' . escapeshellarg($ip_target)  . ' ' . $base_oid . ' 2> ' . $error_redir_dir, $output, $rc);	
1106
+			$command_str = $snmpwalk_bin . ' -m ALL -v ' . escapeshellarg($snmp_version) . ' -c ' . escapeshellarg($snmp_community) . ' ' . escapeshellarg($ip_target)  . ' ' . $base_oid . ' 2> ' . $error_redir_dir;
1107
 			break;
1108
 	}
1109
 	
1110
+	//html_debug_print($command_str);
1111
+	
1112
+	exec($command_str, $output, $rc);
1113
+	
1114
 	// Parse the output of snmpwalk
1115
 	$snmpwalk = array();
1116
 	foreach ($output as $line) {
1117
@@ -2134,4 +2191,29 @@
1118
 	return $news;
1119
 }
1120
 
1121
+
1122
+/**
1123
+ * Print audit data in CSV format.
1124
+ *
1125
+ * @param array Audit data.
1126
+ *
1127
+ */
1128
+function print_audit_csv ($data) {
1129
+	global $config;
1130
+	global $graphic_type;
1131
+
1132
+	$config['ignore_callback'] = true;
1133
+	while (@ob_end_clean ());
1134
+	
1135
+	header("Content-type: application/octet-stream");
1136
+	header("Content-Disposition: attachment; filename=audit_log".date("Y-m-d_His").".csv");
1137
+	header("Pragma: no-cache");
1138
+	header("Expires: 0");
1139
+	
1140
+	echo __('User') . ';' . __('Action') . ';' . __('Date') . ';' . __('Source ID') . ';'. __('Comments') ."\n";
1141
+	foreach ($data as $line) {
1142
+		echo io_safe_output($line['id_usuario']) . ';' .  io_safe_output($line['accion']) . ';' .  $line['fecha'] . ';' .  $line['ip_origen'] . ';'.  io_safe_output($line['descripcion']). "\n";
1143
+	}
1144
+}
1145
+
1146
 ?>
1147
Index: include/functions_agents.php
1148
===================================================================
1149
--- include/functions_agents.php	(revision 10314)
1150
+++ include/functions_agents.php	(working copy)
1151
@@ -360,6 +360,11 @@
1152
 		}
1153
 	}
1154
 	
1155
+	//Fix for postgresql
1156
+	if (empty($filter['id_agente'])) {
1157
+		unset($filter['id_agente']);
1158
+	}
1159
+	
1160
 	$where = db_format_array_where_clause_sql ($filter, 'AND', '');
1161
 	
1162
 	$where_nogroup = db_format_array_where_clause_sql ($filter_nogroup, 'AND', '');
1163
@@ -412,6 +417,7 @@
1164
 				return $sql;
1165
 			else
1166
 				$agents = db_get_all_rows_sql($sql);
1167
+			
1168
 			break;
1169
 		case "oracle":
1170
 			$set = array();
1171
Index: include/functions_graph.php
1172
===================================================================
1173
--- include/functions_graph.php	(revision 10314)
1174
+++ include/functions_graph.php	(working copy)
1175
@@ -102,13 +102,14 @@
1176
 	
1177
 	foreach ($chart_array as $item) {
1178
 		if ($series_suffix != '') {
1179
-			$item['sum'] = $item['sum'.$series_suffix];
1180
-			$item['min'] = $item['min'.$series_suffix];
1181
-			$item['max'] = $item['max'.$series_suffix];
1182
+			$item['sum'] = $item['sum' . $series_suffix];
1183
+			$item['min'] = $item['min' . $series_suffix];
1184
+			$item['max'] = $item['max' . $series_suffix];
1185
 		}
1186
 		
1187
 		//Get stats for normal graph
1188
 		if (isset($item['sum']) && $item['sum']) {
1189
+			
1190
 			//Sum all values later divide by the number of elements
1191
 			$stats['sum']['avg'] = $stats['sum']['avg'] + $item['sum'];
1192
 			
1193
@@ -245,6 +246,7 @@
1194
 	$is_unknown = $start_unknown;
1195
 	
1196
 	// Calculate chart data
1197
+	$last_known = $previous_data;
1198
 	for ($i = 0; $i < $resolution; $i++) {
1199
 		$timestamp = $datelimit + ($interval * $i);
1200
 		
1201
@@ -270,6 +272,7 @@
1202
 				$interval_min = $data[$data_i]['datos'];
1203
 			}
1204
 			$total += $data[$data_i]['datos'];
1205
+			$last_known = $data[$data_i]['datos'];
1206
 			$count++;
1207
 			$data_i++;
1208
 		}
1209
@@ -399,7 +402,6 @@
1210
 				$chart[$timestamp]['sum'.$series_suffix] = $total;
1211
 				$chart[$timestamp]['min'.$series_suffix] = $interval_min;
1212
 			}
1213
-			$previous_data = $total;
1214
 		// Compressed data
1215
 		}
1216
 		else {
1217
@@ -415,12 +417,12 @@
1218
 			}
1219
 			else {
1220
 				if ($avg_only) {
1221
-					$chart[$timestamp]['sum'.$series_suffix] = $previous_data;
1222
+					$chart[$timestamp]['sum'.$series_suffix] = $last_known;
1223
 				}
1224
 				else {
1225
-					$chart[$timestamp]['max'.$series_suffix] = $previous_data;
1226
-					$chart[$timestamp]['sum'.$series_suffix] = $previous_data;
1227
-					$chart[$timestamp]['min'.$series_suffix] = $previous_data;
1228
+					$chart[$timestamp]['max'.$series_suffix] = $last_known;
1229
+					$chart[$timestamp]['sum'.$series_suffix] = $last_known;
1230
+					$chart[$timestamp]['min'.$series_suffix] = $last_known;
1231
 				}
1232
 			}
1233
 		}
1234
@@ -580,7 +582,7 @@
1235
 			if (!$projection) {
1236
 				return fs_error_image ();
1237
 			}
1238
-			else{
1239
+			else {
1240
 				return fs_error_image ();
1241
 			}
1242
 		}
1243
@@ -1103,6 +1105,7 @@
1244
 		$countAvg = 0;
1245
 		
1246
 		// Calculate chart data
1247
+		$last_known = $previous_data;
1248
 		for ($l = 0; $l < $resolution; $l++) {
1249
 			$countAvg ++;
1250
 			
1251
@@ -1117,8 +1120,8 @@
1252
 			$count = 0;
1253
 			
1254
 			// Read data that falls in the current interval
1255
-			$interval_min = $previous_data;
1256
-			$interval_max = $previous_data;
1257
+			$interval_min = $last_known;
1258
+			$interval_max = $last_known;
1259
 			while (isset ($data[$j]) && $data[$j]['utimestamp'] >= $timestamp && $data[$j]['utimestamp'] < ($timestamp + $interval)) {
1260
 				if ($data[$j]['datos'] > $interval_max) {
1261
 					$interval_max = $data[$j]['datos'];
1262
@@ -1127,6 +1130,7 @@
1263
 					$interval_min = $data[$j]['datos'];
1264
 				}
1265
 				$total += $data[$j]['datos'];
1266
+				$last_known = $data[$j]['datos'];
1267
 				$count++;
1268
 				$j++;
1269
 			}
1270
@@ -1153,18 +1157,14 @@
1271
 			if ($count > 0) {
1272
 				//$graph_values[$i][$timestamp] = $total * $weight_list[$i];
1273
 				$temp_graph_values[$timestamp_short] = $total * $weight_list[$i];
1274
-				
1275
-				$previous_data = $total;
1276
 			}
1277
 			else {
1278
 				// Compressed data
1279
 				if ($uncompressed_module || ($timestamp > time ())) {
1280
-					//$graph_values[$i][$timestamp] = 0;
1281
 					$temp_graph_values[$timestamp_short] = 0;
1282
 				}
1283
 				else {
1284
-					//$graph_values[$i][$timestamp] = $previous_data * $weight_list[$i];
1285
-					$temp_graph_values[$timestamp_short] = $previous_data * $weight_list[$i];
1286
+					$temp_graph_values[$timestamp_short] = $last_known * $weight_list[$i];
1287
 				}
1288
 			}
1289
 			
1290
@@ -1459,16 +1459,19 @@
1291
 		$filter['id_agente'] = $id_agent; 
1292
 	}
1293
 	
1294
-	$fields = array('SUM(critical_count) Critical', 
1295
-		'SUM(warning_count) Warning', 
1296
-		'SUM(normal_count) Normal', 
1297
-		'SUM(unknown_count) Unknown');
1298
+	$fields = array('SUM(critical_count) AS Critical', 
1299
+		'SUM(warning_count) AS Warning', 
1300
+		'SUM(normal_count) AS Normal', 
1301
+		'SUM(unknown_count) AS Unknown');
1302
 	
1303
 	if ($show_not_init) {
1304
 		$fields[] = 'SUM(notinit_count) "Not init"';
1305
 	}
1306
 	
1307
 	$data = db_get_row_filter('tagente', $filter, $fields);
1308
+	if (empty($data)) {
1309
+		$data = array();
1310
+	}
1311
 	
1312
 	array_walk($data, 'truncate_negatives');
1313
 	
1314
@@ -1796,6 +1799,7 @@
1315
 	if ($modules === false)
1316
 		$modules = array ();
1317
 	
1318
+	$data = array();
1319
 	foreach ($modules as $module) {
1320
 		$agent_name = agents_get_name ($module['id_agente'], "none");
1321
 		
1322
@@ -1816,7 +1820,8 @@
1323
 	$water_mark = array('file' => $config['homedir'] .  "/images/logo_vertical_water.png",
1324
 		'url' => ui_get_full_url("/images/logo_vertical_water.png"));
1325
 		
1326
-	return hbar_graph($config['flash_charts'], $data, $width, $height, array(),
1327
+	return hbar_graph($config['flash_charts'],
1328
+		$data, $width, $height, array(),
1329
 		array(), "", "", true, "",
1330
 		$water_mark,
1331
 		$config['fontpath'], $config['font_size'], false);
1332
@@ -2670,6 +2675,7 @@
1333
 	$max_value = 0;
1334
 	
1335
 	// Calculate chart data
1336
+	$last_known = $previous_data;
1337
 	for ($i = 0; $i < $resolution; $i++) {
1338
 		$timestamp = $datelimit + ($interval * $i);
1339
 		
1340
@@ -2689,6 +2695,7 @@
1341
 				$count++;
1342
 			}
1343
 			
1344
+			$last_known = $data[$j]['datos'];
1345
 			$j++;
1346
 		}
1347
 		
1348
@@ -2796,43 +2803,20 @@
1349
 			//New code set 0 if there is a 0
1350
 			//Please check the incident #665
1351
 			//http://192.168.50.2/integria/index.php?sec=incidents&sec2=operation/incidents/incident_dashboard_detail&id=665
1352
-			
1353
-			
1354
 			$chart[$timestamp]['sum'.$series_suffix] = 0;
1355
-			$previous_data = 0;
1356
-			
1357
-			//Old code that make a AVG
1358
-			
1359
-			//~ if ($avg_only) {
1360
-				//~ $chart[$timestamp]['sum'.$series_suffix] = $total;
1361
-			//~ }
1362
-			//~ else {
1363
-				//~ $chart[$timestamp]['sum'.$series_suffix] = $total;
1364
-				//~ $chart[$timestamp + 1] = array ('sum'.$series_suffix => 0,
1365
-					//~ //'count' => 0,
1366
-					//~ //'timestamp_bottom' => $timestamp,
1367
-					//~ //'timestamp_top' => $timestamp + $interval,
1368
-					//~ 'min'.$series_suffix => 0,
1369
-					//~ 'max'.$series_suffix => 0,
1370
-					//~ 'event'.$series_suffix => $event_value,
1371
-					//~ 'alert'.$series_suffix => $alert_value);
1372
-			//~ }
1373
-			//~ $previous_data = 0;
1374
 		}
1375
 		else if ($zero == 1) { // Just zeros
1376
 			$chart[$timestamp]['sum'.$series_suffix] = 0;
1377
-			$previous_data = 0;
1378
 		}
1379
 		else if ($count > 0) { // No zeros
1380
 			$chart[$timestamp]['sum'.$series_suffix] = $total;
1381
-			$previous_data = $total;
1382
 		}
1383
 		else { // Compressed data
1384
 			if ($uncompressed_module || ($timestamp > time ()) || $is_unknown) {
1385
 				$chart[$timestamp]['sum'.$series_suffix] = 0;
1386
 			}
1387
 			else {
1388
-				$chart[$timestamp]['sum'.$series_suffix] = $previous_data;
1389
+				$chart[$timestamp]['sum'.$series_suffix] = $last_known;
1390
 			}
1391
 		}
1392
 		
1393
@@ -3279,7 +3263,7 @@
1394
  * @param integer date date
1395
  */
1396
 function grafico_modulo_string ($agent_module_id, $period, $show_events,
1397
-	$width, $height , $title, $unit_name, $show_alerts, $avg_only = 0, $pure=0,
1398
+	$width, $height , $title, $unit_name, $show_alerts, $avg_only = 0, $pure = 0,
1399
 	$date = 0, $only_image = false, $homeurl = '', $adapt_key = '', $ttl = 1, $menu = true) {
1400
 	global $config;
1401
 	global $graphic_type;
1402
@@ -3381,6 +3365,7 @@
1403
 	}
1404
 	
1405
 	// Calculate chart data
1406
+	$last_known = $previous_data;
1407
 	for ($i = 0; $i < $resolution; $i++) {
1408
 		$timestamp = $datelimit + ($interval * $i);
1409
 		
1410
@@ -3388,6 +3373,7 @@
1411
 		$total = 0;	
1412
 		// Read data that falls in the current interval
1413
 		while (isset($data[$j]) && isset ($data[$j]) !== null && $data[$j]['utimestamp'] >= $timestamp && $data[$j]['utimestamp'] <= ($timestamp + $interval)) {
1414
+			$last_known = $data[$j];
1415
 			$count++;
1416
 			$j++;
1417
 		}
1418
@@ -3437,7 +3423,7 @@
1419
 		//The order in chart array is very important!!!!
1420
 		if ($show_events) {
1421
 			$chart[$timestamp]['event'] = $event_value;
1422
-		}	
1423
+		}
1424
 		
1425
 		if ($show_alerts) {
1426
 			$chart[$timestamp]['alert'] = $alert_value;
1427
@@ -3449,11 +3435,10 @@
1428
 		
1429
 		if ($count > 0) {
1430
 			$chart[$timestamp]['sum'] = $count;
1431
-			$previous_data = $total;
1432
 		}
1433
 		else {
1434
 			// Compressed data
1435
-			$chart[$timestamp]['sum'] = $previous_data;
1436
+			$chart[$timestamp]['sum'] = $last_known;
1437
 		}
1438
 		
1439
 		if (!$avg_only) {
1440
@@ -4106,47 +4091,304 @@
1441
 /**
1442
  * Print a solarburst graph with a representation of all the groups, agents, module groups and modules grouped
1443
  */
1444
-function graph_monitor_wheel ($data, $unit, $width = 700, $height = 700) {
1445
+function graph_monitor_wheel ($width = 500, $height = 600) {
1446
 	global $config;
1447
 
1448
-	$data = array();
1449
-
1450
 	include_once ($config['homedir'] . "/include/functions_users.php");
1451
-	//include_once ($config['homedir'] . "/include/functions_groups.php");
1452
+	include_once ($config['homedir'] . "/include/functions_groups.php");
1453
 	include_once ($config['homedir'] . "/include/functions_agents.php");
1454
-	//include_once ($config['homedir'] . "/include/functions_modules.php");
1455
+	include_once ($config['homedir'] . "/include/functions_modules.php");
1456
 
1457
+	$graph_data = array();
1458
+
1459
 	$groups = users_get_groups(false, "AR", false, true);
1460
 
1461
+	$data_groups = array();
1462
 	if (!empty($groups)) {
1463
+		$groups_aux = $groups;
1464
+		$data_groups = groups_get_tree($groups_aux);
1465
+		$groups_aux = $groups = null;
1466
+	}
1467
+
1468
+	if (!empty($data_groups)) {
1469
 		$filter = array('id_grupo' => array_keys($groups));
1470
 		$fields = array('id_agente', 'id_parent', 'id_grupo', 'nombre');
1471
 		$agents = agents_get_agents($filter, $fields);
1472
 
1473
 		if (!empty($agents)) {
1474
 			$agents_id = array();
1475
+			$agents_aux = array();
1476
 			foreach ($agents as $key => $agent) {
1477
-				$agents_id[] = $agent['id_agente'];
1478
+				$agents_aux[$agent['id_agente']] = $agent;
1479
 			}
1480
+			$agents = $agents_aux;
1481
+			$agents_aux = null;
1482
 			$fields = array('id_agente_modulo', 'id_agente', 'id_module_group', 'nombre');
1483
 
1484
 			$module_groups = modules_get_modulegroups();
1485
-			$modules = agents_get_modules($agents_id, $fields);
1486
+			$module_groups[0] = __('Not assigned');
1487
+			$modules = agents_get_modules(array_keys($agents), '*');
1488
 
1489
+			$data_agents = array();
1490
 			if (!empty($modules)) {
1491
-				
1492
+				foreach ($modules as $key => $module) {
1493
+					$module_id = (int) $module['id_agente_modulo'];
1494
+					$agent_id = (int) $module['id_agente'];
1495
+					$module_group_id = (int) $module['id_module_group'];
1496
+					$module_name = $module['nombre'];
1497
+					$module_status = modules_get_agentmodule_status($module_id);
1498
+
1499
+					if (!isset($data_agents[$agent_id])) {
1500
+						$data_agents[$agent_id] = array();
1501
+						$data_agents[$agent_id]['id'] = $agent_id;
1502
+						$data_agents[$agent_id]['name'] = $agents[$agent_id]['nombre'];
1503
+						$data_agents[$agent_id]['group'] = (int) $agents[$agent_id]['id_grupo'];
1504
+						$data_agents[$agent_id]['type'] = 'agent';
1505
+						$data_agents[$agent_id]['size'] = 30;
1506
+						$data_agents[$agent_id]['children'] = array();
1507
+
1508
+						$tooltip_content = __('Agent') . ": <b>" . $data_agents[$agent_id]['name'] . "</b>";
1509
+						$data_agents[$agent_id]['tooltip_content'] = $tooltip_content;
1510
+
1511
+						$data_agents[$agent_id]['modules_critical'] = 0;
1512
+						$data_agents[$agent_id]['modules_warning'] = 0;
1513
+						$data_agents[$agent_id]['modules_normal'] = 0;
1514
+						$data_agents[$agent_id]['modules_not_init'] = 0;
1515
+						$data_agents[$agent_id]['modules_not_normal'] = 0;
1516
+						$data_agents[$agent_id]['modules_unknown'] = 0;
1517
+
1518
+						$data_agents[$agent_id]['color'] = COL_UNKNOWN;
1519
+
1520
+						unset($agents[$agent_id]);
1521
+					}
1522
+					if (!isset($data_agents[$agent_id]['children'][$module_group_id])) {
1523
+						$data_agents[$agent_id]['children'][$module_group_id] = array();
1524
+						$data_agents[$agent_id]['children'][$module_group_id]['id'] = $module_group_id;
1525
+						$data_agents[$agent_id]['children'][$module_group_id]['name'] = $module_groups[$module_group_id];
1526
+						$data_agents[$agent_id]['children'][$module_group_id]['type'] = 'module_group';
1527
+						$data_agents[$agent_id]['children'][$module_group_id]['size'] = 10;
1528
+						$data_agents[$agent_id]['children'][$module_group_id]['children'] = array();
1529
+
1530
+						$tooltip_content = __('Module group') . ": <b>" . $module_groups[$module_group_id] . "</b>";
1531
+						$data_agents[$agent_id]['children'][$module_group_id]['tooltip_content'] = $tooltip_content;
1532
+
1533
+						$data_agents[$agent_id]['children'][$module_group_id]['modules_critical'] = 0;
1534
+						$data_agents[$agent_id]['children'][$module_group_id]['modules_warning'] = 0;
1535
+						$data_agents[$agent_id]['children'][$module_group_id]['modules_normal'] = 0;
1536
+						$data_agents[$agent_id]['children'][$module_group_id]['modules_not_init'] = 0;
1537
+						$data_agents[$agent_id]['children'][$module_group_id]['modules_not_normal'] = 0;
1538
+						$data_agents[$agent_id]['children'][$module_group_id]['modules_unknown'] = 0;
1539
+
1540
+						$data_agents[$agent_id]['children'][$module_group_id]['color'] = COL_UNKNOWN;
1541
+					}
1542
+					
1543
+					switch ($module_status) {
1544
+						case AGENT_MODULE_STATUS_CRITICAL_BAD:
1545
+						case AGENT_MODULE_STATUS_CRITICAL_ALERT:
1546
+							$data_agents[$agent_id]['modules_critical']++;
1547
+							$data_agents[$agent_id]['children'][$module_group_id]['modules_critical']++;
1548
+							break;
1549
+						
1550
+						case AGENT_MODULE_STATUS_WARNING:
1551
+						case AGENT_MODULE_STATUS_WARNING_ALERT:
1552
+							$data_agents[$agent_id]['modules_warning']++;
1553
+							$data_agents[$agent_id]['children'][$module_group_id]['modules_warning']++;
1554
+							break;
1555
+
1556
+						case AGENT_MODULE_STATUS_NORMAL:
1557
+						case AGENT_MODULE_STATUS_NORMAL_ALERT:
1558
+							$data_agents[$agent_id]['modules_normal']++;
1559
+							$data_agents[$agent_id]['children'][$module_group_id]['modules_normal']++;
1560
+							break;
1561
+
1562
+						case AGENT_MODULE_STATUS_NOT_INIT:
1563
+							$data_agents[$agent_id]['modules_not_init']++;
1564
+							$data_agents[$agent_id]['children'][$module_group_id]['modules_not_init']++;
1565
+							break;
1566
+
1567
+						case AGENT_MODULE_STATUS_NOT_NORMAL:
1568
+							$data_agents[$agent_id]['modules_not_normal']++;
1569
+							$data_agents[$agent_id]['children'][$module_group_id]['modules_not_normal']++;
1570
+							break;
1571
+
1572
+						case AGENT_MODULE_STATUS_NO_DATA:
1573
+						case AGENT_MODULE_STATUS_UNKNOWN:
1574
+							$data_agents[$agent_id]['modules_unknown']++;
1575
+							$data_agents[$agent_id]['children'][$module_group_id]['modules_unknown']++;
1576
+							break;
1577
+					}
1578
+
1579
+					if ($data_agents[$agent_id]['modules_critical'] > 0) {
1580
+						$data_agents[$agent_id]['color'] = COL_CRITICAL;
1581
+					}
1582
+					else if ($data_agents[$agent_id]['modules_warning'] > 0) {
1583
+						$data_agents[$agent_id]['color'] = COL_WARNING;
1584
+					}
1585
+					else if ($data_agents[$agent_id]['modules_not_normal'] > 0) {
1586
+						$data_agents[$agent_id]['color'] = COL_WARNING;
1587
+					}
1588
+					else if ($data_agents[$agent_id]['modules_unknown'] > 0) {
1589
+						$data_agents[$agent_id]['color'] = COL_UNKNOWN;
1590
+					}
1591
+					else if ($data_agents[$agent_id]['modules_normal'] > 0) {
1592
+						$data_agents[$agent_id]['color'] = COL_NORMAL;
1593
+					}
1594
+					else {
1595
+						$data_agents[$agent_id]['color'] = COL_NOTINIT;
1596
+					}
1597
+
1598
+					if ($data_agents[$agent_id]['children'][$module_group_id]['modules_critical'] > 0) {
1599
+						$data_agents[$agent_id]['children'][$module_group_id]['color'] = COL_CRITICAL;
1600
+					}
1601
+					else if ($data_agents[$agent_id]['children'][$module_group_id]['modules_warning'] > 0) {
1602
+						$data_agents[$agent_id]['children'][$module_group_id]['color'] = COL_WARNING;
1603
+					}
1604
+					else if ($data_agents[$agent_id]['children'][$module_group_id]['modules_not_normal'] > 0) {
1605
+						$data_agents[$agent_id]['children'][$module_group_id]['color'] = COL_WARNING;
1606
+					}
1607
+					else if ($data_agents[$agent_id]['children'][$module_group_id]['modules_unknown'] > 0) {
1608
+						$data_agents[$agent_id]['children'][$module_group_id]['color'] = COL_UNKNOWN;
1609
+					}
1610
+					else if ($data_agents[$agent_id]['children'][$module_group_id]['modules_normal'] > 0) {
1611
+						$data_agents[$agent_id]['children'][$module_group_id]['color'] = COL_NORMAL;
1612
+					}
1613
+					else {
1614
+						$data_agents[$agent_id]['children'][$module_group_id]['color'] = COL_NOTINIT;
1615
+					}
1616
+					
1617
+					$data_module = array();
1618
+					$data_module['id'] = $module_id;
1619
+					$data_module['name'] = $module_name;
1620
+					$data_module['type'] = 'module';
1621
+					$data_module['size'] = 10;
1622
+
1623
+					$tooltip_content = __('Module') . ": <b>" . $module_name . "</b>";
1624
+					$data_module['tooltip_content'] = $tooltip_content;
1625
+
1626
+					switch ($module_status) {
1627
+						case AGENT_MODULE_STATUS_CRITICAL_BAD:
1628
+						case AGENT_MODULE_STATUS_CRITICAL_ALERT:
1629
+							$data_module['color'] = COL_CRITICAL;
1630
+							break;
1631
+						
1632
+						case AGENT_MODULE_STATUS_WARNING:
1633
+						case AGENT_MODULE_STATUS_WARNING_ALERT:
1634
+							$data_module['color'] = COL_WARNING;
1635
+							break;
1636
+
1637
+						case AGENT_MODULE_STATUS_NORMAL:
1638
+						case AGENT_MODULE_STATUS_NORMAL_ALERT:
1639
+							$data_module['color'] = COL_NORMAL;
1640
+							break;
1641
+
1642
+						case AGENT_MODULE_STATUS_NOT_INIT:
1643
+							$data_module['color'] = COL_NOTINIT;
1644
+							break;
1645
+
1646
+						case AGENT_MODULE_STATUS_NOT_NORMAL:
1647
+							$data_module['color'] = COL_WARNING;
1648
+							break;
1649
+
1650
+						case AGENT_MODULE_STATUS_NO_DATA:
1651
+						case AGENT_MODULE_STATUS_UNKNOWN:
1652
+						default:
1653
+							$data_module['color'] = COL_UNKNOWN;
1654
+							break;
1655
+					}
1656
+
1657
+					$data_agents[$agent_id]['children'][$module_group_id]['children'][] = $data_module;
1658
+
1659
+					unset($modules[$module_id]);
1660
+				}
1661
 			}
1662
+			foreach ($agents as $id => $agent) {
1663
+				if (!isset($data_agents[$id])) {
1664
+					$data_agents[$id] = array();
1665
+					$data_agents[$id]['id'] = (int) $id;
1666
+					$data_agents[$id]['name'] = $agent['nombre'];
1667
+					$data_agents[$id]['type'] = 'agent';
1668
+					$data_agents[$id]['color'] = COL_NOTINIT;
1669
+				}
1670
+			}
1671
+			$agents = null;
1672
 		}
1673
 	}
1674
 
1675
+	function iterate_group_array ($groups, &$data_agents) {
1676
+		
1677
+		$data = array();
1678
 
1679
-	if (empty ($data)) {
1680
-		return fs_error_image ();
1681
+		foreach ($groups as $id => $group) {
1682
+
1683
+			$group_aux = array();
1684
+			$group_aux['id'] = (int) $id;
1685
+			$group_aux['name'] = $group['nombre'];
1686
+			$group_aux['parent'] = (int) $group['parent'];
1687
+			$group_aux['type'] = 'group';
1688
+			$group_aux['size'] = 100;
1689
+			$group_aux['status'] = groups_get_status($id);
1690
+
1691
+			switch ($group_aux['status']) {
1692
+				case AGENT_STATUS_CRITICAL:
1693
+					$group_aux['color'] = COL_CRITICAL;
1694
+					break;
1695
+				
1696
+				case AGENT_STATUS_WARNING:
1697
+				case AGENT_STATUS_ALERT_FIRED:
1698
+					$group_aux['color'] = COL_WARNING;
1699
+					break;
1700
+
1701
+				case AGENT_STATUS_NORMAL:
1702
+					$group_aux['color'] = COL_NORMAL;
1703
+					break;
1704
+
1705
+				case AGENT_STATUS_UNKNOWN:
1706
+				default:
1707
+					$group_aux['color'] = COL_UNKNOWN;
1708
+					break;
1709
+			}
1710
+
1711
+			$tooltip_content = html_print_image("images/groups_small/" . $group['icon'] . ".png", true) . "&nbsp;" . __('Group') . ": <b>" . $group_aux['name'] . "</b>";
1712
+			$group_aux['tooltip_content'] = $tooltip_content;
1713
+
1714
+			if (!isset($group['children']))
1715
+				$group_aux['children'] = array();
1716
+			if (!empty($group['children']))
1717
+				$group_aux['children'] = iterate_group_array($group['children']);
1718
+
1719
+			$agents = extract_agents_with_group_id($data_agents, (int) $id);
1720
+
1721
+			if (!empty($agents))
1722
+				$group_aux['children'] = array_merge($group_aux['children'], $agents);
1723
+			
1724
+			$data[] = $group_aux;
1725
+		}
1726
+
1727
+		return $data;
1728
 	}
1729
 
1730
+	function extract_agents_with_group_id (&$agents, $group_id) {
1731
+		$valid_agents = array();
1732
+		foreach ($agents as $id => $agent) {
1733
+			if (isset($agent['group']) && $agent['group'] == $group_id) {
1734
+				$valid_agents[$id] = $agent;
1735
+				unset($agents[$id]);
1736
+			}
1737
+		}
1738
+		if (!empty($valid_agents))
1739
+			return $valid_agents;
1740
+		else
1741
+			return false;
1742
+	}
1743
+
1744
+	$graph_data = array('name' => __('Main node'), 'children' => iterate_group_array($data_groups, $data_agents));
1745
+	
1746
+	if (empty($graph_data['children']))
1747
+		return fs_error_image();
1748
+
1749
 	include_once($config['homedir'] . "/include/graphs/functions_d3.php");
1750
 
1751
-	return d3_tree_map_graph ($data, $width, $height, true);
1752
+	return d3_sunburst_graph ($graph_data, $width, $height, true);
1753
 }
1754
 
1755
 ?>
1756
Index: include/functions_events.php
1757
===================================================================
1758
--- include/functions_events.php	(revision 10314)
1759
+++ include/functions_events.php	(working copy)
1760
@@ -162,7 +162,16 @@
1761
 						(SELECT ack_utimestamp FROM $table WHERE id_evento = MAX(te.id_evento)) AS ack_utimestamp
1762
 					FROM $table te
1763
 					WHERE 1=1 " . $sql_post . "
1764
-					GROUP BY estado, evento, id_agentmodule, id_evento, id_agente, id_usuario, id_grupo, estado, timestamp, utimestamp, event_type, id_alert_am, criticity, user_comment, tags, source, id_extra" . $groupby_extra . "
1765
+					GROUP BY estado, evento, id_agentmodule, id_evento,
1766
+						id_agente, id_usuario, id_grupo, estado,
1767
+						timestamp, utimestamp, event_type, id_alert_am,
1768
+						criticity, user_comment, tags, source, id_extra,
1769
+						te.critical_instructions,
1770
+						te.warning_instructions,
1771
+						te.unknown_instructions,
1772
+						te.owner_user,
1773
+						te.ack_utimestamp,
1774
+						te.custom_data " . $groupby_extra . "
1775
 					ORDER BY timestamp_rep DESC LIMIT " . $pagination . " OFFSET " . $offset;
1776
 			}
1777
 			break;
1778
@@ -582,7 +591,7 @@
1779
 			
1780
 			$event_comments_array[] = $comment_for_json;
1781
 			
1782
-			$event_comments = json_encode($event_comments_array);
1783
+			$event_comments = io_json_mb_encode($event_comments_array);
1784
 			
1785
 			// Update comment
1786
 			$ret = db_process_sql_update($event_table,  array('user_comment' => $event_comments), array('id_evento' => implode(',', $id_event)));
1787
@@ -2244,6 +2253,7 @@
1788
 	$table_comments->class = "alternate rounded_cells";
1789
 	
1790
 	$event_comments = io_safe_output($event["user_comment"]);
1791
+	$event_comments = str_replace("\n", "<br>", $event_comments);
1792
 	
1793
 	// If comments are not stored in json, the format is old
1794
 	$event_comments_array = json_decode($event_comments, true);
1795
Index: include/graphs/functions_flot.php
1796
===================================================================
1797
--- include/graphs/functions_flot.php	(revision 10314)
1798
+++ include/graphs/functions_flot.php	(working copy)
1799
@@ -442,6 +442,7 @@
1800
 	
1801
 	$max = 0;
1802
 	$i = count($graph_data);
1803
+	$data = array();
1804
 	foreach ($graph_data as $label => $values) {
1805
 		$labels[] = io_safe_output($label);
1806
 		$i--;
1807
Index: include/graphs/pandora.d3.js
1808
===================================================================
1809
--- include/graphs/pandora.d3.js	(revision 10314)
1810
+++ include/graphs/pandora.d3.js	(working copy)
1811
@@ -715,8 +715,11 @@
1812
 		.data(partition.nodes(data))
1813
 		.enter().append("path")
1814
 		.attr("d", arc)
1815
-		.style("fill", function(d) { return color((d.children ? d : d.parent).name); })
1816
-		.on("click", click);
1817
+		.style("fill", function(d) { return d.color ? d3.rgb(d.color) : color((d.children ? d : d.parent).name); })
1818
+		.on("click", click)
1819
+		.on("mouseover", over_user)
1820
+		.on("mouseout", out_user)
1821
+		.on("mousemove", move_tooltip);
1822
 
1823
 	function click(d) {
1824
 		path.transition()
1825
@@ -737,4 +740,68 @@
1826
 				: function(t) { x.domain(xd(t)); y.domain(yd(t)).range(yr(t)); return arc(d); };
1827
 		};
1828
 	}
1829
+
1830
+	function move_tooltip(d) {
1831
+		var x = d3.event.pageX + 10;
1832
+		var y = d3.event.pageY + 10;
1833
+		
1834
+		$("#tooltip").css('left', x + 'px');
1835
+		$("#tooltip").css('top', y + 'px');
1836
+	}
1837
+	
1838
+	function over_user(d) {
1839
+		id = d.id;
1840
+		
1841
+		$("#" + id).css('border', '1px solid black');
1842
+		$("#" + id).css('z-index', '1');
1843
+		
1844
+		show_tooltip(d);
1845
+	}
1846
+	
1847
+	function out_user(d) {
1848
+		id = d.id;
1849
+		
1850
+		$("#" + id).css('border', '');
1851
+		$("#" + id).css('z-index', '');
1852
+		
1853
+		hide_tooltip();
1854
+	}
1855
+
1856
+	function create_tooltip(d, x, y) {
1857
+		var tooltip = (typeof d.tooltip_content != 'undefined') ? d.tooltip_content : d.name;
1858
+
1859
+		if ($("#tooltip").length == 0) {
1860
+			$(recipient)
1861
+				.append($("<div></div>")
1862
+				.attr('id', 'tooltip')
1863
+				.html(tooltip));
1864
+		}
1865
+		else {
1866
+			$("#tooltip").html(tooltip);
1867
+		}
1868
+		
1869
+		$("#tooltip").attr('style', 'background: #fff;' +
1870
+			'position: absolute;' +
1871
+			'display: block;' +
1872
+			'width: 200px;' +
1873
+			'text-align: left;' +
1874
+			'padding: 10px 10px 10px 10px;' +
1875
+			'z-index: 2;' +
1876
+			"-webkit-box-shadow: 7px 7px 5px rgba(50, 50, 50, 0.75);" +
1877
+			"-moz-box-shadow:    7px 7px 5px rgba(50, 50, 50, 0.75);" +
1878
+			"box-shadow:         7px 7px 5px rgba(50, 50, 50, 0.75);" +
1879
+			'left: ' + x + 'px;' +
1880
+			'top: ' + y + 'px;');
1881
+	}
1882
+	
1883
+	function show_tooltip(d) {
1884
+		var x = d3.event.pageX + 10;
1885
+		var y = d3.event.pageY + 10;
1886
+		
1887
+		create_tooltip(d, x, y);
1888
+	}
1889
+	
1890
+	function hide_tooltip() {
1891
+		$("#tooltip").hide();
1892
+	}
1893
 }
1894
\ No newline at end of file
1895
Index: include/graphs/fgraph.php
1896
===================================================================
1897
--- include/graphs/fgraph.php	(revision 10314)
1898
+++ include/graphs/fgraph.php	(working copy)
1899
@@ -398,11 +398,13 @@
1900
 	setup_watermark($water_mark, $water_mark_file, $water_mark_url);
1901
 	
1902
 	if ($flash_chart) {
1903
-		if ($return){
1904
-			return flot_hcolumn_chart ($chart_data, $width, $height, $water_mark_url);
1905
+		if ($return) {
1906
+			return flot_hcolumn_chart(
1907
+				$chart_data, $width, $height, $water_mark_url);
1908
 		}
1909
-		else{
1910
-			echo flot_hcolumn_chart ($chart_data, $width, $height, $water_mark_url);
1911
+		else {
1912
+			echo flot_hcolumn_chart(
1913
+				$chart_data, $width, $height, $water_mark_url);
1914
 		}
1915
 	}
1916
 	else {
1917
@@ -422,7 +424,7 @@
1918
 		
1919
 		$id_graph = serialize_in_temp($graph, null, $ttl);
1920
 		
1921
-		return "<img src='".$homedir."include/graphs/functions_pchart.php?static_graph=1&graph_type=hbar&ttl=".$ttl."&id_graph=".$id_graph."'>";
1922
+		return "<img src='" . $homedir . "include/graphs/functions_pchart.php?static_graph=1&graph_type=hbar&ttl=".$ttl."&id_graph=".$id_graph."'>";
1923
 	}
1924
 }
1925
 
1926
Index: include/db/postgresql.php
1927
===================================================================
1928
--- include/db/postgresql.php	(revision 10314)
1929
+++ include/db/postgresql.php	(working copy)
1930
@@ -332,6 +332,9 @@
1931
 		else if (is_float ($value) || is_double ($value)) {
1932
 			$values_str .= sprintf("%f", $value);
1933
 		}
1934
+		elseif (is_string($value) && (strtoupper($value) === 'NULL')) {
1935
+			$values_str .= "NULL";
1936
+		}
1937
 		else {
1938
 			$values_str .= sprintf("'%s'", $value);
1939
 		}
1940
@@ -346,6 +349,8 @@
1941
 	
1942
 	$query .= ' VALUES (' . $values_str . ')';
1943
 	
1944
+	//html_debug_print($query);
1945
+	
1946
 	return db_process_sql($query, 'insert_id');
1947
 }
1948
 
1949
@@ -362,6 +367,18 @@
1950
 	return $str;
1951
 }
1952
 
1953
+function postgresql_encapsule_fields_with_same_name_to_instructions($field) {
1954
+	$return = $field;
1955
+	
1956
+	if (is_string($return)) {
1957
+		if ($return[0] !== '"') {
1958
+			$return = '"' . $return . '"';
1959
+		}
1960
+	}
1961
+	
1962
+	return $return;
1963
+}
1964
+
1965
 /**
1966
  * Get the first value of the first row of a table in the database from an
1967
  * array with filter conditions.
1968
Index: include/db/mysql.php
1969
===================================================================
1970
--- include/db/mysql.php	(revision 10314)
1971
+++ include/db/mysql.php	(working copy)
1972
@@ -346,6 +346,18 @@
1973
 	return $str;
1974
 }
1975
 
1976
+function mysql_encapsule_fields_with_same_name_to_instructions($field) {
1977
+	$return = $field;
1978
+	
1979
+	if (is_string($return)) {
1980
+		if ($return[0] !== '`') {
1981
+			$return = '`' . $return . '`';
1982
+		}
1983
+	}
1984
+	
1985
+	return $return;
1986
+}
1987
+
1988
 /**
1989
  * Get the first value of the first row of a table in the database from an
1990
  * array with filter conditions.
1991
Index: include/db/oracle.php
1992
===================================================================
1993
--- include/db/oracle.php	(revision 10314)
1994
+++ include/db/oracle.php	(working copy)
1995
@@ -254,7 +254,7 @@
1996
 			else if ($type[0] == '/INSERT'){
1997
 				$query = oci_parse($config['dbconnection'], substr($sql,1));			
1998
 			}
1999
-			else{
2000
+			else {
2001
 				$query = oci_parse($config['dbconnection'], $sql);
2002
 			}
2003
 		}
2004
@@ -448,6 +448,18 @@
2005
 	return str_replace(array('"', "'", '\\'), array('\\"', '\\\'', '\\\\'), $string);
2006
 }
2007
 
2008
+function oracle_encapsule_fields_with_same_name_to_instructions($field) {
2009
+	$return = $field;
2010
+	
2011
+	if (is_string($return)) {
2012
+		if ($return[0] !== '"') {
2013
+			$return = '"' . $return . '"';
2014
+		}
2015
+	}
2016
+	
2017
+	return $return;
2018
+}
2019
+
2020
 /**
2021
  * Get the first value of the first row of a table in the database from an
2022
  * array with filter conditions.
2023
@@ -649,7 +661,7 @@
2024
 			else if ($value[0] == '%') {
2025
 				$query .= sprintf ("%s LIKE '%s'", $field, $value);
2026
 			}
2027
-			else{ 
2028
+			else { 
2029
 				$query .= sprintf ("%s = '%s'", $field, $value);
2030
 			}
2031
 		}
2032
@@ -997,16 +1009,16 @@
2033
 	global $config;
2034
 	
2035
 	$type = explode(' ',strtoupper(trim($sql)));
2036
-	if ($type[0] == 'SELECT'){
2037
+	if ($type[0] == 'SELECT') {
2038
 		$sql = "SELECT count(*) as NUM FROM (" . $sql . ")";
2039
 	}
2040
 	$query = oci_parse($config['dbconnection'], $sql);
2041
 	oci_execute($query);
2042
-	if ($type[0] == 'SELECT'){
2043
+	if ($type[0] == 'SELECT') {
2044
 		$row = oci_fetch_assoc($query);
2045
 		$rows = $row['NUM'];
2046
 	}
2047
-	else{
2048
+	else {
2049
 		$rows = oci_num_rows($query);
2050
 	}
2051
 	
2052
@@ -1027,13 +1039,19 @@
2053
  */
2054
 function oracle_db_get_all_rows_field_filter ($table, $field, $condition, $order_field = "") {
2055
 	if (is_int ($condition) || is_bool ($condition)) {
2056
-		$sql = sprintf ("SELECT * FROM %s WHERE %s = %d", $table, $field, $condition);
2057
+		$sql = sprintf ("SELECT *
2058
+			FROM %s
2059
+			WHERE %s = %d", $table, $field, $condition);
2060
 	}
2061
 	else if (is_float ($condition) || is_double ($condition)) {
2062
-		$sql = sprintf ("SELECT * FROM %s WHERE %s = %f", $table, $field, $condition);
2063
+		$sql = sprintf ("SELECT *
2064
+			FROM %s
2065
+			WHERE %s = %f", $table, $field, $condition);
2066
 	}
2067
 	else {
2068
-		$sql = sprintf ("SELECT * FROM %s WHERE %s = '%s'", $table, $field, $condition);
2069
+		$sql = sprintf ("SELECT *
2070
+			FROM %s
2071
+			WHERE %s = '%s'", $table, $field, $condition);
2072
 	}
2073
 	
2074
 	if ($order_field != "")
2075
Index: include/functions_modules.php
2076
===================================================================
2077
--- include/functions_modules.php	(revision 10314)
2078
+++ include/functions_modules.php	(working copy)
2079
@@ -1663,15 +1663,15 @@
2080
 		$status = STATUS_AGENT_DOWN;
2081
 		$last_status =  modules_get_agentmodule_last_status($id_agent_module);
2082
 		switch($last_status) {
2083
-			case 0:
2084
+			case AGENT_STATUS_NORMAL:
2085
 				$title = __('UNKNOWN') . " - " . __('Last status') .
2086
 					" " . __('NORMAL');
2087
 				break;
2088
-			case 1:
2089
+			case AGENT_STATUS_CRITICAL:
2090
 				$title = __('UNKNOWN') . " - " . __('Last status') .
2091
 					" " . __('CRITICAL');
2092
 				break;
2093
-			case 2:
2094
+			case AGENT_STATUS_WARNING:
2095
 				$title = __('UNKNOWN') . " - " . __('Last status') .
2096
 					" " . __('WARNING');
2097
 				break;
2098
Index: include/functions_reporting.php
2099
===================================================================
2100
--- include/functions_reporting.php	(revision 10314)
2101
+++ include/functions_reporting.php	(working copy)
2102
@@ -907,6 +907,8 @@
2103
 }
2104
 
2105
 function reporting_get_stats_servers($tiny = true) {
2106
+	global $config;
2107
+	
2108
 	$server_performance = servers_get_performance();
2109
 	
2110
 	// Alerts table
2111
@@ -959,7 +961,9 @@
2112
 			$tdata[0] = html_print_image('images/network.png', true, array('title' => __('Network modules'), 'width' => '25px'));
2113
 			$tdata[1] = '<span class="big_data">' . format_numeric($server_performance ["total_network_modules"]) . '</span>';
2114
 			
2115
-			$tdata[2] = '<span class="med_data">' . format_numeric($server_performance ["network_modules_rate"], 2) . '</span>';
2116
+			$tdata[2] = '<span class="med_data">' .
2117
+				format_numeric($server_performance ["network_modules_rate"], 2) .
2118
+				'</span>';
2119
 			$tdata[3] = html_print_image('images/module.png', true, array('title' => __('Ratio') . ': ' . __('Modules by second'), 'width' => '16px')) . '/sec </span>';
2120
 			
2121
 			$table_srv->rowclass[] = '';
2122
@@ -1020,8 +1024,23 @@
2123
 		$table_srv->rowclass[] = '';
2124
 		$table_srv->data[] = $tdata;
2125
 		
2126
-		$system_events = db_get_value_sql('SELECT SQL_NO_CACHE COUNT(id_evento) FROM tevento');
2127
-
2128
+		
2129
+		switch ($config["dbtype"]) {
2130
+			case "mysql":
2131
+				$system_events = db_get_value_sql(
2132
+					'SELECT SQL_NO_CACHE COUNT(id_evento)
2133
+					FROM tevento');
2134
+				break;
2135
+			case "postgresql":
2136
+			case "oracle":
2137
+				$system_events = db_get_value_sql(
2138
+					'SELECT COUNT(id_evento)
2139
+					FROM tevento');
2140
+				break;
2141
+		}
2142
+		
2143
+		
2144
+		
2145
 		$tdata = array();
2146
 		$tdata[0] = html_print_image('images/lightning_go.png', true, array('title' => __('Total events'), 'width' => '25px'));
2147
 		$tdata[1] = '<span class="big_data">' . format_numeric($system_events) . '</span>';
2148
@@ -1109,16 +1128,21 @@
2149
 		$tdata = array();
2150
 		$table_mbs->colspan[count($table_mbs->data)][0] = 4;
2151
 		$table_mbs->cellstyle[count($table_mbs->data)][0] = 'text-align: center;';
2152
-		$tdata[0] = '<div id="outter_status_pie" style="height: ' . $graph_height . 'px"><div id="status_pie" style="margin: auto; width: ' . $graph_width . 'px;">' . graph_agent_status (false, $graph_width, $graph_height, true, true) . '</div></div>';
2153
+		$tdata[0] = '<div id="outter_status_pie" style="height: ' . $graph_height . 'px">' .
2154
+			'<div id="status_pie" style="margin: auto; width: ' . $graph_width . 'px;">' .
2155
+				graph_agent_status(false, $graph_width, $graph_height, true, true) .
2156
+			'</div></div>';
2157
 		$table_mbs->rowclass[] = '';
2158
 		$table_mbs->data[] = $tdata;
2159
 	}
2160
 	
2161
-	$output = '<fieldset class="databox tactical_set">
2162
-				<legend>' . 
2163
-					__('Monitors by status') . 
2164
-				'</legend>' . 
2165
-				html_print_table($table_mbs, true) . '</fieldset>';
2166
+	$output = '
2167
+		<fieldset class="databox tactical_set">
2168
+			<legend>' . 
2169
+				__('Monitors by status') . 
2170
+			'</legend>' . 
2171
+			html_print_table($table_mbs, true) .
2172
+		'</fieldset>';
2173
 	
2174
 	return $output;
2175
 }
2176
@@ -3123,9 +3147,29 @@
2177
 			}
2178
 			else {
2179
 				
2180
-				$data[0] = grafico_modulo_sparse($content['id_agent_module'], $content['period'],
2181
-					false, $sizgraph_w, $sizgraph_h, '', '', false, true, true,
2182
-					$report["datetime"], '', 0, 0, true, true, ui_get_full_url(false) . '/');
2183
+				$data[0] = grafico_modulo_sparse(
2184
+					$content['id_agent_module'],
2185
+					$content['period'],
2186
+					false,
2187
+					$sizgraph_w,
2188
+					$sizgraph_h,
2189
+					'',
2190
+					'',
2191
+					false,
2192
+					true,
2193
+					true,
2194
+					$report["datetime"],
2195
+					'',
2196
+					0,
2197
+					0,
2198
+					true,
2199
+					true,
2200
+					ui_get_full_url(false) . '/',
2201
+					1,
2202
+					false,
2203
+					'',
2204
+					false,
2205
+					true);
2206
 			}
2207
 			
2208
 			array_push ($table->data, $data);
2209
Index: include/auth/ldap.php
2210
===================================================================
2211
--- include/auth/ldap.php	(revision 10314)
2212
+++ include/auth/ldap.php	(working copy)
2213
@@ -65,8 +65,11 @@
2214
 $config["admin_can_make_admin"] = false;
2215
 
2216
 //Required and optional keys for this function to work
2217
-$req_keys = array ("ldap_server", "ldap_base_dn", "ldap_login_attr", "ldap_admin_group_name", "ldap_admin_group_attr", "ldap_admin_group_type", "ldap_user_filter", "ldap_user_attr");
2218
-$opt_keys = array ("ldap_port", "ldap_start_tls", "ldap_version", "ldap_admin_dn", "ldap_admin_pwd");
2219
+$req_keys = array("ldap_server", "ldap_base_dn", "ldap_login_attr",
2220
+	"ldap_admin_group_name", "ldap_admin_group_attr",
2221
+	"ldap_admin_group_type", "ldap_user_filter", "ldap_user_attr");
2222
+$opt_keys = array("ldap_port", "ldap_start_tls", "ldap_version",
2223
+	"ldap_admin_dn", "ldap_admin_pwd");
2224
 
2225
 global $ldap_cache; //Needs to be globalized because config_process_config () function calls this file first and the variable would be local and subsequently lost
2226
 $ldap_cache = array ();
2227
@@ -76,13 +79,15 @@
2228
 //Put each required key in a variable.
2229
 foreach ($req_keys as $key) {
2230
 	if (!isset ($config["auth"][$key])) {
2231
-		user_error ("Required key ".$key." not set", E_USER_ERROR);
2232
+		user_error("Required key " . $key . " not set", E_USER_ERROR);
2233
 	}
2234
 }
2235
 
2236
 // Convert group name to lower case to prevent problems
2237
-$config["auth"]["ldap_admin_group_attr"] = strtolower ($config["auth"]["ldap_admin_group_attr"]);
2238
-$config["auth"]["ldap_admin_group_type"] = strtolower ($config["auth"]["ldap_admin_group_type"]);
2239
+$config["auth"]["ldap_admin_group_attr"] =
2240
+	strtolower ($config["auth"]["ldap_admin_group_attr"]);
2241
+$config["auth"]["ldap_admin_group_type"] =
2242
+	strtolower ($config["auth"]["ldap_admin_group_type"]);
2243
 
2244
 foreach ($opt_keys as $key) {
2245
 	if (!isset ($config["auth"][$key])) {
2246
@@ -122,7 +127,7 @@
2247
 		return false;
2248
 	} 
2249
 	global $config;
2250
-		
2251
+	
2252
 	$profile = db_get_value ("id_usuario", "tusuario_perfil", "id_usuario", $login);
2253
 	
2254
 	if ($profile === false && empty ($config["auth"]["create_user_undefined"])) {
2255
@@ -311,7 +316,8 @@
2256
 	
2257
 	$nick = false;
2258
 	if (ldap_connect_bind ()) {
2259
-		$sr = @ldap_search ($ldap_cache["ds"], $config["auth"]["ldap_base_dn"], "(&(".$config["auth"]["ldap_login_attr"]."=".$login.")".$config["auth"]["ldap_user_filter"].")", array_values ($config["auth"]["ldap_user_attr"]));
2260
+		$sr = @ldap_search ($ldap_cache["ds"],
2261
+			io_safe_output($config["auth"]["ldap_base_dn"]), "(&(".io_safe_output($config["auth"]["ldap_login_attr"])."=".$login.")".io_safe_output($config["auth"]["ldap_user_filter"]).")", array_values ($config["auth"]["ldap_user_attr"]));
2262
 		
2263
 		if (!$sr) {
2264
 			$ldap_cache["error"] .= 'Error searching LDAP server: ' . ldap_error ($ldap_cache["ds"]);
2265
@@ -364,7 +370,7 @@
2266
 			return $ret;
2267
 		}
2268
 		
2269
-		$r = @ldap_bind ($ds, $config["auth"]["ldap_login_attr"]."=".$login.",".$config["auth"]["ldap_base_dn"], $password);
2270
+		$r = @ldap_bind ($ds, io_safe_output($config["auth"]["ldap_login_attr"])."=".$login.",".io_safe_output($config["auth"]["ldap_base_dn"]), $password);
2271
 		if (!$r) {
2272
 			$ldap_cache["error"] .= 'Invalid login';
2273
 		}
2274
@@ -393,7 +399,8 @@
2275
 	$time = get_system_time ();
2276
 	if (ldap_connect_bind ()) {
2277
 		
2278
-		$sr = ldap_search ($ldap_cache["ds"], $config["auth"]["ldap_base_dn"], "(&(".$config["auth"]["ldap_login_attr"]."=".$login.")".$config["auth"]["ldap_user_filter"].")", array_values ($config["auth"]["ldap_user_attr"]));
2279
+		$sr = ldap_search ($ldap_cache["ds"],
2280
+			io_safe_output($config["auth"]["ldap_base_dn"]), "(&(".io_safe_output($config["auth"]["ldap_login_attr"])."=".$login.")".io_safe_output($config["auth"]["ldap_user_filter"]).")", array_values ($config["auth"]["ldap_user_attr"]));
2281
 		
2282
 		if (!$sr) {
2283
 			$ldap_cache["error"] .= 'Error searching LDAP server (load_user): ' . ldap_error( $ldap_cache["ds"] );
2284
@@ -497,7 +504,7 @@
2285
 	$time = get_system_time ();
2286
 	
2287
 	if (ldap_connect_bind ()) {
2288
-		$sr = @ldap_search ($ldap_cache["ds"], $config["auth"]["ldap_base_dn"], $config["auth"]["ldap_user_filter"], array_values ($config["auth"]["ldap_user_attr"]));
2289
+		$sr = @ldap_search ($ldap_cache["ds"], io_safe_output($config["auth"]["ldap_base_dn"]), io_safe_output($config["auth"]["ldap_user_filter"]), array_values ($config["auth"]["ldap_user_attr"]));
2290
 		if (!$sr) {
2291
 			$ldap_cache["error"] .= 'Error searching LDAP server (get_users): ' . ldap_error( $ldap_cache["ds"] );
2292
 		}
2293
Index: include/auth/mysql.php
2294
===================================================================
2295
--- include/auth/mysql.php	(revision 10314)
2296
+++ include/auth/mysql.php	(working copy)
2297
@@ -512,7 +512,11 @@
2298
 		}
2299
 	}
2300
 	
2301
-	if (strlen($password) == 0 || !@ldap_bind ($ds, $config["ldap_login_attr"]."=".$login.",".$config["ldap_base_dn"], $password)) {
2302
+	if (strlen($password) == 0 ||
2303
+		!@ldap_bind($ds,
2304
+			io_safe_output($config["ldap_login_attr"]) . "=" . $login . "," . io_safe_output($config["ldap_base_dn"]),
2305
+			$password)) {
2306
+		
2307
 		$config["auth_error"] = 'User not found in database or incorrect password';
2308
 		@ldap_close ($ds);
2309
 		
2310
Index: include/functions_networkmap.php
2311
===================================================================
2312
--- include/functions_networkmap.php	(revision 10314)
2313
+++ include/functions_networkmap.php	(working copy)
2314
@@ -233,7 +233,8 @@
2315
 	$simple = 0, $font_size = 12, $layout = 'radial', $nooverlap = 0,
2316
 	$zoom = 1, $ranksep = 2.5, $center = 0, $regen = 1, $pure = 0,
2317
 	$id_networkmap = 0, $show_snmp_modules = 0, $cut_names = true,
2318
-	$relative = false, $text_filter = '', $l2_network = false, $ip_mask = null) {
2319
+	$relative = false, $text_filter = '', $l2_network = false, $ip_mask = null,
2320
+	$dont_show_subgroups = false) {
2321
 	
2322
 	global $config;
2323
 	
2324
@@ -262,7 +263,20 @@
2325
 	}
2326
 	
2327
 	if ($group >= 1) {
2328
-		$filter['id_grupo'] = $group;
2329
+		if ($dont_show_subgroups)
2330
+			$filter['id_grupo'] = $group;
2331
+		else {
2332
+			$childrens = groups_get_childrens($group, null, true);
2333
+			if (!empty($childrens)) {
2334
+				$childrens = array_keys($childrens);
2335
+				
2336
+				$filter['id_grupo'] = $childrens;
2337
+				$filter['id_grupo'][] = $group;
2338
+			}
2339
+			else {
2340
+				$filter['id_grupo'] = $group;
2341
+			}
2342
+		}
2343
 		
2344
 		//Order by id_parent ascendant for to avoid the bugs
2345
 		//because the first agents to process in the next
2346
@@ -589,7 +603,13 @@
2347
 }
2348
 
2349
 // Generate a dot graph definition for graphviz with groups
2350
-function networkmap_generate_dot_groups ($pandora_name, $group = 0, $simple = 0, $font_size = 12, $layout = 'radial', $nooverlap = 0, $zoom = 1, $ranksep = 2.5, $center = 0, $regen = 1, $pure = 0, $modwithalerts = 0, $module_group = 0, $hidepolicymodules = 0, $depth = 'all', $id_networkmap = 0, $dont_show_subgroups = 0, $text_filter = '') {
2351
+function networkmap_generate_dot_groups ($pandora_name, $group = 0,
2352
+	$simple = 0, $font_size = 12, $layout = 'radial', $nooverlap = 0,
2353
+	$zoom = 1, $ranksep = 2.5, $center = 0, $regen = 1, $pure = 0,
2354
+	$modwithalerts = 0, $module_group = 0, $hidepolicymodules = 0,
2355
+	$depth = 'all', $id_networkmap = 0, $dont_show_subgroups = 0,
2356
+	$text_filter = '') {
2357
+	
2358
 	global $config;
2359
 	
2360
 	$parents = array();
2361
@@ -682,7 +702,8 @@
2362
 		// Get agents data
2363
 		$agents = agents_get_agents ($filter,
2364
 			array ('id_grupo, nombre, id_os, id_agente, 
2365
-				normal_count, warning_count, critical_count, unknown_count, total_count, notinit_count'));
2366
+				normal_count, warning_count, critical_count,
2367
+				unknown_count, total_count, notinit_count'));
2368
 		
2369
 		if ($agents === false)
2370
 			$agents = array();
2371
@@ -1427,7 +1448,9 @@
2372
 	$values['show_groups'] = $show_groups;
2373
 	$values['show_modules'] = $show_modules;
2374
 	
2375
-	return @db_process_sql_insert ('tnetwork_map', $values);
2376
+	$values['server_name'] = "";
2377
+	
2378
+	return @db_process_sql_insert('tnetwork_map', $values);
2379
 }
2380
 
2381
 /**
2382
Index: include/javascript/introjs.css
2383
===================================================================
2384
--- include/javascript/introjs.css	(revision 0)
2385
+++ include/javascript/introjs.css	(revision 10417)
2386
@@ -0,0 +1,276 @@
2387
+.introjs-overlay {
2388
+  position: absolute;
2389
+  z-index: 999999;
2390
+  background-color: #000;
2391
+  opacity: 0;
2392
+  background: -moz-radial-gradient(center,ellipse cover,rgba(0,0,0,0.4) 0,rgba(0,0,0,0.9) 100%);
2393
+  background: -webkit-gradient(radial,center center,0px,center center,100%,color-stop(0%,rgba(0,0,0,0.4)),color-stop(100%,rgba(0,0,0,0.9)));
2394
+  background: -webkit-radial-gradient(center,ellipse cover,rgba(0,0,0,0.4) 0,rgba(0,0,0,0.9) 100%);
2395
+  background: -o-radial-gradient(center,ellipse cover,rgba(0,0,0,0.4) 0,rgba(0,0,0,0.9) 100%);
2396
+  background: -ms-radial-gradient(center,ellipse cover,rgba(0,0,0,0.4) 0,rgba(0,0,0,0.9) 100%);
2397
+  background: radial-gradient(center,ellipse cover,rgba(0,0,0,0.4) 0,rgba(0,0,0,0.9) 100%);
2398
+  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#66000000',endColorstr='#e6000000',GradientType=1);
2399
+  -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";
2400
+  filter: alpha(opacity=50);
2401
+  -webkit-transition: all 0.3s ease-out;
2402
+     -moz-transition: all 0.3s ease-out;
2403
+      -ms-transition: all 0.3s ease-out;
2404
+       -o-transition: all 0.3s ease-out;
2405
+          transition: all 0.3s ease-out;
2406
+}
2407
+
2408
+.introjs-fixParent {
2409
+  z-index: auto !important;
2410
+  opacity: 1.0 !important;
2411
+}
2412
+
2413
+.introjs-showElement,
2414
+tr.introjs-showElement > td,
2415
+tr.introjs-showElement > th {
2416
+  z-index: 9999999 !important;
2417
+}
2418
+
2419
+.introjs-relativePosition,
2420
+tr.introjs-showElement > td,
2421
+tr.introjs-showElement > th {
2422
+  position: relative;
2423
+}
2424
+
2425
+.introjs-helperLayer {
2426
+  position: absolute;
2427
+  z-index: 9999998;
2428
+  background-color: #FFF;
2429
+  background-color: rgba(255,255,255,.9);
2430
+  border: 1px solid #777;
2431
+  border: 1px solid rgba(0,0,0,.5);
2432
+  border-radius: 4px;
2433
+  box-shadow: 0 2px 15px rgba(0,0,0,.4);
2434
+  -webkit-transition: all 0.3s ease-out;
2435
+     -moz-transition: all 0.3s ease-out;
2436
+      -ms-transition: all 0.3s ease-out;
2437
+       -o-transition: all 0.3s ease-out;
2438
+          transition: all 0.3s ease-out;
2439
+}
2440
+
2441
+.introjs-helperNumberLayer {
2442
+  position: absolute;
2443
+  top: -16px;
2444
+  left: -16px;
2445
+  z-index: 9999999999 !important;
2446
+  padding: 2px;
2447
+  font-family: Arial, verdana, tahoma;
2448
+  font-size: 13px;
2449
+  font-weight: bold;
2450
+  color: white;
2451
+  text-align: center;
2452
+  text-shadow: 1px 1px 1px rgba(0,0,0,.3);
2453
+  background: #ff3019; /* Old browsers */
2454
+  background: -webkit-linear-gradient(top, #ff3019 0%, #cf0404 100%); /* Chrome10+,Safari5.1+ */
2455
+  background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #ff3019), color-stop(100%, #cf0404)); /* Chrome,Safari4+ */
2456
+  background:    -moz-linear-gradient(top, #ff3019 0%, #cf0404 100%); /* FF3.6+ */
2457
+  background:     -ms-linear-gradient(top, #ff3019 0%, #cf0404 100%); /* IE10+ */
2458
+  background:      -o-linear-gradient(top, #ff3019 0%, #cf0404 100%); /* Opera 11.10+ */
2459
+  background:         linear-gradient(to bottom, #ff3019 0%, #cf0404 100%);  /* W3C */
2460
+  width: 20px;
2461
+  height:20px;
2462
+  line-height: 20px;
2463
+  border: 3px solid white;
2464
+  border-radius: 50%;
2465
+  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff3019', endColorstr='#cf0404', GradientType=0); /* IE6-9 */
2466
+  filter: progid:DXImageTransform.Microsoft.Shadow(direction=135, strength=2, color=ff0000); /* IE10 text shadows */
2467
+  box-shadow: 0 2px 5px rgba(0,0,0,.4);
2468
+}
2469
+
2470
+.introjs-arrow {
2471
+  border: 5px solid white;
2472
+  content:'';
2473
+  position: absolute;
2474
+}
2475
+.introjs-arrow.top {
2476
+  top: -10px;
2477
+  border-top-color:transparent;
2478
+  border-right-color:transparent;
2479
+  border-bottom-color:white;
2480
+  border-left-color:transparent;
2481
+}
2482
+.introjs-arrow.top-right {
2483
+  top: -10px;
2484
+  right: 10px;
2485
+  border-top-color:transparent;
2486
+  border-right-color:transparent;
2487
+  border-bottom-color:white;
2488
+  border-left-color:transparent;
2489
+}
2490
+.introjs-arrow.top-middle {
2491
+  top: -10px;
2492
+  left: 50%;
2493
+  margin-left: -5px;
2494
+  border-top-color:transparent;
2495
+  border-right-color:transparent;
2496
+  border-bottom-color:white;
2497
+  border-left-color:transparent;
2498
+}
2499
+.introjs-arrow.right {
2500
+  right: -10px;
2501
+  top: 10px;
2502
+  border-top-color:transparent;
2503
+  border-right-color:transparent;
2504
+  border-bottom-color:transparent;
2505
+  border-left-color:white;
2506
+}
2507
+.introjs-arrow.bottom {
2508
+  bottom: -10px;
2509
+  border-top-color:white;
2510
+  border-right-color:transparent;
2511
+  border-bottom-color:transparent;
2512
+  border-left-color:transparent;
2513
+}
2514
+.introjs-arrow.left {
2515
+  left: -10px;
2516
+  top: 10px;
2517
+  border-top-color:transparent;
2518
+  border-right-color:white;
2519
+  border-bottom-color:transparent;
2520
+  border-left-color:transparent;
2521
+}
2522
+
2523
+.introjs-tooltip {
2524
+  position: absolute;
2525
+  padding: 10px;
2526
+  background-color: white;
2527
+  min-width: 200px;
2528
+  max-width: 300px;
2529
+  border-radius: 3px;
2530
+  box-shadow: 0 1px 10px rgba(0,0,0,.4);
2531
+  -webkit-transition: opacity 0.1s ease-out;
2532
+     -moz-transition: opacity 0.1s ease-out;
2533
+      -ms-transition: opacity 0.1s ease-out;
2534
+       -o-transition: opacity 0.1s ease-out;
2535
+          transition: opacity 0.1s ease-out;
2536
+}
2537
+
2538
+.introjs-tooltipbuttons {
2539
+  text-align: right;
2540
+}
2541
+
2542
+/*
2543
+ Buttons style by http://nicolasgallagher.com/lab/css3-github-buttons/
2544
+ Changed by Afshin Mehrabani
2545
+*/
2546
+.introjs-button {
2547
+  position: relative;
2548
+  overflow: visible;
2549
+  display: inline-block;
2550
+  padding: 0.3em 0.8em;
2551
+  border: 1px solid #d4d4d4;
2552
+  margin: 0;
2553
+  text-decoration: none;
2554
+  text-shadow: 1px 1px 0 #fff;
2555
+  font: 11px/normal sans-serif;
2556
+  color: #333;
2557
+  white-space: nowrap;
2558
+  cursor: pointer;
2559
+  outline: none;
2560
+  background-color: #ececec;
2561
+  background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#f4f4f4), to(#ececec));
2562
+  background-image: -moz-linear-gradient(#f4f4f4, #ececec);
2563
+  background-image: -o-linear-gradient(#f4f4f4, #ececec);
2564
+  background-image: linear-gradient(#f4f4f4, #ececec);
2565
+  -webkit-background-clip: padding;
2566
+  -moz-background-clip: padding;
2567
+  -o-background-clip: padding-box;
2568
+  /*background-clip: padding-box;*/ /* commented out due to Opera 11.10 bug */
2569
+  -webkit-border-radius: 0.2em;
2570
+  -moz-border-radius: 0.2em;
2571
+  border-radius: 0.2em;
2572
+  /* IE hacks */
2573
+  zoom: 1;
2574
+  *display: inline;
2575
+  margin-top: 10px;
2576
+}
2577
+
2578
+.introjs-button:hover {
2579
+  border-color: #bcbcbc;
2580
+  text-decoration: none;
2581
+  box-shadow: 0px 1px 1px #e3e3e3;
2582
+}
2583
+
2584
+.introjs-button:focus,
2585
+.introjs-button:active {
2586
+  background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#ececec), to(#f4f4f4));
2587
+  background-image: -moz-linear-gradient(#ececec, #f4f4f4);
2588
+  background-image: -o-linear-gradient(#ececec, #f4f4f4);
2589
+  background-image: linear-gradient(#ececec, #f4f4f4);
2590
+}
2591
+
2592
+/* overrides extra padding on button elements in Firefox */
2593
+.introjs-button::-moz-focus-inner {
2594
+  padding: 0;
2595
+  border: 0;
2596
+}
2597
+
2598
+.introjs-skipbutton {
2599
+  margin-right: 5px;
2600
+  color: #7a7a7a;
2601
+}
2602
+
2603
+.introjs-prevbutton {
2604
+  -webkit-border-radius: 0.2em 0 0 0.2em;
2605
+  -moz-border-radius: 0.2em 0 0 0.2em;
2606
+  border-radius: 0.2em 0 0 0.2em;
2607
+  border-right: none;
2608
+}
2609
+
2610
+.introjs-nextbutton {
2611
+  -webkit-border-radius: 0 0.2em 0.2em 0;
2612
+  -moz-border-radius: 0 0.2em 0.2em 0;
2613
+  border-radius: 0 0.2em 0.2em 0;
2614
+}
2615
+
2616
+.introjs-disabled, .introjs-disabled:hover, .introjs-disabled:focus {
2617
+  color: #9a9a9a;
2618
+  border-color: #d4d4d4;
2619
+  box-shadow: none;
2620
+  cursor: default;
2621
+  background-color: #f4f4f4;
2622
+  background-image: none;
2623
+  text-decoration: none;
2624
+}
2625
+
2626
+.introjs-bullets {
2627
+  text-align: center;
2628
+}
2629
+.introjs-bullets ul {
2630
+  clear: both;
2631
+  margin: 15px auto 0;
2632
+  padding: 0;
2633
+  display: inline-block;
2634
+}
2635
+.introjs-bullets ul li {
2636
+  list-style: none;
2637
+  float: left;
2638
+  margin: 0 2px;
2639
+}
2640
+.introjs-bullets ul li a {
2641
+  display: block;
2642
+  width: 6px;
2643
+  height: 6px;
2644
+  background: #ccc;
2645
+  border-radius: 10px;
2646
+  -moz-border-radius: 10px;
2647
+  -webkit-border-radius: 10px;
2648
+  text-decoration: none;
2649
+}
2650
+.introjs-bullets ul li a:hover {
2651
+  background: #999;
2652
+}
2653
+.introjs-bullets ul li a.active {
2654
+  background: #999;
2655
+}
2656
+.introjsFloatingElement {
2657
+  position: absolute;
2658
+  height: 0;
2659
+  width: 0;
2660
+  left: 50%;
2661
+  top: 50%;
2662
+}
2663
Index: include/javascript/intro.js
2664
===================================================================
2665
--- include/javascript/intro.js	(revision 0)
2666
+++ include/javascript/intro.js	(revision 10417)
2667
@@ -0,0 +1,1049 @@
2668
+/**
2669
+ * Intro.js v0.9.0
2670
+ * https://github.com/usablica/intro.js
2671
+ * MIT licensed
2672
+ *
2673
+ * Copyright (C) 2013 usabli.ca - A weekend project by Afshin Mehrabani (@afshinmeh)
2674
+ */
2675
+
2676
+(function (root, factory) {
2677
+  if (typeof exports === 'object') {
2678
+    // CommonJS
2679
+    factory(exports);
2680
+  } else if (typeof define === 'function' && define.amd) {
2681
+    // AMD. Register as an anonymous module.
2682
+    define(['exports'], factory);
2683
+  } else {
2684
+    // Browser globals
2685
+    factory(root);
2686
+  }
2687
+} (this, function (exports) {
2688
+  //Default config/variables
2689
+  var VERSION = '0.9.0';
2690
+
2691
+  /**
2692
+   * IntroJs main class
2693
+   *
2694
+   * @class IntroJs
2695
+   */
2696
+  function IntroJs(obj) {
2697
+    this._targetElement = obj;
2698
+
2699
+    this._options = {
2700
+      /* Next button label in tooltip box */
2701
+      nextLabel: 'Next &rarr;',
2702
+      /* Previous button label in tooltip box */
2703
+      prevLabel: '&larr; Back',
2704
+      /* Skip button label in tooltip box */
2705
+      skipLabel: 'Skip',
2706
+      /* Done button label in tooltip box */
2707
+      doneLabel: 'Done',
2708
+      /* Default tooltip box position */
2709
+      tooltipPosition: 'bottom',
2710
+      /* Next CSS class for tooltip boxes */
2711
+      tooltipClass: '',
2712
+      /* Close introduction when pressing Escape button? */
2713
+      exitOnEsc: true,
2714
+      /* Close introduction when clicking on overlay layer? */
2715
+      exitOnOverlayClick: true,
2716
+      /* Show step numbers in introduction? */
2717
+      showStepNumbers: true,
2718
+      /* Let user use keyboard to navigate the tour? */
2719
+      keyboardNavigation: true,
2720
+      /* Show tour control buttons? */
2721
+      showButtons: true,
2722
+      /* Show tour bullets? */
2723
+      showBullets: true,
2724
+      /* Scroll to highlighted element? */
2725
+      scrollToElement: true,
2726
+      /* Set the overlay opacity */
2727
+      overlayOpacity: 0.8
2728
+    };
2729
+  }
2730
+
2731
+  /**
2732
+   * Initiate a new introduction/guide from an element in the page
2733
+   *
2734
+   * @api private
2735
+   * @method _introForElement
2736
+   * @param {Object} targetElm
2737
+   * @returns {Boolean} Success or not?
2738
+   */
2739
+  function _introForElement(targetElm) {
2740
+    var introItems = [],
2741
+        self = this;
2742
+
2743
+    if (this._options.steps) {
2744
+      //use steps passed programmatically
2745
+      var allIntroSteps = [];
2746
+
2747
+      for (var i = 0, stepsLength = this._options.steps.length; i < stepsLength; i++) {
2748
+        var currentItem = _cloneObject(this._options.steps[i]);
2749
+        //set the step
2750
+        currentItem.step = introItems.length + 1;
2751
+        //use querySelector function only when developer used CSS selector
2752
+        if (typeof(currentItem.element) === 'string') {
2753
+          //grab the element with given selector from the page
2754
+          currentItem.element = document.querySelector(currentItem.element);
2755
+        }
2756
+
2757
+        //intro without element
2758
+        if (typeof(currentItem.element) === 'undefined' || currentItem.element == null) {
2759
+          var floatingElementQuery = document.querySelector(".introjsFloatingElement");
2760
+
2761
+          if (floatingElementQuery == null) {
2762
+            floatingElementQuery = document.createElement('div');
2763
+            floatingElementQuery.className = 'introjsFloatingElement';
2764
+
2765
+            document.body.appendChild(floatingElementQuery);
2766
+          }
2767
+
2768
+          currentItem.element  = floatingElementQuery;
2769
+          currentItem.position = 'floating';
2770
+        }
2771
+
2772
+        if (currentItem.element != null) {
2773
+          introItems.push(currentItem);
2774
+        }
2775
+      }
2776
+
2777
+    } else {
2778
+       //use steps from data-* annotations
2779
+      var allIntroSteps = targetElm.querySelectorAll('*[data-intro]');
2780
+      //if there's no element to intro
2781
+      if (allIntroSteps.length < 1) {
2782
+        return false;
2783
+      }
2784
+
2785
+      //first add intro items with data-step
2786
+      for (var i = 0, elmsLength = allIntroSteps.length; i < elmsLength; i++) {
2787
+        var currentElement = allIntroSteps[i];
2788
+        var step = parseInt(currentElement.getAttribute('data-step'), 10);
2789
+
2790
+        if (step > 0) {
2791
+          introItems[step - 1] = {
2792
+            element: currentElement,
2793
+            intro: currentElement.getAttribute('data-intro'),
2794
+            step: parseInt(currentElement.getAttribute('data-step'), 10),
2795
+            tooltipClass: currentElement.getAttribute('data-tooltipClass'),
2796
+            position: currentElement.getAttribute('data-position') || this._options.tooltipPosition
2797
+          };
2798
+        }
2799
+      }
2800
+
2801
+      //next add intro items without data-step
2802
+      //todo: we need a cleanup here, two loops are redundant
2803
+      var nextStep = 0;
2804
+      for (var i = 0, elmsLength = allIntroSteps.length; i < elmsLength; i++) {
2805
+        var currentElement = allIntroSteps[i];
2806
+
2807
+        if (currentElement.getAttribute('data-step') == null) {
2808
+
2809
+          while (true) {
2810
+            if (typeof introItems[nextStep] == 'undefined') {
2811
+              break;
2812
+            } else {
2813
+              nextStep++;
2814
+            }
2815
+          }
2816
+
2817
+          introItems[nextStep] = {
2818
+            element: currentElement,
2819
+            intro: currentElement.getAttribute('data-intro'),
2820
+            step: nextStep + 1,
2821
+            tooltipClass: currentElement.getAttribute('data-tooltipClass'),
2822
+            position: currentElement.getAttribute('data-position') || this._options.tooltipPosition
2823
+          };
2824
+        }
2825
+      }
2826
+    }
2827
+
2828
+    //removing undefined/null elements
2829
+    var tempIntroItems = [];
2830
+    for (var z = 0; z < introItems.length; z++) {
2831
+      introItems[z] && tempIntroItems.push(introItems[z]);  // copy non-empty values to the end of the array
2832
+    }
2833
+
2834
+    introItems = tempIntroItems;
2835
+
2836
+    //Ok, sort all items with given steps
2837
+    introItems.sort(function (a, b) {
2838
+      return a.step - b.step;
2839
+    });
2840
+
2841
+    //set it to the introJs object
2842
+    self._introItems = introItems;
2843
+
2844
+    //add overlay layer to the page
2845
+    if(_addOverlayLayer.call(self, targetElm)) {
2846
+      //then, start the show
2847
+      _nextStep.call(self);
2848
+
2849
+      var skipButton     = targetElm.querySelector('.introjs-skipbutton'),
2850
+          nextStepButton = targetElm.querySelector('.introjs-nextbutton');
2851
+
2852
+      self._onKeyDown = function(e) {
2853
+        if (e.keyCode === 27 && self._options.exitOnEsc == true) {
2854
+          propagate_exit = true;
2855
+          
2856
+          //check if any callback is defined
2857
+          if (self._introExitCallback != undefined) {
2858
+            propagate_exit = self._introExitCallback.call(self);
2859
+            if (typeof(propagate_exit) == "undefined")
2860
+              propagate_exit = true;
2861
+          }
2862
+          
2863
+          //escape key pressed, exit the intro
2864
+          if (propagate_exit)
2865
+            _exitIntro.call(self, targetElm);
2866
+          
2867
+        } else if(e.keyCode === 37) {
2868
+          //left arrow
2869
+          _previousStep.call(self);
2870
+        } else if (e.keyCode === 39 || e.keyCode === 13) {
2871
+          //right arrow or enter
2872
+          _nextStep.call(self);
2873
+          //prevent default behaviour on hitting Enter, to prevent steps being skipped in some browsers
2874
+          if(e.preventDefault) {
2875
+            e.preventDefault();
2876
+          } else {
2877
+            e.returnValue = false;
2878
+          }
2879
+        }
2880
+      };
2881
+
2882
+      self._onResize = function(e) {
2883
+        _setHelperLayerPosition.call(self, document.querySelector('.introjs-helperLayer'));
2884
+      };
2885
+
2886
+      if (window.addEventListener) {
2887
+        if (this._options.keyboardNavigation) {
2888
+          window.addEventListener('keydown', self._onKeyDown, true);
2889
+        }
2890
+        //for window resize
2891
+        window.addEventListener("resize", self._onResize, true);
2892
+      } else if (document.attachEvent) { //IE
2893
+        if (this._options.keyboardNavigation) {
2894
+          document.attachEvent('onkeydown', self._onKeyDown);
2895
+        }
2896
+        //for window resize
2897
+        document.attachEvent("onresize", self._onResize);
2898
+      }
2899
+    }
2900
+    return false;
2901
+  }
2902
+
2903
+ /*
2904
+   * makes a copy of the object
2905
+   * @api private
2906
+   * @method _cloneObject
2907
+  */
2908
+  function _cloneObject(object) {
2909
+      if (object == null || typeof (object) != 'object' || typeof (object.nodeType) != 'undefined') {
2910
+          return object;
2911
+      }
2912
+      var temp = {};
2913
+      for (var key in object) {
2914
+          temp[key] = _cloneObject(object[key]);
2915
+      }
2916
+      return temp;
2917
+  }
2918
+  /**
2919
+   * Go to specific step of introduction
2920
+   *
2921
+   * @api private
2922
+   * @method _goToStep
2923
+   */
2924
+  function _goToStep(step) {
2925
+    //because steps starts with zero
2926
+    this._currentStep = step - 2;
2927
+    if (typeof (this._introItems) !== 'undefined') {
2928
+      _nextStep.call(this);
2929
+    }
2930
+  }
2931
+
2932
+  /**
2933
+   * Go to next step on intro
2934
+   *
2935
+   * @api private
2936
+   * @method _nextStep
2937
+   */
2938
+  function _nextStep() {
2939
+    this._direction = 'forward';
2940
+
2941
+    if (typeof (this._currentStep) === 'undefined') {
2942
+      this._currentStep = 0;
2943
+    } else {
2944
+      ++this._currentStep;
2945
+    }
2946
+
2947
+    if ((this._introItems.length) <= this._currentStep) {
2948
+      //end of the intro
2949
+      //check if any callback is defined
2950
+      if (typeof (this._introCompleteCallback) === 'function') {
2951
+        this._introCompleteCallback.call(this);
2952
+      }
2953
+      _exitIntro.call(this, this._targetElement);
2954
+      return;
2955
+    }
2956
+
2957
+    var nextStep = this._introItems[this._currentStep];
2958
+    if (typeof (this._introBeforeChangeCallback) !== 'undefined') {
2959
+      this._introBeforeChangeCallback.call(this, nextStep.element);
2960
+    }
2961
+
2962
+    _showElement.call(this, nextStep);
2963
+  }
2964
+
2965
+  /**
2966
+   * Go to previous step on intro
2967
+   *
2968
+   * @api private
2969
+   * @method _nextStep
2970
+   */
2971
+  function _previousStep() {
2972
+    this._direction = 'backward';
2973
+
2974
+    if (this._currentStep === 0) {
2975
+      return false;
2976
+    }
2977
+
2978
+    var nextStep = this._introItems[--this._currentStep];
2979
+    if (typeof (this._introBeforeChangeCallback) !== 'undefined') {
2980
+      this._introBeforeChangeCallback.call(this, nextStep.element);
2981
+    }
2982
+
2983
+    _showElement.call(this, nextStep);
2984
+  }
2985
+
2986
+  /**
2987
+   * Exit from intro
2988
+   *
2989
+   * @api private
2990
+   * @method _exitIntro
2991
+   * @param {Object} targetElement
2992
+   */
2993
+  function _exitIntro(targetElement) {
2994
+    //remove overlay layer from the page
2995
+    var overlayLayer = targetElement.querySelector('.introjs-overlay');
2996
+
2997
+    //return if intro already completed or skipped
2998
+    if (overlayLayer == null) {
2999
+      return;
3000
+    }
3001
+
3002
+    //for fade-out animation
3003
+    overlayLayer.style.opacity = 0;
3004
+    setTimeout(function () {
3005
+      if (overlayLayer.parentNode) {
3006
+        overlayLayer.parentNode.removeChild(overlayLayer);
3007
+      }
3008
+    }, 500);
3009
+
3010
+    //remove all helper layers
3011
+    var helperLayer = targetElement.querySelector('.introjs-helperLayer');
3012
+    if (helperLayer) {
3013
+      helperLayer.parentNode.removeChild(helperLayer);
3014
+    }
3015
+
3016
+    //remove intro floating element
3017
+    var floatingElement = document.querySelector('.introjsFloatingElement');
3018
+    if (floatingElement) {
3019
+      floatingElement.parentNode.removeChild(floatingElement);
3020
+    }
3021
+
3022
+    //remove `introjs-showElement` class from the element
3023
+    var showElement = document.querySelector('.introjs-showElement');
3024
+    if (showElement) {
3025
+      showElement.className = showElement.className.replace(/introjs-[a-zA-Z]+/g, '').replace(/^\s+|\s+$/g, ''); // This is a manual trim.
3026
+    }
3027
+
3028
+    //remove `introjs-fixParent` class from the elements
3029
+    var fixParents = document.querySelectorAll('.introjs-fixParent');
3030
+    if (fixParents && fixParents.length > 0) {
3031
+      for (var i = fixParents.length - 1; i >= 0; i--) {
3032
+        fixParents[i].className = fixParents[i].className.replace(/introjs-fixParent/g, '').replace(/^\s+|\s+$/g, '');
3033
+      };
3034
+    }
3035
+
3036
+    //clean listeners
3037
+    if (window.removeEventListener) {
3038
+      window.removeEventListener('keydown', this._onKeyDown, true);
3039
+    } else if (document.detachEvent) { //IE
3040
+      document.detachEvent('onkeydown', this._onKeyDown);
3041
+    }
3042
+
3043
+    //set the step to zero
3044
+    this._currentStep = undefined;
3045
+  }
3046
+
3047
+  /**
3048
+   * Render tooltip box in the page
3049
+   *
3050
+   * @api private
3051
+   * @method _placeTooltip
3052
+   * @param {Object} targetElement
3053
+   * @param {Object} tooltipLayer
3054
+   * @param {Object} arrowLayer
3055
+   */
3056
+  function _placeTooltip(targetElement, tooltipLayer, arrowLayer, helperNumberLayer) {
3057
+    var tooltipCssClass = '',
3058
+        currentStepObj,
3059
+        tooltipOffset,
3060
+        targetElementOffset;
3061
+
3062
+    //reset the old style
3063
+    tooltipLayer.style.top        = null;
3064
+    tooltipLayer.style.right      = null;
3065
+    tooltipLayer.style.bottom     = null;
3066
+    tooltipLayer.style.left       = null;
3067
+    tooltipLayer.style.marginLeft = null;
3068
+    tooltipLayer.style.marginTop  = null;
3069
+
3070
+    arrowLayer.style.display = 'inherit';
3071
+
3072
+    if (typeof(helperNumberLayer) != 'undefined' && helperNumberLayer != null) {
3073
+      helperNumberLayer.style.top  = null;
3074
+      helperNumberLayer.style.left = null;
3075
+    }
3076
+
3077
+    //prevent error when `this._currentStep` is undefined
3078
+    if (!this._introItems[this._currentStep]) return;
3079
+
3080
+    //if we have a custom css class for each step
3081
+    currentStepObj = this._introItems[this._currentStep];
3082
+    if (typeof (currentStepObj.tooltipClass) === 'string') {
3083
+      tooltipCssClass = currentStepObj.tooltipClass;
3084
+    } else {
3085
+      tooltipCssClass = this._options.tooltipClass;
3086
+    }
3087
+
3088
+    tooltipLayer.className = ('introjs-tooltip ' + tooltipCssClass).replace(/^\s+|\s+$/g, '');
3089
+
3090
+    //custom css class for tooltip boxes
3091
+    var tooltipCssClass = this._options.tooltipClass;
3092
+
3093
+    currentTooltipPosition = this._introItems[this._currentStep].position;
3094
+    switch (currentTooltipPosition) {
3095
+      case 'top':
3096
+        tooltipLayer.style.left = '15px';
3097
+        tooltipLayer.style.top = '-' + (_getOffset(tooltipLayer).height + 10) + 'px';
3098
+        arrowLayer.className = 'introjs-arrow bottom';
3099
+        break;
3100
+      case 'right':
3101
+        tooltipLayer.style.left = (_getOffset(targetElement).width + 20) + 'px';
3102
+        arrowLayer.className = 'introjs-arrow left';
3103
+        break;
3104
+      case 'left':
3105
+        if (this._options.showStepNumbers == true) {
3106
+          tooltipLayer.style.top = '15px';
3107
+        }
3108
+        tooltipLayer.style.right = (_getOffset(targetElement).width + 20) + 'px';
3109
+        arrowLayer.className = 'introjs-arrow right';
3110
+        break;
3111
+      case 'floating':
3112
+        arrowLayer.style.display = 'none';
3113
+
3114
+        //we have to adjust the top and left of layer manually for intro items without element
3115
+        tooltipOffset = _getOffset(tooltipLayer);
3116
+
3117
+        tooltipLayer.style.left   = '50%';
3118
+        tooltipLayer.style.top    = '50%';
3119
+        tooltipLayer.style.marginLeft = '-' + (tooltipOffset.width / 2)  + 'px';
3120
+        tooltipLayer.style.marginTop  = '-' + (tooltipOffset.height / 2) + 'px';
3121
+
3122
+        if (typeof(helperNumberLayer) != 'undefined' && helperNumberLayer != null) {
3123
+          helperNumberLayer.style.left = '-' + ((tooltipOffset.width / 2) + 18) + 'px';
3124
+          helperNumberLayer.style.top  = '-' + ((tooltipOffset.height / 2) + 18) + 'px';
3125
+        }
3126
+
3127
+        break;
3128
+      case 'bottom-right-aligned':
3129
+        arrowLayer.className      = 'introjs-arrow top-right';
3130
+        tooltipLayer.style.right  = '0px';
3131
+        tooltipLayer.style.bottom = '-' + (_getOffset(tooltipLayer).height + 10) + 'px';
3132
+        break;
3133
+      case 'bottom-middle-aligned':
3134
+        targetElementOffset = _getOffset(targetElement);
3135
+        tooltipOffset       = _getOffset(tooltipLayer);
3136
+
3137
+        arrowLayer.className      = 'introjs-arrow top-middle';
3138
+        tooltipLayer.style.left   = (targetElementOffset.width / 2 - tooltipOffset.width / 2) + 'px';
3139
+        tooltipLayer.style.bottom = '-' + (tooltipOffset.height + 10) + 'px';
3140
+        break;
3141
+      case 'bottom-left-aligned':
3142
+      // Bottom-left-aligned is the same as the default bottom
3143
+      case 'bottom':
3144
+      // Bottom going to follow the default behavior
3145
+      default:
3146
+        tooltipLayer.style.bottom = '-' + (_getOffset(tooltipLayer).height + 10) + 'px';
3147
+        arrowLayer.className = 'introjs-arrow top';
3148
+        break;
3149
+    }
3150
+  }
3151
+
3152
+  /**
3153
+   * Update the position of the helper layer on the screen
3154
+   *
3155
+   * @api private
3156
+   * @method _setHelperLayerPosition
3157
+   * @param {Object} helperLayer
3158
+   */
3159
+  function _setHelperLayerPosition(helperLayer) {
3160
+    if (helperLayer) {
3161
+      //prevent error when `this._currentStep` in undefined
3162
+      if (!this._introItems[this._currentStep]) return;
3163
+
3164
+      var currentElement  = this._introItems[this._currentStep],
3165
+          elementPosition = _getOffset(currentElement.element),
3166
+          widthHeightPadding = 10;
3167
+
3168
+      if (currentElement.position == 'floating') {
3169
+        widthHeightPadding = 0;
3170
+      }
3171
+
3172
+      //set new position to helper layer
3173
+      helperLayer.setAttribute('style', 'width: ' + (elementPosition.width  + widthHeightPadding)  + 'px; ' +
3174
+                                        'height:' + (elementPosition.height + widthHeightPadding)  + 'px; ' +
3175
+                                        'top:'    + (elementPosition.top    - 5)   + 'px;' +
3176
+                                        'left: '  + (elementPosition.left   - 5)   + 'px;');
3177
+    }
3178
+  }
3179
+
3180
+  /**
3181
+   * Show an element on the page
3182
+   *
3183
+   * @api private
3184
+   * @method _showElement
3185
+   * @param {Object} targetElement
3186
+   */
3187
+  function _showElement(targetElement) {
3188
+
3189
+    if (typeof (this._introChangeCallback) !== 'undefined') {
3190
+        this._introChangeCallback.call(this, targetElement.element);
3191
+    }
3192
+
3193
+    var self = this,
3194
+        oldHelperLayer = document.querySelector('.introjs-helperLayer'),
3195
+        elementPosition = _getOffset(targetElement.element);
3196
+
3197
+    if (oldHelperLayer != null) {
3198
+      var oldHelperNumberLayer = oldHelperLayer.querySelector('.introjs-helperNumberLayer'),
3199
+          oldtooltipLayer      = oldHelperLayer.querySelector('.introjs-tooltiptext'),
3200
+          oldArrowLayer        = oldHelperLayer.querySelector('.introjs-arrow'),
3201
+          oldtooltipContainer  = oldHelperLayer.querySelector('.introjs-tooltip'),
3202
+          skipTooltipButton    = oldHelperLayer.querySelector('.introjs-skipbutton'),
3203
+          prevTooltipButton    = oldHelperLayer.querySelector('.introjs-prevbutton'),
3204
+          nextTooltipButton    = oldHelperLayer.querySelector('.introjs-nextbutton');
3205
+
3206
+      //hide the tooltip
3207
+      oldtooltipContainer.style.opacity = 0;
3208
+
3209
+      if (oldHelperNumberLayer != null) {
3210
+        var lastIntroItem = this._introItems[(targetElement.step - 2 >= 0 ? targetElement.step - 2 : 0)];
3211
+
3212
+        if (lastIntroItem != null && (this._direction == 'forward' && lastIntroItem.position == 'floating') || (this._direction == 'backward' && targetElement.position == 'floating')) {
3213
+          oldHelperNumberLayer.style.opacity = 0;
3214
+        }
3215
+      }
3216
+
3217
+      //set new position to helper layer
3218
+      _setHelperLayerPosition.call(self, oldHelperLayer);
3219
+
3220
+      //remove `introjs-fixParent` class from the elements
3221
+      var fixParents = document.querySelectorAll('.introjs-fixParent');
3222
+      if (fixParents && fixParents.length > 0) {
3223
+        for (var i = fixParents.length - 1; i >= 0; i--) {
3224
+          fixParents[i].className = fixParents[i].className.replace(/introjs-fixParent/g, '').replace(/^\s+|\s+$/g, '');
3225
+        };
3226
+      }
3227
+
3228
+      //remove old classes
3229
+      var oldShowElement = document.querySelector('.introjs-showElement');
3230
+      oldShowElement.className = oldShowElement.className.replace(/introjs-[a-zA-Z]+/g, '').replace(/^\s+|\s+$/g, '');
3231
+      //we should wait until the CSS3 transition is competed (it's 0.3 sec) to prevent incorrect `height` and `width` calculation
3232
+      if (self._lastShowElementTimer) {
3233
+        clearTimeout(self._lastShowElementTimer);
3234
+      }
3235
+      self._lastShowElementTimer = setTimeout(function() {
3236
+        //set current step to the label
3237
+        if (oldHelperNumberLayer != null) {
3238
+          oldHelperNumberLayer.innerHTML = targetElement.step;
3239
+        }
3240
+        //set current tooltip text
3241
+        oldtooltipLayer.innerHTML = targetElement.intro;
3242
+        //set the tooltip position
3243
+        _placeTooltip.call(self, targetElement.element, oldtooltipContainer, oldArrowLayer, oldHelperNumberLayer);
3244
+
3245
+        //change active bullet
3246
+        oldHelperLayer.querySelector('.introjs-bullets li > a.active').className = '';
3247
+        oldHelperLayer.querySelector('.introjs-bullets li > a[data-stepnumber="' + targetElement.step + '"]').className = 'active';
3248
+
3249
+        //show the tooltip
3250
+        oldtooltipContainer.style.opacity = 1;
3251
+        if (oldHelperNumberLayer) oldHelperNumberLayer.style.opacity = 1;
3252
+      }, 350);
3253
+
3254
+    } else {
3255
+      var helperLayer       = document.createElement('div'),
3256
+          arrowLayer        = document.createElement('div'),
3257
+          tooltipLayer      = document.createElement('div'),
3258
+          tooltipTextLayer  = document.createElement('div'),
3259
+          bulletsLayer      = document.createElement('div'),
3260
+          buttonsLayer      = document.createElement('div');
3261
+
3262
+      helperLayer.className = 'introjs-helperLayer';
3263
+
3264
+      //set new position to helper layer
3265
+      _setHelperLayerPosition.call(self, helperLayer);
3266
+
3267
+      //add helper layer to target element
3268
+      this._targetElement.appendChild(helperLayer);
3269
+
3270
+      arrowLayer.className = 'introjs-arrow';
3271
+
3272
+      tooltipTextLayer.className = 'introjs-tooltiptext';
3273
+      tooltipTextLayer.innerHTML = targetElement.intro;
3274
+
3275
+      bulletsLayer.className = 'introjs-bullets';
3276
+
3277
+      if (this._options.showBullets === false) {
3278
+        bulletsLayer.style.display = 'none';
3279
+      }
3280
+
3281
+      var ulContainer = document.createElement('ul');
3282
+
3283
+      for (var i = 0, stepsLength = this._introItems.length; i < stepsLength; i++) {
3284
+        var innerLi    = document.createElement('li');
3285
+        var anchorLink = document.createElement('a');
3286
+
3287
+        anchorLink.onclick = function() {
3288
+          self.goToStep(this.getAttribute('data-stepnumber'));
3289
+        };
3290
+
3291
+        if (i === (targetElement.step-1)) anchorLink.className = "active";
3292
+
3293
+        anchorLink.href = 'javascript:void(0);';
3294
+        anchorLink.innerHTML = "&nbsp;";
3295
+        anchorLink.setAttribute('data-stepnumber', this._introItems[i].step);
3296
+
3297
+        innerLi.appendChild(anchorLink);
3298
+        ulContainer.appendChild(innerLi);
3299
+      }
3300
+
3301
+      bulletsLayer.appendChild(ulContainer);
3302
+
3303
+      buttonsLayer.className = 'introjs-tooltipbuttons';
3304
+      if (this._options.showButtons === false) {
3305
+        buttonsLayer.style.display = 'none';
3306
+      }
3307
+
3308
+      tooltipLayer.className = 'introjs-tooltip';
3309
+      tooltipLayer.appendChild(tooltipTextLayer);
3310
+      tooltipLayer.appendChild(bulletsLayer);
3311
+
3312
+      //add helper layer number
3313
+      if (this._options.showStepNumbers == true) {
3314
+        var helperNumberLayer = document.createElement('span');
3315
+        helperNumberLayer.className = 'introjs-helperNumberLayer';
3316
+        helperNumberLayer.innerHTML = targetElement.step;
3317
+        helperLayer.appendChild(helperNumberLayer);
3318
+      }
3319
+      tooltipLayer.appendChild(arrowLayer);
3320
+      helperLayer.appendChild(tooltipLayer);
3321
+
3322
+      //next button
3323
+      var nextTooltipButton = document.createElement('a');
3324
+
3325
+      nextTooltipButton.onclick = function() {
3326
+        if (self._introItems.length - 1 != self._currentStep) {
3327
+          _nextStep.call(self);
3328
+        }
3329
+      };
3330
+
3331
+      nextTooltipButton.href = 'javascript:void(0);';
3332
+      nextTooltipButton.innerHTML = this._options.nextLabel;
3333
+
3334
+      //previous button
3335
+      var prevTooltipButton = document.createElement('a');
3336
+
3337
+      prevTooltipButton.onclick = function() {
3338
+        if (self._currentStep != 0) {
3339
+          _previousStep.call(self);
3340
+        }
3341
+      };
3342
+
3343
+      prevTooltipButton.href = 'javascript:void(0);';
3344
+      prevTooltipButton.innerHTML = this._options.prevLabel;
3345
+
3346
+      //skip button
3347
+      var skipTooltipButton = document.createElement('a');
3348
+      skipTooltipButton.className = 'introjs-button introjs-skipbutton';
3349
+      skipTooltipButton.href = 'javascript:void(0);';
3350
+      skipTooltipButton.innerHTML = this._options.skipLabel;
3351
+
3352
+      skipTooltipButton.onclick = function() {
3353
+        propagate_exit = true;
3354
+        
3355
+        if (self._introItems.length - 1 == self._currentStep && typeof (self._introCompleteCallback) === 'function') {
3356
+          propagate_exit = self._introCompleteCallback.call(self);
3357
+          if (typeof(propagate_exit) == "undefined")
3358
+            propagate_exit = true;
3359
+        }
3360
+        
3361
+        if (self._introItems.length - 1 != self._currentStep && typeof (self._introExitCallback) === 'function') {
3362
+          propagate_exit = self._introExitCallback.call(self);
3363
+          if (typeof(propagate_exit) == "undefined")
3364
+            propagate_exit = true;
3365
+        }
3366
+        
3367
+        if (propagate_exit)
3368
+          _exitIntro.call(self, self._targetElement);
3369
+      };
3370
+
3371
+      buttonsLayer.appendChild(skipTooltipButton);
3372
+
3373
+      //in order to prevent displaying next/previous button always
3374
+      if (this._introItems.length > 1) {
3375
+        buttonsLayer.appendChild(prevTooltipButton);
3376
+        buttonsLayer.appendChild(nextTooltipButton);
3377
+      }
3378
+
3379
+      tooltipLayer.appendChild(buttonsLayer);
3380
+
3381
+      //set proper position
3382
+      _placeTooltip.call(self, targetElement.element, tooltipLayer, arrowLayer, helperNumberLayer);
3383
+    }
3384
+
3385
+    if (this._currentStep == 0 && this._introItems.length > 1) {
3386
+      prevTooltipButton.className = 'introjs-button introjs-prevbutton introjs-disabled';
3387
+      nextTooltipButton.className = 'introjs-button introjs-nextbutton';
3388
+      skipTooltipButton.innerHTML = this._options.skipLabel;
3389
+    } else if (this._introItems.length - 1 == this._currentStep || this._introItems.length == 1) {
3390
+      skipTooltipButton.innerHTML = this._options.doneLabel;
3391
+      prevTooltipButton.className = 'introjs-button introjs-prevbutton';
3392
+      nextTooltipButton.className = 'introjs-button introjs-nextbutton introjs-disabled';
3393
+    } else {
3394
+      prevTooltipButton.className = 'introjs-button introjs-prevbutton';
3395
+      nextTooltipButton.className = 'introjs-button introjs-nextbutton';
3396
+      skipTooltipButton.innerHTML = this._options.skipLabel;
3397
+    }
3398
+
3399
+    //Set focus on "next" button, so that hitting Enter always moves you onto the next step
3400
+    nextTooltipButton.focus();
3401
+
3402
+    //add target element position style
3403
+    targetElement.element.className += ' introjs-showElement';
3404
+
3405
+    var currentElementPosition = _getPropValue(targetElement.element, 'position');
3406
+    if (currentElementPosition !== 'absolute' &&
3407
+        currentElementPosition !== 'relative') {
3408
+      //change to new intro item
3409
+      targetElement.element.className += ' introjs-relativePosition';
3410
+    }
3411
+
3412
+    var parentElm = targetElement.element.parentNode;
3413
+    while (parentElm != null) {
3414
+      if (parentElm.tagName.toLowerCase() === 'body') break;
3415
+
3416
+      //fix The Stacking Contenxt problem.
3417
+      //More detail: https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Understanding_z_index/The_stacking_context
3418
+      var zIndex = _getPropValue(parentElm, 'z-index');
3419
+      var opacity = parseFloat(_getPropValue(parentElm, 'opacity'));
3420
+      var transform = _getPropValue(parentElm, 'transform') || _getPropValue(parentElm, '-webkit-transform') || _getPropValue(parentElm, '-moz-transform') || _getPropValue(parentElm, '-ms-transform') || _getPropValue(parentElm, '-o-transform');
3421
+      if (/[0-9]+/.test(zIndex) || opacity < 1 || transform !== 'none') {
3422
+        parentElm.className += ' introjs-fixParent';
3423
+      }
3424
+
3425
+      parentElm = parentElm.parentNode;
3426
+    }
3427
+
3428
+    if (!_elementInViewport(targetElement.element) && this._options.scrollToElement === true) {
3429
+      var rect = targetElement.element.getBoundingClientRect(),
3430
+        winHeight=_getWinSize().height,
3431
+        top = rect.bottom - (rect.bottom - rect.top),
3432
+        bottom = rect.bottom - winHeight;
3433
+
3434
+      //Scroll up
3435
+      if (top < 0 || targetElement.element.clientHeight > winHeight) {
3436
+        window.scrollBy(0, top - 30); // 30px padding from edge to look nice
3437
+
3438
+      //Scroll down
3439
+      } else {
3440
+        window.scrollBy(0, bottom + 100); // 70px + 30px padding from edge to look nice
3441
+      }
3442
+    }
3443
+
3444
+    if (typeof (this._introAfterChangeCallback) !== 'undefined') {
3445
+        this._introAfterChangeCallback.call(this, targetElement.element);
3446
+    }
3447
+  }
3448
+
3449
+  /**
3450
+   * Get an element CSS property on the page
3451
+   * Thanks to JavaScript Kit: http://www.javascriptkit.com/dhtmltutors/dhtmlcascade4.shtml
3452
+   *
3453
+   * @api private
3454
+   * @method _getPropValue
3455
+   * @param {Object} element
3456
+   * @param {String} propName
3457
+   * @returns Element's property value
3458
+   */
3459
+  function _getPropValue (element, propName) {
3460
+    var propValue = '';
3461
+    if (element.currentStyle) { //IE
3462
+      propValue = element.currentStyle[propName];
3463
+    } else if (document.defaultView && document.defaultView.getComputedStyle) { //Others
3464
+      propValue = document.defaultView.getComputedStyle(element, null).getPropertyValue(propName);
3465
+    }
3466
+
3467
+    //Prevent exception in IE
3468
+    if (propValue && propValue.toLowerCase) {
3469
+      return propValue.toLowerCase();
3470
+    } else {
3471
+      return propValue;
3472
+    }
3473
+  }
3474
+
3475
+  /**
3476
+   * Provides a cross-browser way to get the screen dimensions
3477
+   * via: http://stackoverflow.com/questions/5864467/internet-explorer-innerheight
3478
+   *
3479
+   * @api private
3480
+   * @method _getWinSize
3481
+   * @returns {Object} width and height attributes
3482
+   */
3483
+  function _getWinSize() {
3484
+    if (window.innerWidth != undefined) {
3485
+      return { width: window.innerWidth, height: window.innerHeight };
3486
+    } else {
3487
+      var D = document.documentElement;
3488
+      return { width: D.clientWidth, height: D.clientHeight };
3489
+    }
3490
+  }
3491
+
3492
+  /**
3493
+   * Add overlay layer to the page
3494
+   * http://stackoverflow.com/questions/123999/how-to-tell-if-a-dom-element-is-visible-in-the-current-viewport
3495
+   *
3496
+   * @api private
3497
+   * @method _elementInViewport
3498
+   * @param {Object} el
3499
+   */
3500
+  function _elementInViewport(el) {
3501
+    var rect = el.getBoundingClientRect();
3502
+
3503
+    return (
3504
+      rect.top >= 0 &&
3505
+      rect.left >= 0 &&
3506
+      (rect.bottom+80) <= window.innerHeight && // add 80 to get the text right
3507
+      rect.right <= window.innerWidth
3508
+    );
3509
+  }
3510
+
3511
+  /**
3512
+   * Add overlay layer to the page
3513
+   *
3514
+   * @api private
3515
+   * @method _addOverlayLayer
3516
+   * @param {Object} targetElm
3517
+   */
3518
+  function _addOverlayLayer(targetElm) {
3519
+    var overlayLayer = document.createElement('div'),
3520
+        styleText = '',
3521
+        self = this;
3522
+
3523
+    //set css class name
3524
+    overlayLayer.className = 'introjs-overlay';
3525
+
3526
+    //check if the target element is body, we should calculate the size of overlay layer in a better way
3527
+    if (targetElm.tagName.toLowerCase() === 'body') {
3528
+      styleText += 'top: 0;bottom: 0; left: 0;right: 0;position: fixed;';
3529
+      overlayLayer.setAttribute('style', styleText);
3530
+    } else {
3531
+      //set overlay layer position
3532
+      var elementPosition = _getOffset(targetElm);
3533
+      if (elementPosition) {
3534
+        styleText += 'width: ' + elementPosition.width + 'px; height:' + elementPosition.height + 'px; top:' + elementPosition.top + 'px;left: ' + elementPosition.left + 'px;';
3535
+        overlayLayer.setAttribute('style', styleText);
3536
+      }
3537
+    }
3538
+
3539
+    targetElm.appendChild(overlayLayer);
3540
+
3541
+    overlayLayer.onclick = function() {
3542
+      if (self._options.exitOnOverlayClick == true) {
3543
+        _exitIntro.call(self, targetElm);
3544
+
3545
+        //check if any callback is defined
3546
+        if (self._introExitCallback != undefined) {
3547
+          self._introExitCallback.call(self);
3548
+        }
3549
+      }
3550
+    };
3551
+
3552
+    setTimeout(function() {
3553
+      styleText += 'opacity: ' + self._options.overlayOpacity.toString() + ';';
3554
+      overlayLayer.setAttribute('style', styleText);
3555
+    }, 10);
3556
+
3557
+    return true;
3558
+  }
3559
+
3560
+  /**
3561
+   * Get an element position on the page
3562
+   * Thanks to `meouw`: http://stackoverflow.com/a/442474/375966
3563
+   *
3564
+   * @api private
3565
+   * @method _getOffset
3566
+   * @param {Object} element
3567
+   * @returns Element's position info
3568
+   */
3569
+  function _getOffset(element) {
3570
+    var elementPosition = {};
3571
+
3572
+    //set width
3573
+    elementPosition.width = element.offsetWidth;
3574
+
3575
+    //set height
3576
+    elementPosition.height = element.offsetHeight;
3577
+
3578
+    //calculate element top and left
3579
+    var _x = 0;
3580
+    var _y = 0;
3581
+    while (element && !isNaN(element.offsetLeft) && !isNaN(element.offsetTop)) {
3582
+      _x += element.offsetLeft;
3583
+      _y += element.offsetTop;
3584
+      element = element.offsetParent;
3585
+    }
3586
+    //set top
3587
+    elementPosition.top = _y;
3588
+    //set left
3589
+    elementPosition.left = _x;
3590
+
3591
+    return elementPosition;
3592
+  }
3593
+
3594
+  /**
3595
+   * Overwrites obj1's values with obj2's and adds obj2's if non existent in obj1
3596
+   * via: http://stackoverflow.com/questions/171251/how-can-i-merge-properties-of-two-javascript-objects-dynamically
3597
+   *
3598
+   * @param obj1
3599
+   * @param obj2
3600
+   * @returns obj3 a new object based on obj1 and obj2
3601
+   */
3602
+  function _mergeOptions(obj1,obj2) {
3603
+    var obj3 = {};
3604
+    for (var attrname in obj1) { obj3[attrname] = obj1[attrname]; }
3605
+    for (var attrname in obj2) { obj3[attrname] = obj2[attrname]; }
3606
+    return obj3;
3607
+  }
3608
+
3609
+  var introJs = function (targetElm) {
3610
+    if (typeof (targetElm) === 'object') {
3611
+      //Ok, create a new instance
3612
+      return new IntroJs(targetElm);
3613
+
3614
+    } else if (typeof (targetElm) === 'string') {
3615
+      //select the target element with query selector
3616
+      var targetElement = document.querySelector(targetElm);
3617
+
3618
+      if (targetElement) {
3619
+        return new IntroJs(targetElement);
3620
+      } else {
3621
+        throw new Error('There is no element with given selector.');
3622
+      }
3623
+    } else {
3624
+      return new IntroJs(document.body);
3625
+    }
3626
+  };
3627
+
3628
+  /**
3629
+   * Current IntroJs version
3630
+   *
3631
+   * @property version
3632
+   * @type String
3633
+   */
3634
+  introJs.version = VERSION;
3635
+
3636
+  //Prototype
3637
+  introJs.fn = IntroJs.prototype = {
3638
+    clone: function () {
3639
+      return new IntroJs(this);
3640
+    },
3641
+    setOption: function(option, value) {
3642
+      this._options[option] = value;
3643
+      return this;
3644
+    },
3645
+    setOptions: function(options) {
3646
+      this._options = _mergeOptions(this._options, options);
3647
+      return this;
3648
+    },
3649
+    start: function () {
3650
+      _introForElement.call(this, this._targetElement);
3651
+      return this;
3652
+    },
3653
+    goToStep: function(step) {
3654
+      _goToStep.call(this, step);
3655
+      return this;
3656
+    },
3657
+    nextStep: function() {
3658
+      _nextStep.call(this);
3659
+      return this;
3660
+    },
3661
+    previousStep: function() {
3662
+      _previousStep.call(this);
3663
+      return this;
3664
+    },
3665
+    exit: function() {
3666
+      _exitIntro.call(this, this._targetElement);
3667
+    },
3668
+    refresh: function() {
3669
+      _setHelperLayerPosition.call(this, document.querySelector('.introjs-helperLayer'));
3670
+      return this;
3671
+    },
3672
+    onbeforechange: function(providedCallback) {
3673
+      if (typeof (providedCallback) === 'function') {
3674
+        this._introBeforeChangeCallback = providedCallback;
3675
+      } else {
3676
+        throw new Error('Provided callback for onbeforechange was not a function');
3677
+      }
3678
+      return this;
3679
+    },
3680
+    onchange: function(providedCallback) {
3681
+      if (typeof (providedCallback) === 'function') {
3682
+        this._introChangeCallback = providedCallback;
3683
+      } else {
3684
+        throw new Error('Provided callback for onchange was not a function.');
3685
+      }
3686
+      return this;
3687
+    },
3688
+    onafterchange: function(providedCallback) {
3689
+      if (typeof (providedCallback) === 'function') {
3690
+        this._introAfterChangeCallback = providedCallback;
3691
+      } else {
3692
+        throw new Error('Provided callback for onafterchange was not a function');
3693
+      }
3694
+      return this;
3695
+    },
3696
+    oncomplete: function(providedCallback) {
3697
+      if (typeof (providedCallback) === 'function') {
3698
+        this._introCompleteCallback = providedCallback;
3699
+      } else {
3700
+        throw new Error('Provided callback for oncomplete was not a function.');
3701
+      }
3702
+      return this;
3703
+    },
3704
+    onexit: function(providedCallback) {
3705
+      if (typeof (providedCallback) === 'function') {
3706
+        this._introExitCallback = providedCallback;
3707
+      } else {
3708
+        throw new Error('Provided callback for onexit was not a function.');
3709
+      }
3710
+      return this;
3711
+    }
3712
+  };
3713
+
3714
+  exports.introJs = introJs;
3715
+  return introJs;
3716
+}));
3717
Index: include/javascript/clippy.js
3718
===================================================================
3719
--- include/javascript/clippy.js	(revision 0)
3720
+++ include/javascript/clippy.js	(revision 10417)
3721
@@ -0,0 +1,8 @@
3722
+function clippy_set_help(help_section) {
3723
+	document.cookie = 'clippy=' + help_section;
3724
+}
3725
+
3726
+function clippy_go_link_show_help(link, help_section) {
3727
+	document.cookie = 'clippy=' + help_section;
3728
+	window.location.href = link;
3729
+}
3730
\ No newline at end of file
3731
Index: include/functions_servers.php
3732
===================================================================
3733
--- include/functions_servers.php	(revision 10314)
3734
+++ include/functions_servers.php	(working copy)
3735
@@ -79,7 +79,9 @@
3736
 	$data["avg_interval_remote_modules"] = array();
3737
 	$data["avg_interval_local_modules"] = 0;
3738
 	$data["local_modules_rate"] = 0;
3739
+	$data["network_modules_rate"] = 0;
3740
 	
3741
+	
3742
 	if ($config["realtimestats"] == 1) {
3743
 		$counts = db_get_all_rows_sql ("SELECT tagente_modulo.id_modulo, COUNT(tagente_modulo.id_agente_modulo) modules
3744
 			FROM tagente_modulo, tagente_estado, tagente
3745
@@ -195,6 +197,8 @@
3746
 		$interval_avgs_agents = array();
3747
 	}
3748
 	
3749
+	$interval_avgs = array();
3750
+	
3751
 	// Merge with the previous calculated array
3752
 	foreach($interval_avgs_agents as $iaagents) {
3753
 		if(!isset($interval_avgs[$iaagents['id_modulo']]['modules'])) {
3754
Index: include/functions_treeview.php
3755
===================================================================
3756
--- include/functions_treeview.php	(revision 10314)
3757
+++ include/functions_treeview.php	(working copy)
3758
@@ -468,11 +468,19 @@
3759
 	echo '<table class="databox" style="width:98%">';
3760
 	echo '<tr><td style="width:50%" valign="top">';
3761
 	
3762
+	
3763
+	
3764
 	if (! defined ('METACONSOLE')) {
3765
+		
3766
 		$list = treeview_getData ($type);
3767
+		
3768
 	}
3769
 	else {
3770
-		$servers = db_get_all_rows_sql ("SELECT * FROM tmetaconsole_setup WHERE disabled = 0");
3771
+		$servers = db_get_all_rows_sql ("
3772
+			SELECT *
3773
+			FROM tmetaconsole_setup
3774
+			WHERE disabled = 0");
3775
+		
3776
 		if ($servers === false) {
3777
 			$servers = array();
3778
 		}
3779
@@ -502,6 +510,8 @@
3780
 		metaconsole_restore_db();
3781
 	}
3782
 	
3783
+	
3784
+	
3785
 	if ($list === false) {
3786
 		ui_print_error_message(__('There aren\'t agents in this agrupation'));
3787
 		echo '</td></tr>';
3788
@@ -543,19 +553,25 @@
3789
 			else {
3790
 				$id = $item['_id_'];
3791
 			}
3792
-
3793
+			
3794
 			echo "<a onfocus='JavaScript: this.blur()' href='javascript: loadSubTree(\"" . $type . "\",\"" . $id . "\", " . $lessBranchs . ", \"\", \"\")'>";
3795
 			
3796
 			echo $img . $item['_iconImg_'] ."&nbsp;" . __($item['_name_']) . ' (';
3797
 			
3798
-			$counts_info = array('total_count' => $item['_num_ok_'] + $item['_num_critical_'] + $item['_num_warning_'] + $item['_num_unknown_'],
3799
-					'normal_count' => $item['_num_ok_'],
3800
-					'critical_count' => $item['_num_critical_'],
3801
-					'warning_count' => $item['_num_warning_'],
3802
-					'unknown_count' => $item['_num_unknown_']);
3803
-
3804
+			$counts_info = array(
3805
+				'total_count' => $item['_num_ok_'] +
3806
+					$item['_num_critical_'] +
3807
+					$item['_num_warning_'] +
3808
+					$item['_num_unknown_'],
3809
+				'normal_count' => $item['_num_ok_'],
3810
+				'critical_count' => $item['_num_critical_'],
3811
+				'warning_count' => $item['_num_warning_'],
3812
+				'unknown_count' => $item['_num_unknown_']);
3813
+			
3814
+			
3815
 			reporting_tiny_stats($counts_info, false, $type);
3816
 			
3817
+			
3818
 			echo ') '. "</a>";
3819
 			
3820
 			echo "<div hiddenDiv='1' loadDiv='0' style='margin: 0px; padding: 0px;' class='tree_view' id='tree_div_" . $type . "_" . $id . "'></div>";
3821
@@ -581,7 +597,11 @@
3822
 	$avariableGroups = users_get_groups ();
3823
 	
3824
 	//Get all groups with agents
3825
-	$full_groups = db_get_all_rows_sql("SELECT DISTINCT id_grupo FROM tagente WHERE total_count > 0");
3826
+	$full_groups = db_get_all_rows_sql("
3827
+		SELECT DISTINCT id_grupo
3828
+		FROM tagente
3829
+		WHERE total_count > 0");
3830
+	
3831
 	if ($full_groups === false) {
3832
 		return array ();
3833
 	}
3834
@@ -607,9 +627,12 @@
3835
 		switch ($select_status) {
3836
 			case NORMAL:
3837
 				foreach ($avariableGroups as $group_name) {
3838
-					$id_group = db_get_value_sql('SELECT id_grupo FROM tgrupo where nombre ="' . $group_name . '"');
3839
+					$id_group = db_get_value_sql('
3840
+						SELECT id_grupo
3841
+						FROM tgrupo
3842
+						WHERE nombre ="' . $group_name . '"');
3843
 					
3844
-					$num_ok = groups_agent_ok($id_group);	
3845
+					$num_ok = groups_agent_ok($id_group);
3846
 					
3847
 					if ($num_ok <= 0)
3848
 						unset($avariableGroups[$id_group]);
3849
@@ -619,7 +642,10 @@
3850
 				break;
3851
 			case WARNING:
3852
 				foreach ($avariableGroups as $group_name) {
3853
-					$id_group = db_get_value_sql('SELECT id_grupo FROM tgrupo where nombre ="' . $group_name . '"');
3854
+					$id_group = db_get_value_sql('
3855
+						SELECT id_grupo
3856
+						FROM tgrupo
3857
+						WHERE nombre ="' . $group_name . '"');
3858
 					
3859
 					$num_warning = groups_agent_warning($id_group);
3860
 					
3861
@@ -629,7 +655,10 @@
3862
 				break;
3863
 			case CRITICAL:
3864
 				foreach ($avariableGroups as $group_name) {
3865
-					$id_group = db_get_value_sql('SELECT id_grupo FROM tgrupo where nombre ="' . $group_name . '"');
3866
+					$id_group = db_get_value_sql('
3867
+						SELECT id_grupo
3868
+						FROM tgrupo
3869
+						WHERE nombre ="' . $group_name . '"');
3870
 					
3871
 					$num_critical = groups_agent_critical($id_group);
3872
 					
3873
@@ -639,7 +668,10 @@
3874
 				break;
3875
 			case UNKNOWN:
3876
 				foreach ($avariableGroups as $group_name) {
3877
-					$id_group = db_get_value_sql('SELECT id_grupo FROM tgrupo where nombre ="' . $group_name . '"');
3878
+					$id_group = db_get_value_sql('
3879
+						SELECT id_grupo
3880
+						FROM tgrupo
3881
+						WHERE nombre ="' . $group_name . '"');
3882
 					
3883
 					$num_unknown = groups_agent_unknown($id_group);
3884
 					
3885
@@ -656,17 +688,42 @@
3886
 	}
3887
 	
3888
 	if ($search_free != '') {
3889
-		$sql_search = " AND id_grupo IN (SELECT id_grupo FROM tagente
3890
-			WHERE tagente.nombre COLLATE utf8_general_ci LIKE '%$search_free%')";
3891
+		switch ($config['dbtype']) {
3892
+			case "mysql":
3893
+				$sql_search = " AND id_grupo IN (
3894
+					SELECT id_grupo
3895
+					FROM tagente
3896
+					WHERE tagente.nombre COLLATE utf8_general_ci LIKE '%$search_free%')";
3897
+				break;
3898
+			case "postgresql":
3899
+				$sql_search = " AND id_grupo IN (
3900
+					SELECT id_grupo
3901
+					FROM tagente
3902
+					WHERE tagente.nombre LIKE '%$search_free%')";
3903
+				break;
3904
+			case "oracle":
3905
+				$sql_search = " AND id_grupo IN (
3906
+					SELECT id_grupo
3907
+					FROM tagente
3908
+					WHERE tagente.nombre COLLATE utf8_general_ci LIKE '%$search_free%')";
3909
+				break;
3910
+		}
3911
 	}
3912
 	else {
3913
 		$sql_search ='';
3914
 	}
3915
 	
3916
+	$order_collate = "";
3917
+	switch ($config['dbtype']) {
3918
+		case "mysql":
3919
+			$order_collate = "COLLATE utf8_general_ci";
3920
+			break;
3921
+	}
3922
+	
3923
 	switch ($type) {
3924
-		case 'os':		
3925
+		case 'os':
3926
 			$sql = agents_get_agents(array (
3927
-				'order' => 'nombre COLLATE utf8_general_ci ASC',
3928
+				'order' => 'nombre ' . $order_collate . ' ASC',
3929
 				'disabled' => 0,
3930
 				'status' => $select_status,
3931
 				'search' => $sql_search),
3932
@@ -676,7 +733,9 @@
3933
 				false,
3934
 				true);
3935
 			
3936
-			$sql_os = sprintf("SELECT * FROM tconfig_os WHERE id_os IN (%s)", $sql);
3937
+			$sql_os = sprintf("SELECT *
3938
+				FROM tconfig_os
3939
+				WHERE id_os IN (%s)", $sql);
3940
 			
3941
 			$list = db_get_all_rows_sql($sql_os);
3942
 			
3943
@@ -692,17 +751,31 @@
3944
 			
3945
 			switch ($config["dbtype"]) {
3946
 				case "mysql":
3947
+					$list = db_get_all_rows_sql("
3948
+						SELECT *
3949
+						FROM tgrupo
3950
+						WHERE nombre IN (" . $stringAvariableGroups . ") $sql_search
3951
+						ORDER BY nombre COLLATE utf8_general_ci ASC");
3952
+					break;
3953
 				case "postgresql":
3954
-					$list = db_get_all_rows_sql("SELECT * FROM tgrupo WHERE nombre IN (" . $stringAvariableGroups . ") $sql_search ORDER BY nombre COLLATE utf8_general_ci ASC");
3955
+					$list = db_get_all_rows_sql("
3956
+						SELECT *
3957
+						FROM tgrupo
3958
+						WHERE nombre IN (" . $stringAvariableGroups . ") $sql_search
3959
+						ORDER BY nombre ASC");
3960
 					break;
3961
 				case "oracle":
3962
-					$list = db_get_all_rows_sql("SELECT * FROM tgrupo WHERE dbms_lob.substr(nombre,4000,1) IN (" . $stringAvariableGroups . ") ORDER BY nombre COLLATE utf8_general_ci ASC");
3963
+					$list = db_get_all_rows_sql("
3964
+						SELECT *
3965
+						FROM tgrupo
3966
+						WHERE dbms_lob.substr(nombre,4000,1) IN (" . $stringAvariableGroups . ")
3967
+						ORDER BY nombre COLLATE utf8_general_ci ASC");
3968
 					break;
3969
 			}
3970
 			break;
3971
 		case 'module_group':
3972
 			$sql = agents_get_agents(array (
3973
-				'order' => 'nombre COLLATE utf8_general_ci ASC',
3974
+				'order' => 'nombre ' . $order_collate . ' ASC',
3975
 				'disabled' => 0,
3976
 				'status' => $select_status,
3977
 				'search' => $sql_search),
3978
@@ -714,8 +787,13 @@
3979
 			// Skip agents without modules
3980
 			$sql .= ' AND tagente.total_count>0';
3981
 			
3982
-			$sql_module_groups = sprintf("SELECT * FROM tmodule_group
3983
-				WHERE id_mg IN (SELECT id_module_group FROM tagente_modulo WHERE id_agente IN (%s))", $sql);			
3984
+			$sql_module_groups = sprintf("
3985
+				SELECT *
3986
+				FROM tmodule_group
3987
+				WHERE id_mg IN (
3988
+					SELECT id_module_group
3989
+					FROM tagente_modulo
3990
+					WHERE id_agente IN (%s))", $sql);
3991
 			
3992
 			
3993
 			$list = db_get_all_rows_sql($sql_module_groups);
3994
@@ -734,7 +812,8 @@
3995
 			$groups = implode(',',$groups_id);
3996
 			
3997
 			if ($search_free != '') {
3998
-				$sql = "SELECT DISTINCT tpolicies.id, tpolicies.name
3999
+				$sql = "
4000
+					SELECT DISTINCT tpolicies.id, tpolicies.name
4001
 					FROM tpolicies, tpolicy_modules,
4002
 						tagente_estado, tagente, tagente_modulo
4003
 					WHERE 
4004
@@ -749,7 +828,7 @@
4005
 						tagente.nombre LIKE '%$search_free%' AND
4006
 						tagente.disabled = 0 AND
4007
 						tagente_modulo.disabled = 0
4008
-						ORDER BY tpolicies.name COLLATE utf8_general_ci ASC";
4009
+					ORDER BY tpolicies.name COLLATE utf8_general_ci ASC";
4010
 				
4011
 				$list = db_get_all_rows_sql($sql);
4012
 				
4013
@@ -825,7 +904,7 @@
4014
 						tagente.id_grupo IN ($groups) AND
4015
 						tagente.disabled = 0 AND
4016
 						tagente_modulo.disabled = 0
4017
-						ORDER BY tpolicies.name COLLATE utf8_general_ci ASC");
4018
+						ORDER BY tpolicies.name ' . $order_collate . ' ASC");
4019
 				
4020
 				$element = 0;
4021
 				switch ($select_status) {
4022
@@ -889,8 +968,28 @@
4023
 			}
4024
 			
4025
 			if ($search_free != '') {
4026
-				$sql_search = " AND t1.id_agente IN (SELECT id_agente FROM tagente
4027
-					WHERE nombre COLLATE utf8_general_ci LIKE '%$search_free%')";
4028
+				switch ($config['dbtype']) {
4029
+					case "mysql":
4030
+						$sql_search = " AND t1.id_agente IN (
4031
+							SELECT id_agente
4032
+							FROM tagente
4033
+							WHERE nombre COLLATE utf8_general_ci LIKE '%$search_free%')";
4034
+						break;
4035
+					case "postgresql":
4036
+						$sql_search = " AND t1.id_agente IN (
4037
+							SELECT id_agente
4038
+							FROM tagente
4039
+							WHERE nombre LIKE '%$search_free%')";
4040
+						break;
4041
+					case "oracle":
4042
+						$sql_search = " AND t1.id_agente IN (
4043
+							SELECT id_agente
4044
+							FROM tagente
4045
+							WHERE nombre COLLATE utf8_general_ci LIKE '%$search_free%')";
4046
+						break;
4047
+				}
4048
+				
4049
+				
4050
 			}
4051
 			else {
4052
 				$sql_search = '';
4053
@@ -899,7 +998,8 @@
4054
 			if ($select_status != -1)
4055
 				$sql_search .= " AND estado = " . $select_status . " ";
4056
 			
4057
-			$sql_search .= tags_get_acl_tags($config['id_user'], 0, 'AR', 'module_condition', 'AND', 't1');
4058
+			$sql_search .= tags_get_acl_tags(
4059
+				$config['id_user'], 0, 'AR', 'module_condition', 'AND', 't1');
4060
 			
4061
 			switch ($config["dbtype"]) {
4062
 				case "mysql":
4063
@@ -915,7 +1015,7 @@
4064
 							$sql_search.'
4065
 						GROUP BY t1.nombre ORDER BY t1.nombre');
4066
 					break;
4067
-				case "oracle":	
4068
+				case "oracle":
4069
 					$list = db_get_all_rows_sql('
4070
 						SELECT dbms_lob.substr(t1.nombre,4000,1) as nombre
4071
 						FROM tagente_modulo t1, tagente t2,
4072
@@ -950,15 +1050,16 @@
4073
 					$search_sql = sprintf(" AND tagente.nombre COLLATE utf8_general_ci LIKE '%%%s%%'", $search_free);
4074
 				}
4075
 				
4076
-				$sql = "SELECT DISTINCT ttag.name 
4077
-						FROM ttag, ttag_module, tagente, tagente_modulo 
4078
-						WHERE ttag.id_tag = ttag_module.id_tag
4079
+				$sql = "
4080
+					SELECT DISTINCT ttag.name 
4081
+					FROM ttag, ttag_module, tagente, tagente_modulo 
4082
+					WHERE ttag.id_tag = ttag_module.id_tag
4083
 						AND tagente.id_agente = tagente_modulo.id_agente
4084
 						AND tagente.disabled = 0
4085
 						AND ttag_module.id_agente_modulo = tagente_modulo.id_agente_modulo" .
4086
 						$search_sql . 
4087
-						$user_tags_sql . 
4088
-						" ORDER BY ttag.name COLLATE utf8_general_ci ASC";
4089
+						$user_tags_sql . "
4090
+					ORDER BY ttag.name ' . $order_collate . ' ASC";
4091
 				
4092
 				$list = db_get_all_rows_sql($sql);
4093
 			break;
4094
@@ -1054,6 +1155,13 @@
4095
 		return false;
4096
 	}
4097
 	
4098
+	$order_collate = "";
4099
+	switch ($config['dbtype']) {
4100
+		case "mysql":
4101
+			$order_collate = "COLLATE utf8_general_ci";
4102
+			break;
4103
+	}
4104
+	
4105
 	//TODO CHANGE POLICY ACL FOR TAG ACL
4106
 	$extra_sql = '';
4107
 	if ($extra_sql != '') {
4108
@@ -1062,7 +1170,18 @@
4109
 	$groups_sql = implode(', ', $avariableGroupsIds);
4110
 	
4111
 	if ($search_free != '') {
4112
-		$search_sql = " AND tagente.nombre COLLATE utf8_general_ci LIKE '%$search_free%'";
4113
+		switch ($config['dbtype']) {
4114
+			case "mysql":
4115
+				$search_sql = " AND tagente.nombre COLLATE utf8_general_ci LIKE '%$search_free%'";
4116
+				break;
4117
+			case "postgresql":
4118
+				$search_sql = " AND tagente.nombre LIKE '%$search_free%'";
4119
+				break;
4120
+			case "oracle":
4121
+				$search_sql = " AND tagente.nombre COLLATE utf8_general_ci LIKE '%$search_free%'";
4122
+				break;
4123
+		}
4124
+		
4125
 	}
4126
 	else {
4127
 		$search_sql = '';
4128
@@ -1078,14 +1197,14 @@
4129
 				}
4130
 			}
4131
 			
4132
-			$sql = agents_get_agents(array (	
4133
+			$sql = agents_get_agents(array (
4134
 				'id_grupo' => $id,
4135
 				'disabled' => 0,
4136
 				'status' => $statusSel,
4137
 				'search' => $search_sql),
4138
 				array ('*'),
4139
 				'AR',
4140
-				array('field' => 'nombre COLLATE utf8_general_ci', 'order' => ' ASC'),
4141
+				array('field' => 'nombre ' . $order_collate, 'order' => ' ASC'),
4142
 				true);
4143
 			break;
4144
 		case 'os':
4145
@@ -1097,7 +1216,7 @@
4146
 				'search' => $search_sql),
4147
 				array ('*'),
4148
 				'AR',
4149
-				array('field' => 'nombre COLLATE utf8_general_ci', 'order' => ' ASC'),
4150
+				array('field' => 'nombre ' . $order_collate, 'order' => ' ASC'),
4151
 				true);
4152
 			break;
4153
 		case 'module_group':
4154
@@ -1117,7 +1236,7 @@
4155
 				FROM tagente_modulo 
4156
 				WHERE id_module_group = ' . $id . ')';
4157
 			
4158
-			$sql .= 'ORDER BY nombre COLLATE utf8_general_ci ASC';
4159
+			$sql .= 'ORDER BY nombre ' . $order_collate . ' ASC';
4160
 			
4161
 			break;
4162
 		case 'policies':
4163
@@ -1144,7 +1263,7 @@
4164
 					AND tagente_estado.utimestamp != 0
4165
 					AND tagente_modulo.id_policy_module != 0
4166
 					AND tpolicy_modules.id_policy = ' . $id . '
4167
-					group by tagente.id_agente
4168
+					GROUP BY tagente.id_agente
4169
 					having COUNT(*) > 0)';
4170
 			}
4171
 			else if ($statusSel == 0) {
4172
@@ -1152,11 +1271,12 @@
4173
 				// If status filter is NORMAL add void agents
4174
 				$sql .= " UNION SELECT * FROM tagente 
4175
 					WHERE tagente.disabled = 0
4176
-					AND tagente.id_agente NOT IN (SELECT tagente_estado.id_agente 
4177
+					AND tagente.id_agente NOT IN (
4178
+						SELECT tagente_estado.id_agente 
4179
 						FROM tagente_estado)";
4180
 			}
4181
 			
4182
-			$sql .= 'ORDER BY nombre COLLATE utf8_general_ci ASC';
4183
+			$sql .= 'ORDER BY nombre ' . $order_collate . ' ASC';
4184
 			
4185
 			break;
4186
 		case 'module':
4187
@@ -1188,7 +1308,7 @@
4188
 				)
4189
 				', $name);
4190
 			
4191
-			$sql .= 'ORDER BY nombre COLLATE utf8_general_ci ASC';
4192
+			$sql .= 'ORDER BY nombre ' . $order_collate . ' ASC';
4193
 			
4194
 			break;
4195
 		case 'tag':
4196
@@ -1219,7 +1339,8 @@
4197
 			
4198
 			$sql .= ' AND tagente.disabled = 0'. $search_sql;
4199
 			
4200
-			$sql .= ' GROUP BY tagente.id_agente ORDER BY tagente.nombre COLLATE utf8_general_ci ASC';
4201
+			$sql .= ' GROUP BY tagente.id_agente
4202
+				ORDER BY tagente.nombre ' . $order_collate . ' ASC';
4203
 			
4204
 			break;
4205
 	}
4206
@@ -1234,25 +1355,36 @@
4207
 // Get SQL for the second tree branch
4208
 function treeview_getSecondBranchSQL ($fatherType, $id, $id_father) {
4209
 	global $config;
4210
+	
4211
+	$order_collate = "";
4212
+	switch ($config['dbtype']) {
4213
+		case "mysql":
4214
+			$order_collate = "COLLATE utf8_general_ci";
4215
+			break;
4216
+	}
4217
+	
4218
 	switch ($fatherType) {
4219
 		case 'group':
4220
 			$sql = 'SELECT * 
4221
 				FROM tagente_modulo AS t1 
4222
-				INNER JOIN tagente_estado AS t2 ON t1.id_agente_modulo = t2.id_agente_modulo
4223
+				INNER JOIN tagente_estado AS t2
4224
+					ON t1.id_agente_modulo = t2.id_agente_modulo
4225
 				WHERE t1.id_agente = ' . $id;
4226
 			$sql .= tags_get_acl_tags($config['id_user'], 0, 'AR', 'module_condition', 'AND', 't1');
4227
 			break;
4228
 		case 'os':
4229
 			$sql = 'SELECT * 
4230
 				FROM tagente_modulo AS t1 
4231
-				INNER JOIN tagente_estado AS t2 ON t1.id_agente_modulo = t2.id_agente_modulo
4232
+				INNER JOIN tagente_estado AS t2
4233
+					ON t1.id_agente_modulo = t2.id_agente_modulo
4234
 				WHERE t1.id_agente = ' . $id;
4235
 			$sql .= tags_get_acl_tags($config['id_user'], 0, 'AR', 'module_condition', 'AND', 't1');
4236
 			break;
4237
 		case 'module_group':
4238
 			$sql = 'SELECT * 
4239
 				FROM tagente_modulo AS t1 
4240
-				INNER JOIN tagente_estado AS t2 ON t1.id_agente_modulo = t2.id_agente_modulo
4241
+				INNER JOIN tagente_estado AS t2
4242
+					ON t1.id_agente_modulo = t2.id_agente_modulo
4243
 				WHERE t1.id_agente = ' . $id . ' AND id_module_group = ' . $id_father;
4244
 			$sql .= tags_get_acl_tags($config['id_user'], 0, 'AR', 'module_condition', 'AND', 't1');
4245
 			break;
4246
@@ -1275,8 +1407,10 @@
4247
 			$symbols = ' !"#$%&\'()*+,./:;<=>?@[\\]^{|}~';
4248
 			$name = $id_father;
4249
 			for ($i = 0; $i < strlen($symbols); $i++) {
4250
-				$name = str_replace('_articapandora_'.ord(substr($symbols, $i, 1)).'_pandoraartica_', substr($symbols, $i, 1), $name);
4251
-			}	
4252
+				$name = str_replace('_articapandora_' .
4253
+					ord(substr($symbols, $i, 1)) .'_pandoraartica_',
4254
+					substr($symbols, $i, 1), $name);
4255
+			}
4256
 			switch ($config["dbtype"]) {
4257
 				case "mysql":
4258
 					$sql = 'SELECT * 
4259
@@ -1315,8 +1449,9 @@
4260
 			break;
4261
 		}
4262
 	
4263
-	// This line checks for initializated modules or (non-initialized) asyncronous modules	
4264
-	$sql .= ' AND disabled = 0 AND (utimestamp > 0 OR id_tipo_modulo IN (21,22,23)) ORDER BY nombre COLLATE utf8_general_ci ASC';
4265
+	// This line checks for initializated modules or (non-initialized) asyncronous modules
4266
+	$sql .= ' AND disabled = 0 AND (utimestamp > 0 OR id_tipo_modulo IN (21,22,23))
4267
+		ORDER BY nombre ' . $order_collate . ' ASC';
4268
 	return $sql;
4269
 }
4270
 ?>
4271
Index: include/functions_config.php
4272
===================================================================
4273
--- include/functions_config.php	(revision 10314)
4274
+++ include/functions_config.php	(working copy)
4275
@@ -182,6 +182,8 @@
4276
 						$error_update[] = __('Command Snapshot');
4277
 					if (!config_update_value ('server_log_dir', get_parameter('server_log_dir')))
4278
 						$error_update[] = __('Server logs directory');
4279
+					if (!config_update_value ('tutorial_mode', get_parameter('tutorial_mode')))
4280
+						$error_update[] = __('Tutorial mode');
4281
 					break;
4282
 				case 'enterprise':
4283
 					if (isset($config['enterprise_installed']) && $config['enterprise_installed'] == 1) {
4284
@@ -433,6 +435,10 @@
4285
 						$error_update[] = __('Default icon in GIS');
4286
 					if (!config_update_value ('autohidden_menu', get_parameter('autohidden_menu')))
4287
 						$error_update[] = __('Autohidden menu');
4288
+					if (!config_update_value ('fixed_header', get_parameter('fixed_header')))
4289
+						$error_update[] = __('Fixed header');
4290
+					if (!config_update_value ('fixed_menu', get_parameter('fixed_menu')))
4291
+						$error_update[] = __('Fixed menu');
4292
 					if (!config_update_value ('paginate_module', get_parameter('paginate_module')))
4293
 						$error_update[] = __('Paginate module');
4294
 					if (!config_update_value ('graphviz_bin_dir', get_parameter('graphviz_bin_dir')))
4295
@@ -781,17 +787,31 @@
4296
 	// 	config_update_value ('autoupdate', true);
4297
 	// }
4298
 	
4299
-	require_once ($config["homedir"]."/include/auth/mysql.php");
4300
+	require_once ($config["homedir"] . "/include/auth/mysql.php");
4301
 	
4302
-	// Next is the directory where "/attachment" directory is placed, to upload files stores. 
4303
-	// This MUST be writtable by http server user, and should be in pandora root. 
4304
-	// By default, Pandora adds /attachment to this, so by default is the pandora console home dir
4305
+	
4306
+	// Next is the directory where "/attachment" directory is placed,
4307
+	// to upload files stores. This MUST be writtable by http server
4308
+	// user, and should be in pandora root. By default, Pandora adds
4309
+	// /attachment to this, so by default is the pandora console home
4310
+	// dir.
4311
 	if (!isset ($config['attachment_store'])) {
4312
-		config_update_value ( 'attachment_store', $config['homedir'].'/attachment');
4313
+		config_update_value('attachment_store',
4314
+			$config['homedir'] . '/attachment');
4315
 	}
4316
+	else {
4317
+		//Fixed when the user moves the pandora console to another dir
4318
+		//after the first uses.
4319
+		if (!is_dir($config['attachment_store'])) {
4320
+			config_update_value('attachment_store',
4321
+				$config['homedir'] . '/attachment');
4322
+		}
4323
+	}
4324
 	
4325
+	
4326
 	if (!isset ($config['fontpath'])) {
4327
-		config_update_value ( 'fontpath', $config['homedir'].'/include/fonts/smallfont.ttf');
4328
+		config_update_value('fontpath',
4329
+			$config['homedir'] . '/include/fonts/smallfont.ttf');
4330
 	}
4331
 	
4332
 	if (!isset ($config['style'])) {
4333
@@ -869,7 +889,7 @@
4334
 	if (!isset ($config['netflow_nfexpire'])) {
4335
 		config_update_value ( 'netflow_nfexpire', '/usr/bin/nfexpire');
4336
 	}
4337
-		
4338
+	
4339
 	if (!isset ($config['netflow_max_resolution'])) {
4340
 		config_update_value ( 'netflow_max_resolution', '50');
4341
 	}
4342
@@ -877,7 +897,7 @@
4343
 	if (!isset ($config['netflow_disable_custom_lvfilters'])) {
4344
 		config_update_value ( 'netflow_disable_custom_lvfilters', 0);
4345
 	}
4346
-
4347
+	
4348
 	if (!isset ($config['netflow_max_lifetime'])) {
4349
 		config_update_value ( 'netflow_max_lifetime', '5');
4350
 	}
4351
@@ -919,13 +939,14 @@
4352
 	}
4353
 	
4354
 	if (!isset ($config['ldap_base_dn'])) {
4355
-		config_update_value ( 'ldap_base_dn', 'ou=People,dc=edu,dc=example,dc=org');
4356
+		config_update_value('ldap_base_dn',
4357
+			'ou=People,dc=edu,dc=example,dc=org');
4358
 	}
4359
 	
4360
 	if (!isset ($config['ldap_login_attr'])) {
4361
 		config_update_value ( 'ldap_login_attr', 'uid');
4362
 	}
4363
-
4364
+	
4365
 	if (!isset ($config['fallback_local_auth'])) {
4366
 		config_update_value ( 'fallback_local_auth', '0');
4367
 	}
4368
@@ -1030,11 +1051,11 @@
4369
 		config_update_value( 'api_password', '');
4370
 	}
4371
 	
4372
-	if(defined('METACONSOLE')) {
4373
+	if (defined('METACONSOLE')) {
4374
 		// Customizable sections (Metaconsole)
4375
 		enterprise_include_once ('include/functions_enterprise.php');
4376
 		$customizable_sections = enterprise_hook('enterprise_get_customizable_sections');
4377
-
4378
+		
4379
 		if($customizable_sections != ENTERPRISE_NOT_HOOK) {
4380
 			foreach($customizable_sections as $k => $v) {
4381
 				if (!isset ($config[$k])) {
4382
@@ -1050,7 +1071,7 @@
4383
 	
4384
 	if (!isset ($config['relative_path']) && (isset ($_POST['nick'])
4385
 		|| isset ($config['id_user'])) && isset($config['enterprise_installed'])) {
4386
-
4387
+		
4388
 		$isFunctionSkins = enterprise_include_once ('include/functions_skins.php');
4389
 		if ($isFunctionSkins !== ENTERPRISE_NOT_HOOK) {
4390
 			
4391
@@ -1153,7 +1174,8 @@
4392
 	}
4393
 	
4394
 	if (!isset($config['custom_report_front_logo'])) {
4395
-		config_update_value ('custom_report_front_logo', 'images/pandora_logo_white.jpg');
4396
+		config_update_value ('custom_report_front_logo',
4397
+			'images/pandora_logo_white.jpg');
4398
 	}
4399
 	
4400
 	if (!isset($config['custom_report_front_header'])) {
4401
@@ -1161,7 +1183,8 @@
4402
 	}
4403
 	
4404
 	if (!isset($config['custom_report_front_firstpage'])) {
4405
-		config_update_value ('custom_report_front_firstpage', "&lt;p&#x20;style=&quot;text-align:&#x20;center;&quot;&gt;&amp;nbsp;&lt;/p&gt;&#x0d;&#x0a;&lt;p&#x20;style=&quot;text-align:&#x20;center;&quot;&gt;&amp;nbsp;&lt;/p&gt;&#x0d;&#x0a;&lt;p&#x20;style=&quot;text-align:&#x20;center;&quot;&gt;&amp;nbsp;&lt;/p&gt;&#x0d;&#x0a;&lt;p&#x20;style=&quot;text-align:&#x20;center;&quot;&gt;&amp;nbsp;&lt;/p&gt;&#x0d;&#x0a;&lt;p&#x20;style=&quot;text-align:&#x20;center;&quot;&gt;&amp;nbsp;&lt;/p&gt;&#x0d;&#x0a;&lt;p&#x20;style=&quot;text-align:&#x20;center;&quot;&gt;&amp;nbsp;&lt;/p&gt;&#x0d;&#x0a;&lt;p&#x20;style=&quot;text-align:&#x20;center;&quot;&gt;&amp;nbsp;&lt;/p&gt;&#x0d;&#x0a;&lt;p&#x20;style=&quot;text-align:&#x20;center;&quot;&gt;&lt;img&#x20;src=&quot;" . ui_get_full_url(false, false, false, false) . "/images/pandora_report_logo.png&quot;&#x20;alt=&quot;&quot;&#x20;width=&quot;800&quot;&#x20;/&gt;&lt;/p&gt;&#x0d;&#x0a;&lt;p&#x20;style=&quot;text-align:&#x20;center;&quot;&gt;&amp;nbsp;&lt;/p&gt;&#x0d;&#x0a;&lt;p&#x20;style=&quot;text-align:&#x20;center;&quot;&gt;&lt;span&#x20;style=&quot;font-size:&#x20;xx-large;&quot;&gt;&#40;_REPORT_NAME_&#41;&lt;/span&gt;&lt;/p&gt;&#x0d;&#x0a;&lt;p&#x20;style=&quot;text-align:&#x20;center;&quot;&gt;&lt;span&#x20;style=&quot;font-size:&#x20;large;&quot;&gt;&#40;_DATETIME_&#41;&lt;/span&gt;&lt;/p&gt;");
4406
+		config_update_value ('custom_report_front_firstpage',
4407
+			"&lt;p&#x20;style=&quot;text-align:&#x20;center;&quot;&gt;&amp;nbsp;&lt;/p&gt;&#x0d;&#x0a;&lt;p&#x20;style=&quot;text-align:&#x20;center;&quot;&gt;&amp;nbsp;&lt;/p&gt;&#x0d;&#x0a;&lt;p&#x20;style=&quot;text-align:&#x20;center;&quot;&gt;&amp;nbsp;&lt;/p&gt;&#x0d;&#x0a;&lt;p&#x20;style=&quot;text-align:&#x20;center;&quot;&gt;&amp;nbsp;&lt;/p&gt;&#x0d;&#x0a;&lt;p&#x20;style=&quot;text-align:&#x20;center;&quot;&gt;&amp;nbsp;&lt;/p&gt;&#x0d;&#x0a;&lt;p&#x20;style=&quot;text-align:&#x20;center;&quot;&gt;&amp;nbsp;&lt;/p&gt;&#x0d;&#x0a;&lt;p&#x20;style=&quot;text-align:&#x20;center;&quot;&gt;&amp;nbsp;&lt;/p&gt;&#x0d;&#x0a;&lt;p&#x20;style=&quot;text-align:&#x20;center;&quot;&gt;&lt;img&#x20;src=&quot;" . ui_get_full_url(false, false, false, false) . "/images/pandora_report_logo.png&quot;&#x20;alt=&quot;&quot;&#x20;width=&quot;800&quot;&#x20;/&gt;&lt;/p&gt;&#x0d;&#x0a;&lt;p&#x20;style=&quot;text-align:&#x20;center;&quot;&gt;&amp;nbsp;&lt;/p&gt;&#x0d;&#x0a;&lt;p&#x20;style=&quot;text-align:&#x20;center;&quot;&gt;&lt;span&#x20;style=&quot;font-size:&#x20;xx-large;&quot;&gt;&#40;_REPORT_NAME_&#41;&lt;/span&gt;&lt;/p&gt;&#x0d;&#x0a;&lt;p&#x20;style=&quot;text-align:&#x20;center;&quot;&gt;&lt;span&#x20;style=&quot;font-size:&#x20;large;&quot;&gt;&#40;_DATETIME_&#41;&lt;/span&gt;&lt;/p&gt;");
4408
 	}
4409
 	
4410
 	if (!isset($config['custom_report_front_footer'])) {
4411
@@ -1176,6 +1199,10 @@
4412
 		config_update_value ('networkmap_max_width', 900);
4413
 	}
4414
 	
4415
+	if (!isset($config['tutorial_mode'])) {
4416
+		config_update_value ('tutorial_mode', 'full');
4417
+	}
4418
+	
4419
 	/* Finally, check if any value was overwritten in a form */
4420
 	config_update_config();
4421
 }
4422
@@ -1312,7 +1339,7 @@
4423
 			$config["alert_cnt"]++;
4424
 			$_SESSION["alert_msg"] .= ui_print_info_message(
4425
 				array('title' => __("New update of Pandora Console"),
4426
-				'message' => __('There is a new update please go to menu Administration and into extensions <a style="font-weight:bold;" href="index.php?sec=gsetup&sec2=godmode/update_manager_xxx/update_manager_xxx&tab=online">go to Update Manager</a> for more details.'),
4427
+				'message' => __('There is a new update please go to menu Administration and into extensions <a style="font-weight:bold;" href="index.php?sec=gsetup&sec2=godmode/update_manager/update_manager&tab=online">go to Update Manager</a> for more details.'),
4428
 				'no_close' => true, 'force_style' => 'color: #000000 !important'), '', true);
4429
 		}
4430
 	}
4431
Index: include/help/clippy/godmode_agentes_modificar_agente.php
4432
===================================================================
4433
--- include/help/clippy/godmode_agentes_modificar_agente.php	(revision 0)
4434
+++ include/help/clippy/godmode_agentes_modificar_agente.php	(revision 10417)
4435
@@ -0,0 +1,71 @@
4436
+<?php
4437
+
4438
+// Pandora FMS - http://pandorafms.com
4439
+// ==================================================
4440
+// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
4441
+// Please see http://pandorafms.org for full contribution list
4442
+
4443
+// This program is free software; you can redistribute it and/or
4444
+// modify it under the terms of the  GNU Lesser General Public License
4445
+// as published by the Free Software Foundation; version 2
4446
+
4447
+// This program is distributed in the hope that it will be useful,
4448
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
4449
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
4450
+// GNU General Public License for more details.
4451
+
4452
+/**
4453
+ * @package Include
4454
+ * @subpackage Clippy
4455
+ */
4456
+
4457
+function clippy_start_page() {
4458
+	
4459
+	$helps = array();
4460
+	
4461
+	//==================================================================
4462
+	//Help tour about the monitoring with a ping (step 1)
4463
+	//------------------------------------------------------------------
4464
+	$helps['monitoring_server_step_1'] = array();
4465
+	$helps['monitoring_server_step_1']['steps'] = array();
4466
+	$helps['monitoring_server_step_1']['steps'][] = array(
4467
+		'element'=> '#clippy',
4468
+		'intro' => __('I show how to monitoring a server.')
4469
+		);
4470
+	$helps['monitoring_server_step_1']['steps'][] = array(
4471
+		'element'=> 'input[name="search"]',
4472
+		'intro' => __('Please type a agent to save the modules for monitoring a server.')
4473
+		);
4474
+	$helps['monitoring_server_step_1']['steps'][] = array(
4475
+		'element'=> 'input[name="srcbutton"]',
4476
+		'intro' => __('Maybe if you typped correctly the name, you can see the agent.')
4477
+		);
4478
+	$helps['monitoring_server_step_1']['conf'] = array();
4479
+	$helps['monitoring_server_step_1']['conf']['showBullets'] = 0;
4480
+	$helps['monitoring_server_step_1']['conf']['showStepNumbers'] = 1;
4481
+	$helps['monitoring_server_step_1']['conf']['next_help'] = 'monitoring_server_step_2';
4482
+	//==================================================================
4483
+	
4484
+	
4485
+	//==================================================================
4486
+	//Help tour about the monitoring with a ping (step 2)
4487
+	//------------------------------------------------------------------
4488
+	$helps['monitoring_server_step_2'] = array();
4489
+	$helps['monitoring_server_step_2']['steps'] = array();
4490
+	$helps['monitoring_server_step_2']['steps'][] = array(
4491
+		'element'=> '#clippy',
4492
+		'intro' => __('Please choose the agent that you have searched.')
4493
+		);
4494
+	$helps['monitoring_server_step_2']['steps'][] = array(
4495
+		'element'=> '#agent_list',
4496
+		'intro' => __('Choose the agent, please click in the name.')
4497
+		);
4498
+	$helps['monitoring_server_step_2']['conf'] = array();
4499
+	$helps['monitoring_server_step_2']['conf']['showBullets'] = 0;
4500
+	$helps['monitoring_server_step_2']['conf']['showStepNumbers'] = 0;
4501
+	$helps['monitoring_server_step_2']['conf']['next_help'] = 'monitoring_server_step_3';
4502
+	//==================================================================
4503
+	
4504
+	clippy_write_javascript_helps_steps($helps, false);
4505
+}
4506
+?>
4507
\ No newline at end of file
4508
Index: include/help/clippy/homepage.php
4509
===================================================================
4510
--- include/help/clippy/homepage.php	(revision 0)
4511
+++ include/help/clippy/homepage.php	(revision 10417)
4512
@@ -0,0 +1,105 @@
4513
+<?php
4514
+
4515
+// Pandora FMS - http://pandorafms.com
4516
+// ==================================================
4517
+// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
4518
+// Please see http://pandorafms.org for full contribution list
4519
+
4520
+// This program is free software; you can redistribute it and/or
4521
+// modify it under the terms of the  GNU Lesser General Public License
4522
+// as published by the Free Software Foundation; version 2
4523
+
4524
+// This program is distributed in the hope that it will be useful,
4525
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
4526
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
4527
+// GNU General Public License for more details.
4528
+
4529
+/**
4530
+ * @package Include
4531
+ * @subpackage Clippy
4532
+ */
4533
+
4534
+function clippy_start_page_homepage() {
4535
+	global $config;
4536
+	
4537
+	$clippy_is_annoying = (int)get_cookie('clippy_is_annoying', 0);
4538
+	
4539
+	clippy_clean_help();
4540
+	
4541
+	$helps = array();
4542
+	
4543
+	//==================================================================
4544
+	//Help tour with the some task for to help the user.
4545
+	//------------------------------------------------------------------
4546
+	$helps['homepage'] = array();
4547
+	$helps['homepage']['steps'] = array();
4548
+	$helps['homepage']['steps'][] = array(
4549
+		'element'=> '#clippy',
4550
+		'intro' => __('Could I help you?<br/><br/>I am Pandorin, the annoying clippy for Pandora. You could follow my advices for to make common and basic tasks in Pandora.') .
4551
+			'<div style="position:relative;">
4552
+			<div id="pandorin" style="display: block; position: absolute; left: -100px; top: 20px;">' .
4553
+				html_print_image('images/pandorin.png', true) .
4554
+			'</div>
4555
+			</div>'
4556
+		);
4557
+	$helps['homepage']['steps'][] = array(
4558
+		'element'=> '#clippy',
4559
+		'intro' => __('What task do you want to do?') . '<br/><br/>' .
4560
+			'<ul style="text-align: left; margin-left: 3px; list-style-type: disc;">' .
4561
+				'<li>' .
4562
+					"<a href='javascript: clippy_go_link_show_help(\"index.php?sec=gagente&sec2=godmode/agentes/modificar_agente\", \"monitoring_server_step_1\");'>" . 
4563
+					//'<a href="index.php?sec=gagente&sec2=godmode/agentes/modificar_agente&clippy=monitoring_server">' . 
4564
+						__('Monitoring a server Linux/Windows with a pandora agent') .
4565
+					'</a>' .
4566
+				'</li>' .
4567
+				'<li>' . __('Monitoring a switch with remote SNMP') . '</li>' .
4568
+				'<li>' . __('Monitoring a Windows server with remote WMI ') . '</li>' .
4569
+			'</ul>' .
4570
+			'<div style="text-align: left;">'.
4571
+			html_print_checkbox_extended
4572
+				('clippy_is_annoying', 1, $clippy_is_annoying, false,
4573
+				'set_clippy_annoying()', '', true) .
4574
+				__('Please the clippy is annoying, I don\'t want see.') .
4575
+			'</div>'
4576
+		);
4577
+	$helps['homepage']['conf'] = array();
4578
+	$helps['homepage']['conf']['showBullets'] = 0;
4579
+	$helps['homepage']['conf']['showStepNumbers'] = 0;
4580
+	$helps['homepage']['conf']['name_obj_tour'] = 'intro_homepage';
4581
+	$helps['homepage']['conf']['other_js'] = "
4582
+		function show_clippy() {
4583
+			intro_homepage.start();
4584
+		}
4585
+		
4586
+		function set_clippy_annoying() {
4587
+			checked = $('input[name=\'clippy_is_annoying\']').is(':checked');
4588
+			intro_homepage.exit();
4589
+			
4590
+			if (checked) {
4591
+				document.cookie = 'clippy_is_annoying=1';
4592
+			}
4593
+			else {
4594
+				document.cookie = 'clippy_is_annoying=0';
4595
+			}
4596
+		}
4597
+		";
4598
+	if ($config['logged']) {
4599
+		$helps['homepage']['conf']['autostart'] = true;
4600
+	}
4601
+	else {
4602
+		$helps['homepage']['conf']['autostart'] = false;
4603
+	}
4604
+	
4605
+	if ($config["tutorial_mode"] == 'on_demand') {
4606
+		$helps['homepage']['conf']['autostart'] = false;
4607
+	}
4608
+	
4609
+	if ($clippy_is_annoying === 1) {
4610
+		$helps['homepage']['conf']['autostart'] = false;
4611
+	}
4612
+	
4613
+	//==================================================================
4614
+	
4615
+	clippy_write_javascript_helps_steps($helps);
4616
+}
4617
+?>
4618
\ No newline at end of file
4619
Index: include/help/clippy/godmode_agentes_configurar_agente.php
4620
===================================================================
4621
--- include/help/clippy/godmode_agentes_configurar_agente.php	(revision 0)
4622
+++ include/help/clippy/godmode_agentes_configurar_agente.php	(revision 10417)
4623
@@ -0,0 +1,126 @@
4624
+<?php
4625
+
4626
+// Pandora FMS - http://pandorafms.com
4627
+// ==================================================
4628
+// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
4629
+// Please see http://pandorafms.org for full contribution list
4630
+
4631
+// This program is free software; you can redistribute it and/or
4632
+// modify it under the terms of the  GNU Lesser General Public License
4633
+// as published by the Free Software Foundation; version 2
4634
+
4635
+// This program is distributed in the hope that it will be useful,
4636
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
4637
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
4638
+// GNU General Public License for more details.
4639
+
4640
+/**
4641
+ * @package Include
4642
+ * @subpackage Clippy
4643
+ */
4644
+
4645
+function clippy_start_page() {
4646
+	$helps = array();
4647
+	
4648
+	//==================================================================
4649
+	//Help tour about the monitoring with a ping (step 3)
4650
+	//------------------------------------------------------------------
4651
+	$helps['monitoring_server_step_3'] = array();
4652
+	$helps['monitoring_server_step_3']['steps'] = array();
4653
+	$helps['monitoring_server_step_3']['steps'][] = array(
4654
+		'element'=> '#clippy',
4655
+		'intro' => __('Now you must go to modules, don\'t worry I teach you.')
4656
+		);
4657
+	$helps['monitoring_server_step_3']['steps'][] = array(
4658
+		'element'=> "img[alt='Modules']",
4659
+		'intro' => __('Please click in this tab.')
4660
+		);
4661
+	$helps['monitoring_server_step_3']['conf'] = array();
4662
+	$helps['monitoring_server_step_3']['conf']['showBullets'] = 0;
4663
+	$helps['monitoring_server_step_3']['conf']['showStepNumbers'] = 0;
4664
+	$helps['monitoring_server_step_3']['conf']['next_help'] = 'monitoring_server_step_4';
4665
+	//==================================================================
4666
+	
4667
+	
4668
+	//==================================================================
4669
+	//Help tour about the monitoring with a ping (step 4)
4670
+	//------------------------------------------------------------------
4671
+	$helps['monitoring_server_step_4'] = array();
4672
+	$helps['monitoring_server_step_4']['steps'] = array();
4673
+	$helps['monitoring_server_step_4']['steps'][] = array(
4674
+		'element'=> '#clippy',
4675
+		'intro' => __('Now you must create the module, don\'t worry I teach you.')
4676
+		);
4677
+	$helps['monitoring_server_step_4']['steps'][] = array(
4678
+		'element'=> "#moduletype",
4679
+		'intro' => __('Choose the network server module.')
4680
+		);
4681
+	$helps['monitoring_server_step_4']['steps'][] = array(
4682
+		'element'=> "input[name='updbutton']",
4683
+		'intro' => __('And click in this button.')
4684
+		);
4685
+	$helps['monitoring_server_step_4']['conf'] = array();
4686
+	$helps['monitoring_server_step_4']['conf']['showBullets'] = 0;
4687
+	$helps['monitoring_server_step_4']['conf']['showStepNumbers'] = 0;
4688
+	$helps['monitoring_server_step_4']['conf']['next_help'] = 'monitoring_server_step_5';
4689
+	//==================================================================
4690
+	
4691
+	
4692
+	//==================================================================
4693
+	//Help tour about the monitoring with a ping (step 5)
4694
+	//------------------------------------------------------------------
4695
+	$helps['monitoring_server_step_5'] = array();
4696
+	$helps['monitoring_server_step_5']['steps'] = array();
4697
+	$helps['monitoring_server_step_5']['steps'][] = array(
4698
+		'element'=> '#clippy',
4699
+		'intro' => __('Now you must create the module, don\'t worry I teach you.')
4700
+		);
4701
+	$helps['monitoring_server_step_5']['steps'][] = array(
4702
+		'element'=> '#clippy',
4703
+		'intro' => __('We are going to fill the form.')
4704
+		);
4705
+	$helps['monitoring_server_step_5']['steps'][] = array(
4706
+		'element'=> "#network_component_group",
4707
+		'intro' => __('Please choose the Network Management.')
4708
+		);
4709
+	$helps['monitoring_server_step_5']['steps'][] = array(
4710
+		'element'=> "#network_component",
4711
+		'intro' => __('And choose the component with the name "Host Alive".')
4712
+		);
4713
+	$helps['monitoring_server_step_5']['steps'][] = array(
4714
+		'element'=> "input[name='name']",
4715
+		'intro' => __('You can change the name.')
4716
+		);
4717
+	$helps['monitoring_server_step_5']['steps'][] = array(
4718
+		'element'=> "input[name='ip_target']",
4719
+		'intro' => __('Check if this IP is the address of your machine.')
4720
+		);
4721
+	$helps['monitoring_server_step_5']['steps'][] = array(
4722
+		'element'=> "input[name='crtbutton']",
4723
+		'intro' => __('And only to finish it is clicking this button.')
4724
+		);
4725
+	$helps['monitoring_server_step_5']['conf'] = array();
4726
+	$helps['monitoring_server_step_5']['conf']['showBullets'] = 0;
4727
+	$helps['monitoring_server_step_5']['conf']['showStepNumbers'] = 0;
4728
+	$helps['monitoring_server_step_5']['conf']['next_help'] = 'monitoring_server_step_6';
4729
+	//==================================================================
4730
+	
4731
+	
4732
+	//==================================================================
4733
+	//Help tour about the monitoring with a ping (step 6)
4734
+	//------------------------------------------------------------------
4735
+	$helps['monitoring_server_step_6'] = array();
4736
+	$helps['monitoring_server_step_6']['steps'] = array();
4737
+	$helps['monitoring_server_step_6']['steps'][] = array(
4738
+		'element'=> '#clippy',
4739
+		'intro' => __('Now, your module is just created.<br/> And the status color is <b>blue</b>.<br/>This meaning of blue status is the module is not executed for first time.<br/>In the next seconds if there is not a problem, the status color will change to red or green.')
4740
+		);
4741
+	$helps['monitoring_server_step_6']['conf'] = array();
4742
+	$helps['monitoring_server_step_6']['conf']['showBullets'] = 0;
4743
+	$helps['monitoring_server_step_6']['conf']['showStepNumbers'] = 0;
4744
+	//==================================================================
4745
+	
4746
+	
4747
+	clippy_write_javascript_helps_steps($helps, false);
4748
+}
4749
+?>
4750
\ No newline at end of file
4751
Index: include/help/clippy/module_unknow.php
4752
===================================================================
4753
--- include/help/clippy/module_unknow.php	(revision 0)
4754
+++ include/help/clippy/module_unknow.php	(revision 10417)
4755
@@ -0,0 +1,55 @@
4756
+<?php
4757
+
4758
+// Pandora FMS - http://pandorafms.com
4759
+// ==================================================
4760
+// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
4761
+// Please see http://pandorafms.org for full contribution list
4762
+
4763
+// This program is free software; you can redistribute it and/or
4764
+// modify it under the terms of the  GNU Lesser General Public License
4765
+// as published by the Free Software Foundation; version 2
4766
+
4767
+// This program is distributed in the hope that it will be useful,
4768
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
4769
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
4770
+// GNU General Public License for more details.
4771
+
4772
+/**
4773
+ * @package Include
4774
+ * @subpackage Clippy
4775
+ */
4776
+
4777
+function clippy_module_unknow() {
4778
+	$helps = array();
4779
+	
4780
+	//==================================================================
4781
+	//Help tour about the monitoring with a ping (step 3)
4782
+	//------------------------------------------------------------------
4783
+	$helps['module_unknow'] = array();
4784
+	$helps['module_unknow']['steps'] = array();
4785
+	$helps['module_unknow']['steps'][] = array(
4786
+		'element'=> '{clippy}', //The template to replace with the autogenerate id
4787
+		'intro' => '<table>' .
4788
+			'<tr>' .
4789
+			'<td class="context_help_title">' .
4790
+			__('You have unknown modules in this agent.') .
4791
+			'</td>' .
4792
+			'</tr>' .
4793
+			'<tr>' .
4794
+			'<td class="context_help_body">' .
4795
+			__('Unknown modules are modules which receive data normally at least in one occassion, but at this time are not receving data. Please check our troubleshoot help page to help you determine why you have unknown modules.') .
4796
+			ui_print_help_icon ('context_module_unknow', true, '', 'images/help_w.png') .
4797
+			'</td>' .
4798
+			'</tr>' .
4799
+			'</table>'
4800
+		);
4801
+	$helps['module_unknow']['conf'] = array();
4802
+	$helps['module_unknow']['conf']['autostart'] = false;
4803
+	$helps['module_unknow']['conf']['showBullets'] = 0;
4804
+	$helps['module_unknow']['conf']['showStepNumbers'] = 0;
4805
+	$helps['module_unknow']['conf']['name_obj_tour'] = '{clippy_obj}';
4806
+	//==================================================================
4807
+	
4808
+	clippy_write_javascript_helps_steps($helps, true);
4809
+}
4810
+?>
4811
\ No newline at end of file
4812
Index: include/help/en/help_context_module_unknow.php
4813
===================================================================
4814
--- include/help/en/help_context_module_unknow.php	(revision 0)
4815
+++ include/help/en/help_context_module_unknow.php	(revision 10417)
4816
@@ -0,0 +1,24 @@
4817
+<?php
4818
+/**
4819
+ * @package Include/help/en
4820
+ */
4821
+?>
4822
+<h1>Unknown modules in Pandora</h1>
4823
+<p>
4824
+You may have unknown modules for many reasons. Unknown module is a special status for a module/monitor which means “I dont have recent data for this monitor and I should have data”. A monitor goes to unknown status when doesnt receive nothing in at least its interval (for example, 300 seconds) multiplied by two, in this case, if you doesn't receive nothing in ten minutes, monitor goes to unknown.
4825
+</p>
4826
+<p>
4827
+These are a few cases where you can get unknown modules:
4828
+</p>
4829
+<ul style="list-style-type: disc; margin-left: 30px;">
4830
+	<li>Your pandora server is down. Restart it, dont forget to check /var/log/pandora/pandora_server.log to see why was down.</li>
4831
+	<li>Your tentacle server is down, and cannot get data from your Pandora FMS agents installed in your remote servers.</li>
4832
+	<li>You have a network problem between your agents and your server.</li>
4833
+	<li>Your pandora fms agent is stopped and is not sending information to your server.</li>
4834
+	<li>Your network is down, or the remote device you are trying to ask is down or changed it's IP address (for example for numerical SNMP remote queries).</li>
4835
+	<li>Your agent is reporting a badly synchronized date. Means reports a timedate in the past and that messup everything.</li>
4836
+	<li>The script / module before works now doesn't, that can be because something is happing in the agent, check it out.</li>
4837
+</ul>
4838
+<p>
4839
+Sometimes UNKNOWN status can be useful to monitor, so you can setup alerts on UNKNOWN status to warn you about that.
4840
+</p>
4841
\ No newline at end of file
4842
Index: include/help/en/help_snmp_alert_field1.php
4843
===================================================================
4844
--- include/help/en/help_snmp_alert_field1.php	(revision 10314)
4845
+++ include/help/en/help_snmp_alert_field1.php	(working copy)
4846
@@ -14,10 +14,10 @@
4847
 <br><br>
4848
 You can use these macros in FieldX (1-10) of any alert
4849
 <br><br>
4850
-<b>_DATA_</b>: Full trap<br>
4851
-<b>_AGENT_</b>: Agent name<br>
4852
-<b>_IP_</b>: IP Address<br>
4853
-<b>_TIMESTAMP_</b>: Trap date<br> 
4854
-<b>_SNMP_OID_</b>: Trap OID<br> 
4855
-<b>_SNMP_VALUE_</b>: Trap OID value<br> 
4856
+<b>_data_</b>: Full trap<br>
4857
+<b>_agent_</b>: Agent name<br>
4858
+<b>_address_</b>: IP Address<br>
4859
+<b>_timestamp_</b>: Trap date<br> 
4860
+<b>_snmp_oid_</b>: Trap OID<br> 
4861
+<b>_snmp_value_</b>: Trap OID value<br> 
4862
 </p>
4863
Index: include/help/es/help_snmp_alert_field1.php
4864
===================================================================
4865
--- include/help/es/help_snmp_alert_field1.php	(revision 10314)
4866
+++ include/help/es/help_snmp_alert_field1.php	(working copy)
4867
@@ -14,10 +14,10 @@
4868
 <br><br>
4869
 Puede usar esas macros en los campos FieldX (1-10) de cualquier alerta.
4870
 <br><br>
4871
-<b>_DATA_</b>: Trap entero <br>
4872
-<b>_AGENT_</b>: Nombre del Agente <br>
4873
-<b>_IP_</b>: Dirección IP<br>
4874
-<b>_TIMESTAMP_</b>: Fecha trap<br>
4875
-<b>_SNMP_OID_</b>: OID del trap<br> 
4876
-<b>_SNMP_VALUE_</b>: Valor del OID del trap<br> 
4877
+<b>_data_</b>: Trap entero <br>
4878
+<b>_agent_</b>: Nombre del Agente <br>
4879
+<b>_address_</b>: Dirección IP<br>
4880
+<b>_timestamp_</b>: Fecha trap<br>
4881
+<b>_snmp_oid_</b>: OID del trap<br> 
4882
+<b>_snmp_value_</b>: Valor del OID del trap<br> 
4883
 </p>
4884
Index: include/help/ja/help_snmp_alert_field1.php
4885
===================================================================
4886
--- include/help/ja/help_snmp_alert_field1.php	(revision 10314)
4887
+++ include/help/ja/help_snmp_alert_field1.php	(working copy)
4888
@@ -7,10 +7,17 @@
4889
 <p>
4890
 
4891
 データフィールドがある場合、アラートでそれを利用する必要があります。この目的のために、特別な _snmp_fX_ というマクロを利用できます。これらのマクロは、SNMP トラップアラート以外では無効です。
4892
-
4893
+<br><br>
4894
 メッセージを生成するには、フィールド1に次のような設定をします。
4895
-
4896
-Chassis Alert: _snmp_f2_ in device _snmp_f1_
4897
-
4898
-これらのマクロは、任意のアラートのフィールドX (1 から 10) で利用できます。
4899
+<br><br>
4900
+&nbsp;Chassis Alert: _snmp_f2_ in device _snmp_f1_
4901
+<br><br>
4902
+任意のアラートのフィールドX (1 から 10) で以下のマクロを利用できます。
4903
+<br><br>
4904
+<b>_data_</b>: トラップ全体<br>
4905
+<b>_agent_</b>: エージェント名<br>
4906
+<b>_address_</b>: IP アドレス<br>
4907
+<b>_timestamp_</b>: トラップのタイムスタンプ<br>
4908
+<b>_snmp_oid_</b>: トラップの OID<br>
4909
+<b>_snmp_value_</b>: トラップ OID の値<br>
4910
 </p>
4911
Index: include/config_process.php
4912
===================================================================
4913
--- include/config_process.php	(revision 10314)
4914
+++ include/config_process.php	(working copy)
4915
@@ -247,4 +247,30 @@
4916
 // cases (reverse proxy, others ports...).
4917
 //======================================================================
4918
 $config["homeurl"] = ui_get_full_url(false);
4919
+
4920
+
4921
+//======================================================================
4922
+// Get the version of DB manager
4923
+//======================================================================
4924
+switch ($config["dbtype"]) {
4925
+	case "mysql":
4926
+		if (!isset($config['quote_string'])) {
4927
+			$config['db_quote_string'] = "\"";
4928
+		}
4929
+		break;
4930
+	case "postgresql":
4931
+		if (!isset($config['dbversion'])) {
4932
+			$result = db_get_sql("select version();");
4933
+			$result_chunks = explode(" ", $result);
4934
+			
4935
+			$config['dbversion'] = $result_chunks[1];
4936
+		}
4937
+		if (!isset($config['quote_string'])) {
4938
+			$config['db_quote_string'] = "'";
4939
+		}
4940
+		break;
4941
+	case "oracle":
4942
+		break;
4943
+}
4944
+//======================================================================
4945
 ?>
4946
Index: include/functions_db.php
4947
===================================================================
4948
--- include/functions_db.php	(revision 10314)
4949
+++ include/functions_db.php	(working copy)
4950
@@ -65,7 +65,8 @@
4951
 	if ($return === false) {
4952
 		if ($critical) {
4953
 			$login_screen = 'error_authconfig';
4954
-			require($config['homeurl'] . '/general/error_screen.php');
4955
+			
4956
+			require($config['homedir'] . '/general/error_screen.php');
4957
 			exit;
4958
 		}
4959
 		else if ($error == 0) {
4960
@@ -108,6 +109,22 @@
4961
 	}
4962
 }
4963
 
4964
+function db_encapsule_fields_with_same_name_to_instructions($field) {
4965
+	global $config;
4966
+	
4967
+	switch ($config["dbtype"]) {
4968
+		case "mysql":
4969
+			return mysql_encapsule_fields_with_same_name_to_instructions($field);
4970
+			break;
4971
+		case "postgresql":
4972
+			return postgresql_encapsule_fields_with_same_name_to_instructions($field);
4973
+			break;
4974
+		case "oracle":
4975
+			return oracle_encapsule_fields_with_same_name_to_instructions($field);
4976
+			break;
4977
+	}
4978
+}
4979
+
4980
 /**
4981
  * Adds an audit log entry (new function in 3.0)
4982
  *
4983
Index: include/functions_extensions.php
4984
===================================================================
4985
--- include/functions_extensions.php	(revision 10314)
4986
+++ include/functions_extensions.php	(working copy)
4987
@@ -99,11 +99,11 @@
4988
 		$dir = ENTERPRISE_DIR.'/'.EXTENSIONS_DIR;
4989
 
4990
 	if (file_exists ($dir))
4991
-		$handle = @opendir ($dir);	
4992
+		$handle = @opendir ($dir);
4993
 	
4994
 	if (empty ($handle))
4995
 		return;
4996
-		
4997
+	
4998
 	$file = readdir ($handle);
4999
 	$extensions = array ();
5000
 	$ignores = array ('.', '..');
5001
@@ -117,6 +117,10 @@
5002
 			$file = readdir ($handle);
5003
 			continue;
5004
 		}
5005
+		
5006
+		if ($file == "update_manager.php")
5007
+			continue;
5008
+		
5009
 		$extension['file'] = $file;
5010
 		$extension['operation_menu'] = '';
5011
 		$extension['godmode_menu'] = '';
5012
Index: ChangeLog
5013
===================================================================
5014
--- ChangeLog	(revision 10314)
5015
+++ ChangeLog	(working copy)
5016
@@ -1,3 +1,425 @@
5017
+2014-08-14  Koichiro Kikuchi <koichiro@rworks.jp>
5018
+
5019
+	* pandora_console_install: Refactored code and added "fakeroot"
5020
+	 installation support.
5021
+
5022
+2014-08-13  Junichi Satoh  <junichi@rworks.jp>
5023
+
5024
+	* pandoradb.sql: Fixed sql error with MySQL 5.6 when NO_ZERO_DATE
5025
+	SQL mode is enabled.
5026
+
5027
+2014-08-13  Junichi Satoh  <junichi@rworks.jp>
5028
+
5029
+	* mobile/operation/events.php: Improved to show event comment.
5030
+
5031
+2014-08-12  Miguel de Dios <miguel.dedios@artica.es>
5032
+	
5033
+	* index.php, operation/agentes/ver_agente.php,
5034
+	operation/agentes/estado_monitores.php, general/header.php,
5035
+	include/functions_clippy.php, include/functions_ui.php,
5036
+	include/help/en/help_context_module_unknow.php,
5037
+	include/help/clippy/module_unknow.php, include/styles/pandora.css,
5038
+	include/javascript/intro.js: added first version of context help
5039
+	interactive.
5040
+
5041
+2014-08-12  Miguel de Dios <miguel.dedios@artica.es>
5042
+	
5043
+	* include/functions_modules.php: killed some unicorns and magic
5044
+	numbers into the function "modules_get_status".
5045
+
5046
+2014-08-12  Miguel de Dios <miguel.dedios@artica.es>
5047
+	
5048
+	* images/clippy_icon.png, images/pandorin.png,
5049
+	include/help/clippy/homepage.php, general/header.php: yes there is
5050
+	a octopus another time in Pandora.
5051
+
5052
+2014-08-12  Miguel de Dios <miguel.dedios@artica.es>
5053
+	
5054
+	* include/functions_clippy.php,
5055
+	include/help/clippy/godmode_agentes_modificar_agente.php,
5056
+	include/help/clippy/godmode_agentes_configurar_agente.php: fixed the
5057
+	execution of help tour when never it started. Sorry the clippy is
5058
+	less annoying.
5059
+
5060
+2014-08-12  Miguel de Dios <miguel.dedios@artica.es>
5061
+	
5062
+	* include/functions_clippy.php: changed to modal version.
5063
+	
5064
+	* include/javascript/intro.js: added feature to avoid the exit, and
5065
+	the pull request to original repository is solicited too
5066
+	(https://github.com/usablica/intro.js/pull/311).
5067
+
5068
+2014-08-12  Miguel de Dios <miguel.dedios@artica.es>
5069
+	
5070
+	* general/header.php, godmode/setup/setup_general.php,
5071
+	include/functions_clippy.php, include/functions_config.php,
5072
+	include/help/clippy/homepage.php: wip in the clippy.
5073
+
5074
+2014-08-12  Sancho Lerena <slerena@artica.es>
5075
+
5076
+	* pandoradb_data.sql: No more "welcome to Pandora FMS 5.0" 
5077
+	removed version code to allow the same text for next releases
5078
+	:-)
5079
+
5080
+2014-08-11  Miguel de Dios <miguel.dedios@artica.es>
5081
+	
5082
+	* include/help/clippy/godmode_agentes_modificar_agente.php,
5083
+	include/help/clippy/homepage.php,
5084
+	include/help/clippy/godmode_agentes_configurar_agente.php,
5085
+	include/functions_clippy.php: wip in the clippy.
5086
+
5087
+2014-08-11  Vanessa Gil <vanessa.gil@artica.es>
5088
+
5089
+	* godmode/agentes/agent_template.php: Fixed bug in FF
5090
+	threshold to apply a template module. Ticket #871.
5091
+
5092
+2014-08-11  Vanessa Gil <vanessa.gil@artica.es>
5093
+
5094
+	* godmode/agentes/agent_conf_gis.php: Altitude coordinate by
5095
+	default. Fixed bug #766.
5096
+
5097
+2014-08-08  Miguel de Dios <miguel.dedios@artica.es>
5098
+	
5099
+	* include/functions.php,
5100
+	include/help/clippy/godmode_agentes_modificar_agente.php,
5101
+	include/help/clippy/homepage.php,
5102
+	include/help/clippy/godmode_agentes_configurar_agente.php,
5103
+	include/javascript/intro.js,
5104
+	include/javascript/introjs.css,
5105
+	include/javascript/clippy.js,
5106
+	include/functions_ui.php,
5107
+	include/functions_clippy.php,
5108
+	index.php,
5109
+	general/header.php: first version of the new feature a annoying
5110
+	clippy such as the lovely micro$oft mascot.
5111
+
5112
+2014-08-07  Alejandro Gallardo <alejandro.gallardo@artica.es>
5113
+	
5114
+	* pandoradb.sql,
5115
+	  extras/pandoradb_migrate_5.0.x_to_5.1.mysql.sql,
5116
+	  extras/pandoradb_migrate_5.0.x_to_5.1.oracle.sql,
5117
+	  extras/pandoradb_migrate_5.0.x_to_5.1.postgreSQL.sql:
5118
+	Modified the decimal precision of the column "post_process"
5119
+	for the table 'tagente_modulo' (Ticket #1124).
5120
+
5121
+2014-08-06  Sancho Lerena <slerena@artica.es>
5122
+
5123
+	* extras/pandoradb_migrate_5.0.x_to_5.1.mysql.sql,
5124
+	pandoradb.sql: Fixed bug introduced in commit 9604
5125
+	altering tagente_modulo.post_process double precission
5126
+	making conversion from bytes to megabytes impossible
5127
+	(0,00000095367432). Pending to fix also the interface for
5128
+	module creation/edition which also fails. This is critical 
5129
+	for SP1 release :(
5130
+
5131
+2014-08-05  Alejandro Gallardo <alejandro.gallardo@artica.es>
5132
+	
5133
+	* general/main_menu.php: Improved the submenus state
5134
+	persistence functionality.
5135
+
5136
+2014-08-05  Alejandro Gallardo <alejandro.gallardo@artica.es>
5137
+	
5138
+	* general/main_menu.php: Fixed the menu position when
5139
+	it's fixed and the header's not.
5140
+
5141
+	* include/functions_graph.php,
5142
+	  include/graphs/pandora.d3.js: Added colors to the elements
5143
+	depending on their status on the functions 'sunburst' and
5144
+	'graph_monitor_wheel'.
5145
+
5146
+	* include/styles/pandora.css: Fixed the z-index of the
5147
+	shortcut bar.
5148
+
5149
+2014-08-04  Alejandro Gallardo <alejandro.gallardo@artica.es>
5150
+	
5151
+	* general/header.php: Now the header can be configured
5152
+	to be fixed at the top.
5153
+
5154
+	* general/main_menu.php: Now the menu can be configured
5155
+	to be fixed at the left.
5156
+
5157
+	* godmode/setup/setup_visuals.php,
5158
+	  include/functions_config.php: Added new options to
5159
+	enable the fixed header and menu.
5160
+
5161
+	* include/styles/menu.css,
5162
+	  include/styles/pandora.css: Changes on the menu styles.
5163
+
5164
+
5165
+2014-08-04  Miguel de Dios <miguel.dedios@artica.es>
5166
+	
5167
+	* include/functions_config.php,
5168
+	include/functions_update_manager.php: some fixes into the update
5169
+	manager.
5170
+
5171
+2014-08-04  Alejandro Gallardo <alejandro.gallardo@artica.es>
5172
+	
5173
+	* general/main_menu.php: Now the submenus opened by the
5174
+	user remain opened when navigating through Pandora FMS.
5175
+
5176
+2014-08-04  Miguel de Dios <miguel.dedios@artica.es>
5177
+	
5178
+	* include/config_process.php: added global config var for the
5179
+	quote strings (for example, PostgreSQL).
5180
+
5181
+2014-08-03  Junichi Satoh  <junichi@rworks.jp>
5182
+
5183
+	* include/functions_ui.php: Fixed that the fast forward and the going
5184
+	to the last of pagination doesn't work in the modal window for module
5185
+	data display.
5186
+	And fixed incorrect offset calculation for the fast forward.
5187
+
5188
+2014-08-02  Junichi Satoh  <junichi@rworks.jp>
5189
+
5190
+	* operation/agentes/estado_monitores.php: Fixed that module data
5191
+	display does not work correctly when time range mode is selected
5192
+	and paginated.
5193
+
5194
+2014-08-02  Junichi Satoh  <junichi@rworks.jp>
5195
+
5196
+	* operation/agentes/estado_agente.php: Fixed sql error.
5197
+
5198
+2014-08-01  Miguel de Dios <miguel.dedios@artica.es>
5199
+	
5200
+	* godmode/agentes/planned_downtime.editor.php: fixed the acl.
5201
+	
5202
+	MERGED FROM THE BRANCH 5.0
5203
+
5204
+2014-07-31  Miguel de Dios <miguel.dedios@artica.es>
5205
+	
5206
+	* include/functions_networkmap.php, include/functions_graph.php,
5207
+	include/db/postgresql.php, include/db/oracle.php,
5208
+	include/functions_api.php, extensions/agents_alerts.php,
5209
+	operation/search_main.php, operation/search_agents.getdata.php,
5210
+	operation/agentes/status_monitor.php,
5211
+	operation/agentes/networkmap.topology.php,
5212
+	operation/agentes/ver_agente.php,
5213
+	operation/search_modules.getdata.php, operation/search_results.php,
5214
+	operation/events/events_list.php,
5215
+	godmode/alerts/alert_list.builder.php,
5216
+	godmode/alerts/configure_alert_template.php,
5217
+	godmode/modules/manage_network_components_form.php,
5218
+	godmode/reporting/reporting_builder.php,
5219
+	godmode/reporting/map_builder.php: tiny fixes for the improve the
5220
+	support of postgreSQL databases.
5221
+
5222
+2014-07-30  Miguel de Dios <miguel.dedios@artica.es>
5223
+	
5224
+	* include/ajax/module.php: tiny fixes for the improve the support of
5225
+	postgreSQL databases.
5226
+
5227
+2014-07-30  Miguel de Dios <miguel.dedios@artica.es>
5228
+	
5229
+	* godmode/servers/manage_recontask.php,
5230
+	godmode/servers/manage_recontask_form.php,
5231
+	include/functions_treeview.php, include/ajax/module.php,
5232
+	include/functions_reporting.php, include/db/postgresql.php,
5233
+	include/functions_servers.php, operation/agentes/estado_agente.php,
5234
+	operation/tree.php: tiny fixes for the improve
5235
+	the support of postgreSQL databases.
5236
+
5237
+2014-07-29  Miguel de Dios <miguel.dedios@artica.es>
5238
+	
5239
+	* include/functions_graph.php, include/functions_reporting.php,
5240
+	operation/agentes/estado_monitores.php: tiny fixes for the improve
5241
+	the support of postgreSQL databases.
5242
+
5243
+2014-07-29  Junichi Satoh  <junichi@rworks.jp>
5244
+
5245
+	* include/functions_events.php: Fixed a bug that event's comment
5246
+	is not shown when it includes newline.
5247
+
5248
+2014-07-28  Junichi Satoh  <junichi@rworks.jp>
5249
+
5250
+	* operation/agentes/estado_agente.php: Fixed sql error.
5251
+
5252
+2014-07-24  Miguel de Dios <miguel.dedios@artica.es>
5253
+	
5254
+	* operation/snmpconsole/snmp_view.php,
5255
+	operation/events/events_list.php, operation/incidents/incident.php,
5256
+	extensions/files_repo.php,
5257
+	extensions/files_repo/sql/files_repo.postgreSQL.sql,
5258
+	extensions/files_repo/functions_files_repo.php,
5259
+	extensions/files_repo/files_repo_list.php,
5260
+	godmode/agentes/modificar_agente.php,
5261
+	godmode/snmpconsole/snmp_alert.php, godmode/db/db_info.php,
5262
+	include/functions_graph.php, include/functions_db.php,
5263
+	include/db/postgresql.php, include/db/oracle.php,
5264
+	include/db/mysql.php, include/functions_update_manager.php,
5265
+	include/functions_events.php, include/graphs/functions_flot.php,
5266
+	include/graphs/fgraph.php: tiny fixes for the improve the support of
5267
+	postgreSQL databases.
5268
+
5269
+2014-07-23  Miguel de Dios <miguel.dedios@artica.es>
5270
+	
5271
+	* extensions/module_groups.php, extensions/agents_alerts.php,
5272
+	include/functions_agents.php, operation/agentes/exportdata.php: tiny
5273
+	fixes for the improve the support of postgreSQL databases.
5274
+	
5275
+	* include/functions_db.php: fix blank screen when the connection
5276
+	fail, now it shows the error message again.
5277
+
5278
+2014-07-23  Miguel de Dios <miguel.dedios@artica.es>
5279
+	
5280
+	* include/config_process.php, operation/agentes/status_monitor.php,
5281
+	operation/agentes/estado_generalagente.php,
5282
+	operation/agentes/estado_agente.php: tiny fixes for the improve the
5283
+	support of postgreSQL databases.
5284
+
5285
+2014-07-23  Miguel de Dios <miguel.dedios@artica.es>
5286
+	
5287
+	* include/functions_servers.php, include/functions_reporting.php:
5288
+	tiny fixes for the improve the support of postgreSQL databases.
5289
+
5290
+2014-07-23  Miguel de Dios <miguel.dedios@artica.es>
5291
+	
5292
+	* operation/agentes/estado_generalagente.php: fixed the show the
5293
+	agent access box when the agent is new without data.
5294
+	
5295
+	INCIDENT: #1078
5296
+
5297
+2014-07-23  Miguel de Dios <miguel.dedios@artica.es>
5298
+	
5299
+	* godmode/agentes/agent_wizard.snmp_explorer.php,
5300
+	godmode/agentes/module_manager_editor_plugin.php: some fixes for
5301
+	the snmp version 3.
5302
+
5303
+2014-07-22 Juan Manuel Ramon <juanmanuel.ramon@artica.es>
5304
+
5305
+        * include/ajax/events.php: Fixed custom fields view in
5306
+        metaconsole event extended view.
5307
+
5308
+        This is my last commit for Pandora guys! Bye ;-)
5309
+
5310
+2014-07-22  Miguel de Dios <miguel.dedios@artica.es>
5311
+	
5312
+	* godmode/agentes/agent_wizard.snmp_explorer.php,
5313
+	include/functions.php: some fixes for the snmp v3.
5314
+
5315
+2014-07-22  Miguel de Dios <miguel.dedios@artica.es>
5316
+	
5317
+	* godmode/agentes/agent_manager.php: fixed to show the QR code image
5318
+	in the creation of a new agent.
5319
+
5320
+2014-07-21  Miguel de Dios <miguel.dedios@artica.es>
5321
+	
5322
+	* pandoradb.postgreSQL.sql: fixed the SQL.
5323
+
5324
+2014-07-18  Miguel de Dios <miguel.dedios@artica.es>
5325
+	
5326
+	* include/functions_graph.php, include/functions_reporting.php:
5327
+	fixed to show the unknown graph in simple graph.
5328
+	
5329
+	INCIDENT: #1035
5330
+
5331
+2014-07-17  Miguel de Dios <miguel.dedios@artica.es>
5332
+	
5333
+	* include/auth/ldap.php, include/auth/mysql.php: fixed the
5334
+	parameters with white spaces.
5335
+	
5336
+	INCIDENT: #1063
5337
+
5338
+2014-07-17  Miguel de Dios <miguel.dedios@artica.es>
5339
+	
5340
+	* include/functions_groups.php: added parameter to avoid the check
5341
+	the propagation in the function "groups_get_childrens".
5342
+	
5343
+	* include/functions_networkmap.php,
5344
+	operation/agentes/networkmap.php,
5345
+	operation/agentes/networkmap.topology.php: added feature to show the
5346
+	agents in subgroups (or not).
5347
+	
5348
+	INCIDENT: #1018
5349
+
5350
+2014-07-14  Vanessa Gil <vanessa.gil@artica.es>
5351
+
5352
+	* godmode/admin_access_log.php
5353
+	  include/functions.php: Added export to csv.
5354
+
5355
+	* godmode/audit_log_csv.php: Added file.
5356
+
5357
+2014-07-10  Miguel de Dios <miguel.dedios@artica.es>
5358
+	
5359
+	* include/functions_api.php: fixed the call "set_update_agent"
5360
+	because before the call get the id_server but this data never
5361
+	was translated to name_server. And added id_server into the call
5362
+	"get_pandora_servers" in the last position.
5363
+
5364
+2014-07-10  Miguel de Dios <miguel.dedios@artica.es>
5365
+	
5366
+	* include/functions_api.php: restored the parameter name server in
5367
+	the api call "set_new_agent", thanks KOSAKA.
5368
+
5369
+2014-07-10  Junichi Satoh  <junichi@rworks.jp>
5370
+
5371
+	* include/help/ja/help_snmp_alert_field1.php: Updated help.
5372
+
5373
+2014-07-09  Mario Pulido <mario.pulido@artica.es>
5374
+
5375
+        * include/help/ja/help_snmp_alert_field1.php: Added macros snmp alert help
5376
+
5377
+2014-07-09  Junichi Satoh  <junichi@rworks.jp>
5378
+
5379
+	* include/help/ja/help_snmp_alert_field1.php: Updated help.
5380
+
5381
+2014-07-09  Junichi Satoh  <junichi@rworks.jp>
5382
+
5383
+	* include/functions_events.php, operation/events/events.php,
5384
+	operation/events/events_list.php: Replaced json_encode()
5385
+	with io_json_mb_encode() to avoid invalid encoding with multi-byte
5386
+	characters.
5387
+
5388
+2014-07-08  Mario Pulido <mario.pulido@artica.es>
5389
+
5390
+	* include/help/en/help_snmp_alert_field1.php,
5391
+	include/help/es/help_snmp_alert_field1.php: Change macros snmp alert help
5392
+
5393
+2014-07-08 Hirofumi Kosaka <kosaka@rworks.jp>
5394
+
5395
+	* include/functions_api.php: Fixed that 'set enable_module'
5396
+	had not worked.
5397
+
5398
+	MERGED FROM BRANCH 5.0
5399
+
5400
+2014-07-07  Miguel de Dios <miguel.dedios@artica.es>
5401
+	
5402
+	* include/functions_visual_map.php: show in the tooltip of
5403
+	"static graph" the last value of module.
5404
+	
5405
+	INCIDENT: #1014 
5406
+
5407
+2014-07-07  Miguel de Dios <miguel.dedios@artica.es>
5408
+	
5409
+	* godmode/setup/license.php: fixed the white screen.
5410
+	
5411
+	INCIDENT: #996
5412
+
5413
+2014-07-07  Miguel de Dios <miguel.dedios@artica.es>
5414
+	
5415
+	* operation/agentes/alerts_status.php: fixed the pagination with
5416
+	the column sorted.
5417
+	
5418
+	INCIDENT: #977
5419
+
5420
+2014-07-04  Alejandro Gallardo <alejandro.gallardo@artica.es>
5421
+	
5422
+	* index.php: Now the shortcut bar isn't loaded while
5423
+	the pandora console is in fullscreen mode.
5424
+
5425
+2014-07-04  Ramon Novoa  <rnovoa@artica.es>
5426
+
5427
+	* include/functions_graph.php: When drawing charts, propagate the last value
5428
+	  in the database instead of the value of the last interval (which is the
5429
+	  average value for that interval).
5430
+
5431
+	* operation/agentes/estado_monitores.php: Show events for boolean modules by default.
5432
+
5433
+2014-07-04  Miguel de Dios <miguel.dedios@artica.es>
5434
+	
5435
+	* include/functions_config.php, include/functions_extensions.php:
5436
+	fixed the show old update manager and set the correct link in the
5437
+	header warning message to update manager.
5438
+
5439
 2014-06-30 Koichiro KIKUCHI <koichiro@rworks.jp>
5440
 
5441
 	* operation/agentes/estado_monitores.php,
5442
Index: pandoradb.sql
5443
===================================================================
5444
--- pandoradb.sql	(revision 10314)
5445
+++ pandoradb.sql	(working copy)
5446
@@ -203,7 +203,7 @@
5447
 	`plugin_pass` text,
5448
 	`plugin_parameter` text,
5449
 	`id_plugin` int(10) default '0',
5450
-	`post_process` double default NULL,
5451
+	`post_process` double(18,15) default 0,
5452
 	`prediction_module` bigint(14) default '0',
5453
 	`max_timeout` int(4) unsigned default '0',
5454
 	`max_retries` int(4) unsigned default '0',
5455
@@ -490,7 +490,7 @@
5456
 CREATE TABLE IF NOT EXISTS `talert_special_days` (
5457
 	`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
5458
 	`id_group` INT(10) NOT NULL DEFAULT 0,
5459
-	`date` date NOT NULL DEFAULT '0000-00-00',
5460
+	`date` date NOT NULL DEFAULT '1970-01-01',
5461
 	`same_day` enum('monday','tuesday','wednesday','thursday','friday','saturday','sunday') NOT NULL DEFAULT 'sunday',
5462
 	`description` text,
5463
 	PRIMARY KEY (`id`)
5464
Index: pandoradb.postgreSQL.sql
5465
===================================================================
5466
--- pandoradb.postgreSQL.sql	(revision 10314)
5467
+++ pandoradb.postgreSQL.sql	(working copy)
5468
@@ -26,7 +26,8 @@
5469
 
5470
 --\c "pandora"
5471
 
5472
-CREATE OR REPLACE LANGUAGE plpgsql;
5473
+-- For previous PostgreSQL version 9.0
5474
+CREATE LANGUAGE plpgsql;
5475
 
5476
 CREATE OR REPLACE FUNCTION unix_timestamp(TIMESTAMP without time zone = CURRENT_TIMESTAMP) RETURNS double precision AS 'SELECT ceil(date_part(''epoch'', $1)); ' LANGUAGE SQL;
5477
 
5478
@@ -240,10 +241,10 @@
5479
 	"disabled_types_event" TEXT default '',
5480
 	"module_macros" TEXT default '',
5481
 	"min_ff_event_normal" INTEGER default 0,
5482
-        "min_ff_event_warning" INTEGER default 0,
5483
-        "min_ff_event_critical" INTEGER default 0,
5484
-        "each_ff" SMALLINT default 0,
5485
-	"ff_timeout" INTEGER unsigned default 0
5486
+	"min_ff_event_warning" INTEGER default 0,
5487
+	"min_ff_event_critical" INTEGER default 0,
5488
+	"each_ff" SMALLINT default 0,
5489
+	"ff_timeout" INTEGER default 0
5490
 );
5491
 CREATE INDEX "tagente_modulo_id_agente_idx" ON "tagente_modulo"("id_agente");
5492
 CREATE INDEX "tagente_modulo_id_tipo_modulo_idx" ON "tagente_modulo"("id_tipo_modulo");
5493
@@ -1595,7 +1596,7 @@
5494
 -- -----------------------------------------------------
5495
 -- Table `tevent_response`
5496
 -- -----------------------------------------------------
5497
-CREATE TABLE IF NOT EXISTS "tevent_response" (
5498
+CREATE TABLE "tevent_response" (
5499
 	"id"  SERIAL NOT NULL PRIMARY KEY,
5500
 	"name" varchar(600) NOT NULL default '',
5501
 	"description" TEXT,
5502
@@ -1611,7 +1612,7 @@
5503
 -- ---------------------------------------------------------------------
5504
 -- Table "tcategory"
5505
 -- ---------------------------------------------------------------------
5506
-CREATE TABLE IF NOT EXISTS "tcategory" (
5507
+CREATE TABLE "tcategory" (
5508
 	"id"  SERIAL NOT NULL PRIMARY KEY,
5509
 	"name" varchar(600) NOT NULL default ''
5510
 );
5511
Index: pandora_console_install
5512
===================================================================
5513
--- pandora_console_install	(revision 10314)
5514
+++ pandora_console_install	(working copy)
5515
@@ -11,92 +11,103 @@
5516
 
5517
 PI_VERSION=4.0
5518
 FORCE=0
5519
+DESTDIR=""
5520
 LOG_TIMESTAMP=`date +"%Y/%m/%d %H:%M:%S"`
5521
 MODE=$1
5522
 
5523
+#
5524
+# set_global_vars
5525
+#	Check platform and set DISTRO, OS_VERSION, WWWUSER, WWWGROUP, WWWROOT,
5526
+#	PANDORA_HOME and PANDORA_HOME_GROUP.
5527
+#
5528
+set_global_vars () {
5529
+	DISTRO="GENERIC"
5530
 
5531
-get_distro () {
5532
-
5533
-	OS_NAME=`uname -s`
5534
-
5535
-	# Get Linux Distro type and version
5536
-	if [ -f "/etc/SuSE-release" ]
5537
-	then
5538
-		OS_VERSION=`cat /etc/SuSE-release | grep VERSION | cut -f 3 -d " "`
5539
-		LINUX_DISTRO=SUSE
5540
-	else
5541
-		if [ -f "/etc/lsb-release" ] && [ ! -f "/etc/redhat-release" ]
5542
+	case `uname -s` in
5543
+	Linux)
5544
+		# Get Linux Distro type and version
5545
+		if [ -f "/etc/SuSE-release" ]
5546
 		then
5547
+			OS_VERSION=`cat /etc/SuSE-release | grep VERSION | cut -f 3 -d " "`
5548
+			DISTRO=SUSE
5549
+		elif [ -f "/etc/lsb-release" ] && [ ! -f "/etc/redhat-release" ]
5550
+		then
5551
 			OS_VERSION=`cat /etc/lsb-release | grep DISTRIB_RELEASE | cut -f 2 -d "="`
5552
-			LINUX_DISTRO=UBUNTU
5553
+			DISTRO=UBUNTU
5554
 			OS_VERSION="UBUNTU $OS_VERSION"
5555
-		else
5556
-			if [ -f "/etc/debian_version" ]
5557
-			then
5558
-				OS_VERSION=`cat /etc/debian_version`
5559
-				OS_VERSION="DEBIAN $OS_VERSION"
5560
-				LINUX_DISTRO=DEBIAN
5561
-			else
5562
-				if [ -f "/etc/fedora-release" ]
5563
-				then
5564
-					OS_VERSION=`cat /etc/fedora-release | cut -f 4 -d " "`
5565
-					OS_VERSION="FEDORA $OS_VERSION"
5566
-					LINUX_DISTRO=FEDORA
5567
-				else
5568
-					if [ -f "/etc/redhat-release" ]
5569
-					then
5570
-						LINUX_DISTRO=RHEL_CENTOS
5571
-					else
5572
-						if [ "$OS_NAME" = "FreeBSD" ]
5573
-						then
5574
-							LINUX_DISTRO=FreeBSD
5575
-						else
5576
-							if [ "$OS_NAME" = "NetBSD" ]
5577
-							then
5578
-								LINUX_DISTRO=NetBSD
5579
-							else
5580
-								LINUX_DISTRO=GENERIC
5581
-							fi
5582
-						fi
5583
-						OS_VERSION=`uname -r`
5584
-					fi
5585
-				fi
5586
-			fi
5587
+		elif [ -f "/etc/debian_version" ]
5588
+		then
5589
+			OS_VERSION=`cat /etc/debian_version`
5590
+			OS_VERSION="DEBIAN $OS_VERSION"
5591
+			DISTRO=DEBIAN
5592
+		elif [ -f "/etc/fedora-release" ]
5593
+		then
5594
+			OS_VERSION=`cat /etc/fedora-release | cut -f 4 -d " "`
5595
+			OS_VERSION="FEDORA $OS_VERSION"
5596
+			DISTRO=FEDORA
5597
+		elif [ -f "/etc/redhat-release" ]
5598
+		then
5599
+			DISTRO=RHEL_CENTOS
5600
 		fi
5601
+		case $DISTRO in
5602
+		SUSE)
5603
+			WWWUSER=wwwrun
5604
+			WWWGROUP=www
5605
+			PANDORA_HOME_GROUP=root
5606
+			WWWROOT=/srv/www/htdocs
5607
+			;;
5608
+		UBUNTU|DEBIAN)
5609
+			WWWUSER=www-data
5610
+			WWWGROUP=www-data
5611
+			WWWROOT=/var/www
5612
+			;;
5613
+		FEDORA|RHEL_CENTOS)
5614
+			WWWUSER=apache
5615
+			WWWGROUP=apache
5616
+			WWWROOT=/var/www/html
5617
+			;;
5618
+		esac
5619
+		;;
5620
+	FreeBSD)
5621
+		DISTRO=FreeBSD
5622
+		WWWUSER=www
5623
+		WWWGROUP=www
5624
+		WWWROOT=/usr/local/www
5625
+
5626
+		local apache
5627
+		for apache in apache24 apache22
5628
+		do
5629
+			[ ! -d $WWWROOT/$apache ] && continue
5630
+			WWWROOT=$WWWROOT/$apache/data
5631
+			break
5632
+		done
5633
+		;;
5634
+	NetBSD)
5635
+		DISTRO=NetBSD
5636
+		WWWUSER=www
5637
+		WWWGROUP=www
5638
+		WWWROOT=/usr/pkg/share/httpd/htdocs
5639
+		;;
5640
+	esac
5641
+
5642
+	# backward compatible defaults (Assuming SUSE)
5643
+	if [ "$DISTRO" = GENERIC ]
5644
+	then
5645
+		WWWUSER=wwwrun
5646
+		WWWGROUP=www
5647
+		WWWROOT=/srv/www/htdocs
5648
+		PANDORA_HOME_GROUP=root
5649
 	fi
5650
-	echo $LINUX_DISTRO
5651
+	# Use WWWGROUP as default for PANDORA_HOME_GROUP
5652
+	: ${PANDORA_HOME_GROUP:=$WWWGROUP}
5653
+
5654
+	OS_VERSION=`uname -r`
5655
+	PANDORA_HOME="$WWWROOT/pandora_console"
5656
 }
5657
 
5658
 uninstall () {
5659
-	DISTRO=`get_distro`
5660
+	set_global_vars
5661
 
5662
-	if [ "$DISTRO" = "UBUNTU" ]
5663
-	then
5664
-		PANDORA_HOME=/var/www/pandora_console
5665
-	else
5666
-		if [ "$DISTRO" = "RHEL_CENTOS" ]
5667
-		then
5668
-			PANDORA_HOME=/var/www/html/pandora_console
5669
-		else
5670
-			if [ "$DISTRO" = "FEDORA" ]
5671
-			then
5672
-				PANDORA_HOME=/var/www/html/pandora_console
5673
-			else
5674
-				if [ "$DISTRO" = "FreeBSD" ]
5675
-				then
5676
-					PANDORA_HOME="/usr/local/www/data/pandora_console /usr/local/www/apache24/data/pandora_console /usr/local/www/apache22/data/pandora_console"
5677
-				else
5678
-					if [ "$DISTRO" = "NetBSD" ]
5679
-					then
5680
-						PANDORA_HOME="/usr/pkg/share/httpd/htdocs/pandora_console"
5681
-					else
5682
-						PANDORA_HOME=/srv/www/htdocs/pandora_console
5683
-					fi
5684
-				fi
5685
-			fi
5686
-		fi
5687
-	fi
5688
-
5689
 	echo "Removing Pandora FMS Console"
5690
 	rm -Rf $PANDORA_HOME
5691
 	echo "You need to drop manually pandora database from your Database server"
5692
@@ -104,81 +115,43 @@
5693
 }
5694
 
5695
 install () {
5696
+	set_global_vars
5697
 
5698
-	DISTRO=`get_distro`
5699
 	OLDFILENAMETMP=`date +"%Y-%m-%d"`
5700
-	
5701
-	if [ "$DISTRO" = "UBUNTU" ]
5702
-	then
5703
-		PANDORA_HOME=/var/www/pandora_console
5704
-		PANDORA_CONF=$PANDORA_HOME/include/config.php
5705
-	else
5706
-		if [ "$DISTRO" = "RHEL_CENTOS" ]
5707
-		then
5708
-			PANDORA_HOME=/var/www/html/pandora_console
5709
-			PANDORA_CONF=$PANDORA_HOME/include/config.php
5710
-		else
5711
-			if [ "$DISTRO" = "FEDORA" ]
5712
-			then
5713
-				PANDORA_HOME=/var/www/html/pandora_console
5714
-				PANDORA_CONF=$PANDORA_HOME/include/config.php
5715
-			else
5716
-				if [ "$DISTRO" = "FreeBSD" ]
5717
-				then
5718
-					if [ -d /usr/local/www/apache24 ]
5719
-					then
5720
-						PANDORA_HOME=/usr/local/www/apache24/data/pandora_console
5721
-					else
5722
-						if [ -d /usr/local/www/apache22 ]
5723
-						then
5724
-							PANDORA_HOME=/usr/local/www/apache22/data/pandora_console
5725
-						else
5726
-							PANDORA_HOME=/usr/local/www/data/pandora_console
5727
-						fi
5728
-					fi
5729
-					PANDORA_CONF=$PANDORA_HOME/include/config.php
5730
-				else
5731
-					if [ "$DISTRO" = "NetBSD" ]
5732
-					then
5733
-						PANDORA_HOME=/usr/pkg/share/httpd/htdocs/pandora_console
5734
-						PANDORA_CONF=$PANDORA_HOME/include/config.php
5735
-					else
5736
-						PANDORA_HOME=/srv/www/htdocs/pandora_console
5737
-						PANDORA_CONF=$PANDORA_HOME/include/config.php
5738
-					fi
5739
-				fi
5740
-			fi
5741
-		fi
5742
-	fi
5743
+	PANDORA_CONF=$PANDORA_HOME/include/config.php
5744
 
5745
 	echo "Detecting operating system: $DISTRO"
5746
 	
5747
-	if [ -f $PANDORA_HOME ] && [ "$FORCE" = "0" ]
5748
+	if [ -f $DESTDIR$PANDORA_HOME ] && [ "$FORCE" = "0" ]
5749
 	then
5750
 		echo "Seems that default dir already exists. Please use --force to"
5751
-		echo "force installer to install on $PANDORA_HOME"
5752
+		echo "force installer to install on $DESTDIR$PANDORA_HOME"
5753
 		exit
5754
 	else
5755
-		echo "Checking default dir $PANDORA_HOME..."
5756
+		echo "Checking default dir $DESTDIR$PANDORA_HOME..."
5757
 	fi
5758
 
5759
-	# Create directories
5760
-	echo "Creating Pandora FMS Console home directory at $PANDORA_HOME ..."
5761
-	mkdir -p $PANDORA_HOME 2> /dev/null
5762
-
5763
-	# Copying Pandora FMS console
5764
-	echo "Copying Pandora FMS Console to $PANDORA_HOME.."
5765
-	cp -R * $PANDORA_HOME
5766
-	chmod -R u+rwX,g+rX,g-w,o-rwx $PANDORA_HOME
5767
-
5768
-
5769
-	# Creating 'pandora' user
5770
+	# Check and create 'pandora' user if needed
5771
 	id pandora 2> /dev/null
5772
 	if [ $? -eq 0 ]; then
5773
 		echo " "
5774
 		echo "User pandora does exist, skipping this step"
5775
+	elif [ "$DESTDIR" ]
5776
+	then
5777
+		# don't create user with "fakeroot" installation
5778
+		echo "User 'pandora' does not exist. All chown operations may fail."
5779
+		echo "You should manualy set proper ownership to $DESTDIR$PANDORA_HOME and $DESTDIR$PANDORA_SPOOL if it's required."
5780
+		echo
5781
 	else
5782
-		echo "Creating 'pandora' user"
5783
+		echo "Are you sure we can create a standard 'pandora' user locally? [y/N]"
5784
+		read AREYOUSURE
5785
+		if [ "$AREYOUSURE" != "y" ]
5786
+		then
5787
+			echo "Please create the 'pandora' user manually according to your authentication scheme, then start again the installation"
5788
+			echo "Aborting..."
5789
+			exit 1
5790
+		fi
5791
+		# creating user
5792
 		if [ "$DISTRO" = "FreeBSD" ]
5793
 		then
5794
 			echo "pandora:41121:::::Pandora FMS:/home/pandora:/usr/sbin/nologin:" | adduser -f - -w no 2> /dev/null
5795
@@ -190,46 +163,31 @@
5796
 		fi
5797
 	fi
5798
 
5799
-	if [ ! -d /var/spool/pandora ]
5800
-	then
5801
-		mkdir -p /var/spool/pandora
5802
-	fi
5803
+	# Create directories
5804
+	echo "Creating Pandora FMS Console home directory at $DESTDIR$PANDORA_HOME ..."
5805
+	mkdir -p $DESTDIR$PANDORA_HOME 2> /dev/null
5806
 
5807
+	# Copying Pandora FMS console
5808
+	echo "Copying Pandora FMS Console to $DESTDIR$PANDORA_HOME.."
5809
+	cp -R * $DESTDIR$PANDORA_HOME
5810
+	chmod -R u+rwX,g+rX,g-w,o-rwx $DESTDIR$PANDORA_HOME
5811
+
5812
+	# prepare /var/spool/pandora/data_in and sub directories
5813
+	for subdir in collections conf md5 netflow
5814
+	do
5815
+		[ ! -d $DESTDIR/var/spool/pandora/data_in/$subdir ] && mkdir -p $DESTDIR/var/spool/pandora/data_in/$subdir
5816
+	done
5817
+
5818
 	#Ownership
5819
-	if [ "$DISTRO" = "UBUNTU" ]
5820
-	then
5821
-		chown -R www-data:root $PANDORA_HOME
5822
-		chown -R pandora:www-data /var/spool/pandora/
5823
-	else 
5824
-		if [ "$DISTRO" = "RHEL_CENTOS" ]
5825
-		then
5826
-			chown -R apache:apache $PANDORA_HOME
5827
-			chown -R pandora:apache /var/spool/pandora/	
5828
-		else 
5829
-			if [ "$DISTRO" = "FEDORA" ]
5830
-			then
5831
-				chown -R apache:apache $PANDORA_HOME
5832
-				chown -R pandora:apache /var/spool/pandora/	
5833
-			else
5834
-				if [ "$DISTRO" = "FreeBSD" -o "$DISTRO" = "NetBSD" ]
5835
-				then
5836
-					chown -R www:www $PANDORA_HOME
5837
-					chown -R pandora:www /var/spool/pandora/
5838
-				else
5839
-					# Assuming SUSE
5840
-					chown -R wwwrun:root $PANDORA_HOME
5841
-					chown -R pandora:www /var/spool/pandora/
5842
-				fi
5843
-			fi
5844
-		fi
5845
-	fi
5846
+	chown -R $WWWUSER:$PANDORA_HOME_GROUP $DESTDIR$PANDORA_HOME 2> /dev/null
5847
+	chown -R pandora:$WWWGROUP $DESTDIR/var/spool/pandora/	2> /dev/null
5848
 
5849
 	echo "Setting secure permissions for Pandora FMS spool dir..."
5850
-	chmod -R u+rwX,g+rwX,o-rwx /var/spool/pandora/
5851
+	chmod -R u+rwX,g+rwX,o-rwx $DESTDIR/var/spool/pandora/
5852
 
5853
 	echo "Done."
5854
 	echo " "
5855
-	echo "You have your Pandora FMS console installed on $PANDORA_HOME."
5856
+	echo "You have your Pandora FMS console installed on $DESTDIR$PANDORA_HOME."
5857
 	echo " "
5858
 	echo "Now you can setup your Pandora FMS console and install"
5859
 	echo "database using a browser and point to: "
5860
@@ -240,17 +198,40 @@
5861
 }
5862
 
5863
 help () {
5864
+	echo "Syntax":
5865
+	echo
5866
+	echo "    ./pandora_console_install < --mode > [ --option ]"
5867
+	echo " "
5868
+	echo "Modes:"
5869
+	echo
5870
 	echo "    --force-install     To force installation if already installed on this system"
5871
 	echo "    --install           To install Pandora FMS Console on this system"
5872
-	echo " "
5873
+	echo "    --uninstall         To uninstall/remove Pandora FMS Console on this System"
5874
+	echo
5875
+	echo "Option:"
5876
+	echo
5877
+	echo "	  --destdir DIR	      Specify root directory for \"fakeroot\" installation"
5878
+	echo
5879
 }
5880
 
5881
 # Script banner at start
5882
 echo " "
5883
-echo "Pandora FMS Console Installer $PI_VERSION (c) 2008-2011 ArticaST"
5884
+echo "Pandora FMS Console Installer $PI_VERSION (c) 2008-2014 ArticaST"
5885
 echo "This program is licensed under GPL2 Terms. http://pandorafms.com"
5886
 echo " "
5887
 
5888
+# parse option
5889
+if [ "$2" = "--destdir" ]
5890
+then
5891
+	if [ -z "$3" ]
5892
+	then
5893
+		echo '"--datadir" option requires an argument'
5894
+		help
5895
+		exit 1
5896
+	fi
5897
+	DESTDIR="$3"
5898
+fi
5899
+
5900
 case "$MODE" in
5901
 
5902
 '--force-install')
5903
Index: index.php
5904
===================================================================
5905
--- index.php	(revision 10314)
5906
+++ index.php	(working copy)
5907
@@ -355,6 +355,7 @@
5908
  * Load here, because if not, some extensions not load well, I don't why.
5909
  */
5910
 
5911
+$config['logged'] = false;
5912
 extensions_load_extensions ($config['extensions']);
5913
 if ($process_login) {
5914
 	 /* Call all extensions login function */
5915
@@ -376,6 +377,8 @@
5916
 	
5917
 	//Set the initial global counter for chat.
5918
 	users_get_last_global_counter('session');
5919
+	
5920
+	$config['logged'] = true;
5921
 }
5922
 
5923
 //Get old parameters before navigation.
5924
@@ -562,7 +565,9 @@
5925
 			require("general/logon_ok.php");
5926
 		}
5927
 	}
5928
-	require("general/shortcut_bar.php");
5929
+	if ($config["pure"] == 0) {
5930
+		require("general/shortcut_bar.php");
5931
+	}
5932
 }
5933
 
5934
 if ($config["pure"] == 0) {
5935
@@ -583,6 +588,11 @@
5936
 	require ("general/footer.php");
5937
 	echo '</div>';
5938
 }
5939
+
5940
+/// Clippy function
5941
+require_once('include/functions_clippy.php');
5942
+clippy_start($sec2);
5943
+
5944
 while (@ob_end_flush ());
5945
 
5946
 db_print_database_debug ();
5947
Index: extensions/agents_alerts.php
5948
===================================================================
5949
--- extensions/agents_alerts.php	(revision 10314)
5950
+++ extensions/agents_alerts.php	(working copy)
5951
@@ -172,13 +172,18 @@
5952
 		echo "<th width='20px' style='vertical-align:top; padding-top: 35px;' rowspan='".($nagents+1)."'><a href='index.php?sec=extensions&sec2=extensions/agents_alerts&refr=0&hor_offset=".$new_hor_offset."&offset=".$offset."&group_id=".$group_id."'>".html_print_image("images/darrowleft.png",true, array('title' => __('Previous templates')))."</a> </th>";
5953
 	}
5954
 	
5955
+	$templates_raw = array();
5956
 	if (!empty($templates)) {
5957
 		$sql = sprintf('SELECT id, name
5958
-			FROM talert_templates WHERE id IN (%s)',implode(',',array_keys($templates)));
5959
+			FROM talert_templates
5960
+			WHERE id IN (%s)',implode(',',array_keys($templates)));
5961
 		
5962
 		$templates_raw = db_get_all_rows_sql($sql);
5963
 	}
5964
 	
5965
+	if (empty($templates_raw))
5966
+		$templates_raw = array();
5967
+	
5968
 	$alerts = array();
5969
 	$ntemplates = 0;
5970
 	foreach ($templates_raw as $temp) {
5971
@@ -225,7 +230,7 @@
5972
 				if($anyfired) {
5973
 					$cellstyle = 'background:'.COL_ALERTFIRED.';';
5974
 				}
5975
-								
5976
+				
5977
 				echo '<td style="text-align:center;'.$cellstyle.'"> ';
5978
 				
5979
 				$uniqid = uniqid();
5980
@@ -266,9 +271,12 @@
5981
 		$data[0] = modules_get_agentmodule_name ($alert['id_agent_module']);
5982
 		
5983
 		$actions = alerts_get_alert_agent_module_actions ($alert['id']);
5984
-				
5985
-		$actionDefault = db_get_value_sql("SELECT id_alert_action FROM talert_templates WHERE id = " . $alert['id_alert_template']);
5986
 		
5987
+		$actionDefault = db_get_value_sql("
5988
+			SELECT id_alert_action
5989
+			FROM talert_templates
5990
+			WHERE id = " . $alert['id_alert_template']);
5991
+		
5992
 		$actionText = '';
5993
 		
5994
 		if (!empty($actions)) {
5995
@@ -284,10 +292,13 @@
5996
 		}
5997
 		else {
5998
 			if (!empty($actionDefault)) {
5999
-				$actionText = db_get_sql ("SELECT name FROM talert_actions WHERE id = $actionDefault"). " <i>(".__("Default") . ")</i>";
6000
+				$actionText = db_get_sql ("SELECT name
6001
+					FROM talert_actions
6002
+					WHERE id = $actionDefault") .
6003
+					" <i>(" . __("Default") . ")</i>";
6004
 			}
6005
 		}
6006
-	
6007
+		
6008
 		$data[1] = $actionText;
6009
 		$data[2] = ui_print_timestamp ($alert["last_fired"], true);
6010
 		
6011
Index: extensions/files_repo/sql/files_repo.postgreSQL.sql
6012
===================================================================
6013
--- extensions/files_repo/sql/files_repo.postgreSQL.sql	(revision 10314)
6014
+++ extensions/files_repo/sql/files_repo.postgreSQL.sql	(working copy)
6015
@@ -1,2 +1,2 @@
6016
-CREATE TABLE IF NOT EXISTS "tfiles_repo" ("id" SERIAL NOT NULL PRIMARY KEY, "name" VARCHAR(255) NOT NULL, "description" VARCHAR(500) NULL default '', "hash" VARCHAR(8) NULL default '');
6017
-CREATE TABLE IF NOT EXISTS "tfiles_repo_group" ("id" SERIAL NOT NULL PRIMARY KEY, "id_file" INTEGER NOT NULL REFERENCES tfiles_repo("id") ON DELETE CASCADE, "id_group" INTEGER NOT NULL);
6018
+CREATE TABLE  "tfiles_repo" ("id" SERIAL NOT NULL PRIMARY KEY, "name" VARCHAR(255) NOT NULL, "description" VARCHAR(500) NULL default '', "hash" VARCHAR(8) NULL default '');
6019
+CREATE TABLE  "tfiles_repo_group" ("id" SERIAL NOT NULL PRIMARY KEY, "id_file" INTEGER NOT NULL REFERENCES tfiles_repo("id") ON DELETE CASCADE, "id_group" INTEGER NOT NULL);
6020
Index: extensions/files_repo/functions_files_repo.php
6021
===================================================================
6022
--- extensions/files_repo/functions_files_repo.php	(revision 10314)
6023
+++ extensions/files_repo/functions_files_repo.php	(working copy)
6024
@@ -125,31 +125,33 @@
6025
 
6026
 function files_repo_get_files ($filter = false, $count = false) {
6027
 	global $config;
6028
-
6029
+	
6030
 	// Don't use the realpath for the download links!
6031
 	$files_repo_path = io_safe_output($config['attachment_store'])."/files_repo";
6032
-
6033
-	$sql = "SELECT * FROM tfiles_repo " . db_format_array_where_clause_sql($filter, "AND", "WHERE");
6034
+	
6035
+	$sql = "SELECT *
6036
+		FROM tfiles_repo
6037
+		" . db_format_array_where_clause_sql($filter, "AND", "WHERE");
6038
 	$files = db_get_all_rows_sql($sql);
6039
-
6040
+	
6041
 	if ($files === false)
6042
 		$files = array();
6043
-
6044
+	
6045
 	$user_groups = files_repo_get_user_groups($config['id_user']);
6046
-
6047
+	
6048
 	$files_data = array();
6049
 	foreach ($files as $file) {
6050
-
6051
+		
6052
 		$file_groups = files_repo_get_file_groups($file['id']);
6053
 		$permission = files_repo_check_file_acl ($file['id'], $config['id_user'], $file_groups, $user_groups);
6054
 		if (!$permission) {
6055
 			continue;
6056
 		}
6057
-
6058
+		
6059
 		$data = array();
6060
 		$data['name'] = $file['name'];
6061
 		$data['description'] = $file['description'];
6062
-		$data['location'] = $files_repo_path."/".$file['id']."_".$data['name'];
6063
+		$data['location'] = $files_repo_path . "/" . $file['id']."_".$data['name'];
6064
 		// Size in bytes
6065
 		$data['size'] = filesize($data['location']);
6066
 		// Last modification time in unix timestamp
6067
@@ -158,7 +160,7 @@
6068
 		$data['hash'] = $file['hash'];
6069
 		$files_data[$file['id']] = $data;
6070
 	}
6071
-
6072
+	
6073
 	if ($count) {
6074
 		$files_data = count($files_data);
6075
 	}
6076
Index: extensions/files_repo/files_repo_list.php
6077
===================================================================
6078
--- extensions/files_repo/files_repo_list.php	(revision 10314)
6079
+++ extensions/files_repo/files_repo_list.php	(working copy)
6080
@@ -17,16 +17,19 @@
6081
 
6082
 global $config;
6083
 
6084
-$full_extensions_dir = $config['homedir']."/".EXTENSIONS_DIR."/";
6085
-require_once ($full_extensions_dir."files_repo/functions_files_repo.php");
6086
+$full_extensions_dir = $config['homedir'] . "/" . EXTENSIONS_DIR . "/";
6087
+require_once ($full_extensions_dir .
6088
+	"files_repo/functions_files_repo.php");
6089
 
6090
 $offset = (int) get_parameter('offset');
6091
 $filter = array();
6092
 $filter['limit'] = $config['block_size'];
6093
 $filter['offset'] = $offset;
6094
 $filter['order'] = array('field' => 'id', 'order' => 'DESC');
6095
+
6096
 $files = files_repo_get_files($filter);
6097
 
6098
+
6099
 if (!empty($files)) {
6100
 	
6101
 	echo "<br>";
6102
Index: extensions/module_groups.php
6103
===================================================================
6104
--- extensions/module_groups.php	(revision 10314)
6105
+++ extensions/module_groups.php	(working copy)
6106
@@ -141,7 +141,8 @@
6107
 				GROUP BY estado";
6108
 			break;
6109
 		case "postgresql":
6110
-			$sql = "SELECT COUNT(id_agente) AS count, case utimestamp when 0 then 5 else estado end as estado
6111
+			$sql = "SELECT COUNT(id_agente) AS count,
6112
+					case utimestamp when 0 then 5 else estado end as estado
6113
 				FROM tagente_estado
6114
 				WHERE id_agente IN
6115
 					(SELECT id_agente FROM tagente WHERE id_grupo = %d AND disabled = 0)
6116
@@ -149,7 +150,7 @@
6117
 					(SELECT id_agente_modulo
6118
 						FROM tagente_modulo
6119
 						WHERE id_module_group = %d AND disabled = 0 AND delete_pending = 0)
6120
-				GROUP BY estado";
6121
+				GROUP BY estado, utimestamp";
6122
 			break;
6123
 		case "oracle":
6124
 			$sql = "SELECT COUNT(id_agente) AS count, case when utimestamp = 0 then 5 else estado end estado
6125
@@ -185,7 +186,8 @@
6126
 		//Metaobject use in html_print_table
6127
 		$table = null;
6128
 		$table->align[0] = 'right'; //Align to right the first column.
6129
-		$table->style[0] = 'color: #ffffff; background-color: #778866; font-weight: bolder;';
6130
+		$table->style[0] = 'color: #ffffff; '.
6131
+			'background-color: #778866; font-weight: bolder;';
6132
 		$table->head = $head;
6133
 		$table->width = '98%';
6134
 		
6135
@@ -201,7 +203,7 @@
6136
 			
6137
 			foreach ($modelGroups as $idModelGroup => $modelGroup) {
6138
 				$fired = false;
6139
-				$query = sprintf($sql,$idAgentGroup, $idModelGroup);
6140
+				$query = sprintf($sql, $idAgentGroup, $idModelGroup);
6141
 				
6142
 				$rowsDB = db_get_all_rows_sql ($query);
6143
 				
6144
Index: extensions/files_repo.php
6145
===================================================================
6146
--- extensions/files_repo.php	(revision 10314)
6147
+++ extensions/files_repo.php	(working copy)
6148
@@ -18,12 +18,14 @@
6149
 function pandora_files_repo_install () {
6150
 	global $config;
6151
 	
6152
+	
6153
 	if (isset($config['files_repo_installed'])) {
6154
 		if ($config['files_repo_installed'] == 1) {
6155
 			return;
6156
 		}
6157
 	}
6158
-
6159
+	
6160
+	
6161
 	$full_extensions_dir = $config['homedir']."/".EXTENSIONS_DIR."/";
6162
 	$full_sql_dir = $full_extensions_dir."files_repo/sql/";
6163
 	
6164
@@ -40,6 +42,7 @@
6165
 			break;
6166
 	}
6167
 	
6168
+	
6169
 	foreach ($sentences as $sentence) {
6170
 		if (trim ($sentence) == "")
6171
 			continue;
6172
@@ -61,22 +64,22 @@
6173
 	
6174
 	switch ($config["dbtype"]) {
6175
 		case "mysql":
6176
-			db_process_sql ('DROP TABLE `tfiles_repo_group`');
6177
-			db_process_sql ('DROP TABLE `tfiles_repo`');
6178
-			db_process_sql ('DELETE FROM `tconfig`
6179
-							 WHERE `token` LIKE "files_repo_%"');
6180
+			db_process_sql('DROP TABLE `tfiles_repo_group`');
6181
+			db_process_sql('DROP TABLE `tfiles_repo`');
6182
+			db_process_sql('DELETE FROM `tconfig`
6183
+				WHERE `token` LIKE "files_repo_%"');
6184
 			break;
6185
 		case "postgresql":
6186
-			db_process_sql ('DROP TABLE `tfiles_repo_group`');
6187
-			db_process_sql ('DROP TABLE `tfiles_repo`');
6188
-			db_process_sql ('DELETE FROM "tconfig"
6189
-							 WHERE "token" LIKE \'files_repo_%\'');
6190
+			db_process_sql('DROP TABLE "tfiles_repo_group"');
6191
+			db_process_sql('DROP TABLE "tfiles_repo"');
6192
+			db_process_sql('DELETE FROM "tconfig"
6193
+				WHERE "token" LIKE \'files_repo_%\'');
6194
 			break;
6195
 		case "oracle":
6196
-			db_process_sql ('DROP TABLE `tfiles_repo_group`');
6197
-			db_process_sql ('DROP TABLE `tfiles_repo`');
6198
-			db_process_sql ('DELETE FROM tconfig
6199
-							 WHERE token LIKE \'files_repo_%\'');
6200
+			db_process_sql('DROP TABLE "tfiles_repo_group"');
6201
+			db_process_sql('DROP TABLE "tfiles_repo"');
6202
+			db_process_sql('DELETE FROM tconfig
6203
+				WHERE token LIKE \'files_repo_%\'');
6204
 			break;
6205
 	}
6206
 
6207
@@ -86,11 +89,11 @@
6208
 
6209
 function pandora_files_repo_godmode () {
6210
 	global $config;
6211
-
6212
+	
6213
 	if (!isset($config['files_repo_installed']) || !$config['files_repo_installed']) {
6214
 		ui_print_error_message(__('Extension not installed'));
6215
 	}
6216
-
6217
+	
6218
 	// ACL Check
6219
 	check_login ();
6220
 	if (! check_acl ($config['id_user'], 0, "PM")) {
6221
@@ -98,37 +101,41 @@
6222
 		require ("general/noaccess.php");
6223
 		return;
6224
 	}
6225
-
6226
+	
6227
 	// Header tabs
6228
 	$godmode['text'] = '<a href="index.php?sec=gextensions&sec2=extensions/files_repo">'
6229
 			. html_print_image ("images/setup.png", true, array ("title" => __('Administration view')))
6230
 			. "</a>";
6231
 	$godmode['godmode'] = 1;
6232
 	$godmode['active'] = 1;
6233
-		
6234
+	
6235
 	$operation['text'] = '<a href="index.php?sec=extensions&sec2=extensions/files_repo">'
6236
 			. html_print_image ("images/operation.png", true, array ("title" => __('Operation view')))
6237
 			. "</a>";
6238
 	$operation['operation'] = 1;
6239
-			
6240
+	
6241
 	$onheader = array('godmode' => $godmode, 'operation' => $operation);
6242
 	// Header
6243
 	ui_print_page_header (__("Files repository manager"), "images/extensions.png", false, "", true, $onheader);
6244
-
6245
+	
6246
 	$full_extensions_dir = $config['homedir']."/".EXTENSIONS_DIR."/";
6247
-	require_once ($full_extensions_dir."files_repo/functions_files_repo.php");
6248
-
6249
+	require_once ($full_extensions_dir . "files_repo/functions_files_repo.php");
6250
+	
6251
 	// Directory files_repo check
6252
 	if (!files_repo_check_directory(true)) {
6253
 		return;
6254
 	}
6255
-
6256
+	
6257
+	$server_content_length = 0;
6258
+	if (isset($_SERVER['CONTENT_LENGTH']))
6259
+		$server_content_length =  $_SERVER['CONTENT_LENGTH'];
6260
+	
6261
 	// Check for an anoying error that causes the $_POST and $_FILES arrays
6262
 	// were empty if the file is larger than the post_max_size
6263
-	if (intval($_SERVER['CONTENT_LENGTH']) > 0 && empty($_POST)) {
6264
+	if (intval($server_content_length) > 0 && empty($_POST)) {
6265
 		ui_print_error_message(__('The file exceeds the maximum size'));
6266
 	}
6267
-
6268
+	
6269
 	// GET and POST parameters
6270
 	$file_id = (int) get_parameter ("file_id");
6271
 	$add_file = (bool) get_parameter ("add_file");
6272
@@ -144,7 +151,7 @@
6273
 			$description = mb_substr($description, 0, 200, "UTF-8");
6274
 		}
6275
 		$description = io_safe_input($description);
6276
-
6277
+		
6278
 		if ($add_file) {
6279
 			$result = files_repo_add_file("upfile", $description, $groups, $public);
6280
 		} elseif ($update_file) {
6281
@@ -163,7 +170,7 @@
6282
 		}
6283
 		$file_id = 0;
6284
 	}
6285
-
6286
+	
6287
 	// FORM
6288
 	require ($full_extensions_dir."files_repo/files_repo_form.php");
6289
 	if (!$file_id) {
6290
@@ -175,7 +182,7 @@
6291
 
6292
 function pandora_files_repo_operation () {
6293
 	global $config;
6294
-
6295
+	
6296
 	// Header tabs
6297
 	$onheader = array();
6298
 	if (check_acl($config['id_user'], 0, "PM")) {
6299
@@ -194,18 +201,19 @@
6300
 	}
6301
 	// Header
6302
 	ui_print_page_header (__("Files repository"), "images/extensions.png", false, "", false, $onheader);
6303
-
6304
+	
6305
 	$full_extensions_dir = $config['homedir']."/".EXTENSIONS_DIR."/";
6306
 	require_once ($full_extensions_dir."files_repo/functions_files_repo.php");
6307
-
6308
+	
6309
 	// Directory files_repo check
6310
 	if (!files_repo_check_directory(true)) {
6311
 		return;
6312
 	}
6313
-
6314
+	
6315
 	// LIST
6316
 	$full_extensions_dir = $config['homedir']."/".EXTENSIONS_DIR."/";
6317
-	require ($full_extensions_dir."files_repo/files_repo_list.php");
6318
+	
6319
+	require ($full_extensions_dir . "files_repo/files_repo_list.php");
6320
 }
6321
 
6322
 extensions_add_operation_menu_option(__('Files repository'), null, null, "v1r1");
6323
Index: operation/incidents/incident.php
6324
===================================================================
6325
--- operation/incidents/incident.php	(revision 10314)
6326
+++ operation/incidents/incident.php	(working copy)
6327
@@ -25,7 +25,8 @@
6328
 }
6329
 
6330
 // Header
6331
-ui_print_page_header (__('Incident management'), "images/book_edit.png", false, "", false, "");
6332
+ui_print_page_header (__('Incident management'),
6333
+	"images/book_edit.png", false, "", false, "");
6334
 
6335
 // Take input parameters
6336
 
6337
@@ -197,7 +198,7 @@
6338
 			ORDER BY actualizacion DESC OFFSET ".$offset." LIMIT ".$config["block_size"];
6339
 		$count_sql = "SELECT count(*) FROM tincidencia WHERE
6340
 			id_grupo IN (".implode (",",array_keys ($groups)).")".$filter;
6341
-		breka;
6342
+		break;
6343
 }
6344
 
6345
 $result = db_get_all_rows_sql ($sql);
6346
@@ -250,11 +251,14 @@
6347
 	$agents_incidents = array();
6348
 }
6349
 
6350
-foreach ($agents_incidents as $agent_incident){
6351
+$result_agent_incidents = array();
6352
+foreach ($agents_incidents as $agent_incident) {
6353
 	$result_agent_incidents[$agent_incident['id_agente']] = $agent_incident['nombre'];
6354
 }
6355
 
6356
-html_print_select ($result_agent_incidents, "agent_search", $agent_search, 'javascript:this.form.submit();', __('All agents'), "", false, false, false, "w155");
6357
+html_print_select ($result_agent_incidents, "agent_search",
6358
+	$agent_search, 'javascript:this.form.submit();', __('All agents'),
6359
+	"", false, false, false, "w155");
6360
 
6361
 echo '</td></tr><tr><td colspan=3>';
6362
 	
6363
Index: operation/tree.php
6364
===================================================================
6365
--- operation/tree.php	(revision 10314)
6366
+++ operation/tree.php	(working copy)
6367
@@ -72,7 +72,7 @@
6368
 	}
6369
 	if ($printAlertsTable) {
6370
 		$id_module = get_parameter('id_module');
6371
-				
6372
+		
6373
 		if (defined ('METACONSOLE')) {
6374
 			$server = metaconsole_get_connection ($server_name);
6375
 			metaconsole_connect($server);
6376
@@ -86,7 +86,7 @@
6377
 	}
6378
 	if ($printModuleTable) {
6379
 		$id_module = get_parameter('id_module');
6380
-				
6381
+		
6382
 		if (defined ('METACONSOLE')) {
6383
 			$server = metaconsole_get_connection ($server_name);
6384
 			metaconsole_connect($server);
6385
@@ -139,7 +139,8 @@
6386
 					}
6387
 					$avariableGroups = users_get_groups();
6388
 					$avariableGroupsIds = array_keys($avariableGroups);
6389
-					$sql = treeview_getFirstBranchSQL ($type, $id, $avariableGroupsIds, $statusSel, $search_free);
6390
+					$sql = treeview_getFirstBranchSQL ($type, $id,
6391
+						$avariableGroupsIds, $statusSel, $search_free);
6392
 					if ($sql === false) {
6393
 						$server_rows = array ();
6394
 					}
6395
@@ -437,7 +438,7 @@
6396
 						"id=" . $row["id_agente_modulo"];
6397
 				}
6398
 				echo "<a href='javascript: show_module_detail_dialog(" . $row["id_agente_modulo"] . ", ". $row['id_agente'].", \"" . $server_name . "\", 0, 86400)'>". html_print_image ("images/binary.png", true, array ("style" => 'vertical-align: middle;', "border" => "0" )) . "</a>";
6399
-
6400
+				
6401
 				echo " ";
6402
 				
6403
 				$nmodule_alerts = db_get_value_sql(sprintf("SELECT count(*) FROM talert_template_modules WHERE id_agent_module = %s", $row["id_agente_modulo"]));
6404
@@ -525,35 +526,44 @@
6405
 }
6406
 
6407
 $module_tab = array('text' => "<a href='index.php?extension_in_menu=estado&sec=estado&sec2=operation/tree&refr=0&sort_by=module'>"
6408
-	. html_print_image ("images/brick.png", true, array ("title" => __('Modules'))) . "</a>", 'active' => $activeTab == "module");
6409
+	. html_print_image("images/brick.png",
6410
+		true,
6411
+		array("title" => __('Modules'))) . "</a>",
6412
+		'active' => $activeTab == "module");
6413
 
6414
 $tags_tab = array('text' => "<a href='index.php?&sec=monitoring&sec2=operation/tree&refr=0&sort_by=tag&pure=$pure'>"
6415
-	. html_print_image ("images/tag.png", true, array ("title" => __('Tags'))) . "</a>", 'active' => $activeTab == "tag");
6416
-	
6417
+	. html_print_image("images/tag.png",
6418
+		true,
6419
+		array("title" => __('Tags'))) . "</a>",
6420
+		'active' => $activeTab == "tag");
6421
+
6422
 switch ($activeTab) {
6423
 	case 'group':
6424
-		$order =  __('groups');
6425
+		$order = __('groups');
6426
 		break;
6427
 	case 'module_group':
6428
-		$order =  __('module groups');
6429
+		$order = __('module groups');
6430
 		break;
6431
 	case 'policies':
6432
-		$order =  __('policies');
6433
+		$order = __('policies');
6434
 		break;
6435
 	case 'module':
6436
-		$order =  __('modules');
6437
+		$order = __('modules');
6438
 		break;
6439
 	case 'os':
6440
-		$order =  __('OS');
6441
+		$order = __('OS');
6442
 		break;
6443
 	case 'tag':
6444
-		$order =  __('tags');
6445
+		$order = __('tags');
6446
 		break;
6447
 }
6448
 
6449
 if (! defined ('METACONSOLE')) {
6450
 	$onheader = array('tag' => $tags_tab, 'os' => $os_tab, 'group' => $group_tab, 'module_group' => $module_group_tab, 'policies' => $policies_tab, 'module' => $module_tab);
6451
-	ui_print_page_header (__('Tree view')." - ".__('Sort the agents by ') .$order, "images/extensions.png", false, "", false, $onheader);
6452
+	ui_print_page_header(
6453
+		__('Tree view') . " - " . __('Sort the agents by ') . $order,
6454
+		"images/extensions.png",
6455
+		false, "", false, $onheader);
6456
 }
6457
 else {
6458
 	
6459
@@ -569,7 +579,7 @@
6460
 	if ($config['enable_tags_tree']) {
6461
 		$allowed_tabs[] = 'tag';
6462
 	}
6463
-
6464
+	
6465
 	if (!in_array($activeTab, $allowed_tabs)) {
6466
 		db_pandora_audit("HACK Attempt",
6467
 		"Trying to access to not allowed tab on tree view");
6468
@@ -577,17 +587,19 @@
6469
 		exit;
6470
 	}
6471
 	// End of tab check
6472
-
6473
+	
6474
 	$group_tab = array('text' => "<a href='index.php?sec=monitoring&sec2=operation/tree&refr=0&tab=group&pure=$pure'>"
6475
 		. html_print_image ("images/group.png", true, array ("title" => __('Groups'))) . "</a>",
6476
 		'active' => $activeTab == "group");
6477
 	
6478
 	$subsections['group'] = $group_tab; 
6479
-
6480
-	if($config['enable_tags_tree']) {
6481
-		$tags_tab = array('text' => "<a href='index.php?&sec=monitoring&sec2=operation/tree&refr=0&tab=tag&pure=$pure'>"
6482
-					. html_print_image ("images/tag.png", true, array ("title" => __('Tags'))) . "</a>", 'active' => $activeTab == "tag");
6483
 	
6484
+	if ($config['enable_tags_tree']) {
6485
+		$tags_tab = array(
6486
+			'text' => "<a href='index.php?&sec=monitoring&sec2=operation/tree&refr=0&tab=tag&pure=$pure'>" .
6487
+				html_print_image ("images/tag.png", true, array ("title" => __('Tags'))) . "</a>",
6488
+			'active' => $activeTab == "tag");
6489
+		
6490
 		$subsections['tag'] = $tags_tab;
6491
 	}
6492
 	
6493
@@ -649,6 +661,7 @@
6494
 
6495
 treeview_printTree($activeTab);
6496
 
6497
+
6498
 enterprise_hook('close_meta_frame');
6499
 
6500
 ui_include_time_picker();
6501
@@ -672,10 +685,14 @@
6502
 	 * id_father int use in js and ajax php, its useful when you have a two subtrees with same agent for diferent each one
6503
 	 */
6504
 	function loadSubTree(type, div_id, less_branchs, id_father, server_name) {
6505
-		hiddenDiv = $('#tree_div'+id_father+'_'+type+'_'+div_id).attr('hiddenDiv');
6506
-		loadDiv = $('#tree_div'+id_father+'_'+type+'_'+div_id).attr('loadDiv');
6507
-		pos = parseInt($('#tree_image'+id_father+'_'+type+'_'+div_id).attr('pos_tree'));
6508
+		hiddenDiv = $('#tree_div' + id_father + '_' + type + '_' + div_id)
6509
+			.attr('hiddenDiv');
6510
+		loadDiv = $('#tree_div' + id_father + '_' + type + '_' + div_id)
6511
+			.attr('loadDiv');
6512
 		
6513
+		pos = parseInt($('#tree_image' + id_father + '_' + type + '_' + div_id)
6514
+			.attr('pos_tree'));
6515
+		
6516
 		//If has yet ajax request running
6517
 		if (loadDiv == 2)
6518
 			return;
6519
@@ -683,8 +700,10 @@
6520
 		if (loadDiv == 0) {
6521
 			
6522
 			//Put an spinner to simulate loading process
6523
-			$('#tree_div'+id_father+'_'+type+'_'+div_id).html("<img style='padding-top:10px;padding-bottom:10px;padding-left:20px;' src=images/spinner.gif>");
6524
-			$('#tree_div'+id_father+'_'+type+'_'+div_id).show('normal');
6525
+			$('#tree_div' + id_father + '_' + type + '_' + div_id)
6526
+				.html("<img style='padding-top:10px;padding-bottom:10px;padding-left:20px;' src=images/spinner.gif>");
6527
+			$('#tree_div' + id_father + '_' + type + '_' + div_id)
6528
+				.show('normal');
6529
 			
6530
 			$('#tree_div'+id_father+'_'+type+'_'+div_id).attr('loadDiv', 2);
6531
 			$.ajax({
6532
Index: operation/search_modules.getdata.php
6533
===================================================================
6534
--- operation/search_modules.getdata.php	(revision 10314)
6535
+++ operation/search_modules.getdata.php	(working copy)
6536
@@ -108,7 +108,7 @@
6537
 							) 
6538
 						)
6539
 					) AND
6540
-					t1.nombre COLLATE utf8_general_ci LIKE \'%' . $stringSearchSQL . '%\' OR
6541
+					t1.nombre LIKE \'%' . $stringSearchSQL . '%\' OR
6542
 					t3.nombre LIKE \'%' . $stringSearchSQL . '%\'';
6543
 			break;
6544
 		case "oracle":
6545
Index: operation/search_main.php
6546
===================================================================
6547
--- operation/search_main.php	(revision 10314)
6548
+++ operation/search_main.php	(working copy)
6549
@@ -44,6 +44,7 @@
6550
 $table->style[9] = 'font-weight: bold; text-align: center;';
6551
 $table->style[10] = 'font-weight: bold; text-align: center;';
6552
 $table->style[11] = 'font-weight: bold; text-align: center;';
6553
+$table->style[13] = 'font-weight: bold; text-align: center;';
6554
 
6555
 $table->data[0][0] = html_print_image ("images/agent.png", true, array ("title" => __('Agents found')));
6556
 $table->data[0][1] = "<a href='index.php?search_category=agents&keywords=".$keyword."&head_search_keywords=Search'>" .
6557
Index: operation/events/events_list.php
6558
===================================================================
6559
--- operation/events/events_list.php	(revision 10314)
6560
+++ operation/events/events_list.php	(working copy)
6561
@@ -52,7 +52,7 @@
6562
 		$event_filter['tag_with'] = base64_encode(io_safe_output($event_filter['tag_with']));
6563
 		$event_filter['tag_without'] = base64_encode(io_safe_output($event_filter['tag_without']));
6564
 		
6565
-		echo json_encode($event_filter);
6566
+		echo io_json_mb_encode($event_filter);
6567
 	}
6568
 	
6569
 	// Saves an event filter
6570
@@ -69,8 +69,8 @@
6571
 		$values['event_view_hr'] = get_parameter('event_view_hr');
6572
 		$values['id_user_ack'] = get_parameter('id_user_ack');
6573
 		$values['group_rep'] = get_parameter('group_rep');
6574
-		$values['tag_with'] = get_parameter('tag_with', json_encode(array()));
6575
-		$values['tag_without'] = get_parameter('tag_without', json_encode(array()));
6576
+		$values['tag_with'] = get_parameter('tag_with', io_json_mb_encode(array()));
6577
+		$values['tag_without'] = get_parameter('tag_without', io_json_mb_encode(array()));
6578
 		$values['filter_only_alert'] = get_parameter('filter_only_alert');
6579
 		$values['id_group_filter'] = get_parameter('id_group_filter');
6580
 		
6581
@@ -97,8 +97,8 @@
6582
 		$values['event_view_hr'] = get_parameter('event_view_hr');	
6583
 		$values['id_user_ack'] = get_parameter('id_user_ack');
6584
 		$values['group_rep'] = get_parameter('group_rep');
6585
-		$values['tag_with'] = get_parameter('tag_with', json_encode(array()));
6586
-		$values['tag_without'] = get_parameter('tag_without', json_encode(array()));
6587
+		$values['tag_with'] = get_parameter('tag_with', io_json_mb_encode(array()));
6588
+		$values['tag_without'] = get_parameter('tag_without', io_json_mb_encode(array()));
6589
 		$values['filter_only_alert'] = get_parameter('filter_only_alert');
6590
 		$values['id_group_filter'] = get_parameter('id_group_filter');
6591
 		
6592
@@ -116,7 +116,7 @@
6593
 	if ($get_event_filters) {
6594
 		$event_filter = events_get_event_filter_select();
6595
 		
6596
-		echo json_encode($event_filter);
6597
+		echo io_json_mb_encode($event_filter);
6598
 	}
6599
 	
6600
 	return;
6601
@@ -195,14 +195,14 @@
6602
 	$table->class = 'databox';
6603
 	$table->styleTable = 'font-weight: bold; color: #555; text-align:left;';
6604
 	$table->style[0] = 'width: 50%; width:50%;';
6605
-
6606
+	
6607
 	$data = array();
6608
 	$table->rowid[0] = 'update_save_selector';
6609
 	$data[0] = html_print_radio_button('filter_mode', 'new', '', true, true) . __('New filter') . '<br><br>';
6610
 	$data[1] = html_print_radio_button('filter_mode', 'update', '', false, true) . __('Update filter') . '<br><br>';
6611
 	$table->data[] = $data;
6612
 	$table->rowclass[] = '';
6613
-
6614
+	
6615
 	$data = array();
6616
 	$table->rowid[1] = 'save_filter_row1';
6617
 	$data[0] = __('Filter name') . '<br>';
6618
@@ -212,7 +212,7 @@
6619
 	$data[1] .= html_print_select_groups($config["id_user"], "ER", users_can_manage_group_all(), 'id_group', $id_group, '', '', 0, true, false, false, 'w130');
6620
 	$table->data[] = $data;
6621
 	$table->rowclass[] = '';
6622
-
6623
+	
6624
 	$data = array();
6625
 	$table->rowid[2] = 'save_filter_row2';
6626
 	$data[0] = html_print_submit_button (__('Save filter'), 'save_filter', false, 'class="sub upd"', true);
6627
@@ -220,18 +220,18 @@
6628
 	$table->cellstyle[2][0] = 'text-align:right;';
6629
 	$table->data[] = $data;
6630
 	$table->rowclass[] = '';
6631
-
6632
+	
6633
 	$data = array();
6634
 	$table->rowid[3] = 'update_filter_row1';
6635
 	$data[0] = __("Overwrite filter") . '<br>';
6636
 	# Fix  : Only admin user can see filters of group ALL for update
6637
 	$_filters_update = events_get_event_filter_select(false);
6638
-
6639
+	
6640
 	$data[0] .= html_print_select ($_filters_update, "overwrite_filter", '', '', '', 0, true);
6641
 	$data[1] = html_print_submit_button (__('Update filter'), 'update_filter', false, 'class="sub upd"', true);
6642
 	$table->data[] = $data;
6643
 	$table->rowclass[] = '';
6644
-
6645
+	
6646
 	html_print_table($table);
6647
 	unset($table);
6648
 	echo '</div>';
6649
@@ -340,7 +340,7 @@
6650
 if ($open_filter) {
6651
 	$events_filter .= html_print_input_hidden('open_filter', 'true', true);
6652
 } 
6653
-else{
6654
+else {
6655
 	$events_filter .= html_print_input_hidden('open_filter', 'false', true);
6656
 }
6657
 
6658
@@ -414,8 +414,18 @@
6659
 $table_advanced->rowclass[] = '';
6660
 
6661
 $data = array();
6662
-$data[0] = '<fieldset class="databox" style="width: 310px;"><legend>' . __('Events with following tags') . '</legend>' . html_print_table($tabletags_with, true) . '</fieldset>';
6663
-$data[1] = '<fieldset class="databox" style="width: 310px;"><legend>' . __('Events without following tags') . '</legend>' . html_print_table($tabletags_without, true) . '</fieldset>';
6664
+$data[0] = '<fieldset class="databox" style="width: 310px;">' .
6665
+		'<legend>' .
6666
+			__('Events with following tags') .
6667
+		'</legend>' .
6668
+		html_print_table($tabletags_with, true) .
6669
+	'</fieldset>';
6670
+$data[1] = '<fieldset class="databox" style="width: 310px;">' .
6671
+		'<legend>' .
6672
+			__('Events without following tags') .
6673
+		'</legend>' .
6674
+		html_print_table($tabletags_without, true) .
6675
+	'</fieldset>';
6676
 $table_advanced->data[] = $data;
6677
 $table_advanced->rowclass[] = '';
6678
 
6679
@@ -536,9 +546,15 @@
6680
 	
6681
 	//Extract the events by filter (or not) from db
6682
 	$result = db_get_all_rows_sql ($sql);
6683
+	
6684
 }
6685
 else {
6686
-	$result = events_get_events_grouped($sql_post, $offset, $pagination, $meta, $history);
6687
+	$result = events_get_events_grouped(
6688
+		$sql_post,
6689
+		$offset,
6690
+		$pagination,
6691
+		$meta,
6692
+		$history);
6693
 }
6694
 
6695
 if (!empty($result)) {
6696
Index: operation/events/events.php
6697
===================================================================
6698
--- operation/events/events.php	(revision 10314)
6699
+++ operation/events/events.php	(working copy)
6700
@@ -172,7 +172,7 @@
6701
 			$return = array('fired' => 0);
6702
 		}
6703
 		
6704
-		echo json_encode($return);
6705
+		echo io_json_mb_encode($return);
6706
 	}
6707
 	
6708
 	return;
6709
Index: operation/search_agents.getdata.php
6710
===================================================================
6711
--- operation/search_agents.getdata.php	(revision 10314)
6712
+++ operation/search_agents.getdata.php	(working copy)
6713
@@ -173,7 +173,7 @@
6714
 					AND (
6715
 						t1.nombre LIKE '%%" . $stringSearchSQL . "%%' OR
6716
 						t2.nombre LIKE '%%" . $stringSearchSQL . "%%' OR
6717
-						t1.direction LIKE '%%" . $stringSearchSQL . "%%'
6718
+						t1.direccion LIKE '%%" . $stringSearchSQL . "%%'
6719
 					)
6720
 			";
6721
 			break;
6722
Index: operation/search_results.php
6723
===================================================================
6724
--- operation/search_results.php	(revision 10314)
6725
+++ operation/search_results.php	(working copy)
6726
@@ -58,7 +58,9 @@
6727
 
6728
 if ($searchMain) {
6729
 	$main_tab = array('text' => "<a href='index.php?search_category=main&keywords=".$config['search_keywords']."&head_search_keywords=Search'>"
6730
-		. html_print_image ("images/zoom_mc.png", true, array ("title" => __('Global search'))) . "</a>", 'active' => $searchTab == "main");
6731
+		. html_print_image ("images/zoom_mc.png", true,
6732
+			array ("title" => __('Global search'))) . "</a>",
6733
+				'active' => $searchTab == "main");
6734
 }
6735
 else {
6736
 	$main_tab = '';
6737
@@ -66,7 +68,9 @@
6738
 
6739
 if ($searchAgents) {
6740
 	$agents_tab = array('text' => "<a href='index.php?search_category=agents&keywords=".$config['search_keywords']."&head_search_keywords=Search'>"
6741
-		. html_print_image ("images/op_monitoring.png", true, array ("title" => __('Agents'))) . "</a>", 'active' => $searchTab == "agents");
6742
+		. html_print_image ("images/op_monitoring.png", true,
6743
+			array ("title" => __('Agents'))) . "</a>",
6744
+				'active' => $searchTab == "agents");
6745
 }
6746
 else {
6747
 	$agents_tab = '';
6748
@@ -74,7 +78,9 @@
6749
 
6750
 if ($searchUsers) {
6751
 	$users_tab = array('text' => "<a href='index.php?search_category=users&keywords=".$config['search_keywords']."&head_search_keywords=Search'>"
6752
-		. html_print_image ("images/op_workspace.png", true, array ("title" => __('Users'))) . "</a>", 'active' => $searchTab == "users");
6753
+		. html_print_image ("images/op_workspace.png", true,
6754
+			array ("title" => __('Users'))) . "</a>",
6755
+				'active' => $searchTab == "users");
6756
 }
6757
 else {
6758
 	$users_tab = '';
6759
@@ -82,7 +88,9 @@
6760
 
6761
 if ($searchAlerts) {
6762
 	$alerts_tab = array('text' => "<a href='index.php?search_category=alerts&keywords=".$config['search_keywords']."&head_search_keywords=Search'>"
6763
-		. html_print_image ("images/op_alerts.png", true, array ("title" => __('Alerts'))) . "</a>", 'active' => $searchTab == "alerts");
6764
+		. html_print_image ("images/op_alerts.png", true,
6765
+			array ("title" => __('Alerts'))) . "</a>",
6766
+				'active' => $searchTab == "alerts");
6767
 }
6768
 else {
6769
 	$alerts_tab = '';
6770
@@ -90,7 +98,9 @@
6771
 
6772
 if ($searchGraphs) {
6773
 	$graphs_tab = array('text' => "<a href='index.php?search_category=graphs&keywords=".$config['search_keywords']."&head_search_keywords=Search'>"
6774
-		. html_print_image ("images/chart.png", true, array ("title" => __('Graphs'))) . "</a>", 'active' => $searchTab == "graphs");
6775
+		. html_print_image ("images/chart.png", true,
6776
+			array ("title" => __('Graphs'))) . "</a>",
6777
+				'active' => $searchTab == "graphs");
6778
 }
6779
 else {
6780
 	$graphs_tab = '';
6781
@@ -98,7 +108,9 @@
6782
 
6783
 if ($searchReports) {
6784
 	$reports_tab = array('text' => "<a href='index.php?search_category=reports&keywords=".$config['search_keywords']."&head_search_keywords=Search'>"
6785
-		. html_print_image ("images/op_reporting.png", true, array ("title" => __('Reports'))) . "</a>", 'active' => $searchTab == "reports");
6786
+		. html_print_image ("images/op_reporting.png", true,
6787
+			array ("title" => __('Reports'))) . "</a>",
6788
+				'active' => $searchTab == "reports");
6789
 }
6790
 else {
6791
 	$reports_tab = '';
6792
@@ -106,7 +118,9 @@
6793
 
6794
 if ($searchMaps) {
6795
 	$maps_tab = array('text' => "<a href='index.php?search_category=maps&keywords=".$config['search_keywords']."&head_search_keywords=Search'>"
6796
-		. html_print_image ("images/visual_console.png", true, array ("title" => __('Maps'))) . "</a>", 'active' => $searchTab == "maps");
6797
+		. html_print_image ("images/visual_console.png", true,
6798
+			array ("title" => __('Maps'))) . "</a>",
6799
+				'active' => $searchTab == "maps");
6800
 }
6801
 else {
6802
 	$maps_tab = '';
6803
@@ -114,7 +128,9 @@
6804
 
6805
 if ($searchModules) {
6806
 	$modules_tab = array('text' => "<a href='index.php?search_category=modules&keywords=".$config['search_keywords']."&head_search_keywords=Search'>"
6807
-		. html_print_image ("images/brick.png", true, array ("title" => __('Modules'))) . "</a>", 'active' => $searchTab == "modules");
6808
+		. html_print_image ("images/brick.png", true,
6809
+			array ("title" => __('Modules'))) . "</a>",
6810
+				'active' => $searchTab == "modules");
6811
 }
6812
 else {
6813
 	$modules_tab = '';
6814
@@ -135,6 +151,7 @@
6815
 switch ($searchTab) {
6816
 	case 'main':
6817
 		$only_count = true;
6818
+		
6819
 		require_once('search_agents.getdata.php');
6820
 		require_once('search_agents.php');
6821
 		require_once('search_users.getdata.php');
6822
Index: operation/agentes/status_monitor.php
6823
===================================================================
6824
--- operation/agentes/status_monitor.php	(revision 10314)
6825
+++ operation/agentes/status_monitor.php	(working copy)
6826
@@ -14,8 +14,6 @@
6827
 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
6828
 // GNU General Public License for more details.
6829
 
6830
-
6831
-
6832
 // Load global vars
6833
 global $config;
6834
 
6835
@@ -45,6 +43,8 @@
6836
 	ui_meta_print_header(__("Monitor view"));
6837
 }
6838
 
6839
+
6840
+
6841
 $ag_freestring = get_parameter ('ag_freestring');
6842
 $ag_modulename = (string) get_parameter ('ag_modulename');
6843
 if (!defined('METACONSOLE')) {
6844
@@ -101,9 +101,13 @@
6845
 
6846
 $sql_conditions = " AND tagente_modulo.disabled = 0 AND tagente.disabled = 0";
6847
 
6848
+if (is_numeric($ag_group)) {
6849
+	$id_ag_group = 0;
6850
+}
6851
+else {
6852
+	$id_ag_group = db_get_value('id_grupo', 'tgrupo', 'nombre', $ag_group);
6853
+}
6854
 
6855
-$id_ag_group = db_get_value('id_grupo', 'tgrupo', 'nombre', $ag_group);
6856
-
6857
 // Agent group selector
6858
 if (!defined('METACONSOLE')) {
6859
 	if ($ag_group > 0 && check_acl ($config["id_user"], $ag_group, "AR")) {
6860
@@ -123,6 +127,7 @@
6861
 		$sql_conditions_group = " AND tagente.id_grupo IN (".$user_groups.")";
6862
 	}
6863
 }
6864
+
6865
 // Module group
6866
 if (defined('METACONSOLE')) {
6867
 	if ($modulegroup != '-1')
6868
@@ -198,7 +203,7 @@
6869
 				WHERE ttag_module.id_tag IN (SELECT id_tag FROM ttag where name LIKE '%" . $tag_filter . "%')
6870
 			)";
6871
 	}
6872
-	else{
6873
+	else {
6874
 		$sql_conditions .= " AND tagente_modulo.id_agente_modulo IN (
6875
 				SELECT ttag_module.id_agente_modulo
6876
 				FROM ttag_module
6877
@@ -310,7 +315,9 @@
6878
 if (defined('METACONSOLE')) {
6879
 	
6880
 	// For each server defined and not disabled:
6881
-	$servers = db_get_all_rows_sql ("SELECT * FROM tmetaconsole_setup WHERE disabled = 0");
6882
+	$servers = db_get_all_rows_sql ("SELECT *
6883
+		FROM tmetaconsole_setup
6884
+		WHERE disabled = 0");
6885
 	
6886
 	if ($servers === false)
6887
 		$servers = array();
6888
@@ -727,8 +734,15 @@
6889
 			LIMIT ".$offset.",".$limit_sql;
6890
 		break;
6891
 	case "postgresql":
6892
+		if (strstr($config['dbversion'], "8.4") !== false) {
6893
+			$string_agg = "array_to_string(array_agg(ttag.name), ',')";
6894
+		}
6895
+		else {
6896
+			$string_agg = "STRING_AGG(ttag.name, ',')";
6897
+		}
6898
+		
6899
 		$sql = "SELECT
6900
-			(SELECT  STRING_AGG(ttag.name, ',')
6901
+			(SELECT  " . $string_agg . "
6902
 				FROM ttag
6903
 				WHERE ttag.id_tag IN (
6904
 					SELECT ttag_module.id_tag
6905
@@ -760,7 +774,10 @@
6906
 			tagente_modulo.critical_instructions,
6907
 			tagente_modulo.warning_instructions,
6908
 			tagente_modulo.unknown_instructions,
6909
-			tagente_estado.utimestamp AS utimestamp".$sql_form . $sql_conditions_all." LIMIT " . $limit_sql . " OFFSET " . $offset;
6910
+			tagente_estado.utimestamp AS utimestamp" .
6911
+			$sql_from .
6912
+			$sql_conditions_all .
6913
+			" LIMIT " . $limit_sql . " OFFSET " . $offset;
6914
 		break;
6915
 	case "oracle":
6916
 		$set = array();
6917
@@ -799,7 +816,9 @@
6918
 			tagente_modulo.critical_instructions,
6919
 			tagente_modulo.warning_instructions,
6920
 			tagente_modulo.unknown_instructions,
6921
-			tagente_estado.utimestamp AS utimestamp" . $sql_form . $sql_conditions_all;
6922
+			tagente_estado.utimestamp AS utimestamp" .
6923
+			$sql_from .
6924
+			$sql_conditions_all;
6925
 		$sql = oracle_recode_query ($sql, $set);
6926
 		break;
6927
 }
6928
Index: operation/agentes/alerts_status.php
6929
===================================================================
6930
--- operation/agentes/alerts_status.php	(revision 10314)
6931
+++ operation/agentes/alerts_status.php	(working copy)
6932
@@ -258,7 +258,8 @@
6933
 
6934
 
6935
 $alerts = array();
6936
-$options_simple = array('offset' => $offset_simple, 'limit' => $config['block_size'], 'order' => $order);
6937
+$options_simple = array('offset' => $offset_simple,
6938
+	'limit' => $config['block_size'], 'order' => $order);
6939
 
6940
 $filter_alert = array();
6941
 if($filter_standby == 'standby_on') {
6942
@@ -322,11 +323,11 @@
6943
 }
6944
 
6945
 if ($tab != null) {
6946
-	$url = $url.'&tab='.$tab;
6947
+	$url = $url.'&tab=' . $tab;
6948
 }
6949
 
6950
 if ($pure) {
6951
-	$url .= '&pure='.$pure;
6952
+	$url .= '&pure=' . $pure;
6953
 }
6954
 
6955
 // Filter form
6956
@@ -345,13 +346,17 @@
6957
 if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK) {
6958
 	if ($print_agent) {
6959
 		if (!defined('METACONSOLE')) {
6960
-			$table->head[0] = "<span title='" . __('Policy') . "'>" . __('P.') . "</span>";
6961
+			$table->head[0] = "<span title='" . __('Policy') . "'>" .
6962
+				__('P.') . "</span>";
6963
 		}
6964
 		
6965
-		$table->head[1] = "<span title='" . __('Standby') . "'>" . __('S.') . "</span>";
6966
+		$table->head[1] = "<span title='" . __('Standby') . "'>" .
6967
+			__('S.') . "</span>";
6968
 		
6969
 		if (!defined('METACONSOLE')) {
6970
-			$table->head[2] = "<span title='" . __('Force execution') . "'>" . __('F.') . "</span>";
6971
+			$table->head[2] =
6972
+				"<span title='" . __('Force execution') . "'>" .
6973
+					__('F.') . "</span>";
6974
 		}
6975
 		
6976
 		$table->head[3] = __('Agent');
6977
@@ -481,6 +486,12 @@
6978
 	}
6979
 }
6980
 
6981
+
6982
+if ($sortField) {
6983
+	$url .= '&sort_field=' . $sortField;
6984
+	$url .= '&sort=' . $sort;
6985
+}
6986
+
6987
 $table->data = array ();
6988
 
6989
 $rowPair = true;
6990
@@ -496,9 +507,10 @@
6991
 }
6992
 
6993
 if (!empty ($table->data)) {
6994
-	echo '<form method="post" action="'.$url.'">';
6995
+	echo '<form method="post" action="' . $url . '">';
6996
 	
6997
-	ui_pagination ($countAlertsSimple, $url,  $offset_simple, 0, false, 'offset_simple');
6998
+	ui_pagination ($countAlertsSimple, $url,  $offset_simple, 0, false,
6999
+		'offset_simple');
7000
 	html_print_table ($table);
7001
 	
7002
 	if (!defined('METACONSOLE')) {
7003
Index: operation/agentes/estado_generalagente.php
7004
===================================================================
7005
--- operation/agentes/estado_generalagente.php	(revision 10314)
7006
+++ operation/agentes/estado_generalagente.php	(working copy)
7007
@@ -255,7 +255,7 @@
7008
 	else {
7009
 		$data[1] = __('Enabled');
7010
 	}
7011
-
7012
+	
7013
 	$table_data->data[] = $data;
7014
 }
7015
 
7016
@@ -323,7 +323,7 @@
7017
 		WHERE estado IN (0,1)
7018
 		AND id_agent=$id_agente
7019
 		ORDER BY actualizacion DESC");
7020
-		
7021
+
7022
 if ($last_incident != false) {
7023
 	
7024
 	$table_incident->id = 'agent_incident_main';
7025
@@ -333,10 +333,10 @@
7026
 	$table_incident->class = 'databox';
7027
 	$table_incident->style[0] = 'width: 30%;';
7028
 	$table_incident->style[1] = 'width: 70%;';
7029
-
7030
+	
7031
 	$table_incident->head[0] = ' <span>' . '<a href="index.php?sec=incidencias&amp;sec2=operation/incidents/incident_detail&amp;id='.$last_incident["id_incidencia"].'">' .__('Active incident on this agent') .'</a>'. '</span>';
7032
 	$table_incident->head_colspan[0] = 2;
7033
-
7034
+	
7035
 	$data = array();
7036
 	$data[0] = '<b>' . __('Author') . '</b>';
7037
 	$data[1] = $last_incident["id_creator"];
7038
@@ -391,20 +391,20 @@
7039
 	$table_interface->head_colspan = array();
7040
 	$table_interface->head_colspan[0] = 4;
7041
 	$table_interface->data = array();
7042
-
7043
+	
7044
 	foreach ($modules as $key => $module) {
7045
-
7046
+		
7047
 		// Trying to get the interface name from the module name
7048
 		if (preg_match ("/_(.+)$/", (string)$module['nombre'], $matches)) {
7049
 			if ($matches[1]) {
7050
 				$interface_name = $matches[1];
7051
-
7052
+				
7053
 				$module_id = $module['id_agente_modulo'];
7054
 				$db_status = modules_get_agentmodule_status($module_id);
7055
 				$module_value = modules_get_last_value ($module_id);
7056
 				modules_get_status($module_id, $db_status, $module_value, $status, $title);
7057
 				$status = ui_print_status_image($status, $title, true);
7058
-
7059
+				
7060
 				$ip_target = "--";
7061
 				// Trying to get something like an IP from the description
7062
 				if (preg_match ("/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/", (string)$module['descripcion'], $matches) ||
7063
@@ -421,7 +421,7 @@
7064
 						$description = $matches[0];
7065
 					}
7066
 				}
7067
-
7068
+				
7069
 				$data = array();
7070
 				$data[0] = "<strong>" . $interface_name . "</strong>";
7071
 				$data[1] = $status;
7072
@@ -432,7 +432,7 @@
7073
 		}
7074
 	}
7075
 	unset($modules);
7076
-
7077
+	
7078
 	// This javascript piece of code is used to make expandible the body of the table
7079
 	?>
7080
 	<script type="text/javascript">
7081
@@ -477,7 +477,11 @@
7082
 			'</fieldset>';
7083
 
7084
 // ACCESS RATE GRAPH
7085
-if ($config["agentaccess"]) {
7086
+$access_agent = db_get_value_sql("SELECT COUNT(id_agent)
7087
+	FROM tagent_access
7088
+	WHERE id_agent = " . $id_agente);
7089
+
7090
+if ($config["agentaccess"] && $access_agent > 0) {
7091
 	$data[0] .= '<fieldset class="databox" style="position: static;">
7092
 					<legend style="text-align:left; color: #666;">' . 
7093
 						__('Agent access rate (24h)') . 
7094
Index: operation/agentes/networkmap.topology.php
7095
===================================================================
7096
--- operation/agentes/networkmap.topology.php	(revision 10314)
7097
+++ operation/agentes/networkmap.topology.php	(working copy)
7098
@@ -39,7 +39,7 @@
7099
 $graph = networkmap_generate_dot(__('Pandora FMS'), $group, $simple,
7100
 	$font_size, $layout, $nooverlap, $zoom, $ranksep, $center, $regen,
7101
 	$pure, $id_networkmap, $show_snmp_modules, true, true,
7102
-	$text_filter, $l2_network);
7103
+	$text_filter, $l2_network, null, $dont_show_subgroups);
7104
 
7105
 if ($graph === false) {
7106
 	ui_print_error_message (__('Map could not be generated'));
7107
@@ -79,9 +79,18 @@
7108
 	}
7109
 	else {
7110
 		fwrite ($fh, $graph);
7111
-		$graphviz_path = ($config['graphviz_bin_dir']) ? io_safe_output($config['graphviz_bin_dir']."/") : "";
7112
-		$cmd = escapeshellarg($graphviz_path.$filter) . " -Tcmapx " . escapeshellarg("-o$filename_map") . " -Tpng ". escapeshellarg("-o$filename_img") . " " . escapeshellarg($filename_dot);
7113
+		
7114
+		$graphviz_path = (isset($config['graphviz_bin_dir'])) ?
7115
+			io_safe_output($config['graphviz_bin_dir'] . "/")
7116
+			:
7117
+			"";
7118
+		
7119
+		$cmd = escapeshellarg($graphviz_path . $filter) .
7120
+			" -Tcmapx " . escapeshellarg("-o$filename_map") .
7121
+			" -Tpng ". escapeshellarg("-o$filename_img") .
7122
+			" " . escapeshellarg($filename_dot);
7123
 		$result = system ($cmd);
7124
+		
7125
 		fclose ($fh);
7126
 		unlink ($filename_dot);
7127
 		//~ html_debug_print($cmd);
7128
Index: operation/agentes/estado_agente.php
7129
===================================================================
7130
--- operation/agentes/estado_agente.php	(revision 10314)
7131
+++ operation/agentes/estado_agente.php	(working copy)
7132
@@ -223,18 +223,31 @@
7133
 $selectLastContactDown = '';
7134
 $order = null;
7135
 
7136
+
7137
+$order_collation = "";
7138
+switch ($config["dbtype"]) {
7139
+	case "mysql":
7140
+		$order_collation = " COLLATE utf8_general_ci";
7141
+		break;
7142
+	case "postgresql":
7143
+	case "oracle":
7144
+		$order_collation = "";
7145
+		break;
7146
+}
7147
+
7148
+
7149
 switch ($sortField) {
7150
 	case 'name':
7151
 		switch ($sort) {
7152
 			case 'up':
7153
 				$selectNameUp = $selected;
7154
-				$order = array('field' => 'nombre COLLATE utf8_general_ci',
7155
-					'field2' => 'nombre COLLATE utf8_general_ci', 'order' => 'ASC');
7156
+				$order = array('field' => 'nombre' . $order_collation,
7157
+					'field2' => 'nombre' . $order_collation, 'order' => 'ASC');
7158
 				break;
7159
 			case 'down':
7160
 				$selectNameDown = $selected;
7161
-				$order = array('field' => 'nombre COLLATE utf8_general_ci',
7162
-					'field2' => 'nombre COLLATE utf8_general_ci', 'order' => 'DESC');
7163
+				$order = array('field' => 'nombre' . $order_collation,
7164
+					'field2' => 'nombre' . $order_collation, 'order' => 'DESC');
7165
 				break;
7166
 		}
7167
 		break;
7168
@@ -243,12 +256,12 @@
7169
 			case 'up':
7170
 				$selectOsUp = $selected;
7171
 				$order = array('field' => 'id_os',
7172
-					'field2' => 'nombre COLLATE utf8_general_ci', 'order' => 'ASC');
7173
+					'field2' => 'nombre' . $order_collation, 'order' => 'ASC');
7174
 				break;
7175
 			case 'down':
7176
 				$selectOsDown = $selected;
7177
 				$order = array('field' => 'id_os',
7178
-					'field2' => 'nombre COLLATE utf8_general_ci', 'order' => 'DESC');
7179
+					'field2' => 'nombre' . $order_collation, 'order' => 'DESC');
7180
 				break;
7181
 		}
7182
 		break;
7183
@@ -257,12 +270,12 @@
7184
 			case 'up':
7185
 				$selectIntervalUp = $selected;
7186
 				$order = array('field' => 'intervalo',
7187
-					'field2' => 'nombre COLLATE utf8_general_ci', 'order' => 'ASC');
7188
+					'field2' => 'nombre' . $order_collation, 'order' => 'ASC');
7189
 				break;
7190
 			case 'down':
7191
 				$selectIntervalDown = $selected;
7192
 				$order = array('field' => 'intervalo',
7193
-					'field2' => 'nombre COLLATE utf8_general_ci', 'order' => 'DESC');
7194
+					'field2' => 'nombre' . $order_collation, 'order' => 'DESC');
7195
 				break;
7196
 		}
7197
 		break;
7198
@@ -271,12 +284,12 @@
7199
 			case 'up':
7200
 				$selectGroupUp = $selected;
7201
 				$order = array('field' => 'id_grupo',
7202
-					'field2' => 'nombre COLLATE utf8_general_ci', 'order' => 'ASC');
7203
+					'field2' => 'nombre' . $order_collation, 'order' => 'ASC');
7204
 				break;
7205
 			case 'down':
7206
 				$selectGroupDown = $selected;
7207
 				$order = array('field' => 'id_grupo',
7208
-					'field2' => 'nombre COLLATE utf8_general_ci', 'order' => 'DESC');
7209
+					'field2' => 'nombre' . $order_collation, 'order' => 'DESC');
7210
 				break;
7211
 		}
7212
 		break;
7213
@@ -285,12 +298,12 @@
7214
 			case 'up':
7215
 				$selectLastContactUp = $selected;
7216
 				$order = array('field' => 'ultimo_contacto',
7217
-					'field2' => 'nombre COLLATE utf8_general_ci', 'order' => 'DESC');
7218
+					'field2' => 'nombre' . $order_collation, 'order' => 'DESC');
7219
 				break;
7220
 			case 'down':
7221
 				$selectLastContactDown = $selected;
7222
 				$order = array('field' => 'ultimo_contacto',
7223
-					'field2' => 'nombre COLLATE utf8_general_ci', 'order' => 'ASC');
7224
+					'field2' => 'nombre' . $order_collation, 'order' => 'ASC');
7225
 				break;
7226
 		}
7227
 		break;
7228
@@ -305,15 +318,15 @@
7229
 		$selectGroupDown = '';
7230
 		$selectLastContactUp = '';
7231
 		$selectLastContactDown = '';
7232
-		$order = array('field' => 'nombre COLLATE utf8_general_ci',
7233
-			'field2' => 'nombre COLLATE utf8_general_ci',
7234
+		$order = array('field' => 'nombre' . $order_collation,
7235
+			'field2' => 'nombre' . $order_collation,
7236
 			'order' => 'ASC');
7237
 		break;
7238
 }
7239
 
7240
 $search_sql = '';
7241
 if ($search != "") {
7242
-	$search_sql = " AND ( nombre COLLATE utf8_general_ci LIKE '%$search%' OR direccion LIKE '%$search%' OR comentarios LIKE '%$search%') ";
7243
+	$search_sql = " AND ( nombre " . $order_collation . " LIKE '%$search%' OR direccion LIKE '%$search%' OR comentarios LIKE '%$search%') ";
7244
 }
7245
 
7246
 // Show only selected groups
7247
@@ -340,8 +353,9 @@
7248
 	array ('COUNT(*) as total'), 'AR', false);
7249
 $total_agents = isset ($total_agents[0]['total']) ? $total_agents[0]['total'] : 0;
7250
 
7251
+
7252
 $agents = agents_get_agents(array (
7253
-	'order' => 'nombre COLLATE utf8_general_ci ASC',
7254
+	'order' => 'nombre ' . $order_collation . ' ASC',
7255
 	'id_grupo' => $groups,
7256
 	'disabled' => 0,
7257
 	'status' => $status,
7258
@@ -354,7 +368,7 @@
7259
 		'id_os',
7260
 		'ultimo_contacto',
7261
 		'intervalo',
7262
-		'comentarios description', 
7263
+		'comentarios description',
7264
 		'quiet',
7265
 		'normal_count',
7266
 		'warning_count',
7267
Index: operation/agentes/exportdata.php
7268
===================================================================
7269
--- operation/agentes/exportdata.php	(revision 10314)
7270
+++ operation/agentes/exportdata.php	(working copy)
7271
@@ -40,10 +40,13 @@
7272
 
7273
 switch ($config["dbtype"]) {
7274
 	case "mysql":
7275
-	case "postgresql":
7276
 		$agents = agents_get_agents(
7277
 			array('nombre LIKE "' . $agentName . '"'), array ('id_agente'));
7278
 		break;
7279
+	case "postgresql":
7280
+		$agents = agents_get_agents(
7281
+			array('nombre LIKE \'' . $agentName . '\''), array ('id_agente'));
7282
+		break;
7283
 	case "oracle":
7284
 		$agents = agents_get_agents(
7285
 			array('nombre LIKE \'%' . $agentName . '%\''), array ('id_agente'));
7286
@@ -198,7 +201,7 @@
7287
 	$table->data[0][0] = '<b>'.__('Group').'</b>';
7288
 	
7289
 	$groups = users_get_groups ($config['id_user'], "RR", users_can_manage_group_all());
7290
-
7291
+	
7292
 	$table->data[0][1] = html_print_select_groups($config['id_user'],
7293
 		"RR", users_can_manage_group_all(), "group", $group, '', '', 0, true, false, true,
7294
 		'w130', false);
7295
Index: operation/agentes/estado_monitores.php
7296
===================================================================
7297
--- operation/agentes/estado_monitores.php	(revision 10314)
7298
+++ operation/agentes/estado_monitores.php	(working copy)
7299
@@ -102,6 +102,7 @@
7300
 include_once($config['homedir'] . "/include/functions_modules.php");
7301
 include_once($config['homedir'] . "/include/functions_servers.php");
7302
 include_once($config['homedir'] . "/include/functions_tags.php");
7303
+include_once($config['homedir'] . "/include/functions_clippy.php");
7304
 
7305
 $id_agent = get_parameter('id_agente');
7306
 $url = 'index.php?sec=estado&amp;sec2=operation/agentes/ver_agente&amp;id_agente=' . $id_agent;
7307
@@ -232,7 +233,6 @@
7308
 //Count monitors/modules
7309
 switch ($config["dbtype"]) {
7310
 	case "mysql":
7311
-	case "postgresql":
7312
 		$sql = sprintf("
7313
 			SELECT COUNT(*)
7314
 			FROM tagente_estado,
7315
@@ -246,8 +246,29 @@
7316
 				AND %s %s 
7317
 				AND tagente_estado.estado != %d  
7318
 			ORDER BY tagente_modulo.id_module_group , %s  %s",
7319
-			$id_agente, $status_text_monitor_sql, $status_filter_sql, $tags_sql, AGENT_MODULE_STATUS_NO_DATA, $order['field'], $order['order']);	
7320
+			$id_agente, $status_text_monitor_sql, $status_filter_sql, $tags_sql, AGENT_MODULE_STATUS_NO_DATA, $order['field'], $order['order']);
7321
 		break;
7322
+	case "postgresql":
7323
+		$sql = sprintf("
7324
+			SELECT COUNT(DISTINCT tagente_modulo.id_module_group)
7325
+			FROM tagente_estado,
7326
+				(SELECT *
7327
+				FROM tagente_modulo
7328
+				WHERE id_agente = %d AND nombre LIKE '%s'
7329
+					AND delete_pending = 0
7330
+					AND disabled = 0) tagente_modulo 
7331
+			LEFT JOIN tmodule_group
7332
+				ON tagente_modulo.id_module_group = tmodule_group.id_mg 
7333
+			WHERE tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo 
7334
+				AND %s %s 
7335
+				AND tagente_estado.estado != %d
7336
+			GROUP BY tagente_modulo.id_module_group,
7337
+				tagente_modulo.nombre
7338
+			ORDER BY tagente_modulo.id_module_group , %s  %s",
7339
+			$id_agente, $status_text_monitor_sql, $status_filter_sql,
7340
+			$tags_sql, AGENT_MODULE_STATUS_NO_DATA, $order['field'],
7341
+			$order['order']);
7342
+		break;
7343
 	case "oracle":
7344
 		$sql = sprintf ("
7345
 			SELECT COUNT(*)" .
7346
@@ -265,15 +286,18 @@
7347
 			", $id_agente, $status_text_monitor_sql, $status_filter_sql, $tags_sql, AGENT_MODULE_STATUS_NO_DATA, $order['field'], $order['order']);
7348
 		break;
7349
 }
7350
-$count_modules = db_get_all_rows_sql ($sql);
7351
-$count_modules = reset($count_modules[0]);
7352
 
7353
+$count_modules = db_get_all_rows_sql($sql);
7354
+if (isset($count_modules[0]))
7355
+	$count_modules = reset($count_modules[0]);
7356
+else
7357
+	$count_modules = 0;
7358
 
7359
+
7360
 //Get monitors/modules
7361
 // Get all module from agent
7362
 switch ($config["dbtype"]) {
7363
 	case "mysql":
7364
-	case "postgresql":
7365
 		$sql = sprintf("
7366
 			SELECT *
7367
 			FROM tagente_estado,
7368
@@ -287,8 +311,24 @@
7369
 				AND %s %s 
7370
 				AND tagente_estado.estado != %d  
7371
 			ORDER BY tagente_modulo.id_module_group , %s  %s",
7372
-			$id_agente, $status_text_monitor_sql, $status_filter_sql, $tags_sql, AGENT_MODULE_STATUS_NO_DATA, $order['field'], $order['order']);	
7373
+			$id_agente, $status_text_monitor_sql, $status_filter_sql, $tags_sql, AGENT_MODULE_STATUS_NO_DATA, $order['field'], $order['order']);
7374
 		break;
7375
+	case "postgresql":
7376
+		$sql = sprintf("
7377
+			SELECT *
7378
+			FROM tagente_estado,
7379
+				(SELECT *
7380
+				FROM tagente_modulo
7381
+				WHERE id_agente = %d AND nombre LIKE '%s' AND delete_pending = 0
7382
+					AND disabled = 0) tagente_modulo 
7383
+			LEFT JOIN tmodule_group
7384
+				ON tagente_modulo.id_module_group = tmodule_group.id_mg 
7385
+			WHERE tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo 
7386
+				AND %s %s 
7387
+				AND tagente_estado.estado != %d  
7388
+			ORDER BY tagente_modulo.id_module_group , %s  %s",
7389
+			$id_agente, $status_text_monitor_sql, $status_filter_sql, $tags_sql, AGENT_MODULE_STATUS_NO_DATA, $order['field'], $order['order']);
7390
+		break;
7391
 	// If Dbms is Oracle then field_list in sql statement has to be recoded. See oracle_list_all_field_table()
7392
 	case "oracle":
7393
 		$fields_tagente_estado = oracle_list_all_field_table('tagente_estado', 'string');
7394
@@ -374,6 +414,8 @@
7395
 $id_type_web_content_string = db_get_value('id_tipo', 'ttipo_modulo',
7396
 	'nombre', 'web_content_string');
7397
 
7398
+$show_context_help_first_time = false;
7399
+
7400
 foreach ($modules as $module) {
7401
 	//The code add the row of 1 cell with title of group for to be more organice the list.
7402
 	
7403
@@ -509,7 +551,15 @@
7404
 	modules_get_status($module['id_agente_modulo'], $module['estado'],
7405
 		$module_value, $status, $title);
7406
 	
7407
+	
7408
 	$data[5] = ui_print_status_image($status, $title, true);
7409
+	if (!$show_context_help_first_time) {
7410
+		$show_context_help_first_time = true;
7411
+		
7412
+		if ($module['estado'] == AGENT_MODULE_STATUS_UNKNOWN) {
7413
+			$data[5] .= clippy_context_help("module_unknow");
7414
+		}
7415
+	}
7416
 	
7417
 	
7418
 	if ($module["id_tipo_modulo"] == 24) {
7419
@@ -633,7 +683,13 @@
7420
 		$url = 'include/procesos.php?agente='.$module["id_agente_modulo"];
7421
 		$win_handle=dechex(crc32($module["id_agente_modulo"].$module["nombre"]));
7422
 		
7423
-		$link ="winopeng('operation/agentes/stat_win.php?type=$graph_type&amp;period=86400&amp;id=".$module["id_agente_modulo"]."&amp;label=".rawurlencode(urlencode(base64_encode($module["nombre"])))."&amp;refresh=600','day_".$win_handle."')";
7424
+		# Show events for boolean modules by default.
7425
+		if ($graph_type == 'boolean') {
7426
+			$draw_events = 1;
7427
+		} else {
7428
+			$draw_events = 0;
7429
+		}
7430
+		$link ="winopeng('operation/agentes/stat_win.php?type=$graph_type&amp;period=86400&amp;id=".$module["id_agente_modulo"]."&amp;label=".rawurlencode(urlencode(base64_encode($module["nombre"])))."&amp;refresh=600&amp;draw_events=$draw_events','day_".$win_handle."')";
7431
 		
7432
 		$data[8] .= '<a href="javascript:'.$link.'">' . html_print_image("images/chart_curve.png", true, array("border" => '0', "alt" => "")) . '</a> &nbsp;&nbsp;';
7433
 		$server_name = '';
7434
@@ -736,7 +792,7 @@
7435
 		
7436
 		var server_name = '';
7437
 		var extra_parameters = '';
7438
-		if (period == -1) {
7439
+		if ($('input[name=selection_mode]:checked').val()) {
7440
 			
7441
 			period = $('#period').val();
7442
 			
7443
Index: operation/agentes/ver_agente.php
7444
===================================================================
7445
--- operation/agentes/ver_agente.php	(revision 10314)
7446
+++ operation/agentes/ver_agente.php	(working copy)
7447
@@ -48,7 +48,7 @@
7448
 		$recursion = (int) get_parameter ('recursion', 0);
7449
 		$custom_condition = get_parameter('custom_condition', '');
7450
 		$privilege = (string) get_parameter ('privilege', "AR");
7451
-
7452
+		
7453
 		// Is is possible add keys prefix to avoid auto sorting in js object conversion
7454
 		$keys_prefix = (string) get_parameter ('keys_prefix', '');
7455
 		$status_agents = (int)get_parameter('status_agents', AGENT_STATUS_ALL);
7456
@@ -142,7 +142,7 @@
7457
 		
7458
 		$groups = users_get_groups ($config["id_user"], "AW", false);
7459
 		$group_id_list = ($groups ? join(",",array_keys($groups)):"0");
7460
-
7461
+		
7462
 		$sql = 'SELECT DISTINCT(t1.nombre) as name
7463
 			FROM tagente t1, tagente_modulo t2
7464
 			WHERE t1.id_agente = t2.id_agente
7465
@@ -156,7 +156,7 @@
7466
 					WHERE t3.id_agente = t4.id_agente AND t1.nombre = t3.nombre
7467
 						AND t4.nombre IN (\'' . implode('\',\'', $nameModules) . '\')) = '.count($nameModules);
7468
 		}
7469
-
7470
+		
7471
 		$sql .= ' ORDER BY t1.nombre';
7472
 		
7473
 		$nameAgents = db_get_all_rows_sql($sql);
7474
@@ -468,17 +468,17 @@
7475
 		
7476
 		echo '<strong>'.__('Last contact').':</strong> '.human_time_comparation($agent['ultimo_contacto']).'<br />';
7477
 		echo '<strong>'.__('Last remote contact').':</strong> '.human_time_comparation($agent['ultimo_contacto_remoto']).'<br />';
7478
-	
7479
+			
7480
 			# Fix : Only show agents with module with tags of user profile
7481
 			$_user_tags = tags_get_user_tags($config['id_user'], 'RR');
7482
-
7483
+			
7484
 			$_sql_post = '';
7485
 			if ($_user_tags !== false) {
7486
-
7487
+				
7488
 				$_tags = implode(',', array_keys($_user_tags));
7489
-
7490
+				
7491
 				$_sql_post .= ' AND tagente_modulo.id_agente_modulo IN (SELECT a.id_agente_modulo FROM tagente_modulo a, ttag_module b WHERE a.id_agente_modulo=b.id_agente_modulo AND b.id_tag IN (' . $_tags . ')) ';
7492
-
7493
+				
7494
 			}
7495
 		
7496
 		$sql = sprintf ('SELECT tagente_modulo.descripcion,
7497
@@ -488,9 +488,9 @@
7498
 				AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo
7499
 				AND tagente_modulo.disabled = 0 
7500
 				AND tagente_estado.estado = 1', $id_agent);
7501
-
7502
+		
7503
 		$sql .= $_sql_post;
7504
-
7505
+		
7506
 		if ($metaconsole) {
7507
 			if (metaconsole_connect($server) != NOERR) {
7508
 				return;
7509
@@ -624,7 +624,7 @@
7510
 		if ($modulegroup === false) {
7511
 			echo __('None').'<br />';
7512
 		}
7513
-		else{
7514
+		else {
7515
 			echo $modulegroup.'<br />';
7516
 		}
7517
 		echo '<strong>'.__('Agent').':</strong> ';
7518
Index: operation/agentes/networkmap.php
7519
===================================================================
7520
--- operation/agentes/networkmap.php	(revision 10314)
7521
+++ operation/agentes/networkmap.php	(working copy)
7522
@@ -230,14 +230,14 @@
7523
 	$buttons['addmap'] = array('active' => $activeTab == false,
7524
 	'text' => '<a href="index.php?sec=network&amp;sec2=operation/agentes/networkmap&amp;add_networkmap=1&amp;tab='.$activeTab.'&amp;pure='.$pure.'">' . 
7525
 		html_print_image("images/add_mc.png", true, array ("title" => __('Add map'))) .'</a>');
7526
-
7527
+	
7528
 	if (!$nomaps && $id_networkmap != 0) {
7529
 		$buttons['deletemap'] = array('active' => $activeTab == false,
7530
 		'text' => '<a href="index.php?sec=network&amp;sec2=operation/agentes/networkmap&amp;id_networkmap='.$id_networkmap.'&amp;delete_networkmap=1&amp;tab='.$activeTab.'&amp;pure='.$pure.'">' . 
7531
 			html_print_image("images/delete_mc.png", true, array ("title" => __('Delete map'))) .'</a>');
7532
-	
7533
+		
7534
 		$buttons['savemap'] = array('active' => $activeTab == false,
7535
-		'text' => '<a href="index.php?sec=network&amp;' .
7536
+			'text' => '<a href="index.php?sec=network&amp;' .
7537
 			'sec2=operation/agentes/networkmap&amp;' .
7538
 			'id_networkmap=' . $id_networkmap . '&amp;' .
7539
 			'save_networkmap=1&amp;' .
7540
@@ -320,7 +320,7 @@
7541
 
7542
 
7543
 unset($table);
7544
-$table->width = '95%';
7545
+$table->width = '98%';
7546
 $table->class = 'databox';
7547
 $table->data = array();
7548
 $table->data[0][] = __('Name:') . '&nbsp;' .
7549
@@ -329,7 +329,9 @@
7550
 	html_print_select_groups(false, 'AR', false, 'group', $group, '', 'All', 0, true);
7551
 if ($activeTab == 'groups' || $activeTab == 'policies') {
7552
 	$table->data[0][] = __('Module group') . '&nbsp;' .
7553
-		html_print_select_from_sql ('SELECT id_mg, name FROM tmodule_group', 'module_group', $module_group, '', 'All', 0, true);
7554
+		html_print_select_from_sql ('
7555
+			SELECT id_mg, name
7556
+			FROM tmodule_group', 'module_group', $module_group, '', 'All', 0, true);
7557
 }
7558
 
7559
 if ($activeTab == 'topology') {
7560
@@ -411,7 +413,7 @@
7561
 
7562
 $table->data[2][] = __('Free text for search (*):') . '&nbsp;' .
7563
 	html_print_input_text('text_filter', $text_filter, '', 30, 100, true);
7564
-if ($activeTab == 'groups') {
7565
+if (($activeTab == 'groups') || ($activeTab == 'topology')) {
7566
 	$table->data[2][] = __('Don\'t show subgroups:') .
7567
 		ui_print_help_tip(__('Only run with it is filter for any group'), true) .
7568
 		'&nbsp;' .
7569
Index: operation/snmpconsole/snmp_view.php
7570
===================================================================
7571
--- operation/snmpconsole/snmp_view.php	(revision 10314)
7572
+++ operation/snmpconsole/snmp_view.php	(working copy)
7573
@@ -48,7 +48,8 @@
7574
 foreach ($user_groups as $id=>$name) {
7575
 	if ($i == 0) {
7576
 		$str_user_groups .= $id;
7577
-	} else {
7578
+	}
7579
+	else {
7580
 		$str_user_groups .= ','.$id;
7581
 	}
7582
 	$i++;
7583
@@ -336,8 +337,11 @@
7584
 $table->data[4][2] = html_print_select ($trap_types, 'trap_type', $trap_type, 'this.form.submit();', '', '', true, false, false);
7585
 
7586
 $table->data[3][3] = '<strong>'.__('Group by OID/IP').'</strong>';
7587
-$table->data[3][4] .= __('Yes').'&nbsp;'.html_print_radio_button ('group_by', 1, '', $group_by, true).'&nbsp;&nbsp;';
7588
-$table->data[3][4] .= __('No').'&nbsp;'.html_print_radio_button ('group_by', 0, '', $group_by, true);
7589
+$table->data[3][4] = __('Yes') . '&nbsp;'.
7590
+	html_print_radio_button ('group_by', 1, '', $group_by, true) .
7591
+	'&nbsp;&nbsp;';
7592
+$table->data[3][4] .= __('No') . '&nbsp;' .
7593
+	html_print_radio_button ('group_by', 0, '', $group_by, true);
7594
 
7595
 $filter = '<form method="POST" action="index.php?sec=snmpconsole&sec2=operation/snmpconsole/snmp_view&refr='.((int)get_parameter('refr', 0)).'&pure='.$config["pure"].'&tab='.$tab.'">';
7596
 $filter .= html_print_table($table, true);
7597
Index: images/pandorin.png
7598
===================================================================
7599
Cannot display: file marked as a binary type.
7600
svn:mime-type = application/octet-stream
7601
Index: images/pandorin.png
7602
===================================================================
7603
--- images/pandorin.png	(revision 10314)
7604
+++ images/pandorin.png	(working copy)
7605
7606
Property changes on: images/pandorin.png
7607
___________________________________________________________________
7608
Added: svn:mime-type
7609
## -0,0 +1 ##
7610
+application/octet-stream
7611
\ No newline at end of property
7612
Index: images/clippy_icon.png
7613
===================================================================
7614
Cannot display: file marked as a binary type.
7615
svn:mime-type = application/octet-stream
7616
Index: images/clippy_icon.png
7617
===================================================================
7618
--- images/clippy_icon.png	(revision 10314)
7619
+++ images/clippy_icon.png	(working copy)
7620
7621
Property changes on: images/clippy_icon.png
7622
___________________________________________________________________
7623
Added: svn:mime-type
7624
## -0,0 +1 ##
7625
+application/octet-stream
7626
\ No newline at end of property
7627
Index: extras/pandoradb_migrate_5.0.x_to_5.1.postgreSQL.sql
7628
===================================================================
7629
--- extras/pandoradb_migrate_5.0.x_to_5.1.postgreSQL.sql	(revision 10314)
7630
+++ extras/pandoradb_migrate_5.0.x_to_5.1.postgreSQL.sql	(working copy)
7631
@@ -190,3 +190,9 @@
7632
 -- Table trecon_script
7633
 -- ---------------------------------------------------------------------
7634
 DELETE FROM "trecon_script" WHERE "id_recon_script"=1;
7635
+
7636
+/* 2014/08/07 */
7637
+-- ---------------------------------------------------------------------
7638
+-- Table `tagente_modulo`
7639
+-- ---------------------------------------------------------------------
7640
+ALTER TABLE "tagente_modulo" MODIFY COLUMN "post_process" NUMERIC(18,15) default 0;
7641
\ No newline at end of file
7642
Index: extras/pandoradb_migrate_5.0.x_to_5.1.mysql.sql
7643
===================================================================
7644
--- extras/pandoradb_migrate_5.0.x_to_5.1.mysql.sql	(revision 10314)
7645
+++ extras/pandoradb_migrate_5.0.x_to_5.1.mysql.sql	(working copy)
7646
@@ -48,8 +48,6 @@
7647
 -- ---------------------------------------------------------------------
7648
 -- Table `tagente_modulo`
7649
 -- ---------------------------------------------------------------------
7650
-ALTER TABLE `tagente_modulo` MODIFY COLUMN `post_process` DOUBLE  DEFAULT NULL;
7651
-/* 2014/05/21 */
7652
 ALTER TABLE `tagente_modulo` ADD COLUMN `min_ff_event_normal` int(4) unsigned default '0';
7653
 ALTER TABLE `tagente_modulo` ADD COLUMN `min_ff_event_warning` int(4) unsigned default '0';
7654
 ALTER TABLE `tagente_modulo` ADD COLUMN `min_ff_event_critical` int(4) unsigned default '0';
7655
@@ -230,3 +228,9 @@
7656
 -- Table `trecon_script`
7657
 -- ---------------------------------------------------------------------
7658
 DELETE FROM `trecon_script` WHERE id_recon_script=1;
7659
+
7660
+/* 2014/08/07 */
7661
+-- ---------------------------------------------------------------------
7662
+-- Table `tagente_modulo`
7663
+-- ---------------------------------------------------------------------
7664
+ALTER TABLE tagente_modulo MODIFY COLUMN `post_process` double(18,15) default 0;
7665
\ No newline at end of file
7666
Index: extras/pandoradb_migrate_5.0.x_to_5.1.oracle.sql
7667
===================================================================
7668
--- extras/pandoradb_migrate_5.0.x_to_5.1.oracle.sql	(revision 10314)
7669
+++ extras/pandoradb_migrate_5.0.x_to_5.1.oracle.sql	(working copy)
7670
@@ -216,3 +216,9 @@
7671
 -- Table trecon_script
7672
 -- ---------------------------------------------------------------------
7673
 DELETE FROM trecon_script WHERE id_recon_script=1;
7674
+
7675
+/* 2014/08/07 */
7676
+-- ---------------------------------------------------------------------
7677
+-- Table `tagente_modulo`
7678
+-- ---------------------------------------------------------------------
7679
+ALTER TABLE tagente_modulo MODIFY COLUMN post_process NUMBER(18,15) default 0;
7680
\ No newline at end of file
7681
Index: mobile/operation/events.php
7682
===================================================================
7683
--- mobile/operation/events.php	(revision 10314)
7684
+++ mobile/operation/events.php	(working copy)
7685
@@ -261,6 +261,25 @@
7686
 						if (empty($event["tags"])) {
7687
 							$event["tags"] = '<i>'.__('N/A').'</i>';
7688
 						}
7689
+
7690
+						$event_comments = db_get_value('user_comment', 'tevento', 'id_evento', $id_event);
7691
+						$event_comments_array = array();
7692
+						$event_comments_array = json_decode($event_comments, true);
7693
+						// Support for new format only.
7694
+						if (empty($event_comments_array)) {
7695
+							$comment = '<i>'.__('N/A').'</i>';
7696
+						} else {
7697
+							$comment = '';
7698
+							$event_comments_array = array_reverse($event_comments_array);
7699
+							foreach($event_comments_array as $c) {
7700
+								$comment .=  date ($system->getConfig("date_format"), $c['utimestamp']) . ' (' . $c['id_user'] . ')';
7701
+								$c['comment'] = io_safe_output($c['comment']);
7702
+								$c['comment'] = str_replace("\n", "<br>", $c['comment']);
7703
+								$comment .= '<br>' . $c['comment'] . '<br>';
7704
+							}
7705
+						}
7706
+
7707
+						$event["comments"] = $comment;
7708
 						
7709
 						echo json_encode(array('correct' => 1, 'event' => $event));
7710
 					}
7711
@@ -486,6 +505,10 @@
7712
 					<th><?php echo __('Tags');?></th>
7713
 					<td class="cell_event_tags"></td>
7714
 				</tr>
7715
+				<tr class="event_comments">
7716
+					<th><?php echo __('Comments');?></th>
7717
+					<td class="cell_event_comments"></td>
7718
+				</tr>
7719
 			</tbody>
7720
 		</table>
7721
 		<?php
7722
@@ -828,6 +851,9 @@
7723
 										.html(event[\"group\"]);
7724
 									$(\"#detail_event_dialog .cell_event_tags\")
7725
 										.html(event[\"tags\"]);
7726
+									$(\"#detail_event_dialog .cell_event_comments\")
7727
+
7728
+.html(event[\"comments\"]);
7729
 									$(\"#detail_event_dialog .cell_agent\")
7730
 										.html(event[\"agent\"]);
7731
 									
7732
Index: general/main_menu.php
7733
===================================================================
7734
--- general/main_menu.php	(revision 10314)
7735
+++ general/main_menu.php	(working copy)
7736
@@ -62,74 +62,163 @@
7737
 /* <![CDATA[ */
7738
 
7739
 var autohidden_menu = <?php echo $autohidden_menu; ?>;
7740
+var fixed_menu = <?php echo json_encode((bool)$config['fixed_menu']); ?>;
7741
+var fixed_header = <?php echo json_encode((bool)$config['fixed_header']); ?>;
7742
+var id_user = "<?php echo $config['id_user']; ?>";
7743
+var cookie_name = id_user + '-pandora_menu_state';
7744
+var cookie_name_encoded = btoa(cookie_name);
7745
 
7746
+var menuState = $.cookie(cookie_name_encoded);
7747
+if (!menuState) {
7748
+	menuState = {};
7749
+}
7750
+else {
7751
+	menuState = JSON.parse(menuState);
7752
+	open_submenus();
7753
+}
7754
+
7755
+function open_submenus () {
7756
+	$.each(menuState, function (index, value) {
7757
+		if (value)
7758
+			$('div.menu>ul>li#' + index + '>ul').show();
7759
+	});
7760
+	$('div.menu>ul>li.selected>ul').removeClass('invisible');
7761
+}
7762
+
7763
+
7764
+function close_submenus () {
7765
+	$.each(menuState, function (index, value) {
7766
+		if (value)
7767
+			$('div.menu>ul>li#' + index + '>ul').hide();
7768
+	});
7769
+	$('div.menu>ul>li.selected>ul').addClass('invisible');
7770
+}
7771
+
7772
 $(document).ready( function() {
7773
-	$("img.toggle").click (function () {
7774
-		$(this).siblings ("ul").toggle ();
7775
+
7776
+	$("img.toggle").click (function (e) {
7777
 		//In case the links gets activated, we don't want to follow link
7778
-		return false;
7779
+		e.preventDefault();
7780
+		
7781
+		var menuItem = $(this).parent();
7782
+		var submenu = menuItem.children("ul");
7783
+
7784
+		if (submenu.is(":visible")) {
7785
+			submenu.slideUp();
7786
+			
7787
+			if (typeof menuState[menuItem.attr('id')] != 'undefined')
7788
+				delete menuState[menuItem.attr('id')];
7789
+		}
7790
+		else {
7791
+			submenu.slideDown();
7792
+
7793
+			menuState[menuItem.attr('id')] = 1;
7794
+		}
7795
+		
7796
+		$.cookie(cookie_name_encoded, JSON.stringify(menuState), {expires: 7});
7797
 	});
7798
 	
7799
-	$('#menu_container').hover (handlerIn, handlerOut);
7800
-	var openTime = 0;
7801
-	var handsIn = 0;
7802
-	
7803
-	function handlerIn() {
7804
-		handsIn = 1;
7805
-		if(openTime == 0) {
7806
-			show_menu();
7807
-			openTime = new Date().getTime();
7808
-			
7809
-			// Close in 1 second if is not closed manually
7810
-			setTimeout(function() {
7811
-				if(openTime > 0 && handsIn == 0) {
7812
-					hide_menu();
7813
-					openTime = 0;
7814
+	if (fixed_menu) {
7815
+		$('div#menu')
7816
+			.css('position', 'fixed')
7817
+			.css('z-index', '9000')
7818
+			.css('left', '0')
7819
+			.css('top', $('div#head').innerHeight() + 'px')
7820
+			.css('height', '100%')
7821
+			.css('overflow', 'hidden')
7822
+			.hover(function (e) {
7823
+				if (!autohidden_menu) {
7824
+					$(this).css('overflow', 'auto').children('div').css('width', 'auto');
7825
 				}
7826
-			}, 1000);
7827
+			}, function (e) {
7828
+				if (!autohidden_menu) {
7829
+					$(this).css('overflow', 'hidden').children('div').css('width', '100%');
7830
+				}
7831
+			})
7832
+			.children('div')
7833
+				.css('margin-bottom', $('div#head').innerHeight() + 'px');
7834
+
7835
+		if (!fixed_header) {
7836
+			$(window).scroll(function () {
7837
+				if ($(this).scrollTop() <= $('div#head').innerHeight()) {
7838
+					$('div#menu').css('top', $('div#head').innerHeight() - $(this).scrollTop() + 'px' );
7839
+				} else {
7840
+					$('div#menu').css('top', '0');
7841
+				}
7842
+			});
7843
 		}
7844
 	}
7845
-	
7846
-	function handlerOut() {
7847
-		handsIn = 0;
7848
-		var openedTime = new Date().getTime() - openTime;
7849
+
7850
+	if (autohidden_menu) {
7851
+
7852
+		$('#menu_container').hover (handlerIn, handlerOut);
7853
+		var openTime = 0;
7854
+		var handsIn = 0;
7855
+
7856
+		$('#main').css('margin-left', '50px');
7857
+		hide_menu_pretty();
7858
 		
7859
-		if(openedTime > 1000) {
7860
-			hide_menu();
7861
-			openTime = 0;
7862
+		function handlerIn() {
7863
+			handsIn = 1;
7864
+			if (openTime == 0) {
7865
+				show_menu();
7866
+				openTime = new Date().getTime();
7867
+				
7868
+				// Close in 1 second if is not closed manually
7869
+				setTimeout(function() {
7870
+					if(openTime > 0 && handsIn == 0) {
7871
+						hide_menu();
7872
+						openTime = 0;
7873
+					}
7874
+				}, 1000);
7875
+			}
7876
 		}
7877
+		
7878
+		function handlerOut() {
7879
+			handsIn = 0;
7880
+			var openedTime = new Date().getTime() - openTime;
7881
+			
7882
+			if (openedTime > 1000) {
7883
+				hide_menu();
7884
+				openTime = 0;
7885
+			}
7886
+		}
7887
+		
7888
+		function show_menu () {
7889
+			$('#menu_container').animate({"left": "+=80px"}, 200, function () {
7890
+				if (fixed_menu) {
7891
+					$('#menu_container').parent().css('overflow', 'auto');
7892
+				}
7893
+			});
7894
+			show_menu_pretty();
7895
+		}
7896
+		
7897
+		function show_menu_pretty() {
7898
+			open_submenus();
7899
+			$('div.menu ul li').css('background-position', '');
7900
+			$('ul.submenu li a, li.menu_icon a, li.links a, div.menu>ul>li>img.toggle').show();
7901
+			$('.titop').css('color', 'white');
7902
+			$('.bg3').css('color', 'white');
7903
+			$('.bg4').css('color', 'white');
7904
+		}
7905
+		
7906
+		function hide_menu () {
7907
+			if (fixed_menu) {
7908
+				$('#menu_container').parent().css('overflow', 'hidden');
7909
+			}
7910
+			$('#menu_container').animate({"left": "-=80px"}, 100);
7911
+			hide_menu_pretty();
7912
+		}
7913
+		
7914
+		function hide_menu_pretty() {
7915
+			close_submenus();
7916
+			$('div.menu li').css('background-position', '85px 5px');
7917
+			$('ul.submenu li a, li.menu_icon a, li.links a, div.menu>ul>li>img.toggle').hide();
7918
+			$('.titop').css('color', $('.titop').css('background-color'));
7919
+			$('.bg3').css('color', $('.bg3').css('background-color'));
7920
+			$('.bg4').css('color', $('.bg4').css('background-color'));
7921
+		}
7922
 	}
7923
-	
7924
-	function show_menu () {
7925
-		$('#menu_container').animate({"left": "+=140px"}, 200);
7926
-		show_menu_pretty();
7927
-	}
7928
-	
7929
-	function show_menu_pretty() {
7930
-		$('div.menu ul li').css('background-position', '');
7931
-		$('ul.submenu li a, li.menu_icon a, li.links a').css('visibility', '');
7932
-		$('.titop').css('color', 'white');
7933
-		$('.bg3').css('color', 'white');
7934
-		$('.bg4').css('color', 'white');
7935
-	}
7936
-	
7937
-	function hide_menu () {
7938
-		$('#menu_container').animate({"left": "-=140px"}, 100);
7939
-		hide_menu_pretty();
7940
-	}
7941
-	
7942
-	function hide_menu_pretty() {
7943
-		$('div.menu li').css('background-position', '140px 3px');
7944
-		$('ul.submenu li a, li.menu_icon a, li.links a').css('visibility', 'hidden');
7945
-		$('.titop').css('color', $('.titop').css('background-color'));
7946
-		$('.bg3').css('color', $('.bg3').css('background-color'));
7947
-		$('.bg4').css('color', $('.bg4').css('background-color'));
7948
-	}
7949
-	
7950
-	if (autohidden_menu) {
7951
-		$('#main').css('margin-left', '40px');
7952
-		hide_menu_pretty();
7953
-	}
7954
 });
7955
 /* ]]> */
7956
 </script>
7957
Index: general/header.php
7958
===================================================================
7959
--- general/header.php	(revision 10314)
7960
+++ general/header.php	(working copy)
7961
@@ -58,10 +58,16 @@
7962
 				$table->cellspacing = 0;
7963
 				$table->head = array ();
7964
 				$table->data = array ();
7965
-				$table->style[0] = $table->style[1] = $table->style[3] =
7966
-					$table->style[4] = $table->style[5] =
7967
-					$table->style[6] = $table->style[8] =
7968
-					$table->style[9] = $table->style['qr'] =
7969
+				$table->style[0] =
7970
+					$table->style['clippy'] =
7971
+					$table->style[1] =
7972
+					$table->style[3] =
7973
+					$table->style[4] =
7974
+					$table->style[5] =
7975
+					$table->style[6] =
7976
+					$table->style[8] =
7977
+					$table->style[9] =
7978
+					$table->style['qr'] =
7979
 					'width: 22px; text-align:center; height: 22px; padding-right: 9px;';
7980
 				$table->style[7] = 'width: 20px; padding-right: 9px;';
7981
 				$table->style['searchbar'] = 'width: 180px; min-width: 180px;';
7982
@@ -122,11 +128,26 @@
7983
 				</script>
7984
 				<?php
7985
 				
7986
-				$table->data[0][0] = $servers_link_open . $servers_check_img . $servers_link_close;
7987
+				if ($config['tutorial_mode'] !== 'expert') {
7988
+					$table->data[0]['clippy'] = 
7989
+						'<a href="javascript: show_clippy();">' .
7990
+							html_print_image(
7991
+								"images/clippy_icon.png",
7992
+								true,
7993
+								array("id" => 'clippy',
7994
+									"class" => 'clippy',
7995
+									"alt" => __('Clippy'),
7996
+									'title' => __('Clippy'))) .
7997
+						'</a>';
7998
+				}
7999
 				
8000
 				
8001
+				$table->data[0][0] = $servers_link_open .
8002
+					$servers_check_img . $servers_link_close;
8003
 				
8004
 				
8005
+				
8006
+				
8007
 				//======= Autorefresh code =============================
8008
 				$autorefresh_txt = '';
8009
 				$autorefresh_additional = '';
8010
@@ -303,8 +324,19 @@
8011
 
8012
 <script type="text/javascript">
8013
 	/* <![CDATA[ */
8014
+	
8015
+	var fixed_header = <?php echo json_encode((bool)$config['fixed_header']); ?>;
8016
+	
8017
 	var new_chat = <?php echo (int)$_SESSION['new_chat'];?>;
8018
 	$(document).ready (function () {
8019
+		
8020
+		if (fixed_header) {
8021
+			$('div#head').addClass('fixed_header');
8022
+			$('div#page')
8023
+				.css('padding-top', $('div#head').innerHeight() + 'px')
8024
+				.css('position', 'relative');
8025
+		}
8026
+		
8027
 		check_new_chats_icon('icon_new_messages_chat');
8028
 		
8029
 		/* Temporal fix to hide graphics when ui_dialog are displayed */
8030
Index: godmode/audit_log_csv.php
8031
===================================================================
8032
--- godmode/audit_log_csv.php	(revision 0)
8033
+++ godmode/audit_log_csv.php	(revision 10417)
8034
@@ -0,0 +1,137 @@
8035
+<?php
8036
+// ______                 __                     _______ _______ _______
8037
+//|   __ \.---.-.-----.--|  |.-----.----.---.-. |    ___|   |   |     __|
8038
+//|    __/|  _  |     |  _  ||  _  |   _|  _  | |    ___|       |__     |
8039
+//|___|   |___._|__|__|_____||_____|__| |___._| |___|   |__|_|__|_______|
8040
+//
8041
+// ============================================================================
8042
+// Copyright (c) 2007-2010 Artica Soluciones Tecnologicas, http://www.artica.es
8043
+// This code is NOT free software. This code is NOT licenced under GPL2 licence
8044
+// You cannnot redistribute it without written permission of copyright holder.
8045
+// ============================================================================
8046
+
8047
+if (file_exists("../../../include/config.php"))
8048
+	require ("../../../include/config.php");
8049
+else  {
8050
+	//TODO FIX AND SET AS RELATIVE DIRECTORY
8051
+	if (file_exists("/var/www/pandora_console/include/config.php"))
8052
+		require ("/var/www/pandora_console/include/config.php");
8053
+	if (file_exists("/srv/www/htdocs/pandora_console/include/config.php"))
8054
+		require ("/srv/www/htdocs/pandora_console/include/config.php");
8055
+}
8056
+
8057
+global $config;
8058
+
8059
+require_once ($config["homedir"]."/include/functions.php");
8060
+require_once ($config["homedir"]."/include/functions_db.php");
8061
+require_once ($config["homedir"]."/enterprise/include/functions_reporting_csv.php");
8062
+require_once ($config["homedir"]."/include/auth/mysql.php");
8063
+
8064
+error_reporting(E_ALL);
8065
+ini_set("display_errors", 1);
8066
+
8067
+if (! isset ($_SESSION["id_usuario"])) {
8068
+	session_start ();
8069
+	session_write_close ();
8070
+}
8071
+
8072
+
8073
+// Login check
8074
+if (!isset($_SESSION["id_usuario"])) {
8075
+	$config['id_user'] = null;
8076
+}
8077
+else {
8078
+	$config['id_user'] = $_SESSION["id_usuario"];
8079
+}
8080
+
8081
+if (!check_login()) {
8082
+	db_pandora_audit("ACL Violation", "Trying to access graph builder");
8083
+	include ($config["homedir"]."/general/noaccess.php");
8084
+	return;
8085
+}
8086
+
8087
+if (! check_acl ($config['id_user'], 0, "PM")) {
8088
+	db_pandora_audit( "ACL Violation",
8089
+		"Trying to access event viewer");
8090
+	require ("general/noaccess.php");
8091
+	exit;
8092
+}
8093
+
8094
+$tipo_log = get_parameter ("tipo_log", 'all');
8095
+$user_filter = get_parameter('user_filter', 'all');
8096
+$filter_text = get_parameter('filter_text', '');
8097
+$filter_hours_old = get_parameter('filter_hours_old', 24);
8098
+$filter_ip = get_parameter('filter_ip', '');
8099
+
8100
+$filter = 'WHERE 1 = 1';
8101
+
8102
+if ($tipo_log != 'all') {
8103
+	$filter .= " AND accion = '$tipo_log'";
8104
+}
8105
+switch ($config['dbtype']) {
8106
+	case "mysql":
8107
+		if ($user_filter != 'all') {
8108
+			$filter .= sprintf(' AND id_usuario = "%s"', $user_filter);
8109
+		}
8110
+		
8111
+		$filter .= ' AND (accion LIKE "%' . $filter_text . '%" OR descripcion LIKE "%' . $filter_text . '%")';
8112
+		
8113
+		if ($filter_ip != '') {
8114
+			$filter .= sprintf(' AND ip_origen LIKE "%s"', $filter_ip);
8115
+		}
8116
+		break;
8117
+	case "postgresql":
8118
+	case "oracle":
8119
+		if ($user_filter != 'all') {
8120
+			$filter .= sprintf(' AND id_usuario = \'%s\'', $user_filter);
8121
+		}
8122
+		
8123
+		$filter .= ' AND (accion LIKE \'%' . $filter_text . '%\' OR descripcion LIKE \'%' . $filter_text . '%\')';
8124
+		
8125
+		if ($filter_ip != '') {
8126
+			$filter .= sprintf(' AND ip_origen LIKE \'%s\'', $filter_ip);
8127
+		}
8128
+		break;
8129
+}
8130
+
8131
+if ($filter_hours_old != 0) {
8132
+	switch ($config["dbtype"]) {
8133
+		case "mysql":
8134
+			$filter .= ' AND fecha >= DATE_ADD(NOW(), INTERVAL -' . $filter_hours_old . ' HOUR)';
8135
+			break;
8136
+		case "postgresql":
8137
+			$filter .= ' AND fecha >= NOW() - INTERVAL \'' . $filter_hours_old . ' HOUR \'';
8138
+			break;
8139
+		case "oracle":
8140
+			$filter .= ' AND fecha >= (SYSTIMESTAMP - INTERVAL \'' . $filter_hours_old . '\' HOUR)';
8141
+			break;
8142
+	}
8143
+}
8144
+
8145
+switch ($config["dbtype"]) {
8146
+	case "mysql":
8147
+		$sql = sprintf ("SELECT *
8148
+			FROM tsesion
8149
+			%s
8150
+			ORDER BY fecha DESC", $filter);
8151
+		break;
8152
+	case "postgresql":
8153
+		$sql = sprintf ("SELECT *
8154
+			FROM tsesion
8155
+			%s
8156
+			ORDER BY fecha DESC", $filter);
8157
+		break;
8158
+	case "oracle":
8159
+		$sql = sprintf ("SELECT *
8160
+			FROM tsesion
8161
+			%s
8162
+			ORDER BY fecha DESC", $filter);
8163
+		$result = oracle_recode_query ($sql, $set);
8164
+		break;
8165
+}
8166
+
8167
+$result = db_get_all_rows_sql ($sql);
8168
+
8169
+print_audit_csv ($result);
8170
+
8171
+?>
8172
Index: godmode/admin_access_logs.php
8173
===================================================================
8174
--- godmode/admin_access_logs.php	(revision 10314)
8175
+++ godmode/admin_access_logs.php	(working copy)
8176
@@ -295,6 +295,13 @@
8177
 
8178
 html_print_table ($table);
8179
 
8180
+echo '<div style="width: '.$table->width.'" class="action-buttons">';
8181
+echo '<a href="' .
8182
+			ui_get_full_url(false, false, false, false) . 'godmode/audit_log_csv.php?tipo_log='.$tipo_log.'&user_filter='.$user_filter.'&filter_text='.$filter_text.'&filter_hours_old='.$filter_hours_old.'&filter_ip='.$filter_ip.'"'.
8183
+			'target="_new">' .
8184
+			html_print_button (__('Export to CSV '), 'export_csv', false, '', 'class=sub next', true, false). '</a>';
8185
+echo '</div>';
8186
+
8187
 if ($enterprise_include !== ENTERPRISE_NOT_HOOK) {
8188
 	enterprise_hook('enterpriseAuditFooter');
8189
 }
8190
Index: godmode/db/db_info.php
8191
===================================================================
8192
--- godmode/db/db_info.php	(revision 10314)
8193
+++ godmode/db/db_info.php	(working copy)
8194
@@ -79,7 +79,7 @@
8195
 
8196
 foreach ($count as $agent_id => $value) {
8197
 	$data = array ();
8198
-
8199
+	
8200
 	//First row is a link to the agent
8201
 	$data[0] = '<strong><a href="index.php?sec=gagente&sec2=operation/agentes/ver_agente&id_agente='.$agent_id.'">'.$agents[$agent_id].'</a></strong>';
8202
 	//Second row is a number of modules for the agent
8203
Index: godmode/agentes/agent_template.php
8204
===================================================================
8205
--- godmode/agentes/agent_template.php	(revision 10314)
8206
+++ godmode/agentes/agent_template.php	(working copy)
8207
@@ -96,7 +96,12 @@
8208
 				'warning_instructions' => $row2['warning_instructions'],
8209
 				'unknown_instructions' => $row2['unknown_instructions'],
8210
 				'id_category' => $row2['id_category'],
8211
-				'module_macros' => $row2['module_macros']
8212
+				'module_macros' => $row2['module_macros'],
8213
+				'each_ff' => $row2['each_ff'],
8214
+				'min_ff_event' => $row2['min_ff_event'],
8215
+				'min_ff_event_normal' => $row2['min_ff_event_normal'],
8216
+				'min_ff_event_warning' => $row2['min_ff_event_warning'],
8217
+				'min_ff_event_critical' => $row2['min_ff_event_critical']
8218
 				);
8219
 			
8220
 			$name = $row2["name"];
8221
Index: godmode/agentes/module_manager_editor_plugin.php
8222
===================================================================
8223
--- godmode/agentes/module_manager_editor_plugin.php	(revision 10314)
8224
+++ godmode/agentes/module_manager_editor_plugin.php	(working copy)
8225
@@ -84,7 +84,12 @@
8226
 		if (!empty($m['help'])) {
8227
 			$data[0] .= ui_print_help_tip ($m['help'], true);
8228
 		}
8229
-		if($m['hide']) {
8230
+		
8231
+		$m_hide = false;
8232
+		if (isset($m['hide']))
8233
+			$m_hide = $m['hide'];
8234
+		
8235
+		if ($m_hide) {
8236
 			$data[1] = html_print_input_password($m['macro'], $m['value'], '', 100, 255, true);
8237
 		}
8238
 		else {
8239
Index: godmode/agentes/agent_conf_gis.php
8240
===================================================================
8241
--- godmode/agentes/agent_conf_gis.php	(revision 10314)
8242
+++ godmode/agentes/agent_conf_gis.php	(working copy)
8243
@@ -118,9 +118,7 @@
8244
 	//Validate altitude
8245
 	if ((jQuery.trim(altitude).length == 0) ||
8246
 		isNaN(parseFloat(altitude))) {
8247
-		$('input[name=altitude]').css('background', '#cc0000');
8248
-		
8249
-		valid = false;
8250
+			$('input[name=altitude]').val(1);
8251
 	}
8252
 	
8253
 	if (valid) return true;
8254
Index: godmode/agentes/agent_wizard.snmp_explorer.php
8255
===================================================================
8256
--- godmode/agentes/agent_wizard.snmp_explorer.php	(revision 10314)
8257
+++ godmode/agentes/agent_wizard.snmp_explorer.php	(working copy)
8258
@@ -50,65 +50,74 @@
8259
 // Get the plugin
8260
 $plugin = db_get_row_sql('SELECT * FROM tplugin WHERE execute LIKE "%/snmp_remote.pl"');
8261
 
8262
-if(empty($plugin)) {
8263
+if (empty($plugin)) {
8264
 	ui_print_info_message(array('message' => __('The SNMP remote plugin doesnt seem to be installed') . '. ' . __('It is necessary to use some features') . '.<br><br>' . __('Please, install the SNMP remote plugin (The name of the plugin must be snmp_remote.pl)'), 'no_close' => true));
8265
 }
8266
 
8267
 // Define STATIC SNMP data
8268
 $static_snmp_descriptions = array(
8269
-					'Load-1' => 'Load Average (Last minute)',
8270
-					'Load-5' => 'Load Average (Last 5 minutes)',
8271
-					'Load-15' => 'Load Average (Last 5 minutes)',
8272
-					'memTotalSwap' => 'Total Swap Size configured for the host',
8273
-					'memAvailSwap' => 'Available Swap Space on the host',
8274
-					'memTotalReal' => 'Total Real/Physical Memory Size on the host',
8275
-					'memAvailReal' => 'Available Real/Physical Memory Space on the host',
8276
-					'memTotalFree' => 'Total Available Memory on the host',
8277
-					//'memShared' => 'Total Shared Memory',
8278
-					'memCached' => 'Total Cached Memory',
8279
-					'memBuffer' => 'Total Buffered Memory',
8280
-					'ssSwapIn' => 'Amount of memory swapped in from disk (kB/s)',
8281
-					'ssSwapOut' => 'Amount of memory swapped to disk (kB/s)',
8282
-					'ssIORawSent' => 'Number of blocks sent to a block device',
8283
-					'ssIORawReceived' => 'Number of blocks received from a block device',
8284
-					'ssRawInterrupts' => 'Number of interrupts processed',
8285
-					'ssRawContexts' => 'Number of context switches',
8286
-					'ssCpuRawUser' => 'user CPU time',
8287
-					'ssCpuRawSystem' => 'system CPU time',
8288
-					'ssCpuRawIdle' => 'idle CPU time'
8289
-					);
8290
-					
8291
+	'Load-1' => 'Load Average (Last minute)',
8292
+	'Load-5' => 'Load Average (Last 5 minutes)',
8293
+	'Load-15' => 'Load Average (Last 5 minutes)',
8294
+	'memTotalSwap' => 'Total Swap Size configured for the host',
8295
+	'memAvailSwap' => 'Available Swap Space on the host',
8296
+	'memTotalReal' => 'Total Real/Physical Memory Size on the host',
8297
+	'memAvailReal' => 'Available Real/Physical Memory Space on the host',
8298
+	'memTotalFree' => 'Total Available Memory on the host',
8299
+	//'memShared' => 'Total Shared Memory',
8300
+	'memCached' => 'Total Cached Memory',
8301
+	'memBuffer' => 'Total Buffered Memory',
8302
+	'ssSwapIn' => 'Amount of memory swapped in from disk (kB/s)',
8303
+	'ssSwapOut' => 'Amount of memory swapped to disk (kB/s)',
8304
+	'ssIORawSent' => 'Number of blocks sent to a block device',
8305
+	'ssIORawReceived' => 'Number of blocks received from a block device',
8306
+	'ssRawInterrupts' => 'Number of interrupts processed',
8307
+	'ssRawContexts' => 'Number of context switches',
8308
+	'ssCpuRawUser' => 'user CPU time',
8309
+	'ssCpuRawSystem' => 'system CPU time',
8310
+	'ssCpuRawIdle' => 'idle CPU time'
8311
+	);
8312
+
8313
 $static_snmp_oids = array(
8314
-					'Load-1' => '.1.3.6.1.4.1.2021.10.1.5.1',
8315
-					'Load-5' => '.1.3.6.1.4.1.2021.10.1.5.2',
8316
-					'Load-15' => '.1.3.6.1.4.1.2021.10.1.5.3',
8317
-					'memTotalSwap' => '.1.3.6.1.4.1.2021.4.3.0',
8318
-					'memAvailSwap' => '.1.3.6.1.4.1.2021.4.4.0',
8319
-					'memTotalReal' => '.1.3.6.1.4.1.2021.4.5.0',
8320
-					'memAvailReal' => '.1.3.6.1.4.1.2021.4.6.0',
8321
-					'memTotalFree' => '.1.3.6.1.4.1.2021.4.11.0',
8322
-					//'memShared' => '.1.3.6.1.4.1.2021.4.13',
8323
-					'memCached' => '.1.3.6.1.4.1.2021.4.15.0',
8324
-					'memBuffer' => '.1.3.6.1.4.1.2021.4.14.0',
8325
-					'ssSwapIn' => '.1.3.6.1.4.1.2021.11.3.0',
8326
-					'ssSwapOut' => '.1.3.6.1.4.1.2021.11.4.0',
8327
-					'ssIORawSent' => '.1.3.6.1.4.1.2021.11.57.0',
8328
-					'ssIORawReceived' => '.1.3.6.1.4.1.2021.11.58.0',
8329
-					'ssRawInterrupts' => '.1.3.6.1.4.1.2021.11.59.0',
8330
-					'ssRawContexts' => '.1.3.6.1.4.1.2021.11.60.0',
8331
-					'ssCpuRawUser' => '.1.3.6.1.4.1.2021.11.50.0',
8332
-					'ssCpuRawSystem' => '.1.3.6.1.4.1.2021.11.52.0',
8333
-					'ssCpuRawIdle' => '.1.3.6.1.4.1.2021.11.53.0'
8334
-					);
8335
+	'Load-1' => '.1.3.6.1.4.1.2021.10.1.5.1',
8336
+	'Load-5' => '.1.3.6.1.4.1.2021.10.1.5.2',
8337
+	'Load-15' => '.1.3.6.1.4.1.2021.10.1.5.3',
8338
+	'memTotalSwap' => '.1.3.6.1.4.1.2021.4.3.0',
8339
+	'memAvailSwap' => '.1.3.6.1.4.1.2021.4.4.0',
8340
+	'memTotalReal' => '.1.3.6.1.4.1.2021.4.5.0',
8341
+	'memAvailReal' => '.1.3.6.1.4.1.2021.4.6.0',
8342
+	'memTotalFree' => '.1.3.6.1.4.1.2021.4.11.0',
8343
+	//'memShared' => '.1.3.6.1.4.1.2021.4.13',
8344
+	'memCached' => '.1.3.6.1.4.1.2021.4.15.0',
8345
+	'memBuffer' => '.1.3.6.1.4.1.2021.4.14.0',
8346
+	'ssSwapIn' => '.1.3.6.1.4.1.2021.11.3.0',
8347
+	'ssSwapOut' => '.1.3.6.1.4.1.2021.11.4.0',
8348
+	'ssIORawSent' => '.1.3.6.1.4.1.2021.11.57.0',
8349
+	'ssIORawReceived' => '.1.3.6.1.4.1.2021.11.58.0',
8350
+	'ssRawInterrupts' => '.1.3.6.1.4.1.2021.11.59.0',
8351
+	'ssRawContexts' => '.1.3.6.1.4.1.2021.11.60.0',
8352
+	'ssCpuRawUser' => '.1.3.6.1.4.1.2021.11.50.0',
8353
+	'ssCpuRawSystem' => '.1.3.6.1.4.1.2021.11.52.0',
8354
+	'ssCpuRawIdle' => '.1.3.6.1.4.1.2021.11.53.0'
8355
+	);
8356
 
8357
 // Using plugin
8358
-if(!empty($plugin)) {
8359
+if (!empty($plugin)) {
8360
 	$static_snmp_descriptions['avgCpuLoad'] = 'Average of CPUs Load (%)';
8361
 	$static_snmp_descriptions['memoryUse'] = 'Memory use (%)';
8362
 }
8363
 
8364
 $fail = false;
8365
 
8366
+$devices = array();
8367
+$processes = array();
8368
+$disks = array();
8369
+$temperatures = array();
8370
+
8371
+$arrow = false;
8372
+
8373
+$other_snmp_data = array();
8374
+
8375
 if ($snmpwalk) {
8376
 	// OID Used is for DISKS
8377
 	$snmpis = get_snmpwalk($ip_target, $snmp_version, $snmp_community, $snmp3_auth_user,
8378
@@ -120,7 +129,6 @@
8379
 		$snmpis = array();
8380
 	}
8381
 	else {
8382
-		$disks = array();
8383
 		// We get here only the interface part of the MIB, not full mib
8384
 		foreach($snmpis as $key => $snmp) {
8385
 			
8386
@@ -136,14 +144,14 @@
8387
 			
8388
 			if (array_key_exists(1,$data)) {
8389
 				$disks[$data[1]] = $data[1];
8390
-
8391
+			
8392
 			}
8393
 			else {
8394
 				$disks[$data[0]] = $data[0];
8395
-
8396
-			}	
8397
+				
8398
+			}
8399
 		}
8400
-			
8401
+		
8402
 		// OID Used is for PROCESSES
8403
 		$snmpis = get_snmpwalk($ip_target, $snmp_version, $snmp_community, $snmp3_auth_user,
8404
 			$snmp3_security_level, $snmp3_auth_method, $snmp3_auth_pass,
8405
@@ -152,8 +160,8 @@
8406
 		if ($snmpis === false) {
8407
 			$snmpis = array();
8408
 		}
8409
-
8410
-		$processes = array();
8411
+		
8412
+		
8413
 		// We get here only the interface part of the MIB, not full mib
8414
 		foreach($snmpis as $key => $snmp) {
8415
 			
8416
@@ -168,12 +176,12 @@
8417
 			
8418
 			if (array_key_exists(1,$data)) {
8419
 				$process_name = str_replace  ( "\""  , "" , $data[1]);
8420
-
8421
+				
8422
 			}
8423
 			else {
8424
 				$process_name = str_replace  ( "\""  , "" , $data[0]);
8425
-
8426
-			}	
8427
+				
8428
+			}
8429
 			
8430
 			$processes[$process_name] = $process_name;
8431
 		}
8432
@@ -191,7 +199,7 @@
8433
 			$snmpis = array();
8434
 		}
8435
 		
8436
-		$temperatures = array();
8437
+		
8438
 		// We get here only the interface part of the MIB, not full mib
8439
 		foreach($snmpis as $key => $snmp) {
8440
 			
8441
@@ -208,11 +216,11 @@
8442
 			if ($keydata2[0] == 'lmTempSensorsDevice') {
8443
 				if (array_key_exists(1,$data)) {
8444
 					$temperatures[$keydata2[1]] = $data[1];
8445
-
8446
+					
8447
 				}
8448
 				else {
8449
 					$temperatures[$keydata2[1]] = $data[0];
8450
-
8451
+					
8452
 				}
8453
 			}
8454
 		}
8455
@@ -229,7 +237,7 @@
8456
 			$snmpis = array();
8457
 		}
8458
 		
8459
-		$devices = array();
8460
+		
8461
 		// We get here only the interface part of the MIB, not full mib
8462
 		foreach($snmpis as $key => $snmp) {
8463
 			
8464
@@ -262,8 +270,15 @@
8465
 	
8466
 	// Other SNMP Data
8467
 	$arrow = true;
8468
-	foreach ($static_snmp_oids as $key=>$oid) {
8469
-		$result = snmpget($ip_target, $snmp_community, $oid);
8470
+	
8471
+	foreach ($static_snmp_oids as $key => $oid) {
8472
+		if ($snmp_version == 3) {
8473
+			$result = false; //It is statics oids.
8474
+		}
8475
+		else {
8476
+			$result = snmpget($ip_target, $snmp_community, $oid);
8477
+		}
8478
+		
8479
 		if ($result != false) {
8480
 			$other_snmp_data[$key] = $static_snmp_descriptions[$key];
8481
 		}
8482
@@ -318,7 +333,7 @@
8483
 		ui_print_error_message (__('No agent selected or the agent does not exist'));
8484
 	}
8485
 	else {
8486
-	
8487
+		
8488
 		// Common values
8489
 		$common_values = array();
8490
 		
8491
@@ -341,33 +356,33 @@
8492
 		
8493
 		// DEVICES
8494
 		$devices_prefix_oids = array(
8495
-								'diskIONRead' => '.1.3.6.1.4.1.2021.13.15.1.1.3.',
8496
-								'diskIONWritten' => '.1.3.6.1.4.1.2021.13.15.1.1.4.',
8497
-								'diskIONReads' => '.1.3.6.1.4.1.2021.13.15.1.1.5.',
8498
-								'diskIONWrites' => '.1.3.6.1.4.1.2021.13.15.1.1.6.'
8499
-								);
8500
-								
8501
+			'diskIONRead' => '.1.3.6.1.4.1.2021.13.15.1.1.3.',
8502
+			'diskIONWritten' => '.1.3.6.1.4.1.2021.13.15.1.1.4.',
8503
+			'diskIONReads' => '.1.3.6.1.4.1.2021.13.15.1.1.5.',
8504
+			'diskIONWrites' => '.1.3.6.1.4.1.2021.13.15.1.1.6.'
8505
+			);
8506
+		
8507
 		$devices_prefix_descriptions = array(
8508
-								'diskIONRead' => 'The number of bytes read from this device since boot',
8509
-								'diskIONWritten' => 'The number of bytes written to this device since boot',
8510
-								'diskIONReads' => 'The number of read accesses from this device since boot',
8511
-								'diskIONWrites' => 'The number of write accesses from this device since boot'
8512
-								);
8513
-								
8514
+			'diskIONRead' => 'The number of bytes read from this device since boot',
8515
+			'diskIONWritten' => 'The number of bytes written to this device since boot',
8516
+			'diskIONReads' => 'The number of read accesses from this device since boot',
8517
+			'diskIONWrites' => 'The number of write accesses from this device since boot'
8518
+			);
8519
+		
8520
 		$results = array();
8521
 		
8522
 		foreach ($devices as $device) {
8523
 			$module_values = $common_values;
8524
-
8525
+			
8526
 			// Split module data to get type, name, etc
8527
 			$device_exploded = explode($separator, $device);
8528
 			$device_name = $device_exploded[0];
8529
 			
8530
 			$name_exploded = explode('-', $device_name);
8531
 			$name = ltrim(html_entity_decode($name_exploded[1]));
8532
-
8533
+			
8534
 			$device_type = $device_exploded[1];
8535
-		
8536
+			
8537
 			// Delete type from device id
8538
 			unset($device_exploded[0]);
8539
 			unset($device_exploded[1]);
8540
@@ -376,10 +391,11 @@
8541
 			$device_id = implode($separator, $device_exploded);
8542
 			
8543
 			$module_values['descripcion'] = $devices_prefix_descriptions[$device_type];
8544
-	
8545
+			
8546
 			if (($name == 'Bytes read') || ($name == 'Bytes written')) {
8547
 				$module_values['id_tipo_modulo'] = modules_get_type_id('remote_snmp_inc');
8548
-			} else {
8549
+			}
8550
+			else {
8551
 				$module_values['id_tipo_modulo'] = modules_get_type_id('remote_snmp');
8552
 			}
8553
 			
8554
@@ -398,7 +414,7 @@
8555
 		
8556
 		foreach ($temperatures as $temperature) {
8557
 			$module_values = $common_values;
8558
-
8559
+			
8560
 			// Split module data to get type, name, etc
8561
 			$temperature_exploded = explode($separator, $temperature);
8562
 			$temperature_name = $temperature_exploded[0];
8563
@@ -434,14 +450,14 @@
8564
 			
8565
 			$module_values['descripcion'] = $static_snmp_descriptions[$snmpdata_name];
8566
 			$module_values['id_tipo_modulo'] = modules_get_type_id('remote_snmp');
8567
-
8568
+			
8569
 			//Average use of CPUs is a plugin module
8570
 			switch ($snmpdata_name) {
8571
 				case 'avgCpuLoad':
8572
 				case 'memoryUse':
8573
 					$module_values['id_modulo'] = MODULE_PLUGIN;
8574
 					$module_values['id_plugin'] = $plugin['id'];
8575
-
8576
+					
8577
 					$macros = json_decode($plugin['macros'], true);
8578
 					
8579
 					foreach($macros as $k => $macro) {
8580
@@ -464,6 +480,33 @@
8581
 										$macros[$k]['value'] = '-m memuse';
8582
 										break;
8583
 								}
8584
+								
8585
+								if ($snmp_version == '3') {
8586
+									$macros[$k]['value'] .= " -v3 ";
8587
+									switch ($snmp3_security_level) {
8588
+										case "authNoPriv":
8589
+											$macros[$k]['value'] .= 
8590
+												' -u ' . $snmp3_auth_user .
8591
+												' -A ' . $snmp3_auth_pass .
8592
+												' -l ' . $snmp3_security_level .
8593
+												' -a ' . $snmp3_auth_method;
8594
+											break;
8595
+										case "noAuthNoPriv":
8596
+											$macros[$k]['value'] .= 
8597
+												' -u ' . $snmp3_auth_user .
8598
+												' -l ' . $snmp3_security_level;
8599
+											break;
8600
+										default:
8601
+											$macros[$k]['value'] .= 
8602
+												' -u ' . $snmp3_auth_user .
8603
+												' -A ' . $snmp3_auth_pass .
8604
+												' -l ' . $snmp3_security_level .
8605
+												' -a ' . $snmp3_auth_method .
8606
+												' -x ' . $snmp3_privacy_method .
8607
+												' -X ' . $snmp3_privacy_pass;
8608
+											break;
8609
+									}
8610
+								}
8611
 								break;
8612
 						}
8613
 					}
8614
@@ -497,7 +540,7 @@
8615
 			
8616
 			$macros = json_decode($plugin['macros'], true);
8617
 			
8618
-			foreach($macros as $k => $macro) {
8619
+			foreach ($macros as $k => $macro) {
8620
 				switch($macro['macro']) {
8621
 					case '_field1_':
8622
 						// Field 1 is the IP Address
8623
@@ -510,6 +553,33 @@
8624
 					case '_field3_':
8625
 						// Field 3 is the plugin parameters
8626
 						$macros[$k]['value'] = io_safe_input('-m process -p "' . $process . '"');
8627
+						
8628
+						if ($snmp_version == '3') {
8629
+							$macros[$k]['value'] .= " -v3 ";
8630
+							switch ($snmp3_security_level) {
8631
+								case "authNoPriv":
8632
+									$macros[$k]['value'] .= 
8633
+										' -u ' . $snmp3_auth_user .
8634
+										' -A ' . $snmp3_auth_pass .
8635
+										' -l ' . $snmp3_security_level .
8636
+										' -a ' . $snmp3_auth_method;
8637
+									break;
8638
+								case "noAuthNoPriv":
8639
+									$macros[$k]['value'] .= 
8640
+										' -u ' . $snmp3_auth_user .
8641
+										' -l ' . $snmp3_security_level;
8642
+									break;
8643
+								default:
8644
+									$macros[$k]['value'] .= 
8645
+										' -u ' . $snmp3_auth_user .
8646
+										' -A ' . $snmp3_auth_pass .
8647
+										' -l ' . $snmp3_security_level .
8648
+										' -a ' . $snmp3_auth_method .
8649
+										' -x ' . $snmp3_privacy_method .
8650
+										' -X ' . $snmp3_privacy_pass;
8651
+									break;
8652
+							}
8653
+						}
8654
 						break;
8655
 				}
8656
 			}
8657
@@ -519,7 +589,7 @@
8658
 			unset($module_values['snmp_community']); //snmp_community
8659
 			unset($module_values['ip_target']); //ip_target
8660
 			unset($module_values['tcp_send']); //snmp_version
8661
-
8662
+			
8663
 			$result = modules_create_agent_module ($id_agent, io_safe_input($process), $module_values);
8664
 			
8665
 			$results[$result][] = $process;
8666
@@ -537,7 +607,7 @@
8667
 			
8668
 			$macros = json_decode($plugin['macros'], true);
8669
 			
8670
-			foreach($macros as $k => $macro) {
8671
+			foreach ($macros as $k => $macro) {
8672
 				switch($macro['macro']) {
8673
 					case '_field1_':
8674
 						// Field 1 is the IP Address
8675
@@ -550,7 +620,33 @@
8676
 					case '_field3_':
8677
 						// Field 3 is the plugin parameters
8678
 						$macros[$k]['value'] = io_safe_input('-m diskuse -d "' . io_safe_output($disk) . '"');
8679
-						break;
8680
+						
8681
+						if ($snmp_version == '3') {
8682
+							$macros[$k]['value'] .= " -v3 ";
8683
+							switch ($snmp3_security_level) {
8684
+								case "authNoPriv":
8685
+									$macros[$k]['value'] .= 
8686
+										' -u ' . $snmp3_auth_user .
8687
+										' -A ' . $snmp3_auth_pass .
8688
+										' -l ' . $snmp3_security_level .
8689
+										' -a ' . $snmp3_auth_method;
8690
+									break;
8691
+								case "noAuthNoPriv":
8692
+									$macros[$k]['value'] .= 
8693
+										' -u ' . $snmp3_auth_user .
8694
+										' -l ' . $snmp3_security_level;
8695
+									break;
8696
+								default:
8697
+									$macros[$k]['value'] .= 
8698
+										' -u ' . $snmp3_auth_user .
8699
+										' -A ' . $snmp3_auth_pass .
8700
+										' -l ' . $snmp3_security_level .
8701
+										' -a ' . $snmp3_auth_method .
8702
+										' -x ' . $snmp3_privacy_method .
8703
+										' -X ' . $snmp3_privacy_pass;
8704
+									break;
8705
+							}
8706
+						}
8707
 				}
8708
 			}
8709
 			
8710
@@ -559,34 +655,46 @@
8711
 			unset($module_values['snmp_community']); //snmp_community
8712
 			unset($module_values['ip_target']); //ip_target
8713
 			unset($module_values['tcp_send']); //snmp_version
8714
-
8715
-			$result = modules_create_agent_module ($id_agent, io_safe_input($disk), $module_values);
8716
 			
8717
+			$result = modules_create_agent_module($id_agent, io_safe_input($disk), $module_values);
8718
+			
8719
 			$results[$result][] = $disk;
8720
 		}
8721
-				
8722
+		
8723
 		$success_message = '';
8724
 		$error_message = '';
8725
-	
8726
-		if (count($results[NOERR]) > 0) {
8727
-			$success_message .= sprintf(__('%s modules created succesfully'), count($results[NOERR])) . '<br>';
8728
+		
8729
+		if (isset($results[NOERR])) {
8730
+			if (count($results[NOERR]) > 0) {
8731
+				$success_message .= sprintf(__('%s modules created succesfully'), count($results[NOERR])) . '<br>';
8732
+			}
8733
 		}
8734
-		if (count($results[ERR_GENERIC]) > 0) {
8735
-			$error_message .= sprintf(__('Error creating %s modules') . ': <br>&nbsp;&nbsp;* ' . implode('<br>&nbsp;&nbsp;* ', $results[ERR_GENERIC]), count($results[ERR_GENERIC])) . '<br>';
8736
+		if (isset($results[ERR_GENERIC])) {
8737
+			if (count($results[ERR_GENERIC]) > 0) {
8738
+				$error_message .= sprintf(__('Error creating %s modules') . ': <br>&nbsp;&nbsp;* ' . implode('<br>&nbsp;&nbsp;* ', $results[ERR_GENERIC]), count($results[ERR_GENERIC])) . '<br>';
8739
+			}
8740
 		}
8741
-		if (count($results[ERR_EXIST]) > 0) {
8742
-			$error_message .= sprintf(__('%s modules already exist') . ': <br>&nbsp;&nbsp;* ' . implode('<br>&nbsp;&nbsp;* ', $results[ERR_EXIST]), count($results[ERR_EXIST])) . '<br>';
8743
+		if (isset($results[ERR_DB])) {
8744
+			if (count($results[ERR_DB]) > 0) {
8745
+				$error_message .= sprintf(__('Error creating %s modules') . ': <br>&nbsp;&nbsp;* ' . implode('<br>&nbsp;&nbsp;* ', $results[ERR_DB]), count($results[ERR_DB])) . '<br>';
8746
+			}
8747
 		}
8748
+		if (isset($results[ERR_EXIST])) {
8749
+			if (count($results[ERR_EXIST]) > 0) {
8750
+				$error_message .= sprintf(__('%s modules already exist') . ': <br>&nbsp;&nbsp;* ' . implode('<br>&nbsp;&nbsp;* ', $results[ERR_EXIST]), count($results[ERR_EXIST])) . '<br>';
8751
+			}
8752
+		}
8753
 		 
8754
 		if (!empty($error_message)) {
8755
 			ui_print_error_message($error_message);
8756
-		} else {
8757
+		}
8758
+		else {
8759
 			if (empty($success_message)) {
8760
 				$success_message .= sprintf(__('Modules created succesfully')) . '<br>';
8761
 			}
8762
 			ui_print_success_message($success_message);
8763
 		}
8764
-	}				
8765
+	}
8766
 }
8767
 
8768
 echo '<span id ="none_text" style="display: none;">' . __('None') . '</span>';
8769
@@ -697,17 +805,17 @@
8770
 	$table->data[1][0] .= html_print_select ($modes,
8771
 		'snmp_wizard_modes', '', '', '', '', true, false, false);
8772
 	$table->cellstyle[1][0] = 'vertical-align: middle;';
8773
-
8774
+	
8775
 	$table->colspan[1][0] = 2;
8776
 	$table->data[1][2] = '<b>'.__('Modules').'</b>';
8777
 	$table->cellstyle[1][2] = 'vertical-align: middle;';
8778
-
8779
+	
8780
 	// Devices list
8781
-	$table->data[2][0] .= '<div class="wizard_mode_form wizard_mode_devices">';
8782
+	$table->data[2][0] = '<div class="wizard_mode_form wizard_mode_devices">';
8783
 	$table->data[2][0] .= html_print_select ($devices, 'devices', '', '',
8784
 		'', '', true, true, true, '', false, 'width: 300px;');
8785
 	$table->data[2][0] .= '</div>';
8786
-
8787
+	
8788
 	// If SNMP remote plugin is not installed, show an advice
8789
 	if(empty($plugin)) {
8790
 		// Processes list
8791
@@ -747,7 +855,7 @@
8792
 	$table->data[2][0] .= '</div>';
8793
 	
8794
 	$table->cellstyle[2][0] = 'vertical-align: top; text-align: center;';
8795
-
8796
+	
8797
 	// Devices arrow
8798
 	$table->data[2][1] = '<div class="wizard_mode_form wizard_mode_devices wizard_mode_devices_arrow clickable">' . html_print_image('images/darrowright.png', true, array('title' => __('Add to modules list'))) . '</div>';
8799
 	// Processes arrow
8800
@@ -761,15 +869,15 @@
8801
 		$table->data[2][1] .= '<div class="wizard_mode_form wizard_mode_snmpdata wizard_mode_snmpdata_arrow clickable">' . html_print_image('images/darrowright.png', true, array('title' => __('Add to modules list'))) . '</div>';
8802
 	}
8803
 	$table->data[2][1] .= '<br><br><div class="wizard_mode_delete_arrow clickable">' . html_print_image('images/cross.png', true, array('title' => __('Remove from modules list'))) . '</div>'; 
8804
-	$table->cellstyle[2][1] .= 'vertical-align: middle; text-align: center;';
8805
-
8806
+	$table->cellstyle[2][1] = 'vertical-align: middle; text-align: center;';
8807
+	
8808
 	$table->data[2][2] = html_print_select (array (), 'module[]', 0, false, '', 0, true, true, true, '', false, 'width:300px; height: 100%;');
8809
 	$table->data[2][2] .= html_print_input_hidden('agent', $id_agent, true);
8810
 	$table->cellstyle[2][2] = 'vertical-align: top; text-align: center;';
8811
-
8812
+	
8813
 	html_print_table($table);
8814
 	
8815
-	echo "<div style='text-align:right; width:".$table->width."'>";
8816
+	echo "<div style='text-align:right; width:" . $table->width . "'>";
8817
 	html_print_submit_button(__('Create modules'), 'create_modules_btn', false, array('class' => 'sub add'));
8818
 	echo "</div>";
8819
 	unset($table);
8820
@@ -778,7 +886,7 @@
8821
 	echo "</form>";
8822
 	echo '</div>';
8823
 }
8824
-	
8825
+
8826
 ui_require_jquery_file ('pandora.controls');
8827
 ui_require_jquery_file ('ajaxqueue');
8828
 ui_require_jquery_file ('bgiframe');
8829
Index: godmode/agentes/planned_downtime.editor.php
8830
===================================================================
8831
--- godmode/agentes/planned_downtime.editor.php	(revision 10314)
8832
+++ godmode/agentes/planned_downtime.editor.php	(working copy)
8833
@@ -1,5 +1,4 @@
8834
 <?php
8835
-
8836
 // Pandora FMS - http://pandorafms.com
8837
 // ==================================================
8838
 // Copyright (c) 2005-2010 Artica Soluciones Tecnologicas
8839
@@ -18,6 +17,7 @@
8840
 
8841
 check_login();
8842
 
8843
+
8844
 if (! check_acl ($config['id_user'], 0, "AW")) {
8845
 	db_pandora_audit("ACL Violation",
8846
 		"Trying to access downtime scheduler");
8847
@@ -25,6 +25,7 @@
8848
 	return;
8849
 }
8850
 
8851
+
8852
 require_once ('include/functions_users.php');
8853
 
8854
 // Header
8855
@@ -36,10 +37,7 @@
8856
 	true,
8857
 	"");
8858
 
8859
-// Load global vars
8860
-global $config;
8861
 
8862
-check_login();
8863
 
8864
 //Initialize data
8865
 $id_agent = get_parameter ("id_agent");
8866
@@ -153,7 +151,7 @@
8867
 	$datetime_from = strtotime ($once_date_from . ' ' . $once_time_from);
8868
 	$datetime_to = strtotime ($once_date_to . ' ' . $once_time_to);
8869
 	$now = strtotime(date(DATE_FORMAT). ' ' . date(TIME_FORMAT));
8870
-
8871
+	
8872
 	if ($datetime_from < $now) {
8873
 		ui_print_error_message(__('Not created. Error inserting data. Start time must be higher than the current time' ));
8874
 	}
8875
Index: godmode/agentes/modificar_agente.php
8876
===================================================================
8877
--- godmode/agentes/modificar_agente.php	(revision 10314)
8878
+++ godmode/agentes/modificar_agente.php	(working copy)
8879
@@ -161,6 +161,17 @@
8880
 echo "</div>";
8881
 
8882
 
8883
+$order_collation = "";
8884
+switch ($config["dbtype"]) {
8885
+	case "mysql":
8886
+		$order_collation = "COLLATE utf8_general_ci";
8887
+		break;
8888
+	case "postgresql":
8889
+	case "oracle":
8890
+		$order_collation = "";
8891
+		break;
8892
+}
8893
+
8894
 $selected = 'border: 1px solid black;';
8895
 $selectNameUp = '';
8896
 $selectNameDown = '';
8897
@@ -173,14 +184,14 @@
8898
 		switch ($sort) {
8899
 			case 'up':
8900
 				$selectNameUp = $selected;
8901
-				$order = array('field' => 'nombre COLLATE utf8_general_ci',
8902
-					'field2' => 'nombre COLLATE utf8_general_ci',
8903
+				$order = array('field' => 'nombre ' . $order_collation,
8904
+					'field2' => 'nombre ' . $order_collation,
8905
 					'order' => 'ASC');
8906
 				break;
8907
 			case 'down':
8908
 				$selectNameDown = $selected;
8909
-				$order = array('field' => 'nombre COLLATE utf8_general_ci',
8910
-					'field2' => 'nombre COLLATE utf8_general_ci',
8911
+				$order = array('field' => 'nombre ' . $order_collation,
8912
+					'field2' => 'nombre ' . $order_collation,
8913
 					'order' => 'DESC');
8914
 				break;
8915
 		}
8916
@@ -190,13 +201,13 @@
8917
 			case 'up':
8918
 				$selectOsUp = $selected;
8919
 				$order = array('field' => 'id_os',
8920
-					'field2' => 'nombre COLLATE utf8_general_ci',
8921
+					'field2' => 'nombre ' . $order_collation,
8922
 					'order' => 'ASC');
8923
 				break;
8924
 			case 'down':
8925
 				$selectOsDown = $selected;
8926
 				$order = array('field' => 'id_os',
8927
-					'field2' => 'nombre COLLATE utf8_general_ci',
8928
+					'field2' => 'nombre ' . $order_collation,
8929
 					'order' => 'DESC');
8930
 				break;
8931
 		}
8932
@@ -206,13 +217,13 @@
8933
 			case 'up':
8934
 				$selectGroupUp = $selected;
8935
 				$order = array('field' => 'id_grupo',
8936
-					'field2' => 'nombre COLLATE utf8_general_ci',
8937
+					'field2' => 'nombre ' . $order_collation,
8938
 					'order' => 'ASC');
8939
 				break;
8940
 			case 'down':
8941
 				$selectGroupDown = $selected;
8942
 				$order = array('field' => 'id_grupo',
8943
-					'field2' => 'nombre COLLATE utf8_general_ci',
8944
+					'field2' => 'nombre ' . $order_collation,
8945
 					'order' => 'DESC');
8946
 				break;
8947
 		}
8948
@@ -224,13 +235,16 @@
8949
 		$selectOsDown = '';
8950
 		$selectGroupUp = '';
8951
 		$selectGroupDown = '';
8952
-		$order = array('field' => 'nombre COLLATE utf8_general_ci', 'field2' => 'nombre COLLATE utf8_general_ci', 'order' => 'ASC');
8953
+		$order = array('field' => 'nombre ' . $order_collation,
8954
+			'field2' => 'nombre ' . $order_collation,
8955
+			'order' => 'ASC');
8956
 		break;
8957
 }
8958
 
8959
 $search_sql = '';
8960
 if ($search != "") {
8961
-	$search_sql = " AND ( nombre COLLATE utf8_general_ci LIKE '%$search%' OR direccion LIKE '%$search%') ";
8962
+	$search_sql = " AND ( nombre " . $order_collation . "
8963
+		LIKE '%$search%' OR direccion LIKE '%$search%') ";
8964
 }
8965
 
8966
 // Show only selected groups
8967
Index: godmode/agentes/agent_manager.php
8968
===================================================================
8969
--- godmode/agentes/agent_manager.php	(revision 10314)
8970
+++ godmode/agentes/agent_manager.php	(working copy)
8971
@@ -159,7 +159,8 @@
8972
 	
8973
 	$table->data[0][1] .= "&nbsp;<b>" . __("ID") . "</b>&nbsp; $id_agente &nbsp;";
8974
 	$table->data[0][1] .= '&nbsp;&nbsp;<a href="index.php?sec=gagente&amp;sec2=operation/agentes/ver_agente&amp;id_agente='.$id_agente.'">';
8975
-	$table->data[0][1] .= html_print_image ("images/zoom.png", true, array ("border" => 0, "title" => __('Agent detail')));
8976
+	$table->data[0][1] .= html_print_image ("images/zoom.png",
8977
+		true, array ("border" => 0, "title" => __('Agent detail')));
8978
 	$table->data[0][1] .= '</a>';
8979
 }
8980
 
8981
@@ -215,9 +216,14 @@
8982
 </style>
8983
 <?php
8984
 $table->rowspan[1][2] = 7;
8985
-$table->data[1][2] =
8986
-	"<a id='qr_code_agent_view' href='javascript: show_dialog_qrcode(null, \"" .
8987
-		ui_get_full_url('index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=' . $id_agente) . "\" );'></a>";
8988
+if ($id_agente) {
8989
+	$table->data[1][2] =
8990
+		"<a id='qr_code_agent_view' href='javascript: show_dialog_qrcode(null, \"" .
8991
+			ui_get_full_url('index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=' . $id_agente) . "\" );'></a>";
8992
+}
8993
+else {
8994
+	$table->data[1][2] = __("Only it is show when<br />the agent is saved.");
8995
+}
8996
 
8997
 $groups = users_get_groups ($config["id_user"], "AR",false);
8998
 $agents = agents_get_group_agents (array_keys ($groups));
8999
Index: godmode/servers/manage_recontask.php
9000
===================================================================
9001
--- godmode/servers/manage_recontask.php	(revision 10314)
9002
+++ godmode/servers/manage_recontask.php	(working copy)
9003
@@ -204,6 +204,7 @@
9004
 		if (($id_recon_script == 'NULL') && preg_match("/[0-9]+.+[0-9]+.+[0-9]+.+[0-9]+\/+[0-9]/", $network))
9005
 		{
9006
 			$result = db_process_sql_insert('trecon_task', $values);
9007
+			
9008
 			$reason = __("Network provided is not correct");
9009
 		}
9010
 		elseif ($id_recon_script != 'NULL') {
9011
@@ -215,9 +216,10 @@
9012
 			$result = false;
9013
 		}
9014
 	}
9015
-	else
9016
+	else {
9017
 		$result = false;
9018
-		
9019
+	}
9020
+	
9021
 	if ($result !== false) {
9022
 		ui_print_success_message(__('Successfully created recon task'));
9023
 	}
9024
Index: godmode/servers/manage_recontask_form.php
9025
===================================================================
9026
--- godmode/servers/manage_recontask_form.php	(revision 10314)
9027
+++ godmode/servers/manage_recontask_form.php	(working copy)
9028
@@ -54,7 +54,7 @@
9029
 		echo io_json_mb_encode($macros);
9030
 		return;
9031
 	}
9032
-
9033
+	
9034
 	return;
9035
 }
9036
 
9037
@@ -261,7 +261,7 @@
9038
 
9039
 
9040
 $explanation = db_get_value('description', 'trecon_script', 'id_recon_script', $id_recon_script);
9041
-		
9042
+
9043
 $table->data[12][0] = "<b>" . __('Explanation') . "</b>";
9044
 $table->data[12][1] = "<span id='spinner_layour' style='display: none;'>" . html_print_image ("images/spinner.gif", true) .
9045
 "</span>" . html_print_textarea('explanation', 4, 60, $explanation, 'style="width: 388px;"', true);
9046
Index: godmode/alerts/configure_alert_template.php
9047
===================================================================
9048
--- godmode/alerts/configure_alert_template.php	(revision 10314)
9049
+++ godmode/alerts/configure_alert_template.php	(working copy)
9050
@@ -394,11 +394,15 @@
9051
 	}
9052
 	if ($result) {
9053
 		//db_pandora_audit("Command management", "Create alert command " . $result, false, false, json_encode($values));
9054
-		db_pandora_audit("Template alert management", "Create alert template #" . $result, false, false, json_encode($values));
9055
+		db_pandora_audit("Template alert management",
9056
+			"Create alert template #" . $result, false, false,
9057
+			json_encode($values));
9058
 	}
9059
 	else {
9060
 		//db_pandora_audit("Command management", "Fail try to create alert command", false, false, json_encode($values));
9061
-		db_pandora_audit("Template alert management", "Fail try to create alert template", false, false, json_encode($values));
9062
+		db_pandora_audit("Template alert management",
9063
+			"Fail try to create alert template", false, false,
9064
+			json_encode($values));
9065
 	}
9066
 	
9067
 	ui_print_result_message ($result,
9068
@@ -455,7 +459,7 @@
9069
 	for ($i = 1; $i <= 10; $i++) {
9070
 		$fields_recovery[$i] = $template['field'.$i.'_recovery'];
9071
 	}
9072
-
9073
+	
9074
 	$default_action = $template['id_alert_action'];
9075
 	$priority = $template['priority'];
9076
 	$id_group = $template['id_group'];
9077
@@ -474,6 +478,10 @@
9078
 $table->size[2] = '20%';
9079
 
9080
 if ($step == 2) {
9081
+	
9082
+	if (!isset($show_matches))
9083
+		$show_matches = false;
9084
+	
9085
 	/* Firing conditions and events */
9086
 	$table->colspan = array ();
9087
 	$table->colspan[4][1] = 3;
9088
@@ -493,7 +501,7 @@
9089
 	$table->data[0][1] .= html_print_checkbox ('saturday', 1, $saturday, true);
9090
 	$table->data[0][1] .= __('Sun');
9091
 	$table->data[0][1] .= html_print_checkbox ('sunday', 1, $sunday, true);
9092
-
9093
+	
9094
 	$table->data[0][2] = __('Use special days list');
9095
 	$table->data[0][3] = html_print_checkbox ('special_day', 1, $special_day, true);
9096
 	
9097
@@ -512,11 +520,11 @@
9098
 	'', false, true);
9099
 	
9100
 	$table->data[3][0] = __('Min. number of alerts');
9101
-	$table->data[3][1] = html_print_input_text ('min_alerts', $min_alerts, '',
9102
-		5, 7, true);
9103
+	$table->data[3][1] = html_print_input_text ('min_alerts',
9104
+		$min_alerts, '', 5, 7, true);
9105
 	$table->data[3][2] = __('Max. number of alerts');
9106
-	$table->data[3][3] = html_print_input_text ('max_alerts', $max_alerts, '',
9107
-		5, 7, true);
9108
+	$table->data[3][3] = html_print_input_text ('max_alerts',
9109
+		$max_alerts, '', 5, 7, true);
9110
 	
9111
 	$table->data[4][0] = __('Default action');
9112
 	$usr_groups = implode(',', array_keys(users_get_groups($config['id_user'], 'LM', true)));
9113
@@ -529,7 +537,8 @@
9114
 				ORDER BY name', $usr_groups);
9115
 			break;
9116
 		case "oracle":
9117
-			$sql_query = sprintf('SELECT id, dbms_lob.substr(name,4000,1) as nombre
9118
+			$sql_query = sprintf('SELECT id,
9119
+					dbms_lob.substr(name,4000,1) AS nombre
9120
 				FROM talert_actions
9121
 				WHERE id_group IN (%s)
9122
 				ORDER BY dbms_lob.substr(name,4000,1)', $usr_groups);
9123
@@ -543,13 +552,15 @@
9124
 	$table->data[5][0] = __('Condition type');
9125
 	$table->data[5][1] = html_print_select (alerts_get_alert_templates_types (), 'type',
9126
 		$type, '', __('Select'), 0, true, false, false);
9127
-	$table->data[5][1] .= '<span id="matches_value" '.($show_matches ? '' : 'style="display: none"').'>';
9128
+	$table->data[5][1] .= '<span id="matches_value" ' .
9129
+		($show_matches ? '' : 'style="display: none"').'>';
9130
 	$table->data[5][1] .= '&nbsp;'.html_print_checkbox ('matches_value', 1, $matches, true);
9131
-	$table->data[5][1] .= html_print_label (__('Trigger when matches the value'),
9132
+	$table->data[5][1] .= html_print_label(
9133
+		__('Trigger when matches the value'),
9134
 		'checkbox-matches_value', true);
9135
 	$table->data[5][1] .= '</span>';
9136
 	$table->colspan[5][1] = 3;
9137
-
9138
+	
9139
 	$table->data['value'][0] = __('Value');
9140
 	$table->data['value'][1] = html_print_input_text ('value', $value, '',
9141
 		35, 255, true);
9142
@@ -566,17 +577,20 @@
9143
 			'width' => '20px'));
9144
 	$table->data['value'][1] .= '</span>';
9145
 	$table->colspan['value'][1] = 3;
9146
-
9147
+	
9148
 	//Min first, then max, that's more logical
9149
 	$table->data['min'][0] = __('Min.');
9150
-	$table->data['min'][1] = html_print_input_text ('min', $min, '', 5, 255, true);
9151
+	$table->data['min'][1] = html_print_input_text ('min', $min, '', 5,
9152
+		255, true);
9153
 	$table->colspan['min'][1] = 3;
9154
-
9155
+	
9156
 	$table->data['max'][0] = __('Max.');
9157
-	$table->data['max'][1] = html_print_input_text ('max', $max, '', 5, 255, true);
9158
+	$table->data['max'][1] = html_print_input_text ('max', $max, '', 5,
9159
+		255, true);
9160
 	$table->colspan['max'][1] = 3;
9161
-
9162
-	$table->data['example'][1] = ui_print_alert_template_example ($id, true, false);
9163
+	
9164
+	$table->data['example'][1] = ui_print_alert_template_example($id,
9165
+		true, false);
9166
 	$table->colspan['example'][1] = 4;
9167
 }
9168
 else if ($step == 3) {
9169
@@ -585,7 +599,7 @@
9170
 	$table->style[2] = 'font-weight: bold; vertical-align: top';
9171
 	$table->size = array ();
9172
 	$table->size[0] = '20%';
9173
-
9174
+	
9175
 	/* Alert recover */
9176
 	if (! $recovery_notify) {
9177
 		$table->cellstyle['label_fields'][2] = 'display:none;';
9178
@@ -610,7 +624,7 @@
9179
 	$table->data['label_fields'][0] = '';
9180
 	$table->data['label_fields'][1] = __('Firing fields');
9181
 	$table->data['label_fields'][2] = __('Recovery fields');
9182
-		
9183
+	
9184
 	for ($i = 1; $i <= 10; $i++) {
9185
 		if (isset($template[$name])) {
9186
 			$value = $template[$name];
9187
@@ -621,8 +635,9 @@
9188
 		
9189
 		//$table->rowclass['field'.$i] = 'row_field';
9190
 		
9191
-		$table->data['field'.$i][0] = sprintf(__('Field %s'), $i) . ui_print_help_icon ('alert_macros', true);
9192
-		$table->data['field'.$i][1] = html_print_textarea ('field'.$i, 1, 1, isset($fields[$i]) ? $fields[$i] : '', 'style="min-height:40px;" class="fields"', true);
9193
+		$table->data['field'.$i][0] = sprintf(__('Field %s'), $i) .
9194
+			ui_print_help_icon ('alert_macros', true);
9195
+		$table->data['field'.$i][1] = html_print_textarea('field'.$i, 1, 1, isset($fields[$i]) ? $fields[$i] : '', 'style="min-height:40px;" class="fields"', true);
9196
 		// Recovery
9197
 		$table->data['field'.$i][2] = html_print_textarea ('field'.$i.'_recovery', 1, 1, isset($fields_recovery[$i]) ? $fields_recovery[$i] : '', 'style="min-height:40px" class="fields"', true);
9198
 	}
9199
Index: godmode/alerts/alert_list.builder.php
9200
===================================================================
9201
--- godmode/alerts/alert_list.builder.php	(revision 10314)
9202
+++ godmode/alerts/alert_list.builder.php	(working copy)
9203
@@ -80,7 +80,7 @@
9204
 $own_info = get_user_info ($config['id_user']);
9205
 if ($own_info['is_admin'] || check_acl ($config['id_user'], 0, "PM"))
9206
 	$templates = alerts_get_alert_templates (false, array ('id', 'name'));
9207
-else{
9208
+else {
9209
 	$usr_groups = users_get_groups($config['id_user'], 'LW', true);
9210
 	$filter_groups = '';
9211
 	$filter_groups = implode(',', array_keys($usr_groups));
9212
@@ -107,13 +107,17 @@
9213
 	$actions = db_get_all_rows_sql($sql);
9214
 }
9215
 $table->data[2][1] = '<div class="actions_container">';
9216
-$table->data[2][1] .= html_print_select(index_array ($actions, 'id', 'name'),'action_select','','',__('Default action'),'0',true, '', true, '', false, 'width: 250px;');
9217
+$table->data[2][1] .= html_print_select(
9218
+	index_array($actions, 'id', 'name'), 'action_select', '', '',
9219
+	__('Default action'), '0', true, '', true, '', false,
9220
+	'width: 250px;');
9221
 $table->data[2][1] .= '<span id="advanced_action" class="advanced_actions invisible"><br>';
9222
 $table->data[2][1] .= __('Number of alerts match from').' ';
9223
 $table->data[2][1] .= html_print_input_text ('fires_min', '', '', 4, 10, true);
9224
-$table->data[2][1] .= ' '.__('to').' ';
9225
+$table->data[2][1] .= ' ' . __('to') . ' ';
9226
 $table->data[2][1] .= html_print_input_text ('fires_max', '', '', 4, 10, true);
9227
-$table->data[2][1] .= ui_print_help_icon ("alert-matches", true, ui_get_full_url(false, false, false, false));
9228
+$table->data[2][1] .= ui_print_help_icon ("alert-matches", true,
9229
+	ui_get_full_url(false, false, false, false));
9230
 $table->data[2][1] .= '</span>';
9231
 $table->data[2][1] .= '</div>';
9232
 if (check_acl ($config['id_user'], 0, "LM")) {
9233
Index: godmode/snmpconsole/snmp_alert.php
9234
===================================================================
9235
--- godmode/snmpconsole/snmp_alert.php	(revision 10314)
9236
+++ godmode/snmpconsole/snmp_alert.php	(working copy)
9237
@@ -476,10 +476,11 @@
9238
 $user_groups = users_get_groups($config['id_user'],"AR", true);
9239
 $str_user_groups = '';
9240
 $i = 0;
9241
-foreach ($user_groups as $id=>$name) {
9242
+foreach ($user_groups as $id => $name) {
9243
 	if ($i == 0) {
9244
 		$str_user_groups .= $id;
9245
-	} else {
9246
+	}
9247
+	else {
9248
 		$str_user_groups .= ','.$id;
9249
 	}
9250
 	$i++;
9251
@@ -895,6 +896,7 @@
9252
 		$where_sql .= ' AND `priority` = ' . $priority_filter;
9253
 	}
9254
 	
9255
+	$where_sql = "";
9256
 	if (!empty($free_search)) {
9257
 		$where_sql .= " AND (`single_value` LIKE '%" . $free_search . "%'
9258
 			OR `_snmp_f10_` LIKE '%" . $free_search . "%'
9259
@@ -914,7 +916,8 @@
9260
 	}
9261
 	
9262
 	$count = db_get_value_sql("SELECT COUNT(*)
9263
-		FROM talert_snmp WHERE id_group IN ($str_user_groups) " . $where_sql);
9264
+		FROM talert_snmp WHERE id_group IN ($str_user_groups) " .
9265
+		$where_sql);
9266
 	
9267
 	$result = array();
9268
 	
9269
Index: godmode/setup/setup_general.php
9270
===================================================================
9271
--- godmode/setup/setup_general.php	(revision 10314)
9272
+++ godmode/setup/setup_general.php	(working copy)
9273
@@ -252,6 +252,17 @@
9274
 $table->data[32][0] = __('Server logs directory') . ui_print_help_tip (__("Directory where the server logs are stored."), true);
9275
 $table->data[32][1] = html_print_input_text ('server_log_dir', $config["server_log_dir"], '', 50, 255, true);
9276
 
9277
+$modes_tutorial = array(
9278
+	'full' => __('Full mode'),
9279
+	'on_demand' => __('On demand'),
9280
+	'expert' => __('Expert')
9281
+	);
9282
+$table->data['tutorial_mode'][0] = __('Tutorial mode') .
9283
+	ui_print_help_tip (__("Configuration of our clippy, 'full mode' show the icon in the header and the contextual helps and it is noise, 'on demand' it is equal to full but it is not noise and 'expert' the icons in the header and the context is not."), true);
9284
+$table->data['tutorial_mode'][1] = 
9285
+	html_print_select($modes_tutorial, 'tutorial_mode',
9286
+		$config["tutorial_mode"], '', '', 0, true);
9287
+
9288
 echo '<form id="form_setup" method="post" action="index.php?sec=gsetup&sec2=godmode/setup/setup&amp;section=general&amp;pure='.$config['pure'].'">';
9289
 
9290
 echo "<fieldset>";
9291
Index: godmode/setup/license.php
9292
===================================================================
9293
--- godmode/setup/license.php	(revision 10314)
9294
+++ godmode/setup/license.php	(working copy)
9295
@@ -47,7 +47,8 @@
9296
 }
9297
 
9298
 echo '<script type="text/javascript">';
9299
-print_js_var_enteprise();
9300
+if (enterprise_installed())
9301
+	print_js_var_enteprise();
9302
 echo '</script>';
9303
 
9304
 echo '<form method="post">';
9305
@@ -71,11 +72,13 @@
9306
 $table->data[4][1] = html_print_input_text('expires', $license['license_mode'], '', 10, 255, true, true);
9307
 
9308
 html_print_table ($table);
9309
-echo '<div class="action-buttons" style="width: '.$table->width.'">';
9310
-html_print_input_hidden ('update_settings', 1);
9311
-html_print_submit_button (__('Validate'), 'update_button', false, 'class="sub upd"');
9312
-html_print_button(__('Request new license'), '', false, 'generate_request_code()', 'class="ui-button-dialog ui-widget ui-state-default ui-corner-all ui-button-text-only sub next"');
9313
-echo '</div>';
9314
+if (enterprise_installed()) {
9315
+	echo '<div class="action-buttons" style="width: '.$table->width.'">';
9316
+	html_print_input_hidden ('update_settings', 1);
9317
+	html_print_submit_button (__('Validate'), 'update_button', false, 'class="sub upd"');
9318
+	html_print_button(__('Request new license'), '', false, 'generate_request_code()', 'class="ui-button-dialog ui-widget ui-state-default ui-corner-all ui-button-text-only sub next"');
9319
+	echo '</div>';
9320
+}
9321
 echo '</form>';
9322
 echo '<div id="code_license_dialog" style="display: none; text-align: left;" title="' . __('Request new license') . '">';
9323
 echo '<div id="logo">';
9324
Index: godmode/setup/setup_visuals.php
9325
===================================================================
9326
--- godmode/setup/setup_visuals.php	(revision 10314)
9327
+++ godmode/setup/setup_visuals.php	(working copy)
9328
@@ -399,6 +399,16 @@
9329
 
9330
 $row++;
9331
 
9332
+$table->data[$row][0] = __('Fixed header');
9333
+$table->data[$row][1] = html_print_checkbox('fixed_header', 1, $config['fixed_header'], true);
9334
+
9335
+$row++;
9336
+
9337
+$table->data[$row][0] = __('Fixed menu');
9338
+$table->data[$row][1] = html_print_checkbox('fixed_menu', 1, $config['fixed_menu'], true);
9339
+
9340
+$row++;
9341
+
9342
 echo '<form id="form_setup" method="post">';
9343
 html_print_input_hidden ('update_config', 1);
9344
 html_print_table ($table);
9345
Index: godmode/modules/manage_network_components_form.php
9346
===================================================================
9347
--- godmode/modules/manage_network_components_form.php	(revision 10314)
9348
+++ godmode/modules/manage_network_components_form.php	(working copy)
9349
@@ -489,7 +489,7 @@
9350
 		$("input[name=snmp_community]").css({backgroundColor: '#ddd'});
9351
 		$("input[name=snmp_community]").attr("disabled",true);
9352
 	}
9353
-	else{
9354
+	else {
9355
 		$("input[name=snmp3_auth_user]").val("");
9356
 		$("input[name=snmp3_auth_user]").css({backgroundColor: '#ddd'});
9357
 		$("input[name=snmp3_auth_user]").attr("disabled", true);
9358
Index: godmode/reporting/reporting_builder.php
9359
===================================================================
9360
--- godmode/reporting/reporting_builder.php	(revision 10314)
9361
+++ godmode/reporting/reporting_builder.php	(working copy)
9362
@@ -66,12 +66,12 @@
9363
 		'args' => serialize ($parameters),
9364
 		'scheduled' => $scheduled,
9365
 		'flag_delete' => 1);
9366
-
9367
+	
9368
 	$result = db_process_sql_insert('tuser_task_scheduled', $values);
9369
 	
9370
 	ui_print_result_message ($result,
9371
-				__('Your report has been planned, and the system will email you a PDF with the report as soon as its finished'),
9372
-				__('An error has ocurred'));
9373
+		__('Your report has been planned, and the system will email you a PDF with the report as soon as its finished'),
9374
+		__('An error has ocurred'));
9375
 	echo '<br>';
9376
 }
9377
 
9378
@@ -451,10 +451,13 @@
9379
 					$data[2] = '<a href="' . $config['homeurl'] . 'index.php?sec=reporting&sec2=operation/reporting/reporting_viewer&id='.$report['id_report'].'&pure='.$pure.'">' .
9380
 						html_print_image("images/html.png", true, array('title' => __('HTML view'))) . '</a>';
9381
 					$data[3] = '<a href="'. ui_get_full_url(false, false, false, false) . 'ajax.php?page=' . $config['homedir'] . '/operation/reporting/reporting_xml&id='.$report['id_report'].'">' . html_print_image("images/xml.png", true, array('title' => __('Export to XML'))) . '</a>'; //I chose ajax.php because it's supposed to give XML anyway
9382
-				} else {
9383
-					$data[2] =  html_print_image("images/html_disabled.png", true);
9384
-					$data[3] =  html_print_image("images/xml_disabled.png", true);
9385
 				}
9386
+				else {
9387
+					$data[2] = html_print_image(
9388
+						"images/html_disabled.png", true);
9389
+					$data[3] = html_print_image(
9390
+						"images/xml_disabled.png", true);
9391
+				}
9392
 				
9393
 				
9394
 				//Calculate dinamically the number of the column
9395
@@ -475,7 +478,8 @@
9396
 					$next++;
9397
 					
9398
 					
9399
-					$data[$next] = ui_print_group_icon($report['id_group'], true, "groups_small", '', !defined('METACONSOLE')); 
9400
+					$data[$next] = ui_print_group_icon(
9401
+						$report['id_group'], true, "groups_small", '', !defined('METACONSOLE')); 
9402
 					$next++;
9403
 				}
9404
 				
9405
@@ -801,7 +805,7 @@
9406
 						else
9407
 							$values['id_agent_module'] = get_parameter('id_agent_module');
9408
 						
9409
-						$values['only_display_wrong'] = get_parameter('checkbox_only_display_wrong');
9410
+						$values['only_display_wrong'] = (int)get_parameter('checkbox_only_display_wrong', 0);
9411
 						$values['monday'] = get_parameter('monday', 0);
9412
 						$values['tuesday'] = get_parameter('tuesday', 0);
9413
 						$values['wednesday'] = get_parameter('wednesday', 0);
9414
@@ -814,7 +818,7 @@
9415
 						$values['group_by_agent'] = get_parameter ('checkbox_row_group_by_agent');
9416
 						$values['show_resume'] = get_parameter ('checkbox_show_resume');
9417
 						$values['order_uptodown'] = get_parameter ('radiobutton_order_uptodown');
9418
-						$values['exception_condition'] = get_parameter('exception_condition');
9419
+						$values['exception_condition'] = (int)get_parameter('exception_condition', 0);
9420
 						$values['exception_condition_value'] = get_parameter('exception_condition_value');
9421
 						$values['show_graph'] = get_parameter('combo_graph_options');
9422
 						$values['id_module_group'] = get_parameter('combo_modulegroup');
9423
@@ -916,7 +920,7 @@
9424
 						if ($good_format) {
9425
 							$resultOperationDB = db_process_sql_update('treport_content', $values, array('id_rc' => $idItem));
9426
 						}
9427
-						else{
9428
+						else {
9429
 							$resultOperationDB = false;
9430
 						}
9431
 						break;
9432
@@ -926,6 +930,7 @@
9433
 						$values['type'] = get_parameter('type', null);
9434
 						$values['name'] = (string) get_parameter('name');
9435
 						$values['description'] = get_parameter('description');
9436
+						
9437
 						// Support for projection graph, prediction date and SLA reports
9438
 						// 'top_n_value', 'top_n' and 'text' fields will be reused for these types of report
9439
 						switch ($values['type']) {
9440
@@ -1007,15 +1012,15 @@
9441
 						switch ($config['dbtype']) {
9442
 							case "mysql":
9443
 							case "postgresql":
9444
-								$values['only_display_wrong'] = get_parameter('checkbox_only_display_wrong');
9445
+								$values['only_display_wrong'] = (int)get_parameter('checkbox_only_display_wrong', 0);
9446
 								break;
9447
 							case "oracle":
9448
 								$only_display_wrong_tmp = get_parameter('checkbox_only_display_wrong');
9449
 								if (empty($only_display_wrong_tmp)) {
9450
 									$values['only_display_wrong'] = 0;
9451
 								}
9452
-								else{
9453
-									$values['only_display_wrong'] = $only_display_wrong_tmp;					
9454
+								else {
9455
+									$values['only_display_wrong'] = $only_display_wrong_tmp;
9456
 								}
9457
 								break;
9458
 						}
9459
@@ -1040,7 +1045,7 @@
9460
 						$values['group_by_agent'] = get_parameter ('checkbox_row_group_by_agent',0);
9461
 						$values['show_resume'] = get_parameter ('checkbox_show_resume',0);
9462
 						$values['order_uptodown'] = get_parameter ('radiobutton_order_uptodown',0);
9463
-						$values['exception_condition'] = get_parameter('radiobutton_exception_condition');
9464
+						$values['exception_condition'] = (int)get_parameter('radiobutton_exception_condition', 0);
9465
 						$values['exception_condition_value'] = get_parameter('exception_condition_value');
9466
 						$values['show_graph'] = get_parameter('combo_graph_options');
9467
 						$values['id_module_group'] = get_parameter('combo_modulegroup');
9468
@@ -1391,11 +1396,17 @@
9469
 			default:
9470
 				switch ($config["dbtype"]) {
9471
 					case "mysql":
9472
-						$oldOrder = db_get_value_sql('SELECT `order` FROM treport_content WHERE id_rc = ' . $idItem);
9473
+						$oldOrder = db_get_value_sql('
9474
+							SELECT `order`
9475
+							FROM treport_content
9476
+							WHERE id_rc = ' . $idItem);
9477
 						break;
9478
 					case "postgresql":
9479
 					case "oracle":
9480
-						$oldOrder = db_get_value_sql('SELECT "order" FROM treport_content WHERE id_rc = ' . $idItem);
9481
+						$oldOrder = db_get_value_sql('
9482
+							SELECT "order"
9483
+							FROM treport_content
9484
+							WHERE id_rc = ' . $idItem);
9485
 						break;
9486
 				}
9487
 				//db_get_value_filter('order', 'treport_content', array('id_rc' => $idItem));
9488
@@ -1413,17 +1424,20 @@
9489
 					case "mysql":
9490
 						$resultOperationDB = db_process_sql_update('treport_content',
9491
 							array('`order`' => $oldOrder),
9492
-							array('`order`' => $newOrder, 'id_report' => $idReport));
9493
+							array('`order`' => $newOrder,
9494
+								'id_report' => $idReport));
9495
 						break;
9496
 					case "postgresql":
9497
 						$resultOperationDB = db_process_sql_update('treport_content',
9498
 							array('"order"' => $oldOrder),
9499
-							array('"order"' => $newOrder, 'id_report' => $idReport));
9500
+							array('"order"' => $newOrder,
9501
+								'id_report' => $idReport));
9502
 						break;
9503
 					case "oracle":
9504
 						$resultOperationDB = db_process_sql_update('treport_content',
9505
 							array('"order"' => $oldOrder),
9506
-							array('"order"' => $newOrder, 'id_report' => $idReport),
9507
+							array('"order"' => $newOrder,
9508
+								'id_report' => $idReport),
9509
 							'AND', false);
9510
 						break;
9511
 				}
9512
@@ -1505,7 +1519,7 @@
9513
 		$resultOperationDB = $result;
9514
 	}
9515
 }
9516
-			
9517
+
9518
 $buttons = array(
9519
 	'list_reports' => array('active' => false,
9520
 		'text' => '<a href="index.php?sec=reporting&sec2=godmode/reporting/reporting_builder&pure='.$pure.'">' . 
9521
@@ -1545,15 +1559,21 @@
9522
 // Page header for metaconsole
9523
 if ($enterpriseEnable and defined('METACONSOLE')) {
9524
 	// Bread crumbs
9525
-	ui_meta_add_breadcrumb(array('link' => 'index.php?sec=reporting&sec2=godmode/reporting/reporting_builder&pure='.$pure, 'text' => __('Reporting')));
9526
+	ui_meta_add_breadcrumb(
9527
+		array('link' =>
9528
+			'index.php?sec=reporting&sec2=godmode/reporting/reporting_builder&pure=' . $pure,
9529
+		'text' => __('Reporting')));
9530
 	
9531
 	ui_meta_print_page_header($nav_bar);
9532
 	
9533
 	// Print header
9534
 	ui_meta_print_header(__('Reporting'). $textReportName, "", $buttons);
9535
 }
9536
-else
9537
-	ui_print_page_header(__('Reporting') . $textReportName, "images/op_reporting.png", false, "reporting_" . $activeTab . "_tab", false, $buttons);
9538
+else {
9539
+	ui_print_page_header(__('Reporting') . $textReportName,
9540
+		"images/op_reporting.png", false,
9541
+		"reporting_" . $activeTab . "_tab", false, $buttons);
9542
+}
9543
 
9544
 enterprise_hook('open_meta_frame');
9545
 
9546
@@ -1563,13 +1583,16 @@
9547
 
9548
 switch ($activeTab) {
9549
 	case 'main':
9550
-		require_once($config['homedir'] . '/godmode/reporting/reporting_builder.main.php');
9551
+		require_once($config['homedir'] .
9552
+			'/godmode/reporting/reporting_builder.main.php');
9553
 		break;
9554
 	case 'list_items':
9555
-		require_once($config['homedir'] . '/godmode/reporting/reporting_builder.list_items.php');
9556
+		require_once($config['homedir'] .
9557
+			'/godmode/reporting/reporting_builder.list_items.php');
9558
 		break;
9559
 	case 'item_editor':
9560
-		require_once($config['homedir'] . '/godmode/reporting/reporting_builder.item_editor.php');
9561
+		require_once($config['homedir'] .
9562
+			'/godmode/reporting/reporting_builder.item_editor.php');
9563
 		break;
9564
 	default:
9565
 		reporting_enterprise_select_tab($activeTab);
9566
Index: godmode/reporting/map_builder.php
9567
===================================================================
9568
--- godmode/reporting/map_builder.php	(revision 10314)
9569
+++ godmode/reporting/map_builder.php	(working copy)
9570
@@ -125,7 +125,7 @@
9571
 				ui_print_error_message(__('Not copied. Error copying data'));
9572
 			}
9573
 		}
9574
-		else{
9575
+		else {
9576
 			// If the array is empty the copy is completed
9577
 			ui_print_success_message(__('Successfully copied'));
9578
 			db_clean_cache();
(-)b/net-mgmt/pandorafms_console/pkg-plist (-221 / +254 lines)
Lines 4-9 Link Here
4
@group www
4
@group www
5
@mode
5
@mode
6
%%WWWDIR%%/ajax.php
6
%%WWWDIR%%/ajax.php
7
%%WWWDIR%%/attachment/index.html
8
%%WWWDIR%%/attachment/mibs/index.html
9
%%WWWDIR%%/attachment/plugin/index.html
7
%%WWWDIR%%/COPYING
10
%%WWWDIR%%/COPYING
8
%%WWWDIR%%/extensions/agents_alerts.php
11
%%WWWDIR%%/extensions/agents_alerts.php
9
%%WWWDIR%%/extensions/agents_modules.php
12
%%WWWDIR%%/extensions/agents_modules.php
Lines 95-100 Link Here
95
%%WWWDIR%%/godmode/agentes/module_manager_editor_prediction.php
98
%%WWWDIR%%/godmode/agentes/module_manager_editor_prediction.php
96
%%WWWDIR%%/godmode/agentes/module_manager_editor_wmi.php
99
%%WWWDIR%%/godmode/agentes/module_manager_editor_wmi.php
97
%%WWWDIR%%/godmode/agentes/planned_downtime.editor.php
100
%%WWWDIR%%/godmode/agentes/planned_downtime.editor.php
101
%%WWWDIR%%/godmode/agentes/planned_downtime.export_csv.php
98
%%WWWDIR%%/godmode/agentes/planned_downtime.list.php
102
%%WWWDIR%%/godmode/agentes/planned_downtime.list.php
99
%%WWWDIR%%/godmode/alerts/alert_actions.php
103
%%WWWDIR%%/godmode/alerts/alert_actions.php
100
%%WWWDIR%%/godmode/alerts/alert_commands.php
104
%%WWWDIR%%/godmode/alerts/alert_commands.php
Lines 117-123 Link Here
117
%%WWWDIR%%/godmode/db/db_main.php
121
%%WWWDIR%%/godmode/db/db_main.php
118
%%WWWDIR%%/godmode/db/db_purge.php
122
%%WWWDIR%%/godmode/db/db_purge.php
119
%%WWWDIR%%/godmode/db/db_refine.php
123
%%WWWDIR%%/godmode/db/db_refine.php
120
%%WWWDIR%%/godmode/db/db_sanity.php
121
%%WWWDIR%%/godmode/events/custom_events.php
124
%%WWWDIR%%/godmode/events/custom_events.php
122
%%WWWDIR%%/godmode/events/event_edit_filter.php
125
%%WWWDIR%%/godmode/events/event_edit_filter.php
123
%%WWWDIR%%/godmode/events/event_filter.php
126
%%WWWDIR%%/godmode/events/event_filter.php
Lines 307-314 Link Here
307
%%WWWDIR%%/images/chart_curve_threshold.png
310
%%WWWDIR%%/images/chart_curve_threshold.png
308
%%WWWDIR%%/images/check-cross.png
311
%%WWWDIR%%/images/check-cross.png
309
%%WWWDIR%%/images/clean.png
312
%%WWWDIR%%/images/clean.png
313
%%WWWDIR%%/images/clippy/clippy.png
314
%%WWWDIR%%/images/clippy/easter_egg_00.png
315
%%WWWDIR%%/images/clippy/easter_egg_01.png
316
%%WWWDIR%%/images/clippy/easter_egg_02.png
317
%%WWWDIR%%/images/clippy/easter_egg_03.png
318
%%WWWDIR%%/images/clippy/easter_egg_04.png
319
%%WWWDIR%%/images/clippy_icon.png
310
%%WWWDIR%%/images/clock.png
320
%%WWWDIR%%/images/clock.png
311
%%WWWDIR%%/images/clock2.png
321
%%WWWDIR%%/images/clock2.png
322
%%WWWDIR%%/images/close_button_dialog.png
312
%%WWWDIR%%/images/cog.png
323
%%WWWDIR%%/images/cog.png
313
%%WWWDIR%%/images/cog_db.png
324
%%WWWDIR%%/images/cog_db.png
314
%%WWWDIR%%/images/cog_del.png
325
%%WWWDIR%%/images/cog_del.png
Lines 1114-1119 Link Here
1114
%%WWWDIR%%/images/printer.png
1125
%%WWWDIR%%/images/printer.png
1115
%%WWWDIR%%/images/profiles.png
1126
%%WWWDIR%%/images/profiles.png
1116
%%WWWDIR%%/images/qrcode_icon.jpg
1127
%%WWWDIR%%/images/qrcode_icon.jpg
1128
%%WWWDIR%%/images/radial_dynamic_network_icon.png
1117
%%WWWDIR%%/images/recon.png
1129
%%WWWDIR%%/images/recon.png
1118
%%WWWDIR%%/images/recon_icon.png
1130
%%WWWDIR%%/images/recon_icon.png
1119
%%WWWDIR%%/images/refresh.png
1131
%%WWWDIR%%/images/refresh.png
Lines 1357-1362 Link Here
1357
%%WWWDIR%%/images/wand.png
1369
%%WWWDIR%%/images/wand.png
1358
%%WWWDIR%%/images/wand_agent.png
1370
%%WWWDIR%%/images/wand_agent.png
1359
%%WWWDIR%%/images/wand_interfaces.png
1371
%%WWWDIR%%/images/wand_interfaces.png
1372
%%WWWDIR%%/images/wand_services.png
1360
%%WWWDIR%%/images/wand_sla.png
1373
%%WWWDIR%%/images/wand_sla.png
1361
%%WWWDIR%%/images/wand_snmp.png
1374
%%WWWDIR%%/images/wand_snmp.png
1362
%%WWWDIR%%/images/wand_wmi.png
1375
%%WWWDIR%%/images/wand_wmi.png
Lines 1378-1383 Link Here
1378
%%WWWDIR%%/include/ajax/agent.php
1391
%%WWWDIR%%/include/ajax/agent.php
1379
%%WWWDIR%%/include/ajax/alert_list.ajax.php
1392
%%WWWDIR%%/include/ajax/alert_list.ajax.php
1380
%%WWWDIR%%/include/ajax/events.php
1393
%%WWWDIR%%/include/ajax/events.php
1394
%%WWWDIR%%/include/ajax/graph.ajax.php
1381
%%WWWDIR%%/include/ajax/menu.ajax.php
1395
%%WWWDIR%%/include/ajax/menu.ajax.php
1382
%%WWWDIR%%/include/ajax/module.php
1396
%%WWWDIR%%/include/ajax/module.php
1383
%%WWWDIR%%/include/ajax/networkmap.ajax.php
1397
%%WWWDIR%%/include/ajax/networkmap.ajax.php
Lines 1439-1444 Link Here
1439
%%WWWDIR%%/include/functions_network_profiles.php
1453
%%WWWDIR%%/include/functions_network_profiles.php
1440
%%WWWDIR%%/include/functions_networkmap.php
1454
%%WWWDIR%%/include/functions_networkmap.php
1441
%%WWWDIR%%/include/functions_os.php
1455
%%WWWDIR%%/include/functions_os.php
1456
%%WWWDIR%%/include/functions_planned_downtimes.php
1442
%%WWWDIR%%/include/functions_profile.php
1457
%%WWWDIR%%/include/functions_profile.php
1443
%%WWWDIR%%/include/functions_reporting.php
1458
%%WWWDIR%%/include/functions_reporting.php
1444
%%WWWDIR%%/include/functions_reports.php
1459
%%WWWDIR%%/include/functions_reports.php
Lines 1510-1519 Link Here
1510
%%WWWDIR%%/include/graphs/pChart/palettes/spring.color
1525
%%WWWDIR%%/include/graphs/pChart/palettes/spring.color
1511
%%WWWDIR%%/include/graphs/pChart/palettes/summer.color
1526
%%WWWDIR%%/include/graphs/pChart/palettes/summer.color
1512
%%WWWDIR%%/include/graphs/pandora.d3.js
1527
%%WWWDIR%%/include/graphs/pandora.d3.js
1528
%%WWWDIR%%/include/help/clippy/agent_out_of_limits.php
1529
%%WWWDIR%%/include/help/clippy/extension_cron_send_email.php
1513
%%WWWDIR%%/include/help/clippy/godmode_agentes_configurar_agente.php
1530
%%WWWDIR%%/include/help/clippy/godmode_agentes_configurar_agente.php
1514
%%WWWDIR%%/include/help/clippy/godmode_agentes_modificar_agente.php
1531
%%WWWDIR%%/include/help/clippy/godmode_agentes_modificar_agente.php
1532
%%WWWDIR%%/include/help/clippy/godmode_alerts_alert_actions.php
1533
%%WWWDIR%%/include/help/clippy/godmode_alerts_configure_alert_action.php
1515
%%WWWDIR%%/include/help/clippy/homepage.php
1534
%%WWWDIR%%/include/help/clippy/homepage.php
1516
%%WWWDIR%%/include/help/clippy/module_unknow.php
1535
%%WWWDIR%%/include/help/clippy/module_unknow.php
1536
%%WWWDIR%%/include/help/clippy/modules_not_init.php
1537
%%WWWDIR%%/include/help/clippy/modules_not_learning_mode.php
1538
%%WWWDIR%%/include/help/clippy/operation_agentes_status_monitor.php
1539
%%WWWDIR%%/include/help/clippy/operation_agentes_ver_agente.php
1517
%%WWWDIR%%/include/help/en/help_action_threshold.php
1540
%%WWWDIR%%/include/help/en/help_action_threshold.php
1518
%%WWWDIR%%/include/help/en/help_agent_access.php
1541
%%WWWDIR%%/include/help/en/help_agent_access.php
1519
%%WWWDIR%%/include/help/en/help_agent_server.php
1542
%%WWWDIR%%/include/help/en/help_agent_server.php
Lines 1542-1547 Link Here
1542
%%WWWDIR%%/include/help/en/help_conf_alert_template.php
1565
%%WWWDIR%%/include/help/en/help_conf_alert_template.php
1543
%%WWWDIR%%/include/help/en/help_configure_gis_map.php
1566
%%WWWDIR%%/include/help/en/help_configure_gis_map.php
1544
%%WWWDIR%%/include/help/en/help_context_module_unknow.php
1567
%%WWWDIR%%/include/help/en/help_context_module_unknow.php
1568
%%WWWDIR%%/include/help/en/help_context_pandora_server_email.php
1545
%%WWWDIR%%/include/help/en/help_create_agent.php
1569
%%WWWDIR%%/include/help/en/help_create_agent.php
1546
%%WWWDIR%%/include/help/en/help_critical_status.php
1570
%%WWWDIR%%/include/help/en/help_critical_status.php
1547
%%WWWDIR%%/include/help/en/help_custom_logo.php
1571
%%WWWDIR%%/include/help/en/help_custom_logo.php
Lines 1590-1595 Link Here
1590
%%WWWDIR%%/include/help/en/help_pcap_filter.php
1614
%%WWWDIR%%/include/help/en/help_pcap_filter.php
1591
%%WWWDIR%%/include/help/en/help_performance.php
1615
%%WWWDIR%%/include/help/en/help_performance.php
1592
%%WWWDIR%%/include/help/en/help_planned_downtime.php
1616
%%WWWDIR%%/include/help/en/help_planned_downtime.php
1617
%%WWWDIR%%/include/help/en/help_planned_downtime_time.php
1593
%%WWWDIR%%/include/help/en/help_plugin_definition.php
1618
%%WWWDIR%%/include/help/en/help_plugin_definition.php
1594
%%WWWDIR%%/include/help/en/help_plugin_macros.php
1619
%%WWWDIR%%/include/help/en/help_plugin_macros.php
1595
%%WWWDIR%%/include/help/en/help_plugin_parameters.php
1620
%%WWWDIR%%/include/help/en/help_plugin_parameters.php
Lines 1601-1606 Link Here
1601
%%WWWDIR%%/include/help/en/help_prediction_source_module.php
1626
%%WWWDIR%%/include/help/en/help_prediction_source_module.php
1602
%%WWWDIR%%/include/help/en/help_profile.php
1627
%%WWWDIR%%/include/help/en/help_profile.php
1603
%%WWWDIR%%/include/help/en/help_projection_graph.php
1628
%%WWWDIR%%/include/help/en/help_projection_graph.php
1629
%%WWWDIR%%/include/help/en/help_propagate_acl.php
1604
%%WWWDIR%%/include/help/en/help_reconscript_definition.php
1630
%%WWWDIR%%/include/help/en/help_reconscript_definition.php
1605
%%WWWDIR%%/include/help/en/help_recontask.php
1631
%%WWWDIR%%/include/help/en/help_recontask.php
1606
%%WWWDIR%%/include/help/en/help_reporting_advanced_tab.php
1632
%%WWWDIR%%/include/help/en/help_reporting_advanced_tab.php
Lines 1722-1727 Link Here
1722
%%WWWDIR%%/include/help/es/help_pcap_filter.php
1748
%%WWWDIR%%/include/help/es/help_pcap_filter.php
1723
%%WWWDIR%%/include/help/es/help_performance.php
1749
%%WWWDIR%%/include/help/es/help_performance.php
1724
%%WWWDIR%%/include/help/es/help_planned_downtime.php
1750
%%WWWDIR%%/include/help/es/help_planned_downtime.php
1751
%%WWWDIR%%/include/help/es/help_planned_downtime_time.php
1725
%%WWWDIR%%/include/help/es/help_plugin_definition.php
1752
%%WWWDIR%%/include/help/es/help_plugin_definition.php
1726
%%WWWDIR%%/include/help/es/help_plugin_macros.php
1753
%%WWWDIR%%/include/help/es/help_plugin_macros.php
1727
%%WWWDIR%%/include/help/es/help_plugin_parameters.php
1754
%%WWWDIR%%/include/help/es/help_plugin_parameters.php
Lines 1733-1738 Link Here
1733
%%WWWDIR%%/include/help/es/help_prediction_source_module.php
1760
%%WWWDIR%%/include/help/es/help_prediction_source_module.php
1734
%%WWWDIR%%/include/help/es/help_profile.php
1761
%%WWWDIR%%/include/help/es/help_profile.php
1735
%%WWWDIR%%/include/help/es/help_projection_graph.php
1762
%%WWWDIR%%/include/help/es/help_projection_graph.php
1763
%%WWWDIR%%/include/help/es/help_propagate_acl.php
1736
%%WWWDIR%%/include/help/es/help_reconscript_definition.php
1764
%%WWWDIR%%/include/help/es/help_reconscript_definition.php
1737
%%WWWDIR%%/include/help/es/help_recontask.php
1765
%%WWWDIR%%/include/help/es/help_recontask.php
1738
%%WWWDIR%%/include/help/es/help_reporting_advanced_tab.php
1766
%%WWWDIR%%/include/help/es/help_reporting_advanced_tab.php
Lines 1805-1810 Link Here
1805
%%WWWDIR%%/include/help/ja/help_component_groups.php
1833
%%WWWDIR%%/include/help/ja/help_component_groups.php
1806
%%WWWDIR%%/include/help/ja/help_conf_alert_template.php
1834
%%WWWDIR%%/include/help/ja/help_conf_alert_template.php
1807
%%WWWDIR%%/include/help/ja/help_configure_gis_map.php
1835
%%WWWDIR%%/include/help/ja/help_configure_gis_map.php
1836
%%WWWDIR%%/include/help/ja/help_context_pandora_server_email.php
1808
%%WWWDIR%%/include/help/ja/help_create_agent.php
1837
%%WWWDIR%%/include/help/ja/help_create_agent.php
1809
%%WWWDIR%%/include/help/ja/help_critical_status.php
1838
%%WWWDIR%%/include/help/ja/help_critical_status.php
1810
%%WWWDIR%%/include/help/ja/help_custom_logo.php
1839
%%WWWDIR%%/include/help/ja/help_custom_logo.php
Lines 1863-1868 Link Here
1863
%%WWWDIR%%/include/help/ja/help_prediction_source_module.php
1892
%%WWWDIR%%/include/help/ja/help_prediction_source_module.php
1864
%%WWWDIR%%/include/help/ja/help_profile.php
1893
%%WWWDIR%%/include/help/ja/help_profile.php
1865
%%WWWDIR%%/include/help/ja/help_projection_graph.php
1894
%%WWWDIR%%/include/help/ja/help_projection_graph.php
1895
%%WWWDIR%%/include/help/ja/help_propagate_acl.php
1866
%%WWWDIR%%/include/help/ja/help_reconscript_definition.php
1896
%%WWWDIR%%/include/help/ja/help_reconscript_definition.php
1867
%%WWWDIR%%/include/help/ja/help_recontask.php
1897
%%WWWDIR%%/include/help/ja/help_recontask.php
1868
%%WWWDIR%%/include/help/ja/help_reporting_advanced_tab.php
1898
%%WWWDIR%%/include/help/ja/help_reporting_advanced_tab.php
Lines 2514-2519 Link Here
2514
%%WWWDIR%%/include/languages/util-update-po
2544
%%WWWDIR%%/include/languages/util-update-po
2515
%%WWWDIR%%/include/languages/zh_CN.mo
2545
%%WWWDIR%%/include/languages/zh_CN.mo
2516
%%WWWDIR%%/include/languages/zh_CN.po
2546
%%WWWDIR%%/include/languages/zh_CN.po
2547
%%WWWDIR%%/include/languages/zh_TW.mo
2548
%%WWWDIR%%/include/languages/zh_TW.po
2517
%%WWWDIR%%/include/php_to_js_values.php
2549
%%WWWDIR%%/include/php_to_js_values.php
2518
%%WWWDIR%%/include/sounds/Door_Alarm.wav
2550
%%WWWDIR%%/include/sounds/Door_Alarm.wav
2519
%%WWWDIR%%/include/sounds/EAS_beep.wav
2551
%%WWWDIR%%/include/sounds/EAS_beep.wav
Lines 2798-2803 Link Here
2798
%%WWWDIR%%/operation/agentes/gis_view.php
2830
%%WWWDIR%%/operation/agentes/gis_view.php
2799
%%WWWDIR%%/operation/agentes/graphs.php
2831
%%WWWDIR%%/operation/agentes/graphs.php
2800
%%WWWDIR%%/operation/agentes/group_view.php
2832
%%WWWDIR%%/operation/agentes/group_view.php
2833
%%WWWDIR%%/operation/agentes/interface_traffic_graph_win.php
2801
%%WWWDIR%%/operation/agentes/networkmap.dinamic.php
2834
%%WWWDIR%%/operation/agentes/networkmap.dinamic.php
2802
%%WWWDIR%%/operation/agentes/networkmap.groups.php
2835
%%WWWDIR%%/operation/agentes/networkmap.groups.php
2803
%%WWWDIR%%/operation/agentes/networkmap.php
2836
%%WWWDIR%%/operation/agentes/networkmap.php
Lines 2834-2840 Link Here
2834
%%WWWDIR%%/operation/integria_incidents/incident.php
2867
%%WWWDIR%%/operation/integria_incidents/incident.php
2835
%%WWWDIR%%/operation/integria_incidents/incident.tracking.php
2868
%%WWWDIR%%/operation/integria_incidents/incident.tracking.php
2836
%%WWWDIR%%/operation/integria_incidents/incident.workunits.php
2869
%%WWWDIR%%/operation/integria_incidents/incident.workunits.php
2837
%%WWWDIR%%/operation/integria_incidents/incident_detail.php
2838
%%WWWDIR%%/operation/integria_incidents/incident_statistics.php
2870
%%WWWDIR%%/operation/integria_incidents/incident_statistics.php
2839
%%WWWDIR%%/operation/menu.php
2871
%%WWWDIR%%/operation/menu.php
2840
%%WWWDIR%%/operation/messages/message_edit.php
2872
%%WWWDIR%%/operation/messages/message_edit.php
Lines 2850-2855 Link Here
2850
%%WWWDIR%%/operation/search_alerts.php
2882
%%WWWDIR%%/operation/search_alerts.php
2851
%%WWWDIR%%/operation/search_graphs.getdata.php
2883
%%WWWDIR%%/operation/search_graphs.getdata.php
2852
%%WWWDIR%%/operation/search_graphs.php
2884
%%WWWDIR%%/operation/search_graphs.php
2885
%%WWWDIR%%/operation/search_helps.getdata.php
2886
%%WWWDIR%%/operation/search_helps.php
2853
%%WWWDIR%%/operation/search_main.php
2887
%%WWWDIR%%/operation/search_main.php
2854
%%WWWDIR%%/operation/search_maps.getdata.php
2888
%%WWWDIR%%/operation/search_maps.getdata.php
2855
%%WWWDIR%%/operation/search_maps.php
2889
%%WWWDIR%%/operation/search_maps.php
Lines 2863-2868 Link Here
2863
%%WWWDIR%%/operation/servers/recon_view.php
2897
%%WWWDIR%%/operation/servers/recon_view.php
2864
%%WWWDIR%%/operation/snmpconsole/snmp_browser.php
2898
%%WWWDIR%%/operation/snmpconsole/snmp_browser.php
2865
%%WWWDIR%%/operation/snmpconsole/snmp_mib_uploader.php
2899
%%WWWDIR%%/operation/snmpconsole/snmp_mib_uploader.php
2900
%%WWWDIR%%/operation/snmpconsole/snmp_statistics.php
2866
%%WWWDIR%%/operation/snmpconsole/snmp_view.php
2901
%%WWWDIR%%/operation/snmpconsole/snmp_view.php
2867
%%WWWDIR%%/operation/system_alert.php
2902
%%WWWDIR%%/operation/system_alert.php
2868
%%WWWDIR%%/operation/tree.php
2903
%%WWWDIR%%/operation/tree.php
Lines 2890-3082 Link Here
2890
%%WWWDIR%%/pandoradb.postgreSQL.sql
2925
%%WWWDIR%%/pandoradb.postgreSQL.sql
2891
%%WWWDIR%%/pandoradb.sql
2926
%%WWWDIR%%/pandoradb.sql
2892
%%WWWDIR%%/pandoradb_data.sql
2927
%%WWWDIR%%/pandoradb_data.sql
2893
@dirrm %%WWWDIR%%/operation/visual_console
2928
@dir %%WWWDIR%%/operation/visual_console
2894
@dirrm %%WWWDIR%%/operation/users
2929
@dir %%WWWDIR%%/operation/users
2895
@dirrm %%WWWDIR%%/operation/tree
2930
@dir %%WWWDIR%%/operation/tree
2896
@dirrm %%WWWDIR%%/operation/snmpconsole
2931
@dir %%WWWDIR%%/operation/snmpconsole
2897
@dirrm %%WWWDIR%%/operation/servers
2932
@dir %%WWWDIR%%/operation/servers
2898
@dirrm %%WWWDIR%%/operation/reporting
2933
@dir %%WWWDIR%%/operation/reporting
2899
@dirrm %%WWWDIR%%/operation/netflow
2934
@dir %%WWWDIR%%/operation/netflow
2900
@dirrm %%WWWDIR%%/operation/messages
2935
@dir %%WWWDIR%%/operation/messages
2901
@dirrm %%WWWDIR%%/operation/integria_incidents
2936
@dir %%WWWDIR%%/operation/integria_incidents
2902
@dirrm %%WWWDIR%%/operation/incidents
2937
@dir %%WWWDIR%%/operation/incidents
2903
@dirrm %%WWWDIR%%/operation/gis_maps
2938
@dir %%WWWDIR%%/operation/gis_maps
2904
@dirrm %%WWWDIR%%/operation/events
2939
@dir %%WWWDIR%%/operation/events
2905
@dirrm %%WWWDIR%%/operation/agentes
2940
@dir %%WWWDIR%%/operation/agentes
2906
@dirrm %%WWWDIR%%/operation
2941
@dir %%WWWDIR%%/operation
2907
@dirrm %%WWWDIR%%/mobile/operation
2942
@dir %%WWWDIR%%/mobile/operation
2908
@dirrm %%WWWDIR%%/mobile/include/style/images
2943
@dir %%WWWDIR%%/mobile/include/style/images
2909
@dirrm %%WWWDIR%%/mobile/include/style
2944
@dir %%WWWDIR%%/mobile/include/style
2910
@dirrm %%WWWDIR%%/mobile/include/javascript
2945
@dir %%WWWDIR%%/mobile/include/javascript
2911
@dirrm %%WWWDIR%%/mobile/include
2946
@dir %%WWWDIR%%/mobile/include
2912
@dirrm %%WWWDIR%%/mobile/images
2947
@dir %%WWWDIR%%/mobile/images
2913
@dirrm %%WWWDIR%%/mobile
2948
@dir %%WWWDIR%%/mobile
2914
@dirrm %%WWWDIR%%/include/swiftmailer/dependency_maps
2949
@dir %%WWWDIR%%/include/swiftmailer/dependency_maps
2915
@dirrm %%WWWDIR%%/include/swiftmailer/classes/Swift/Transport/Esmtp/Auth
2950
@dir %%WWWDIR%%/include/swiftmailer/classes/Swift/Transport/Esmtp/Auth
2916
@dirrm %%WWWDIR%%/include/swiftmailer/classes/Swift/Transport/Esmtp
2951
@dir %%WWWDIR%%/include/swiftmailer/classes/Swift/Transport/Esmtp
2917
@dirrm %%WWWDIR%%/include/swiftmailer/classes/Swift/Transport
2952
@dir %%WWWDIR%%/include/swiftmailer/classes/Swift/Transport
2918
@dirrm %%WWWDIR%%/include/swiftmailer/classes/Swift/StreamFilters
2953
@dir %%WWWDIR%%/include/swiftmailer/classes/Swift/StreamFilters
2919
@dirrm %%WWWDIR%%/include/swiftmailer/classes/Swift/Plugins/Reporters
2954
@dir %%WWWDIR%%/include/swiftmailer/classes/Swift/Plugins/Reporters
2920
@dirrm %%WWWDIR%%/include/swiftmailer/classes/Swift/Plugins/Pop
2955
@dir %%WWWDIR%%/include/swiftmailer/classes/Swift/Plugins/Pop
2921
@dirrm %%WWWDIR%%/include/swiftmailer/classes/Swift/Plugins/Loggers
2956
@dir %%WWWDIR%%/include/swiftmailer/classes/Swift/Plugins/Loggers
2922
@dirrm %%WWWDIR%%/include/swiftmailer/classes/Swift/Plugins/Decorator
2957
@dir %%WWWDIR%%/include/swiftmailer/classes/Swift/Plugins/Decorator
2923
@dirrm %%WWWDIR%%/include/swiftmailer/classes/Swift/Plugins
2958
@dir %%WWWDIR%%/include/swiftmailer/classes/Swift/Plugins
2924
@dirrm %%WWWDIR%%/include/swiftmailer/classes/Swift/Mime/Headers
2959
@dir %%WWWDIR%%/include/swiftmailer/classes/Swift/Mime/Headers
2925
@dirrm %%WWWDIR%%/include/swiftmailer/classes/Swift/Mime/HeaderEncoder
2960
@dir %%WWWDIR%%/include/swiftmailer/classes/Swift/Mime/HeaderEncoder
2926
@dirrm %%WWWDIR%%/include/swiftmailer/classes/Swift/Mime/ContentEncoder
2961
@dir %%WWWDIR%%/include/swiftmailer/classes/Swift/Mime/ContentEncoder
2927
@dirrm %%WWWDIR%%/include/swiftmailer/classes/Swift/Mime
2962
@dir %%WWWDIR%%/include/swiftmailer/classes/Swift/Mime
2928
@dirrm %%WWWDIR%%/include/swiftmailer/classes/Swift/Mailer
2963
@dir %%WWWDIR%%/include/swiftmailer/classes/Swift/Mailer
2929
@dirrm %%WWWDIR%%/include/swiftmailer/classes/Swift/KeyCache
2964
@dir %%WWWDIR%%/include/swiftmailer/classes/Swift/KeyCache
2930
@dirrm %%WWWDIR%%/include/swiftmailer/classes/Swift/Events
2965
@dir %%WWWDIR%%/include/swiftmailer/classes/Swift/Events
2931
@dirrm %%WWWDIR%%/include/swiftmailer/classes/Swift/Encoder
2966
@dir %%WWWDIR%%/include/swiftmailer/classes/Swift/Encoder
2932
@dirrm %%WWWDIR%%/include/swiftmailer/classes/Swift/CharacterStream
2967
@dir %%WWWDIR%%/include/swiftmailer/classes/Swift/CharacterStream
2933
@dirrm %%WWWDIR%%/include/swiftmailer/classes/Swift/CharacterReaderFactory
2968
@dir %%WWWDIR%%/include/swiftmailer/classes/Swift/CharacterReaderFactory
2934
@dirrm %%WWWDIR%%/include/swiftmailer/classes/Swift/CharacterReader
2969
@dir %%WWWDIR%%/include/swiftmailer/classes/Swift/CharacterReader
2935
@dirrm %%WWWDIR%%/include/swiftmailer/classes/Swift/ByteStream
2970
@dir %%WWWDIR%%/include/swiftmailer/classes/Swift/ByteStream
2936
@dirrm %%WWWDIR%%/include/swiftmailer/classes/Swift
2971
@dir %%WWWDIR%%/include/swiftmailer/classes/Swift
2937
@dirrm %%WWWDIR%%/include/swiftmailer/classes
2972
@dir %%WWWDIR%%/include/swiftmailer/classes
2938
@dirrm %%WWWDIR%%/include/swiftmailer
2973
@dir %%WWWDIR%%/include/swiftmailer
2939
@dirrm %%WWWDIR%%/include/styles/images
2974
@dir %%WWWDIR%%/include/styles/images
2940
@dirrm %%WWWDIR%%/include/styles
2975
@dir %%WWWDIR%%/include/styles
2941
@dirrm %%WWWDIR%%/include/sounds
2976
@dir %%WWWDIR%%/include/sounds
2942
@dirrm %%WWWDIR%%/include/languages/datepicker
2977
@dir %%WWWDIR%%/include/languages/datepicker
2943
@dirrm %%WWWDIR%%/include/languages
2978
@dir %%WWWDIR%%/include/languages
2944
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/utils
2979
@dir %%WWWDIR%%/include/javascript/tiny_mce/utils
2945
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/themes/simple/skins/o2k7/img
2980
@dir %%WWWDIR%%/include/javascript/tiny_mce/themes/simple/skins/o2k7/img
2946
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/themes/simple/skins/o2k7
2981
@dir %%WWWDIR%%/include/javascript/tiny_mce/themes/simple/skins/o2k7
2947
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/themes/simple/skins/default
2982
@dir %%WWWDIR%%/include/javascript/tiny_mce/themes/simple/skins/default
2948
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/themes/simple/skins
2983
@dir %%WWWDIR%%/include/javascript/tiny_mce/themes/simple/skins
2949
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/themes/simple/langs
2984
@dir %%WWWDIR%%/include/javascript/tiny_mce/themes/simple/langs
2950
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/themes/simple/img
2985
@dir %%WWWDIR%%/include/javascript/tiny_mce/themes/simple/img
2951
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/themes/simple
2986
@dir %%WWWDIR%%/include/javascript/tiny_mce/themes/simple
2952
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/themes/advanced/skins/o2k7/img
2987
@dir %%WWWDIR%%/include/javascript/tiny_mce/themes/advanced/skins/o2k7/img
2953
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/themes/advanced/skins/o2k7
2988
@dir %%WWWDIR%%/include/javascript/tiny_mce/themes/advanced/skins/o2k7
2954
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/themes/advanced/skins/highcontrast
2989
@dir %%WWWDIR%%/include/javascript/tiny_mce/themes/advanced/skins/highcontrast
2955
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/themes/advanced/skins/default/img
2990
@dir %%WWWDIR%%/include/javascript/tiny_mce/themes/advanced/skins/default/img
2956
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/themes/advanced/skins/default
2991
@dir %%WWWDIR%%/include/javascript/tiny_mce/themes/advanced/skins/default
2957
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/themes/advanced/skins
2992
@dir %%WWWDIR%%/include/javascript/tiny_mce/themes/advanced/skins
2958
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/themes/advanced/langs
2993
@dir %%WWWDIR%%/include/javascript/tiny_mce/themes/advanced/langs
2959
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/themes/advanced/js
2994
@dir %%WWWDIR%%/include/javascript/tiny_mce/themes/advanced/js
2960
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/themes/advanced/img
2995
@dir %%WWWDIR%%/include/javascript/tiny_mce/themes/advanced/img
2961
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/themes/advanced
2996
@dir %%WWWDIR%%/include/javascript/tiny_mce/themes/advanced
2962
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/themes
2997
@dir %%WWWDIR%%/include/javascript/tiny_mce/themes
2963
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/plugins/xhtmlxtras/langs
2998
@dir %%WWWDIR%%/include/javascript/tiny_mce/plugins/xhtmlxtras/langs
2964
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/plugins/xhtmlxtras/js
2999
@dir %%WWWDIR%%/include/javascript/tiny_mce/plugins/xhtmlxtras/js
2965
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/plugins/xhtmlxtras/css
3000
@dir %%WWWDIR%%/include/javascript/tiny_mce/plugins/xhtmlxtras/css
2966
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/plugins/xhtmlxtras
3001
@dir %%WWWDIR%%/include/javascript/tiny_mce/plugins/xhtmlxtras
2967
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/plugins/wordcount
3002
@dir %%WWWDIR%%/include/javascript/tiny_mce/plugins/wordcount
2968
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/plugins/visualchars
3003
@dir %%WWWDIR%%/include/javascript/tiny_mce/plugins/visualchars
2969
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/plugins/visualblocks/css
3004
@dir %%WWWDIR%%/include/javascript/tiny_mce/plugins/visualblocks/css
2970
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/plugins/visualblocks
3005
@dir %%WWWDIR%%/include/javascript/tiny_mce/plugins/visualblocks
2971
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/plugins/template/langs
3006
@dir %%WWWDIR%%/include/javascript/tiny_mce/plugins/template/langs
2972
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/plugins/template/js
3007
@dir %%WWWDIR%%/include/javascript/tiny_mce/plugins/template/js
2973
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/plugins/template/css
3008
@dir %%WWWDIR%%/include/javascript/tiny_mce/plugins/template/css
2974
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/plugins/template
3009
@dir %%WWWDIR%%/include/javascript/tiny_mce/plugins/template
2975
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/plugins/table/langs
3010
@dir %%WWWDIR%%/include/javascript/tiny_mce/plugins/table/langs
2976
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/plugins/table/js
3011
@dir %%WWWDIR%%/include/javascript/tiny_mce/plugins/table/js
2977
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/plugins/table/css
3012
@dir %%WWWDIR%%/include/javascript/tiny_mce/plugins/table/css
2978
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/plugins/table
3013
@dir %%WWWDIR%%/include/javascript/tiny_mce/plugins/table
2979
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/plugins/tabfocus
3014
@dir %%WWWDIR%%/include/javascript/tiny_mce/plugins/tabfocus
2980
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/plugins/style/langs
3015
@dir %%WWWDIR%%/include/javascript/tiny_mce/plugins/style/langs
2981
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/plugins/style/js
3016
@dir %%WWWDIR%%/include/javascript/tiny_mce/plugins/style/js
2982
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/plugins/style/css
3017
@dir %%WWWDIR%%/include/javascript/tiny_mce/plugins/style/css
2983
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/plugins/style
3018
@dir %%WWWDIR%%/include/javascript/tiny_mce/plugins/style
2984
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/plugins/spellchecker/includes
3019
@dir %%WWWDIR%%/include/javascript/tiny_mce/plugins/spellchecker/img
2985
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/plugins/spellchecker/img
3020
@dir %%WWWDIR%%/include/javascript/tiny_mce/plugins/spellchecker/css
2986
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/plugins/spellchecker/css
3021
@dir %%WWWDIR%%/include/javascript/tiny_mce/plugins/spellchecker
2987
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/plugins/spellchecker/classes/utils
3022
@dir %%WWWDIR%%/include/javascript/tiny_mce/plugins/searchreplace/langs
2988
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/plugins/spellchecker/classes
3023
@dir %%WWWDIR%%/include/javascript/tiny_mce/plugins/searchreplace/js
2989
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/plugins/spellchecker
3024
@dir %%WWWDIR%%/include/javascript/tiny_mce/plugins/searchreplace/css
2990
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/plugins/searchreplace/langs
3025
@dir %%WWWDIR%%/include/javascript/tiny_mce/plugins/searchreplace
2991
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/plugins/searchreplace/js
3026
@dir %%WWWDIR%%/include/javascript/tiny_mce/plugins/save
2992
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/plugins/searchreplace/css
3027
@dir %%WWWDIR%%/include/javascript/tiny_mce/plugins/print
2993
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/plugins/searchreplace
3028
@dir %%WWWDIR%%/include/javascript/tiny_mce/plugins/preview/jscripts
2994
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/plugins/save
3029
@dir %%WWWDIR%%/include/javascript/tiny_mce/plugins/preview
2995
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/plugins/print
3030
@dir %%WWWDIR%%/include/javascript/tiny_mce/plugins/paste/langs
2996
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/plugins/preview/jscripts
3031
@dir %%WWWDIR%%/include/javascript/tiny_mce/plugins/paste/js
2997
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/plugins/preview
3032
@dir %%WWWDIR%%/include/javascript/tiny_mce/plugins/paste
2998
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/plugins/paste/langs
3033
@dir %%WWWDIR%%/include/javascript/tiny_mce/plugins/pagebreak
2999
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/plugins/paste/js
3034
@dir %%WWWDIR%%/include/javascript/tiny_mce/plugins/noneditable
3000
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/plugins/paste
3035
@dir %%WWWDIR%%/include/javascript/tiny_mce/plugins/nonbreaking
3001
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/plugins/pagebreak
3036
@dir %%WWWDIR%%/include/javascript/tiny_mce/plugins/media/langs
3002
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/plugins/noneditable
3037
@dir %%WWWDIR%%/include/javascript/tiny_mce/plugins/media/js
3003
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/plugins/nonbreaking
3038
@dir %%WWWDIR%%/include/javascript/tiny_mce/plugins/media/css
3004
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/plugins/media/langs
3039
@dir %%WWWDIR%%/include/javascript/tiny_mce/plugins/media
3005
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/plugins/media/js
3040
@dir %%WWWDIR%%/include/javascript/tiny_mce/plugins/lists
3006
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/plugins/media/css
3041
@dir %%WWWDIR%%/include/javascript/tiny_mce/plugins/legacyoutput
3007
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/plugins/media
3042
@dir %%WWWDIR%%/include/javascript/tiny_mce/plugins/layer
3008
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/plugins/lists
3043
@dir %%WWWDIR%%/include/javascript/tiny_mce/plugins/insertdatetime
3009
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/plugins/legacyoutput
3044
@dir %%WWWDIR%%/include/javascript/tiny_mce/plugins/inlinepopups/skins/clearlooks2/img
3010
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/plugins/layer
3045
@dir %%WWWDIR%%/include/javascript/tiny_mce/plugins/inlinepopups/skins/clearlooks2
3011
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/plugins/insertdatetime
3046
@dir %%WWWDIR%%/include/javascript/tiny_mce/plugins/inlinepopups/skins
3012
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/plugins/inlinepopups/skins/clearlooks2/img
3047
@dir %%WWWDIR%%/include/javascript/tiny_mce/plugins/inlinepopups
3013
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/plugins/inlinepopups/skins/clearlooks2
3048
@dir %%WWWDIR%%/include/javascript/tiny_mce/plugins/iespell
3014
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/plugins/inlinepopups/skins
3049
@dir %%WWWDIR%%/include/javascript/tiny_mce/plugins/fullscreen
3015
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/plugins/inlinepopups
3050
@dir %%WWWDIR%%/include/javascript/tiny_mce/plugins/fullpage/langs
3016
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/plugins/iespell
3051
@dir %%WWWDIR%%/include/javascript/tiny_mce/plugins/fullpage/js
3017
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/plugins/fullscreen
3052
@dir %%WWWDIR%%/include/javascript/tiny_mce/plugins/fullpage/css
3018
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/plugins/fullpage/langs
3053
@dir %%WWWDIR%%/include/javascript/tiny_mce/plugins/fullpage
3019
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/plugins/fullpage/js
3054
@dir %%WWWDIR%%/include/javascript/tiny_mce/plugins/example_dependency
3020
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/plugins/fullpage/css
3055
@dir %%WWWDIR%%/include/javascript/tiny_mce/plugins/example/langs
3021
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/plugins/fullpage
3056
@dir %%WWWDIR%%/include/javascript/tiny_mce/plugins/example/js
3022
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/plugins/example_dependency
3057
@dir %%WWWDIR%%/include/javascript/tiny_mce/plugins/example/img
3023
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/plugins/example/langs
3058
@dir %%WWWDIR%%/include/javascript/tiny_mce/plugins/example
3024
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/plugins/example/js
3059
@dir %%WWWDIR%%/include/javascript/tiny_mce/plugins/emotions/langs
3025
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/plugins/example/img
3060
@dir %%WWWDIR%%/include/javascript/tiny_mce/plugins/emotions/js
3026
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/plugins/example
3061
@dir %%WWWDIR%%/include/javascript/tiny_mce/plugins/emotions/img
3027
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/plugins/emotions/langs
3062
@dir %%WWWDIR%%/include/javascript/tiny_mce/plugins/emotions
3028
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/plugins/emotions/js
3063
@dir %%WWWDIR%%/include/javascript/tiny_mce/plugins/directionality
3029
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/plugins/emotions/img
3064
@dir %%WWWDIR%%/include/javascript/tiny_mce/plugins/contextmenu
3030
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/plugins/emotions
3065
@dir %%WWWDIR%%/include/javascript/tiny_mce/plugins/bbcode
3031
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/plugins/directionality
3066
@dir %%WWWDIR%%/include/javascript/tiny_mce/plugins/autosave
3032
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/plugins/contextmenu
3067
@dir %%WWWDIR%%/include/javascript/tiny_mce/plugins/autoresize
3033
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/plugins/bbcode
3068
@dir %%WWWDIR%%/include/javascript/tiny_mce/plugins/autolink
3034
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/plugins/autosave
3069
@dir %%WWWDIR%%/include/javascript/tiny_mce/plugins/advlist
3035
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/plugins/autoresize
3070
@dir %%WWWDIR%%/include/javascript/tiny_mce/plugins/advlink/langs
3036
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/plugins/autolink
3071
@dir %%WWWDIR%%/include/javascript/tiny_mce/plugins/advlink/js
3037
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/plugins/advlist
3072
@dir %%WWWDIR%%/include/javascript/tiny_mce/plugins/advlink/css
3038
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/plugins/advlink/langs
3073
@dir %%WWWDIR%%/include/javascript/tiny_mce/plugins/advlink
3039
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/plugins/advlink/js
3074
@dir %%WWWDIR%%/include/javascript/tiny_mce/plugins/advimage/langs
3040
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/plugins/advlink/css
3075
@dir %%WWWDIR%%/include/javascript/tiny_mce/plugins/advimage/js
3041
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/plugins/advlink
3076
@dir %%WWWDIR%%/include/javascript/tiny_mce/plugins/advimage/img
3042
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/plugins/advimage/langs
3077
@dir %%WWWDIR%%/include/javascript/tiny_mce/plugins/advimage/css
3043
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/plugins/advimage/js
3078
@dir %%WWWDIR%%/include/javascript/tiny_mce/plugins/advimage
3044
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/plugins/advimage/img
3079
@dir %%WWWDIR%%/include/javascript/tiny_mce/plugins/advhr/langs
3045
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/plugins/advimage/css
3080
@dir %%WWWDIR%%/include/javascript/tiny_mce/plugins/advhr/js
3046
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/plugins/advimage
3081
@dir %%WWWDIR%%/include/javascript/tiny_mce/plugins/advhr/css
3047
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/plugins/advhr/langs
3082
@dir %%WWWDIR%%/include/javascript/tiny_mce/plugins/advhr
3048
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/plugins/advhr/js
3083
@dir %%WWWDIR%%/include/javascript/tiny_mce/plugins
3049
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/plugins/advhr/css
3084
@dir %%WWWDIR%%/include/javascript/tiny_mce/langs
3050
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/plugins/advhr
3085
@dir %%WWWDIR%%/include/javascript/tiny_mce
3051
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/plugins
3086
@dir %%WWWDIR%%/include/javascript/mergely
3052
@dirrm %%WWWDIR%%/include/javascript/tiny_mce/langs
3087
@dir %%WWWDIR%%/include/javascript/i18n
3053
@dirrm %%WWWDIR%%/include/javascript/tiny_mce
3088
@dir %%WWWDIR%%/include/javascript/OpenLayers/theme/default/img
3054
@dirrm %%WWWDIR%%/include/javascript/mergely
3089
@dir %%WWWDIR%%/include/javascript/OpenLayers/theme/default
3055
@dirrm %%WWWDIR%%/include/javascript/i18n
3090
@dir %%WWWDIR%%/include/javascript/OpenLayers/theme
3056
@dirrm %%WWWDIR%%/include/javascript/OpenLayers/theme/default/img
3091
@dir %%WWWDIR%%/include/javascript/OpenLayers/img
3057
@dirrm %%WWWDIR%%/include/javascript/OpenLayers/theme/default
3092
@dir %%WWWDIR%%/include/javascript/OpenLayers
3058
@dirrm %%WWWDIR%%/include/javascript/OpenLayers/theme
3093
@dir %%WWWDIR%%/include/javascript
3059
@dirrm %%WWWDIR%%/include/javascript/OpenLayers/img
3094
@dir %%WWWDIR%%/include/help/ja
3060
@dirrm %%WWWDIR%%/include/javascript/OpenLayers
3095
@dir %%WWWDIR%%/include/help/es
3061
@dirrm %%WWWDIR%%/include/javascript
3096
@dir %%WWWDIR%%/include/help/en
3062
@dirrm %%WWWDIR%%/include/help/ja
3097
@dir %%WWWDIR%%/include/help/clippy
3063
@dirrm %%WWWDIR%%/include/help/es
3098
@dir %%WWWDIR%%/include/help
3064
@dirrm %%WWWDIR%%/include/help/en
3099
@dir %%WWWDIR%%/include/graphs/pChart/palettes
3065
@dirrm %%WWWDIR%%/include/help/clippy
3100
@dir %%WWWDIR%%/include/graphs/pChart/fonts
3066
@dirrm %%WWWDIR%%/include/help
3101
@dir %%WWWDIR%%/include/graphs/pChart/data
3067
@dirrm %%WWWDIR%%/include/graphs/pChart/palettes
3102
@dir %%WWWDIR%%/include/graphs/pChart
3068
@dirrm %%WWWDIR%%/include/graphs/pChart/fonts
3103
@dir %%WWWDIR%%/include/graphs/images_graphs
3069
@dirrm %%WWWDIR%%/include/graphs/pChart/data
3104
@dir %%WWWDIR%%/include/graphs/flot
3070
@dirrm %%WWWDIR%%/include/graphs/pChart/cache
3105
@dir %%WWWDIR%%/include/graphs
3071
@dirrm %%WWWDIR%%/include/graphs/pChart
3106
@dir %%WWWDIR%%/include/fonts
3072
@dirrm %%WWWDIR%%/include/graphs/images_graphs
3107
@dir %%WWWDIR%%/include/db
3073
@dirrm %%WWWDIR%%/include/graphs/flot
3108
@dir %%WWWDIR%%/include/auth
3074
@dirrm %%WWWDIR%%/include/graphs
3109
@dir %%WWWDIR%%/include/ajax
3075
@dirrm %%WWWDIR%%/include/fonts
3110
@dir %%WWWDIR%%/include/Image
3076
@dirrm %%WWWDIR%%/include/db
3077
@dirrm %%WWWDIR%%/include/auth
3078
@dirrm %%WWWDIR%%/include/ajax
3079
@dirrm %%WWWDIR%%/include/Image
3080
@dirrmtry %%WWWDIR%%/include
3111
@dirrmtry %%WWWDIR%%/include
3081
@dirrmtry %%WWWDIR%%/images/status_sets/faces
3112
@dirrmtry %%WWWDIR%%/images/status_sets/faces
3082
@dirrmtry %%WWWDIR%%/images/status_sets/default
3113
@dirrmtry %%WWWDIR%%/images/status_sets/default
Lines 3094-3135 Link Here
3094
@dirrmtry %%WWWDIR%%/images/console/icons
3125
@dirrmtry %%WWWDIR%%/images/console/icons
3095
@dirrmtry %%WWWDIR%%/images/console/background
3126
@dirrmtry %%WWWDIR%%/images/console/background
3096
@dirrmtry %%WWWDIR%%/images/console
3127
@dirrmtry %%WWWDIR%%/images/console
3128
@dirrmtry %%WWWDIR%%/images/clippy
3097
@dirrmtry %%WWWDIR%%/images/backgrounds
3129
@dirrmtry %%WWWDIR%%/images/backgrounds
3098
@dirrmtry %%WWWDIR%%/images
3130
@dirrmtry %%WWWDIR%%/images
3099
@dirrm %%WWWDIR%%/godmode/users
3131
@dir %%WWWDIR%%/godmode/users
3100
@dirrm %%WWWDIR%%/godmode/update_manager
3132
@dir %%WWWDIR%%/godmode/update_manager
3101
@dirrm %%WWWDIR%%/godmode/tag
3133
@dir %%WWWDIR%%/godmode/tag
3102
@dirrm %%WWWDIR%%/godmode/snmpconsole
3134
@dir %%WWWDIR%%/godmode/snmpconsole
3103
@dirrm %%WWWDIR%%/godmode/setup
3135
@dir %%WWWDIR%%/godmode/setup
3104
@dirrm %%WWWDIR%%/godmode/servers
3136
@dir %%WWWDIR%%/godmode/servers
3105
@dirrm %%WWWDIR%%/godmode/reporting
3137
@dir %%WWWDIR%%/godmode/reporting
3106
@dirrm %%WWWDIR%%/godmode/netflow
3138
@dir %%WWWDIR%%/godmode/netflow
3107
@dirrm %%WWWDIR%%/godmode/modules
3139
@dir %%WWWDIR%%/godmode/modules
3108
@dirrm %%WWWDIR%%/godmode/massive
3140
@dir %%WWWDIR%%/godmode/massive
3109
@dirrm %%WWWDIR%%/godmode/groups
3141
@dir %%WWWDIR%%/godmode/groups
3110
@dirrm %%WWWDIR%%/godmode/gis_maps
3142
@dir %%WWWDIR%%/godmode/gis_maps
3111
@dirrm %%WWWDIR%%/godmode/events
3143
@dir %%WWWDIR%%/godmode/events
3112
@dirrm %%WWWDIR%%/godmode/db
3144
@dir %%WWWDIR%%/godmode/db
3113
@dirrm %%WWWDIR%%/godmode/category
3145
@dir %%WWWDIR%%/godmode/category
3114
@dirrm %%WWWDIR%%/godmode/alerts
3146
@dir %%WWWDIR%%/godmode/alerts
3115
@dirrm %%WWWDIR%%/godmode/agentes
3147
@dir %%WWWDIR%%/godmode/agentes
3116
@dirrm %%WWWDIR%%/godmode
3148
@dir %%WWWDIR%%/godmode
3117
@dirrm %%WWWDIR%%/general/ui
3149
@dir %%WWWDIR%%/general/ui
3118
@dirrm %%WWWDIR%%/general/license
3150
@dir %%WWWDIR%%/general/license
3119
@dirrm %%WWWDIR%%/general
3151
@dir %%WWWDIR%%/general
3120
@dirrmtry %%WWWDIR%%/fonts
3152
@dirrmtry %%WWWDIR%%/fonts
3121
@dirrm %%WWWDIR%%/extras
3153
@dir %%WWWDIR%%/extras
3122
@dirrm %%WWWDIR%%/extensions/users
3154
@dir %%WWWDIR%%/extensions/users
3123
@dirrm %%WWWDIR%%/extensions/ssh_gateway
3155
@dir %%WWWDIR%%/extensions/ssh_gateway
3124
@dirrm %%WWWDIR%%/extensions/realtime_graphs
3156
@dir %%WWWDIR%%/extensions/realtime_graphs
3125
@dirrm %%WWWDIR%%/extensions/net_tools
3157
@dir %%WWWDIR%%/extensions/net_tools
3126
@dirrm %%WWWDIR%%/extensions/module_groups
3158
@dir %%WWWDIR%%/extensions/module_groups
3127
@dirrm %%WWWDIR%%/extensions/matrix_events
3159
@dir %%WWWDIR%%/extensions/matrix_events
3128
@dirrm %%WWWDIR%%/extensions/files_repo/sql
3160
@dir %%WWWDIR%%/extensions/files_repo/sql
3129
@dirrm %%WWWDIR%%/extensions/files_repo
3161
@dir %%WWWDIR%%/extensions/files_repo
3130
@dirrm %%WWWDIR%%/extensions/dbmanager
3162
@dir %%WWWDIR%%/extensions/dbmanager
3131
@dirrm %%WWWDIR%%/extensions/agents_modules
3163
@dir %%WWWDIR%%/extensions/agents_modules
3132
@dirrmtry %%WWWDIR%%/extensions
3164
@dirrmtry %%WWWDIR%%/extensions
3165
@dirrmtry %%WWWDIR%%/attachment/collections
3133
@dirrmtry %%WWWDIR%%/attachment/plugin
3166
@dirrmtry %%WWWDIR%%/attachment/plugin
3134
@dirrmtry %%WWWDIR%%/attachment/mibs
3167
@dirrmtry %%WWWDIR%%/attachment/mibs
3135
@dirrmtry %%WWWDIR%%/attachment
3168
@dirrmtry %%WWWDIR%%/attachment
(-)b/net-mgmt/pandorafms_server/Makefile (-5 / +2 lines)
Lines 2-9 Link Here
2
# $FreeBSD: head/net-mgmt/pandorafms_server/Makefile 365676 2014-08-22 16:55:01Z wg $
2
# $FreeBSD: head/net-mgmt/pandorafms_server/Makefile 365676 2014-08-22 16:55:01Z wg $
3
3
4
PORTNAME=	pandora_server
4
PORTNAME=	pandora_server
5
PORTREVISION=	1
6
7
CATEGORIES=	net-mgmt
5
CATEGORIES=	net-mgmt
8
6
9
MAINTAINER=	koichiro@rworks.jp
7
MAINTAINER=	koichiro@rworks.jp
Lines 21-34 PANDORA_DEPS= p5-DBI>=0:${PORTSDIR}/databases/p5-DBI \ Link Here
21
		p5-XML-Simple>=0:${PORTSDIR}/textproc/p5-XML-Simple \
19
		p5-XML-Simple>=0:${PORTSDIR}/textproc/p5-XML-Simple \
22
		p5-XML-Twig>=0:${PORTSDIR}/textproc/p5-XML-Twig \
20
		p5-XML-Twig>=0:${PORTSDIR}/textproc/p5-XML-Twig \
23
		p5-JSON>=0:${PORTSDIR}/converters/p5-JSON
21
		p5-JSON>=0:${PORTSDIR}/converters/p5-JSON
24
25
BUILD_DEPENDS=	${PANDORA_DEPS}
22
BUILD_DEPENDS=	${PANDORA_DEPS}
26
27
RUN_DEPENDS=	p5-libwww>=0:${PORTSDIR}/www/p5-libwww \
23
RUN_DEPENDS=	p5-libwww>=0:${PORTSDIR}/www/p5-libwww \
28
		p5-DBD-mysql>=4:${PORTSDIR}/databases/p5-DBD-mysql \
24
		p5-DBD-mysql>=4:${PORTSDIR}/databases/p5-DBD-mysql \
29
		${LOCALBASE}/bin/wmic:${PORTSDIR}/net-mgmt/wmi-client \
25
		${LOCALBASE}/bin/wmic:${PORTSDIR}/net-mgmt/wmi-client \
30
		${LOCALBASE}/bin/nmap:${PORTSDIR}/security/nmap \
26
		${LOCALBASE}/bin/nmap:${PORTSDIR}/security/nmap \
31
		p5-Storable>=0:${PORTSDIR}/devel/p5-Storable \
27
		p5-Storable>=0:${PORTSDIR}/devel/p5-Storable \
28
		p5-Encode-Locale>=0:${PORTSDIR}/converters/p5-Encode-Locale \
32
		${PANDORA_DEPS}
29
		${PANDORA_DEPS}
33
30
34
OPTIONS_DEFINE=	DOCS TENTACLE XPROBE PGSQL ORACLE EXTRAS
31
OPTIONS_DEFINE=	DOCS TENTACLE XPROBE PGSQL ORACLE EXTRAS
Lines 105-111 post-install: Link Here
105
	@${MV} ${STAGEDIR}${ETCDIR}/pandora_server.conf ${STAGEDIR}${ETCDIR}/pandora_server.conf.sample
102
	@${MV} ${STAGEDIR}${ETCDIR}/pandora_server.conf ${STAGEDIR}${ETCDIR}/pandora_server.conf.sample
106
	@${MKDIR} ${STAGEDIR}${DOCSDIR}
103
	@${MKDIR} ${STAGEDIR}${DOCSDIR}
107
.for x in ${PORTDOCS}
104
.for x in ${PORTDOCS}
108
	@${INSTALL_DATA} ${WRKSRC}/${x} ${STAGEDIR}${DOCSDIR}
105
	${INSTALL_DATA} ${WRKSRC}/${x} ${STAGEDIR}${DOCSDIR}
109
.endfor
106
.endfor
110
107
111
.include <bsd.port.post.mk>
108
.include <bsd.port.post.mk>
(-)b/net-mgmt/pandorafms_server/bsd.pandora.mk (-4 / +4 lines)
Lines 1-6 Link Here
1
# $FreeBSD: head/net-mgmt/pandorafms_server/bsd.pandora.mk 365508 2014-08-20 20:01:17Z wg $
1
# $FreeBSD: head/net-mgmt/pandorafms_server/bsd.pandora.mk 365508 2014-08-20 20:01:17Z wg $
2
2
3
PANDORA_VERSION=	5.1
3
PANDORA_VERSION=	5.1SP1
4
PANDORA_LICENSE=	GPLv2
4
PANDORA_LICENSE=	GPLv2
5
PANDORA_LICENSE_FILE=	${WRKSRC}/COPYING
5
PANDORA_LICENSE_FILE=	${WRKSRC}/COPYING
6
6
Lines 12-20 PANDORA_HOMEDIR?= ${PANDORA_ETCDIR}/home Link Here
12
PANDORA_INSTALLER=	${PORTNAME}_installer
12
PANDORA_INSTALLER=	${PORTNAME}_installer
13
PANDORA_INSTALLER_ARGS=	--install
13
PANDORA_INSTALLER_ARGS=	--install
14
14
15
PORTVERSION=	${PANDORA_VERSION:C/((SP[0-9]*)?)$/.0\1/}
15
PORTVERSION=	${PANDORA_VERSION:C/SP/./}
16
16
17
MASTER_SITES?=	SF/pandora/Pandora%20FMS%20${PANDORA_VERSION}/Final/Tarball
17
MASTER_SITES?=	SF/pandora/Pandora%20FMS%20${PANDORA_VERSION:C/(SP[0-9]*)/\/\1/}Final/Tarball
18
.if ${PORTNAME} == "pandora_agent"
18
.if ${PORTNAME} == "pandora_agent"
19
DISTNAME=	pandorafms_agent_unix-${PANDORA_VERSION}
19
DISTNAME=	pandorafms_agent_unix-${PANDORA_VERSION}
20
.else
20
.else
Lines 38-44 PLIST_SUB+= SPOOLDIR="${PANDORA_SPOOLDIR}" LOGDIR="${PANDORA_LOGDIR}" \ Link Here
38
SUB_LIST+=	PANDORA_VERSION="${PANDORA_VERSION}"
38
SUB_LIST+=	PANDORA_VERSION="${PANDORA_VERSION}"
39
PLIST=		${WRKDIR}/PLIST
39
PLIST=		${WRKDIR}/PLIST
40
40
41
PORTDOCS?=	AUTHORS ChangeLog
41
PORTDOCS?=	AUTHORS
42
42
43
.if ${PORTNAME} == "pandora_server"
43
.if ${PORTNAME} == "pandora_server"
44
USE_LOGDIR=	""
44
USE_LOGDIR=	""
(-)b/net-mgmt/pandorafms_server/distinfo (-2 / +2 lines)
Lines 1-2 Link Here
1
SHA256 (pandora/pandorafms_server-5.1.tar.gz) = 00b163f3fad5474380ba02afcbac2c4221ff03d4bd293957590310504a5a0b3e
1
SHA256 (pandora/pandorafms_server-5.1SP1.tar.gz) = c7b49da0b941315a59de9d3edebb10f0103eb4ee59956e961d3b6787f4449b27
2
SIZE (pandora/pandorafms_server-5.1.tar.gz) = 4064063
2
SIZE (pandora/pandorafms_server-5.1SP1.tar.gz) = 4011575
(-)a/net-mgmt/pandorafms_server/files/patch-update (-5592 lines)
Removed Link Here
1
Index: NetBSD/pandora_server.conf.new
2
===================================================================
3
--- NetBSD/pandora_server.conf.new	(revision 0)
4
+++ NetBSD/pandora_server.conf.new	(revision 10417)
5
@@ -0,0 +1,443 @@
6
+#############################################################################
7
+# Pandora FMS Server Parameters
8
+# Pandora FMS, the Flexible Monitoring System.
9
+# Version 5.1BETA1
10
+# Licensed under GPL license v2,
11
+# (c) 2003-2014 Artica Soluciones Tecnologicas
12
+# http://www.pandorafms.com
13
+# Please change it for your setup needs
14
+#############################################################################
15
+
16
+# Servername: Name of this server
17
+# if not given, it takes hostname. It's preferable to setup one
18
+# because machine name could change by some reason.
19
+
20
+#servername greystone
21
+
22
+# incomingdir:  Defines directory where incoming data packets are stored
23
+# You could set directory relative to base path or absolute, starting with /
24
+
25
+incomingdir /var/spool/pandora/data_in
26
+
27
+# log_file: Main logfile for pandora_server
28
+# You could set file relative to base path or absolute, starting with /
29
+
30
+log_file /var/log/pandora/pandora_server.log
31
+
32
+# Log file for Pandora FMS SNMP console. Its generated by NetSNMP Trap daemon
33
+
34
+snmp_logfile /var/log/pandora/pandora_snmptrap.log
35
+
36
+# Error logfile: aux logfile for pandora_server errors (in Daemon mode)
37
+# You could set file relative to base path or absolute, starting with /
38
+
39
+errorlog_file /var/log/pandora/pandora_server.error
40
+
41
+# daemon: Runs in daemon mode (background) if 1, if 0 runs in foreground 
42
+# this could be also configured on commandline with -D option
43
+
44
+# daemon 1
45
+
46
+# dbengine: mysql, postgresql or oracle (mysql by default)
47
+
48
+dbengine mysql
49
+
50
+# Database credentials. A VERY important configuration.
51
+# This must be the same credentials used by your Pandora FMS Console
52
+# but could be different if your console is not running in the same
53
+# host than the server. Check your console setup in /include/config.php
54
+
55
+# dbname: Database name (pandora by default)
56
+
57
+dbname pandora
58
+
59
+# dbuser:  Database user name (pandora by default)
60
+
61
+dbuser pandora
62
+
63
+# dbpass: Database password
64
+
65
+dbpass pandora
66
+
67
+# dbhost: Database hostname or IP address
68
+
69
+dbhost 127.0.0.1
70
+
71
+# dbport: Database port number
72
+# Default value depends on the dbengine (mysql: 3306, postgresql: 5432, oracle: 1521)
73
+
74
+#dbport 3306
75
+
76
+# By default, parent agent will not be updated
77
+
78
+#update_parent 0
79
+
80
+# verbosity: level of detail on errors/messages (0 default, 1 verbose, 2 debug.... 10 noisy)
81
+# -v in command line (verbose) or -d (debug). Set this to 10 when try to locate problems and
82
+# set to 0 or 1 on production enviroments.
83
+
84
+verbosity 1
85
+
86
+# Master Server, 1 if master server (normal mode), 0 for slave mode (slave in multi-server setup)
87
+
88
+master 1
89
+
90
+# Activate Pandora SNMP console (depending on snmptrapd)
91
+
92
+snmpconsole 0
93
+
94
+# snmptrapd will ignore authenticationFailure traps if set to 1.
95
+
96
+snmp_ignore_authfailure 1
97
+
98
+# snmptrapd will read the PDU source address instead of the agent-addr field is set to 1.
99
+
100
+snmp_pdu_address 0
101
+
102
+# Activate (1) Pandora Network Server 
103
+
104
+networkserver 1
105
+
106
+# Activate (1) Pandora Data Server
107
+
108
+dataserver 1
109
+
110
+# Activate (1) Pandora FMS Recon server
111
+
112
+reconserver 1
113
+
114
+# pluginserver : 1 or 0. Set to 1 to activate plugin server with this setup
115
+
116
+pluginserver 1
117
+
118
+# Pandora FMS Plugin exec tool filepath (by default at /usr/local/bin)
119
+
120
+plugin_exec /usr/local/bin/gtimeout
121
+
122
+# predictionserver : 1 or 0. Set to 1 to activate prediction server with this setup
123
+# DISABLED BY DEFAULT 
124
+
125
+predictionserver 0
126
+
127
+# wmiserver : 1 or 0. Set to 1 to activate WMI server with this setup
128
+# DISABLED BY DEFAULT
129
+
130
+wmiserver 1
131
+
132
+# wmic: Needed by Pandora FMS wmi server.
133
+
134
+wmi_client /usr/local/bin/wmic
135
+
136
+# Network timeout (in seconds) for timeout in network connections for Network agents
137
+
138
+network_timeout 4
139
+
140
+# Server keepalive (in seconds)
141
+
142
+server_keepalive 45
143
+
144
+# Server Threshold: defines number of seconds of main loop (in sec)
145
+
146
+server_threshold 5
147
+
148
+# Network threads: Do not set too high (~40). Each threads make a network module check.
149
+
150
+network_threads 4
151
+
152
+# icmp_checks x : defines number of pings for each icmp_proc module type. at least one of 
153
+# that ping should be 1 to report 1. Values of 1 have more performance, but are more feasible
154
+# to produce false positives. 
155
+
156
+icmp_checks 3
157
+
158
+# tcp specific options :
159
+# tcp_checks: number of tcp retries if first attempt fails.
160
+# tcp_timeout: specific timeout for tcp connections
161
+
162
+tcp_checks 1
163
+tcp_timeout 10
164
+
165
+# snmp specific options :
166
+# snmp_checks: number of snmp request retries if first attempt fails.
167
+# snmp_timeout: specific timeout for snmp request.
168
+
169
+snmp_checks 1
170
+snmp_timeout 4
171
+
172
+# snmp_proc_deadresponse 1 (default): Return DOWN if cannot contact 
173
+# or receive NULL from a SNMP PROC module.
174
+
175
+snmp_proc_deadresponse 1
176
+
177
+# plugin_threads: Specify number of plugin server threads for processing plugin calls
178
+
179
+plugin_threads 1
180
+
181
+# plugin_timeout: Specify number of seconds calling plugin exec waiting for response
182
+# after this time, call is aborted and result is "unknown".
183
+
184
+plugin_timeout 12
185
+
186
+# wmi_timeout : specific timeout for wmi request.
187
+
188
+wmi_timeout 7
189
+
190
+# wmi_threads: Specify number of WMI server threads for processing WMI remote calls
191
+
192
+wmi_threads 1
193
+
194
+# recon_threads. Each thread will scan a different scantask.
195
+
196
+recon_threads 1
197
+
198
+# dataserver_threads: Number of threads for data server (XML processing threads)
199
+
200
+dataserver_threads 1
201
+
202
+# mta_address: External Mailer (MTA) IP Address to be used by Pandora FMS internal email capabilities
203
+
204
+mta_address localhost
205
+
206
+# mta_port, this is the mail server port (default 25)
207
+
208
+#mta_port 25
209
+
210
+# mta_user MTA User (if needed for auth, FQD or simple user, depending on your server)
211
+
212
+#mta_user myuser@mydomain.com
213
+
214
+# mta_pass MTA Pass (if needed for auth)
215
+
216
+#mta_pass mypassword
217
+
218
+# mta_auth MTA Auth system (if needed, it supports LOGIN, PLAIN, CRAM-MD5, DIGEST-MD)
219
+
220
+#mta_auth LOGIN
221
+
222
+# mta_from Email address that sends the mail, by default is pandora@localhost 
223
+#           probably you need to change it to avoid problems with your antispam
224
+
225
+#mta_from Pandora FMS <pandora@mydomain.com>
226
+
227
+# Set 1 if want eMail deliver alert in separate mail  (default).
228
+# Set 0 if want eMail deliver shared mail by all destination.
229
+mail_in_separate 1
230
+
231
+
232
+# xprobe2: Optional package to detect OS types using advanced TCP/IP 
233
+# fingerprinting tecniques, much more accurates than stadard nmap.
234
+# If not provided, nmap is used insted xprobe2
235
+
236
+xprobe2 /usr/local/bin/xprobe2
237
+
238
+# nmap: If provided, is used to detect OS type with recon server using 
239
+# advanded OS fingerprint technique. Xprobe2 gives more accurate results
240
+# Nmap is also used to do TCP port scanning in detected host.
241
+
242
+nmap /usr/pkg/bin/nmap
243
+
244
+# snmpget: Needed to do SNMP checks. By default is on /usr/local/bin/snmpget
245
+
246
+snmpget /usr/pkg/bin/snmpget
247
+
248
+# snmp_trapd: Needed by Pandora FMS SNMP console.
249
+
250
+snmp_trapd /usr/pkg/sbin/snmptrapd
251
+
252
+# Location of the braa binary needed by the Enterprise SNMP Server (/usr/local/bin/braa by default) (PANDORA FMS ENTERPRISE ONLY).
253
+
254
+braa /usr/local/bin/braa
255
+
256
+# Number of retries before braa hands a module over to the Network Server (PANDORA FMS ENTERPRISE ONLY).
257
+
258
+braa_retries 3
259
+
260
+# Default group id for new agents created with Pandora FMS Data Server
261
+
262
+autocreate_group 2
263
+
264
+# Set to 1 if want to autocreate agents with Pandora FMS Data Server, 
265
+# set to 0 to disable (for security purposes, for example).
266
+
267
+autocreate 1
268
+
269
+# max_log_size: Specify max size of Pandora FMS server log file (1MB by default). If
270
+# log file grows above this limit, is renamed to "pandora_server.log.old".
271
+
272
+max_log_size 65536
273
+
274
+# max_queue_files (500 by default)
275
+# When server have more than max_queue_files in incoming directory, skips the read   
276
+# the directory to avoid filesystem overhead.
277
+
278
+max_queue_files 500
279
+
280
+# Use the XML file last modification time as timestamp.
281
+# use_xml_timestamp 1
282
+
283
+# Pandora FMS will autorestart itself each XXX seconds, use this if you experience problems with 
284
+# shutting down threads, or other stability problems.
285
+
286
+# auto_restart 86400
287
+
288
+# Pandora FMS will restart after restart_delay seconds on critical errors.
289
+
290
+restart 1
291
+restart_delay 60
292
+
293
+# More information about GIS Setup in /usr/share/pandora_server/util/gis.README
294
+# Flag to activate GIS (positional information for agents and maps) 
295
+# by default it is desactivated
296
+
297
+#activate_gis 0
298
+
299
+# Radius of error in meters to consider two gis locations as the same location.
300
+
301
+#location_error 50
302
+
303
+# Recon reverse geolocation mode [disabled, sql, file]
304
+#   disabled    The recon task doesn't try to geolocate the ip discovered.
305
+#   sql         The recon task trys to query the SQL database to geolocate the 
306
+#               ip discovered
307
+#   file        The recon task trys to find the geolocation information of the 
308
+#               ip discovered in the file indicated in the 
309
+#                recon_reverse_geolocation_file parameter 
310
+
311
+# recon_reverse_geolocation_mode disabled
312
+
313
+# Recon reverse geolocation file. This is the database with the reverse 
314
+# geolocation information using MaxMind GPL GeoLiteCity.dat format).
315
+
316
+#recon_reverse_geolocation_file /usr/local/share/GeoIP/GeoIPCity.dat
317
+
318
+# Radius (in meters) of the circle in where the agents will be place randomly 
319
+# when finded by a recon task. Center of the circle is guessed 
320
+# by geolocating the IP.
321
+#recon_location_scatter_radius 1000
322
+
323
+# Pandora Server self-monitoring (embedded agent) (by default enabled)
324
+
325
+self_monitoring 1
326
+
327
+# Update parent from the agent xml
328
+
329
+#update_parent 1
330
+#
331
+#
332
+# This enable realtime reverse geocoding using Google Maps public api.
333
+# This requires internet access, and could have performance penalties processing GIS
334
+# information due the connetion needed to resolve all GIS input.
335
+# NOTE: If you dont pay the service to google, they will ban your IP in a few days.
336
+
337
+# google_maps_description 1
338
+
339
+# This enable realtime reverse geocoding using Openstreet Maps public api.
340
+# This requires internet access, and could have performance penalties processing GIS
341
+# information due the connetion needed to resolve all GIS input.
342
+# You can alter the code to use a local (your own) openstreet maps server.
343
+
344
+# openstreetmaps_description 1
345
+
346
+# Enable (1) or disable (0) Pandora FMS Event Web Server (PANDORA FMS ENTERPRISE ONLY).
347
+
348
+webserver 1
349
+
350
+# Number of threads for the Web Server (PANDORA FMS ENTERPRISE ONLY).
351
+
352
+web_threads 1
353
+
354
+# Enable (1) or disable (0) Pandora FMS Inventory Server (PANDORA FMS ENTERPRISE ONLY).
355
+
356
+inventoryserver 1
357
+
358
+# Number of threads for the Web Server (PANDORA FMS ENTERPRISE ONLY).
359
+
360
+inventory_threads 1
361
+
362
+# Enable (1) or disable (0) Pandora FMS Export Server (PANDORA FMS ENTERPRISE ONLY).
363
+
364
+exportserver 0
365
+
366
+# Number of threads for the Export Server (PANDORA FMS ENTERPRISE ONLY).
367
+
368
+export_threads 1
369
+
370
+# Enable (1) or disable (0) Pandora FMS Event Server (PANDORA FMS ENTERPRISE ONLY).
371
+
372
+eventserver 0
373
+
374
+# Event Server event window in seconds (3600 by default) (PANDORA FMS ENTERPRISE ONLY).
375
+
376
+event_window 3600
377
+
378
+# Enable (1) or disable (0) Pandora FMS Enterprise ICMP Server (PANDORA FMS ENTERPRISE ONLY).
379
+# You need nmap 5.20 or higher in order to use this !
380
+
381
+icmpserver 1
382
+
383
+# Number of threads for the Enterprise ICMP Server (PANDORA FMS ENTERPRISE ONLY).
384
+
385
+icmp_threads 1
386
+
387
+# Enable (1) or disable (0) Pandora FMS Enterprise SNMP Server (PANDORA FMS ENTERPRISE ONLY).
388
+# Check braa tool is running and operative.
389
+
390
+snmpserver 1
391
+
392
+# Number of threads for the Enterprise SNMP Server (PANDORA FMS ENTERPRISE ONLY).
393
+
394
+snmp_threads 1
395
+
396
+# Block size for block producer/consumer servers, that is, the number of modules
397
+# per block (20 by default) (PANDORA FMS ENTERPRISE ONLY).
398
+
399
+block_size 20
400
+
401
+# Path to the netflow daemon nfcapd.
402
+
403
+netflow_daemon /usr/pkg/bin/nfcapd
404
+
405
+# If set to 1, process XML data files in a stack instead of a queue. 0 by default.
406
+# WARNING: Incremental modules will not work properly if dataserver_lifo is set to 1!!!
407
+
408
+dataserver_lifo 0
409
+
410
+# If set to 1, the policy manager is enabled and the server is listening the policy queue. 
411
+# 0 by default (PANDORA FMS ENTERPRISE ONLY) 
412
+
413
+policy_manager 1
414
+
415
+# If set to 1, the event replicate process is enabled. 0 by default. (PANDORA FMS ENTERPRISE ONLY) 
416
+# WARNING: This process doesn't do anything if is not properly configured from the console setup 
417
+
418
+event_replication 0
419
+
420
+# If set to 1, new events validate older event for the same module. This will
421
+# affect the performance of the server. This was the "normal behaviour" on previous (4.x) versions.
422
+# disable only if you really know what you are doing !!.
423
+
424
+event_auto_validation 1
425
+
426
+# If defined, events generated by Pandora FMS will be written to the specified text file.
427
+#event_file /var/log/pandora/pandora_events.txt
428
+
429
+# Set the maximum number of traps that will be processed from a single source in a
430
+# configured time interval.
431
+snmp_storm_protection 25
432
+
433
+# Time interval for snmp_storm protection (in seconds).
434
+snmp_storm_timeout 10
435
+
436
+# Default texts for some events. The macros _module_ and _data_ are supported.
437
+#text_going_down_normal Module '_module_' is going to NORMAL (_data_)
438
+#text_going_up_critical Module '_module_' is going to CRITICAL (_data_)
439
+#text_going_up_warning Module '_module_' is going to WARNING (_data_)
440
+#text_going_down_warning Module '_module_' is going to WARNING (_data_)
441
+#text_going_unknown Module '_module_' is going to UNKNOWN
442
+
443
+# Events older that the specified time (in seconds) will be auto-validated. Set to 0 to disable this feature.
444
+event_expiry_time 0
445
+
446
+# Only events more recent than the specified time window (in seconds) will be auto-validated. This value must
447
+# be greater than event_expiry_time.
448
+#event_expiry_window 86400
449
Index: NetBSD/pandora_server.conf
450
===================================================================
451
--- NetBSD/pandora_server.conf	(revision 10314)
452
+++ NetBSD/pandora_server.conf	(working copy)
453
@@ -1,442 +0,0 @@
454
-#############################################################################
455
-# Pandora FMS Server Parameters
456
-# Pandora FMS, the Flexible Monitoring System.
457
-# Version 5.1BETA1
458
-# Licensed under GPL license v2,
459
-# (c) 2003-2014 Artica Soluciones Tecnologicas
460
-# http://www.pandorafms.com
461
-# Please change it for your setup needs
462
-#############################################################################
463
-
464
-# Servername: Name of this server
465
-# if not given, it takes hostname. It's preferable to setup one
466
-# because machine name could change by some reason.
467
-
468
-#servername greystone
469
-
470
-# incomingdir:  Defines directory where incoming data packets are stored
471
-# You could set directory relative to base path or absolute, starting with /
472
-
473
-incomingdir /var/spool/pandora/data_in
474
-
475
-# log_file: Main logfile for pandora_server
476
-# You could set file relative to base path or absolute, starting with /
477
-
478
-log_file /var/log/pandora/pandora_server.log
479
-
480
-# Log file for Pandora FMS SNMP console. Its generated by NetSNMP Trap daemon
481
-
482
-snmp_logfile /var/log/pandora/pandora_snmptrap.log
483
-
484
-# Error logfile: aux logfile for pandora_server errors (in Daemon mode)
485
-# You could set file relative to base path or absolute, starting with /
486
-
487
-errorlog_file /var/log/pandora/pandora_server.error
488
-
489
-# daemon: Runs in daemon mode (background) if 1, if 0 runs in foreground 
490
-# this could be also configured on commandline with -D option
491
-
492
-# daemon 1
493
-
494
-# dbengine: mysql, postgresql or oracle (mysql by default)
495
-
496
-dbengine mysql
497
-
498
-# Database credentials. A VERY important configuration.
499
-# This must be the same credentials used by your Pandora FMS Console
500
-# but could be different if your console is not running in the same
501
-# host than the server. Check your console setup in /include/config.php
502
-
503
-# dbname: Database name (pandora by default)
504
-
505
-dbname pandora
506
-
507
-# dbuser:  Database user name (pandora by default)
508
-
509
-dbuser pandora
510
-
511
-# dbpass: Database password
512
-
513
-dbpass pandora
514
-
515
-# dbhost: Database hostname or IP address
516
-
517
-dbhost 127.0.0.1
518
-
519
-# dbport: Database port number
520
-# Default value depends on the dbengine (mysql: 3306, postgresql: 5432, oracle: 1521)
521
-
522
-#dbport 3306
523
-
524
-# By default, parent agent will not be updated
525
-
526
-#update_parent 0
527
-
528
-# verbosity: level of detail on errors/messages (0 default, 1 verbose, 2 debug.... 10 noisy)
529
-# -v in command line (verbose) or -d (debug). Set this to 10 when try to locate problems and
530
-# set to 0 or 1 on production enviroments.
531
-
532
-verbosity 1
533
-
534
-# Master Server, 1 if master server (normal mode), 0 for slave mode (slave in multi-server setup)
535
-
536
-master 1
537
-
538
-# Activate Pandora SNMP console (depending on snmptrapd)
539
-
540
-snmpconsole 0
541
-
542
-# snmptrapd will ignore authenticationFailure traps if set to 1.
543
-
544
-snmp_ignore_authfailure 1
545
-
546
-# snmptrapd will read the PDU source address instead of the agent-addr field is set to 1.
547
-
548
-snmp_pdu_address 0
549
-
550
-# Activate (1) Pandora Network Server 
551
-
552
-networkserver 1
553
-
554
-# Activate (1) Pandora Data Server
555
-
556
-dataserver 1
557
-
558
-# Activate (1) Pandora FMS Recon server
559
-
560
-reconserver 1
561
-
562
-# pluginserver : 1 or 0. Set to 1 to activate plugin server with this setup
563
-
564
-pluginserver 1
565
-
566
-# Pandora FMS Plugin exec tool filepath (by default at /usr/local/bin)
567
-
568
-plugin_exec /usr/local/bin/gtimeout
569
-
570
-# predictionserver : 1 or 0. Set to 1 to activate prediction server with this setup
571
-# DISABLED BY DEFAULT 
572
-
573
-predictionserver 0
574
-
575
-# wmiserver : 1 or 0. Set to 1 to activate WMI server with this setup
576
-# DISABLED BY DEFAULT
577
-
578
-wmiserver 1
579
-
580
-# wmic: Needed by Pandora FMS wmi server.
581
-
582
-wmi_client /usr/local/bin/wmic
583
-
584
-# Network timeout (in seconds) for timeout in network connections for Network agents
585
-
586
-network_timeout 4
587
-
588
-# Server keepalive (in seconds)
589
-
590
-server_keepalive 45
591
-
592
-# Server Threshold: defines number of seconds of main loop (in sec)
593
-
594
-server_threshold 5
595
-
596
-# Network threads: Do not set too high (~40). Each threads make a network module check.
597
-
598
-network_threads 4
599
-
600
-# icmp_checks x : defines number of pings for each icmp_proc module type. at least one of 
601
-# that ping should be 1 to report 1
602
-
603
-icmp_checks 1
604
-
605
-# tcp specific options :
606
-# tcp_checks: number of tcp retries if first attempt fails.
607
-# tcp_timeout: specific timeout for tcp connections
608
-
609
-tcp_checks 1
610
-tcp_timeout 10
611
-
612
-# snmp specific options :
613
-# snmp_checks: number of snmp request retries if first attempt fails.
614
-# snmp_timeout: specific timeout for snmp request.
615
-
616
-snmp_checks 1
617
-snmp_timeout 4
618
-
619
-# snmp_proc_deadresponse 1 (default): Return DOWN if cannot contact 
620
-# or receive NULL from a SNMP PROC module.
621
-
622
-snmp_proc_deadresponse 1
623
-
624
-# plugin_threads: Specify number of plugin server threads for processing plugin calls
625
-
626
-plugin_threads 1
627
-
628
-# plugin_timeout: Specify number of seconds calling plugin exec waiting for response
629
-# after this time, call is aborted and result is "unknown".
630
-
631
-plugin_timeout 12
632
-
633
-# wmi_timeout : specific timeout for wmi request.
634
-
635
-wmi_timeout 7
636
-
637
-# wmi_threads: Specify number of WMI server threads for processing WMI remote calls
638
-
639
-wmi_threads 1
640
-
641
-# recon_threads. Each thread will scan a different scantask.
642
-
643
-recon_threads 1
644
-
645
-# dataserver_threads: Number of threads for data server (XML processing threads)
646
-
647
-dataserver_threads 1
648
-
649
-# mta_address: External Mailer (MTA) IP Address to be used by Pandora FMS internal email capabilities
650
-
651
-mta_address localhost
652
-
653
-# mta_port, this is the mail server port (default 25)
654
-
655
-#mta_port 25
656
-
657
-# mta_user MTA User (if needed for auth, FQD or simple user, depending on your server)
658
-
659
-#mta_user myuser@mydomain.com
660
-
661
-# mta_pass MTA Pass (if needed for auth)
662
-
663
-#mta_pass mypassword
664
-
665
-# mta_auth MTA Auth system (if needed, it supports LOGIN, PLAIN, CRAM-MD5, DIGEST-MD)
666
-
667
-#mta_auth LOGIN
668
-
669
-# mta_from Email address that sends the mail, by default is pandora@localhost 
670
-#           probably you need to change it to avoid problems with your antispam
671
-
672
-#mta_from Pandora FMS <pandora@mydomain.com>
673
-
674
-# Set 1 if want eMail deliver alert in separate mail  (default).
675
-# Set 0 if want eMail deliver shared mail by all destination.
676
-mail_in_separate 1
677
-
678
-
679
-# xprobe2: Optional package to detect OS types using advanced TCP/IP 
680
-# fingerprinting tecniques, much more accurates than stadard nmap.
681
-# If not provided, nmap is used insted xprobe2
682
-
683
-xprobe2 /usr/local/bin/xprobe2
684
-
685
-# nmap: If provided, is used to detect OS type with recon server using 
686
-# advanded OS fingerprint technique. Xprobe2 gives more accurate results
687
-# Nmap is also used to do TCP port scanning in detected host.
688
-
689
-nmap /usr/pkg/bin/nmap
690
-
691
-# snmpget: Needed to do SNMP checks. By default is on /usr/local/bin/snmpget
692
-
693
-snmpget /usr/pkg/bin/snmpget
694
-
695
-# snmp_trapd: Needed by Pandora FMS SNMP console.
696
-
697
-snmp_trapd /usr/pkg/sbin/snmptrapd
698
-
699
-# Location of the braa binary needed by the Enterprise SNMP Server (/usr/local/bin/braa by default) (PANDORA FMS ENTERPRISE ONLY).
700
-
701
-braa /usr/local/bin/braa
702
-
703
-# Number of retries before braa hands a module over to the Network Server (PANDORA FMS ENTERPRISE ONLY).
704
-
705
-braa_retries 3
706
-
707
-# Default group id for new agents created with Pandora FMS Data Server
708
-
709
-autocreate_group 2
710
-
711
-# Set to 1 if want to autocreate agents with Pandora FMS Data Server, 
712
-# set to 0 to disable (for security purposes, for example).
713
-
714
-autocreate 1
715
-
716
-# max_log_size: Specify max size of Pandora FMS server log file (1MB by default). If
717
-# log file grows above this limit, is renamed to "pandora_server.log.old".
718
-
719
-max_log_size 65536
720
-
721
-# max_queue_files (500 by default)
722
-# When server have more than max_queue_files in incoming directory, skips the read   
723
-# the directory to avoid filesystem overhead.
724
-
725
-max_queue_files 500
726
-
727
-# Use the XML file last modification time as timestamp.
728
-# use_xml_timestamp 1
729
-
730
-# Pandora FMS will autorestart itself each XXX seconds, use this if you experience problems with 
731
-# shutting down threads, or other stability problems.
732
-
733
-# auto_restart 86400
734
-
735
-# Pandora FMS will restart after restart_delay seconds on critical errors.
736
-
737
-restart 1
738
-restart_delay 60
739
-
740
-# More information about GIS Setup in /usr/share/pandora_server/util/gis.README
741
-# Flag to activate GIS (positional information for agents and maps) 
742
-# by default it is desactivated
743
-
744
-#activate_gis 0
745
-
746
-# Radius of error in meters to consider two gis locations as the same location.
747
-
748
-#location_error 50
749
-
750
-# Recon reverse geolocation mode [disabled, sql, file]
751
-#   disabled    The recon task doesn't try to geolocate the ip discovered.
752
-#   sql         The recon task trys to query the SQL database to geolocate the 
753
-#               ip discovered
754
-#   file        The recon task trys to find the geolocation information of the 
755
-#               ip discovered in the file indicated in the 
756
-#                recon_reverse_geolocation_file parameter 
757
-
758
-# recon_reverse_geolocation_mode disabled
759
-
760
-# Recon reverse geolocation file. This is the database with the reverse 
761
-# geolocation information using MaxMind GPL GeoLiteCity.dat format).
762
-
763
-#recon_reverse_geolocation_file /usr/local/share/GeoIP/GeoIPCity.dat
764
-
765
-# Radius (in meters) of the circle in where the agents will be place randomly 
766
-# when finded by a recon task. Center of the circle is guessed 
767
-# by geolocating the IP.
768
-#recon_location_scatter_radius 1000
769
-
770
-# Pandora Server self-monitoring (embedded agent) (by default enabled)
771
-
772
-self_monitoring 1
773
-
774
-# Update parent from the agent xml
775
-
776
-#update_parent 1
777
-#
778
-#
779
-# This enable realtime reverse geocoding using Google Maps public api.
780
-# This requires internet access, and could have performance penalties processing GIS
781
-# information due the connetion needed to resolve all GIS input.
782
-# NOTE: If you dont pay the service to google, they will ban your IP in a few days.
783
-
784
-# google_maps_description 1
785
-
786
-# This enable realtime reverse geocoding using Openstreet Maps public api.
787
-# This requires internet access, and could have performance penalties processing GIS
788
-# information due the connetion needed to resolve all GIS input.
789
-# You can alter the code to use a local (your own) openstreet maps server.
790
-
791
-# openstreetmaps_description 1
792
-
793
-# Enable (1) or disable (0) Pandora FMS Event Web Server (PANDORA FMS ENTERPRISE ONLY).
794
-
795
-webserver 1
796
-
797
-# Number of threads for the Web Server (PANDORA FMS ENTERPRISE ONLY).
798
-
799
-web_threads 1
800
-
801
-# Enable (1) or disable (0) Pandora FMS Inventory Server (PANDORA FMS ENTERPRISE ONLY).
802
-
803
-inventoryserver 1
804
-
805
-# Number of threads for the Web Server (PANDORA FMS ENTERPRISE ONLY).
806
-
807
-inventory_threads 1
808
-
809
-# Enable (1) or disable (0) Pandora FMS Export Server (PANDORA FMS ENTERPRISE ONLY).
810
-
811
-exportserver 0
812
-
813
-# Number of threads for the Export Server (PANDORA FMS ENTERPRISE ONLY).
814
-
815
-export_threads 1
816
-
817
-# Enable (1) or disable (0) Pandora FMS Event Server (PANDORA FMS ENTERPRISE ONLY).
818
-
819
-eventserver 0
820
-
821
-# Event Server event window in seconds (3600 by default) (PANDORA FMS ENTERPRISE ONLY).
822
-
823
-event_window 3600
824
-
825
-# Enable (1) or disable (0) Pandora FMS Enterprise ICMP Server (PANDORA FMS ENTERPRISE ONLY).
826
-# You need nmap 5.20 or higher in order to use this !
827
-
828
-icmpserver 1
829
-
830
-# Number of threads for the Enterprise ICMP Server (PANDORA FMS ENTERPRISE ONLY).
831
-
832
-icmp_threads 1
833
-
834
-# Enable (1) or disable (0) Pandora FMS Enterprise SNMP Server (PANDORA FMS ENTERPRISE ONLY).
835
-# Check braa tool is running and operative.
836
-
837
-snmpserver 1
838
-
839
-# Number of threads for the Enterprise SNMP Server (PANDORA FMS ENTERPRISE ONLY).
840
-
841
-snmp_threads 1
842
-
843
-# Block size for block producer/consumer servers, that is, the number of modules
844
-# per block (20 by default) (PANDORA FMS ENTERPRISE ONLY).
845
-
846
-block_size 20
847
-
848
-# Path to the netflow daemon nfcapd.
849
-
850
-netflow_daemon /usr/pkg/bin/nfcapd
851
-
852
-# If set to 1, process XML data files in a stack instead of a queue. 0 by default.
853
-# WARNING: Incremental modules will not work properly if dataserver_lifo is set to 1!!!
854
-
855
-dataserver_lifo 0
856
-
857
-# If set to 1, the policy manager is enabled and the server is listening the policy queue. 
858
-# 0 by default (PANDORA FMS ENTERPRISE ONLY) 
859
-
860
-policy_manager 1
861
-
862
-# If set to 1, the event replicate process is enabled. 0 by default. (PANDORA FMS ENTERPRISE ONLY) 
863
-# WARNING: This process doesn't do anything if is not properly configured from the console setup 
864
-
865
-event_replication 0
866
-
867
-# If set to 1, new events validate older event for the same module. This will
868
-# affect the performance of the server. This was the "normal behaviour" on previous (4.x) versions.
869
-# disable only if you really know what you are doing !!.
870
-
871
-event_auto_validation 1
872
-
873
-# If defined, events generated by Pandora FMS will be written to the specified text file.
874
-#event_file /var/log/pandora/pandora_events.txt
875
-
876
-# Set the maximum number of traps that will be processed from a single source in a
877
-# configured time interval.
878
-snmp_storm_protection 25
879
-
880
-# Time interval for snmp_storm protection (in seconds).
881
-snmp_storm_timeout 10
882
-
883
-# Default texts for some events. The macros _module_ and _data_ are supported.
884
-#text_going_down_normal Module '_module_' is going to NORMAL (_data_)
885
-#text_going_up_critical Module '_module_' is going to CRITICAL (_data_)
886
-#text_going_up_warning Module '_module_' is going to WARNING (_data_)
887
-#text_going_down_warning Module '_module_' is going to WARNING (_data_)
888
-#text_going_unknown Module '_module_' is going to UNKNOWN
889
-
890
-# Events older that the specified time (in seconds) will be auto-validated. Set to 0 to disable this feature.
891
-event_expiry_time 0
892
-
893
-# Only events more recent than the specified time window (in seconds) will be auto-validated. This value must
894
-# be greater than event_expiry_time.
895
-#event_expiry_window 86400
896
Index: conf/pandora_server.conf.new
897
===================================================================
898
--- conf/pandora_server.conf.new	(revision 10314)
899
+++ conf/pandora_server.conf.new	(working copy)
900
@@ -86,6 +86,18 @@
901
 
902
 snmpconsole 0
903
 
904
+# snmpconsole_threads: number of SNMP console threads for processing SNMP traps.
905
+
906
+snmpconsole_threads 1
907
+
908
+# Attempt to translate variable bindings when processing SNMP traps. 1 enabled, 0 disabled. 0 by default. (ENTERPRISE ONLY).
909
+
910
+translate_variable_bindings 0
911
+
912
+# Attempt to translate enterprise strings when processing SNMP traps. 1 enabled, 0 disabled. 1 by default. (ENTERPRISE ONLY).
913
+
914
+translate_enterprise_strings 0
915
+
916
 # snmptrapd will ignore authenticationFailure traps if set to 1.
917
 
918
 snmp_ignore_authfailure 1
919
@@ -141,9 +153,10 @@
920
 network_threads 4
921
 
922
 # icmp_checks x : defines number of pings for each icmp_proc module type. at least one of 
923
-# that ping should be 1 to report 1
924
+# that ping should be 1 to report 1. Setting this to 1 will make all icmp montioring faster but
925
+# with more probability of failure. 
926
 
927
-icmp_checks 1
928
+icmp_checks 3
929
 
930
 # tcp specific options :
931
 # tcp_checks: number of tcp retries if first attempt fails.
932
@@ -231,6 +244,9 @@
933
 
934
 nmap /usr/bin/nmap
935
 
936
+# A value that specifies how aggressive nmap should be from 1 to 5. 1 means slower but more reliable, 5 means faster but less reliable. 2 by default.
937
+nmap_timing_template 2
938
+
939
 # snmpget: Needed to do SNMP checks. By default is on /usr/bin/snmpget
940
 
941
 snmpget /usr/bin/snmpget
942
Index: ChangeLog
943
===================================================================
944
--- ChangeLog	(revision 10314)
945
+++ ChangeLog	(working copy)
946
@@ -1,3 +1,160 @@
947
+2014-08-14  Koichiro Kikuchi <koichiro@rworks.jp>
948
+
949
+	* FreeBSD/tentacle_server: Set rcvar statically.
950
+
951
+2014-08-13  Ramon Novoa  <rnovoa@artica.es>
952
+
953
+	* pandora_server.redhat.spec: Fixed some typos (packages were not
954
+	  being built).
955
+
956
+2014-08-12  Koichiro Kikuchi <koichiro@rworks.jp>
957
+
958
+	* bin/pandora_server: Fixed issue that pandora_server failed to
959
+	 shut down properly on non-Linux systems.
960
+
961
+	Merged r10335 from branch 5.0.
962
+
963
+2014-08-12  Koichiro Kikuchi <koichiro@rworks.jp>
964
+
965
+	* pandora_server_installer: Refactord implementation, added
966
+	"fakeroot" installation support, small bug fixes and improvements:
967
+	fixed processing arguments, replace "test -e" with "test -f" for portability
968
+	(solaris' /bin/sh doesn't support "test -e").
969
+
970
+	* Makefile.PL: Install bin/tentacle_server if WITHOUT_TENTACLE=0 so that
971
+	MakeMaker can fix perl path in the shebang line.
972
+
973
+	* pandora_server.redhat.spec: Added missing dependency.
974
+
975
+	* FreeBSD/pandora_server.conf -> FreeBSD/pandora_server.conf.new: Renamed
976
+	* NetBSD/pandora_server.conf  -> NetBSD/pandora_server.conf.new: Rename
977
+
978
+	* FreeBSD/tentacle_server: Small bug fix and improvements. Fixed
979
+	"tentacle_server_flags" and modified code to use proper variables and
980
+	to get pid more strictly.
981
+
982
+	* FreeBSD/pandora_server: Added support to start multiple pandora_server
983
+	instances.
984
+
985
+2014-08-12  Junichi Satoh <junichi@rworks.jp>
986
+
987
+	* lib/PandoraFMS/Core.pm, lib/PandoraFMS/DataServer.pm: Fixed sql
988
+	error with MySQL 5.6 and its default sql_mode.
989
+
990
+2014-08-11 Hirofumi Kosaka <kosaka@rworks.jp>
991
+
992
+	* lib/PandoraFMS/Core.pm: Fixed modules would have ignored
993
+	ff_threshold when the module shifted from normal to critical
994
+	while its status remained unknown.
995
+
996
+2014-08-07  Ramon Novoa  <rnovoa@artica.es>
997
+
998
+	* util/recon_scripts/snmp-recon.pl,
999
+	  util/recon_scripts/wmi-recon.pl: Set a default value
1000
+	  for nmap_timing_template.
1001
+
1002
+2014-08-07  Ramon Novoa  <rnovoa@artica.es>
1003
+
1004
+	* conf/pandora_server.conf.new,
1005
+	  lib/PandoraFMS/Config.pm,
1006
+	  lib/PandoraFMS/ReconServer.pm,
1007
+	  util/recon_scripts/snmp-recon.pl,
1008
+	  util/recon_scripts/wmi-recon.pl: Added a new parameter to control how
1009
+	  aggressive nmap should be.
1010
+
1011
+2014-08-06  Sancho Lerena <slerena@artica.es>
1012
+
1013
+	* NetBSD/pandora_server.conf,
1014
+	conf/pandora_server.conf.new,
1015
+	conf/pandora_server.conf.windows: New default value for icmp_retries
1016
+	to have default setup more realiable but a bit slower. 
1017
+
1018
+2014-08-06  Alejandro Gallardo <alejandro.gallardo@artica.es>
1019
+
1020
+	* lib/PandoraFMS/NetworkServer.pm: Little syntax fix.
1021
+
1022
+	* util/pandora_revent_create.pl: Changed the url encode
1023
+	separator of the api call from "," to "|".
1024
+
1025
+2014-08-06  Ramon Novoa  <rnovoa@artica.es>
1026
+
1027
+	* lib/PandoraFMS/NetworkServer.pm: Rewrote TCP module socket code for
1028
+	  sending data (tcp_send). Fixes ticket #1096.
1029
+
1030
+2014-08-05 Hirofumi Kosaka <kosaka@rworks.jp>
1031
+
1032
+	* lib/PandoraFMS/Core.pm: Suppress "going to normal (warning,
1033
+	critical)" events from "unknown" status, if you disable "Throw
1034
+	unknown events" at the Console.
1035
+
1036
+2014-08-05 Hirofumi Kosaka <kosaka@rworks.jp>
1037
+
1038
+	* lib/PandoraFMS/Core.pm: Fixed that unknown modules would be
1039
+	set to normal if its status is not normal, when new data
1040
+	arrives but ff_threshold is greater than 0.
1041
+
1042
+2014-07-30  Ramon Novoa  <rnovoa@artica.es>
1043
+
1044
+	* util/trap_rate.sh: Added to repository. Script to calculate the rate of
1045
+	  SNMP traps received by snmptrapd.
1046
+
1047
+2014-07-30  Ramon Novoa  <rnovoa@artica.es>
1048
+
1049
+	* lib/PandoraFMS/Core.pm: Set unknown modules to normal if new data
1050
+	  arrives but ff_threshold is greater than 0.
1051
+
1052
+2014-07-28  Ramon Novoa  <rnovoa@artica.es>
1053
+
1054
+	* conf/pandora_server.conf.new,
1055
+	  lib/PandoraFMS/Config.pm: Added configuration tokens to disable the
1056
+	  translation of enterprise strings and variable bindings (SNMP console).
1057
+
1058
+	* lib/PandoraFMS/SNMPServer.pm: Added thread support to the SNMP console.
1059
+
1060
+	* lib/PandoraFMS/DB.pm: Fixed a warning.
1061
+
1062
+2014-07-25  Miguel de Dios <miguel.dedios@artica.es>
1063
+	
1064
+	* lib/PandoraFMS/GIS.pm, lib/PandoraFMS/DB.pm,
1065
+	lib/PandoraFMS/Core.pm, lib/PandoraFMS/ReconServer.pm,
1066
+	lib/PandoraFMS/DataServer.pm: tiny fixes for to improve the support
1067
+	of PostgreSQL.
1068
+
1069
+2014-07-25  Junichi Satoh <junichi@rworks.jp>
1070
+
1071
+	* util/pandora_db.pl: Fixed error when 'dbengine' token is not defined
1072
+	in pandora_server.conf with enterprise installed.
1073
+
1074
+2014-07-23  Miguel de Dios <miguel.dedios@artica.es>
1075
+	
1076
+	* util/plugin/snmp_remote.pl: some fixed for the snmp v3.
1077
+
1078
+2014-06-17  Vanessa Gil <vanessa.gil@artica.es>
1079
+
1080
+	* lib/PandoraFMS/Core.pm: Added macros
1081
+	'_alert_critical_instructions_' and
1082
+	'_alert_warning_instructions_'.
1083
+
1084
+2014-07-11 Hirofumi Kosaka <kosaka@rworks.jp>
1085
+
1086
+	* util/pandora_manage.pl: To handle multi-byte strings in
1087
+	command line arguments (assumes utf-8).
1088
+
1089
+2014-07-08 Vanessa Gil <vanessa.gil@artica.es>
1090
+	
1091
+	* util/pandora_manage.pl: Fixed problem
1092
+	with entities.
1093
+
1094
+2014-07-08 Vanessa Gil <vanessa.gil@artica.es>
1095
+	
1096
+	* util/pandora_manage.pl: Fixed help screen.
1097
+
1098
+2014-07-08 Vanessa Gil <vanessa.gil@artica.es>
1099
+	
1100
+	* util/pandora_manage.pl
1101
+	  lib/PandoraFMS/Core.pm: Added 'create_data_module_from_local_component'
1102
+	and 'create_local_component' functions to CLI.
1103
+
1104
 2014-06-26  Ramon Novoa  <rnovoa@artica.es>
1105
 
1106
 	* util/pandora_xml_stress.pl: Remove new line and carriage return
1107
Index: Makefile.PL
1108
===================================================================
1109
--- Makefile.PL	(revision 10314)
1110
+++ Makefile.PL	(working copy)
1111
@@ -1,6 +1,12 @@
1112
 use 5.000;
1113
 use ExtUtils::MakeMaker;
1114
 
1115
+my %ARGV = map { my @r = split /=/,$_; defined $r[1] or $r[1]=1; @r } @ARGV;
1116
+
1117
+my @exe_files = qw(bin/pandora_server bin/pandora_exec);
1118
+
1119
+$ARGV{WITHOUT_TENTACLE} or push @exe_files, 'bin/tentacle_server';
1120
+
1121
 WriteMakefile(
1122
 	INSTALLSITELIB  => '/usr/lib/perl5',
1123
 	(($^O eq 'freebsd')
1124
@@ -27,10 +33,9 @@
1125
 		HTML::Entities => 0,
1126
 		IO::Socket::INET6 => 0,
1127
 		JSON => 0,
1128
-    },
1129
-    EXE_FILES 		=> [ 'bin/pandora_server', 'bin/pandora_exec'],
1130
-    PMLIBDIRS  		=> [ 'lib' ],
1131
-    'dist'		=> { 'TAR' => 'tar', 'TARFLAGS' => 'cvfz', 'SUFFIX'
1132
-=> '.gz', 'COMPRESS' => 'gzip'}
1133
+	},
1134
+	EXE_FILES 		=> [ @exe_files ],
1135
+	PMLIBDIRS  		=> [ 'lib' ],
1136
+	'dist'		=> { 'TAR' => 'tar', 'TARFLAGS' => 'cvfz', 'SUFFIX' => '.gz', 'COMPRESS' => 'gzip'}
1137
 );
1138
 
1139
Index: pandora_server_installer
1140
===================================================================
1141
--- pandora_server_installer	(revision 10314)
1142
+++ pandora_server_installer	(working copy)
1143
@@ -10,97 +10,177 @@
1144
 
1145
 
1146
 MODE=$1
1147
-SECOPT=$2
1148
+shift
1149
+
1150
+# Defaults
1151
+PREFIX=/usr
1152
 PANDORA_SPOOL=/var/spool/pandora
1153
-PANDORA_HOME=/usr/share/pandora_server
1154
+PANDORA_HOME=$PREFIX/share/pandora_server
1155
 PANDORA_CFG_DIR=/etc/pandora
1156
 PANDORA_LOG=/var/log/pandora
1157
 PANDORA_SERVER=/etc/init.d/pandora_server
1158
 TENTACLE_SERVER=/etc/init.d/tentacle_serverd
1159
-PANDORA_CFG_FILE=/etc/pandora/pandora_server.conf
1160
+PANDORA_CFG_FILE=$PANDORA_CFG_DIR/pandora_server.conf
1161
+PANDORA_CFG_FILE_DIST=conf/pandora_server.conf.new
1162
+PANDORA_INIT_SCRIPT=util/pandora_server
1163
+TENTACLE_INIT_SCRIPT=util/tentacle_serverd
1164
+PERL=perl
1165
+MANDIR=$PREFIX/share/man/man1
1166
+INITDIR=/etc/init.d
1167
+WITHOUT_TENTACLE=0
1168
 
1169
+#
1170
+# set_global_vars
1171
+#	Check platform and set DISTRO, OS_VERSION and LINUX.
1172
+#	Also, define some platform sepcific variables (e.g. PANDORA_RC_VAR for (Free|Net)BSD) 
1173
+#	and override some of defaults defined above if needed.
1174
+#
1175
+set_global_vars () {
1176
+	# Default
1177
+	LINUX=NO
1178
+	OS_VERSION=`uname -r`
1179
+	DISTRO=`uname -s`
1180
 
1181
-get_distro () {
1182
-	# Get Linux Distro type and version
1183
-	# We assume we are on Linux unless told otherwise
1184
-	LINUX=YES
1185
-	if [ -f "/etc/SuSE-release" ]
1186
-	then
1187
-		OS_VERSION=`cat /etc/SuSE-release | grep VERSION | cut -f 3 -d " "`
1188
-		LINUX_DISTRO=SUSE
1189
-	elif [ -f "/etc/lsb-release" ] && [ ! -f "/etc/redhat-release" ]
1190
-	then
1191
-		OS_VERSION=`cat /etc/lsb-release | grep DISTRIB_RELEASE | cut -f 2 -d "="`
1192
-		LINUX_DISTRO=UBUNTU
1193
-		OS_VERSION="UBUNTU $OS_VERSION"
1194
-	elif [ -f "/etc/debian_version" ]
1195
-	then
1196
-		OS_VERSION=`cat /etc/debian_version`
1197
-		OS_VERSION="DEBIAN $OS_VERSION"
1198
-		LINUX_DISTRO=DEBIAN
1199
-	elif [ -f "/etc/fedora-release" ]
1200
-	then
1201
-		OS_VERSION=`cat /etc/fedora-release | cut -f 4 -d " "`
1202
-		OS_VERSION="FEDORA $OS_VERSION"
1203
-		LINUX_DISTRO=FEDORA
1204
-	elif [ `uname -s` = "Darwin" ]
1205
-	then
1206
-		# For future reference, Darwin doesn't have /etc/init.d but uses LaunchDaemons
1207
-		LINUX_DISTRO="Darwin"
1208
-		OS_VERSION=`uname -r`
1209
-		LINUX=NO
1210
-	elif [ `uname -s` = "AIX" ]
1211
-	then
1212
-		# For future reference, AIX doesn't have /etc/init.d
1213
-		LINUX_DISTRO="AIX"
1214
-		OS_VERSION=`uname -r`
1215
-		LINUX=NO
1216
-	elif [ `uname -s` = "SunOS" ]
1217
-	then
1218
+	# set corret value for LINUX_DISTRO
1219
+	case $DISTRO in
1220
+	Linux)
1221
+		# Default for Linux
1222
+		LINUX=YES
1223
+		DISTRO="GENERIC"
1224
+		# Get Linux Distro type and version
1225
+		# We assume we are on Linux unless told otherwise
1226
+		if [ -f "/etc/SuSE-release" ]
1227
+		then
1228
+			OS_VERSION=`cat /etc/SuSE-release | grep VERSION | cut -f 3 -d " "`
1229
+			DISTRO=SUSE
1230
+		elif [ -f "/etc/lsb-release" ] && [ ! -f "/etc/redhat-release" ]
1231
+		then
1232
+			OS_VERSION=`cat /etc/lsb-release | grep DISTRIB_RELEASE | cut -f 2 -d "="`
1233
+			DISTRO=UBUNTU
1234
+			OS_VERSION="UBUNTU $OS_VERSION"
1235
+		elif [ -f "/etc/debian_version" ]
1236
+		then
1237
+			OS_VERSION=`cat /etc/debian_version`
1238
+			OS_VERSION="DEBIAN $OS_VERSION"
1239
+			DISTRO=DEBIAN
1240
+		elif [ -f "/etc/fedora-release" ]
1241
+		then
1242
+			OS_VERSION=`cat /etc/fedora-release | cut -f 4 -d " "`
1243
+			OS_VERSION="FEDORA $OS_VERSION"
1244
+			DISTRO=FEDORA
1245
+		fi
1246
+		;;
1247
+	Darwin|AIX)
1248
+		# For future reference, Darwin doesn't have /etc/init.d but uses LaunchDaemons.
1249
+		# AIX doesn't have /etc/init.d
1250
+		;;
1251
+	SunOS)
1252
 		# Some Solaris and other Unices don't have /etc/init.d, some have /usr/spool instead of /var/spool
1253
-		LINUX_DISTRO="Solaris"
1254
-		OS_VERSION=`uname -r`
1255
-		LINUX=NO
1256
-	elif [ `uname -s` = "Linux" ]
1257
+		DISTRO="Solaris"
1258
+		;;
1259
+	FreeBSD)
1260
+		PREFIX=/usr/local
1261
+		PANDORA_HOME=$PREFIX/share/pandora_server
1262
+		PANDORA_CFG_DIR=$PREFIX/etc/pandora
1263
+		PANDORA_SERVER=$PREFIX/etc/rc.d/pandora_server
1264
+		TENTACLE_SERVER=$PREFIX/etc/rc.d/tentacle_server
1265
+		PANDORA_CFG_FILE=$PANDORA_CFG_DIR/pandora_server.conf
1266
+		PANDORA_CFG_FILE_DIST=$DISTRO/pandora_server.conf.new
1267
+		PANDORA_INIT_SCRIPT=$DISTRO/pandora_server
1268
+		TENTACLE_INIT_SCRIPT=$DISTRO/tentacle_server
1269
+		MANDIR=$PREFIX/man/man1
1270
+		INITDIR=$PREFIX/etc/rc.d
1271
+		PERL=/usr/local/bin/perl
1272
+		PANDORA_RC_VAR="pandora_server_enable"
1273
+		TENTACLE_RC_VAR="tentacle_server_enable"
1274
+		;;
1275
+	NetBSD)
1276
+		PREFIX=/usr/local
1277
+		PANDORA_HOME=$PREFIX/share/pandora_server
1278
+		PANDORA_CFG_DIR=$PREFIX/etc/pandora
1279
+		PANDORA_SERVER=/etc/rc.d/pandora_server
1280
+		TENTACLE_SERVER=/etc/rc.d/tentacle_server
1281
+		PANDORA_CFG_FILE=$PANDORA_CFG_DIR/pandora_server.conf
1282
+		PANDORA_CFG_FILE_DIST=$DISTRO/pandora_server.conf.new
1283
+		PANDORA_INIT_SCRIPT=$DISTRO/pandora_server
1284
+		TENTACLE_INIT_SCRIPT=$DISTRO/tentacle_server
1285
+		PERL=/usr/pkg/bin/perl
1286
+		INITDIR=/etc/rc.d
1287
+		PANDORA_RC_VAR="pandora_server"
1288
+		TENTACLE_RC_VAR="tentacle_server"
1289
+		;;
1290
+	esac
1291
+}
1292
+
1293
+#
1294
+# install_startup_script [options...] SRC
1295
+#	copy SRC into the $INITDIR and do additional required operation according to $DISTRO
1296
+#	if $INITDIR is not set or empty, do nothing.
1297
+#	If $DESTDIR is set, skip enabling service
1298
+#	OPTIONS:
1299
+#		-s SPRIO  specify startup priority for service
1300
+#
1301
+install_startup_script () {
1302
+	[ "$INITDIR" ] || return 1
1303
+	if [ "$1" = "-s" ]
1304
 	then
1305
-		# Test for Linux to make sure we're on Linux
1306
-		LINUX_DISTRO="GENERIC"
1307
-		OS_VERSION=`uname -r`
1308
-	elif [ `uname -s` = "FreeBSD" ]
1309
-	then
1310
-		LINUX_DISTRO="FreeBSD"
1311
-		OS_VERSION=`uname -r`
1312
-		LINUX=NO
1313
-	elif [ `uname -s` = "NetBSD" ]
1314
-	then
1315
-		LINUX_DISTRO="NetBSD"
1316
-		OS_VERSION=`uname -r`
1317
-		LINUX=NO
1318
-	else
1319
-		# Default to Linux is false, test for real Linux above - that way we don't assume we can just plunk down files everywhere
1320
-		LINUX_DISTRO=`uname -s`
1321
-		OS_VERSION=`uname -r`
1322
-		LINUX=NO
1323
+		SPRIO=$2
1324
+		shift;shift
1325
 	fi
1326
-	echo "$LINUX_DISTRO:$OS_VERSION:$LINUX"
1327
+	SRC=$1
1328
+	SCRIPT_NAME=`basename $SRC`
1329
+
1330
+	echo "Copying the daemon script into $INITDIR"
1331
+	cp $SRC $DESTDIR$INITDIR
1332
+
1333
+	[ "$DESTDIR" ] && return
1334
+
1335
+	case $DISTRO in
1336
+	UBUNTU|DEBIAN)
1337
+		echo "Linking startup script to /etc/rc2.d"
1338
+		update-rc.d $SCRIPT_NAME defaults
1339
+		;;
1340
+	SUSE)
1341
+		echo "Creating startup daemons"
1342
+		insserv $SCRIPT_NAME
1343
+		;;
1344
+	FeeBSD|NetBSD)
1345
+		chmod 555 $DESTDIR$INITDIR/$SCRIPT_NAME
1346
+		;;
1347
+	*)
1348
+		if [ "$LINUX" = YES ]
1349
+		then
1350
+			# Pandora FMS Server install (Other Distros)
1351
+			INITLV=`grep '[0-9]:initdefault' /etc/inittab | cut -f 2 -d ':'`
1352
+			: ${INITLV:=2}
1353
+			echo "Linking startup script to /etc/rc.d/rc$INITLV.d/S$SPRIO$SCRIPT_NAME"
1354
+			ln -s $INITDIR/$SCRIPT_NAME /etc/rc.d/rc$INITLV.d/S$SPRIO$SCRIPT_NAME
1355
+		fi
1356
+		;;
1357
+	esac
1358
 }
1359
 
1360
-
1361
 install () {
1362
+	set_global_vars
1363
 
1364
-	perl Makefile.PL > output 2>&1 #&& sleep 2 && cat output | grep "found" | wc -l 
1365
+	FORCE=0
1366
+
1367
+	# parse options
1368
+	while :
1369
+	do
1370
+		case $1 in
1371
+		--force) FORCE=1;;
1372
+		--no-tentacle) WITHOUT_TENTALCE=1;;
1373
+		--destdir) DESTDIR=$2;shift;;
1374
+		*) break;;
1375
+		esac
1376
+		shift
1377
+	done
1378
+
1379
+	$PERL Makefile.PL INSTALLMAN1DIR=none WITHOUT_TENTACLE=$WITHOUT_TENTACLE > output 2>&1
1380
+	#&& sleep 2 && cat output | grep "found" | wc -l 
1381
 	DEPENDENCIAS=`cat output | grep "found" | wc -l`
1382
 
1383
-	FORCE=0
1384
-
1385
-	if [ ! -z "$SECOPT" ]
1386
-	then
1387
-		if [ "$SECOPT" = "--force" ]
1388
-		then
1389
-			FORCE=1
1390
-		fi
1391
-	fi
1392
-			
1393
 	if [ $DEPENDENCIAS -gt 0 ] && [ $FORCE -eq 0 ]
1394
 	then
1395
 		echo "You are missing the following dependencies"
1396
@@ -142,448 +222,251 @@
1397
 		echo "	$ cpan Time::Local DBI Socket6 XML::Simple XML::Twig IO::Socket Time::HiRes NetAddr::IP HTML::Entities IO::Socket::INET6 JSON"
1398
 		echo " "
1399
 		rm output
1400
-	else
1401
+		exit 1
1402
+	fi
1403
+	rm output
1404
 
1405
-		# This returns a multiple value string, separated with ":" -> $LINUX_DISTRO:$OS_VERSION:$LINUX	
1406
-		GET_DISTRO="`get_distro`"
1407
-		DISTRO=`echo $GET_DISTRO | cut -f 1 -d ":"`
1408
-		OS_VERSION=`echo $GET_DISTRO | cut -f 2 -d ":"`
1409
-		LINUX=`echo $GET_DISTRO | cut -f 3 -d ":"`	
1410
-	
1411
-		if [ "$DISTRO" = "UBUNTU" ]
1412
-		then
1413
-			echo "UBUNTU distribution detected"
1414
-		elif [ "$DISTRO" = "SUSE" ]
1415
-		then
1416
-			echo "SUSE distribution detected"
1417
-		elif [ "$DISTRO" = "FreeBSD" ]
1418
-                then
1419
-			echo "FreeBSD detected"
1420
-			PANDORA_SPOOL=/var/spool/pandora
1421
-			PANDORA_HOME=/usr/local/share/pandora_server
1422
-			PANDORA_CFG_DIR=/usr/local/etc/pandora
1423
-			PANDORA_LOG=/var/log/pandora
1424
-			PANDORA_SERVER=/usr/local/etc/rc.d/pandora_server
1425
-			TENTACLE_SERVER=/usr/local/etc/rc.d/tentacle_server
1426
-			PANDORA_CFG_FILE=/usr/local/etc/pandora/pandora_server.conf
1427
-		elif [ "$DISTRO" = "NetBSD" ]
1428
-		then
1429
-			echo "NetBSD detected"
1430
-			PANDORA_SPOOL=/var/spool/pandora
1431
-			PANDORA_HOME=/usr/local/share/pandora_server
1432
-			PANDORA_CFG_DIR=/usr/local/etc/pandora
1433
-			PANDORA_LOG=/var/log/pandora
1434
-			PANDORA_SERVER=/etc/rc.d/pandora_server
1435
-			TENTACLE_SERVER=/etc/rc.d/tentacle_server
1436
-			PANDORA_CFG_FILE=/usr/local/etc/pandora/pandora_server.conf
1437
-                
1438
-			sed s:/usr/bin/perl:/usr/pkg/bin/perl: bin/pandora_server > bin/tmp
1439
-			mv bin/tmp bin/pandora_server
1440
-			sed s:/usr/bin/perl:/usr/pkg/bin/perl: bin/pandora_exec > bin/tmp
1441
-			mv bin/tmp bin/pandora_exec
1442
-			sed s:/usr/bin/perl:/usr/pkg/bin/perl: bin/tentacle_server > bin/tmp
1443
-			mv bin/tmp bin/tentacle_server
1444
-
1445
-		fi
1446
+	if [ "$LINUX" = YES ]
1447
+	then
1448
+		echo "$DISTRO distribution detected"
1449
+	else 
1450
+		echo "$DISTRO detected"
1451
+	fi
1452
 		
1453
-		echo "Installing binaries and libraries"
1454
-		make
1455
-		make install
1456
+	echo "Installing binaries and libraries"
1457
+	make
1458
+	make DESTDIR=$DESTDIR install
1459
 		
1460
-	    echo "Checking binaries at /usr/local/bin -> /usr/bin"
1461
-		if [ ! -e "/usr/bin/pandora_server" ]
1462
+	echo "Checking binaries at /usr/local/bin -> /usr/bin"
1463
+	if [ ! -f "$DESTDIR/usr/bin/pandora_server" ] 
1464
+	then
1465
+		if [ ! -f "$DESTDIR/usr/local/bin/pandora_server" ]
1466
 		then
1467
-			if [ ! -e "/usr/local/bin/pandora_server" ]
1468
-			then
1469
-				echo "ERROR compiling Pandora FMS Server from sources. Aborting"
1470
-				exit 1
1471
-			fi
1472
-			if [ "$DISTRO" != "FreeBSD" -a "$DISTRO" != "NetBSD" ]
1473
-			then
1474
-				ln -s /usr/local/bin/pandora_server /usr/bin
1475
-				ln -s /usr/local/bin/pandora_exec /usr/bin		
1476
-			fi
1477
+			echo "ERROR compiling Pandora FMS Server from sources. Aborting"
1478
+			exit 1
1479
 		fi
1480
-
1481
-		echo "Creating common Pandora FMS directories"
1482
-		id pandora 2> /dev/null
1483
-		if [ $? -eq 0 ]; then
1484
-			echo " "
1485
-			echo "User pandora does exist, make sure the SSH directories are correct"
1486
-		else
1487
-			echo "Are you sure we can create a standard 'pandora' user locally? [y/N]"
1488
-			read AREYOUSURE
1489
-			if [ "$AREYOUSURE" = "y" ]; then
1490
-				if [ "$DISTRO" = "FreeBSD" ]
1491
-				then
1492
-					echo "pandora:41121:::::Pandora FMS:/home/pandora:/usr/sbin/nologin:" | adduser -f - -w no 2> /dev/null
1493
-				else
1494
-					useradd pandora 
1495
-					mkdir /home/pandora 2> /dev/null
1496
-					mkdir /home/pandora/.ssh 2> /dev/null
1497
-					chown -R pandora /home/pandora 
1498
-				fi
1499
-			else
1500
-				echo "Please create the 'pandora' user manually according to your authentication scheme, then start again the installation"
1501
-				echo "Aborting..."
1502
-				exit 1
1503
-			fi
1504
+		if [ "$DISTRO" != "FreeBSD" ] && [ "$DISTRO" != "NetBSD" ]
1505
+		then
1506
+			ln -s /usr/local/bin/pandora_server $DESTDIR$PREFIX
1507
+			ln -s /usr/local/bin/pandora_exec $DESTDIR$PREFIX
1508
 		fi
1509
+	fi
1510
 
1511
-		mkdir $PANDORA_SPOOL 2> /dev/null
1512
-		mkdir $PANDORA_SPOOL/data_in 2> /dev/null
1513
-		chmod 770 $PANDORA_SPOOL/data_in
1514
-		mkdir $PANDORA_SPOOL/data_in/conf 2> /dev/null
1515
-		chmod 770 $PANDORA_SPOOL/data_in/conf
1516
-		mkdir $PANDORA_SPOOL/data_in/md5 2> /dev/null
1517
-		chmod 770 $PANDORA_SPOOL/data_in/md5
1518
-		mkdir $PANDORA_SPOOL/data_in/collections 2> /dev/null
1519
-		chmod 770 $PANDORA_SPOOL/data_in/collections
1520
-		mkdir $PANDORA_SPOOL/data_in/netflow 2> /dev/null
1521
-		chmod 770 $PANDORA_SPOOL/data_in/netflow
1522
-		mkdir $PANDORA_LOG 2> /dev/null	
1523
-
1524
-		echo "Giving proper permission to /var/spool/pandora"
1525
-		IDGROUP=`id -g www-data 2> /dev/null`
1526
-		if [ $? -eq 0 ]
1527
-		then
1528
-			GROUPNAME=`cat /etc/group | grep ":$IDGROUP:" | awk -F":" '{print $1}'`
1529
-			chown -R pandora:$GROUPNAME $PANDORA_SPOOL
1530
-		else
1531
-			IDGROUP=`id -g wwwrun 2> /dev/null`
1532
-			if [ $? -eq 0 ]
1533
+	echo "Creating common Pandora FMS directories"
1534
+	id pandora 2> /dev/null
1535
+	if [ $? -eq 0 ]; then
1536
+		echo " "
1537
+		echo "User pandora does exist, make sure the SSH directories are correct"
1538
+	elif [ "$DESTDIR" ]
1539
+	then
1540
+		# chown can fail with fakeroot installation
1541
+		echo "User 'pandora' does not exist. All chown operations may fail."
1542
+		echo "You should manualy set proper ownership to $DESTDIR$PANDORA_SPOOL if needed."
1543
+		echo
1544
+	else
1545
+		echo "Are you sure we can create a standard 'pandora' user locally? [y/N]"
1546
+		read AREYOUSURE
1547
+		if [ "$AREYOUSURE" = "y" ]; then
1548
+			if [ "$DISTRO" = "FreeBSD" ]
1549
 			then
1550
-				GROUPNAME=`cat /etc/group | grep ":$IDGROUP:" | awk -F":" '{print $1}'`
1551
-				chown -R pandora:$GROUPNAME $PANDORA_SPOOL
1552
+				echo "pandora:41121:::::Pandora FMS:/home/pandora:/usr/sbin/nologin:" | adduser -f - -w no 2> /dev/null
1553
 			else
1554
-				IDGROUP=`id -g www 2> /dev/null`
1555
-				if [ $? -eq 0 ]
1556
-				then
1557
-					GROUPNAME=`cat /etc/group | grep ":$IDGROUP:" | awk -F":" '{print $1}'`
1558
-					chown -R pandora:$GROUPNAME $PANDORA_SPOOL
1559
-				else
1560
-					IDGROUP=`id -g apache 2> /dev/null`
1561
-					if [ $? -eq 0 ]
1562
-					then
1563
-						GROUPNAME=`cat /etc/group | grep ":$IDGROUP:" | awk -F":" '{print $1}'`
1564
-						chown -R pandora:$GROUPNAME $PANDORA_SPOOL
1565
-					else
1566
-						echo "No web server user found, some functionality might not perform correctly"
1567
-						chown -R pandora:root $PANDORA_SPOOL
1568
-					fi
1569
-				fi
1570
+				useradd pandora 
1571
+				mkdir /home/pandora 2> /dev/null
1572
+				mkdir /home/pandora/.ssh 2> /dev/null
1573
+				chown -R pandora /home/pandora 
1574
 			fi
1575
-		fi
1576
-		
1577
-		
1578
-		echo "Creating setup directory in $PANDORA_CFG_DIR"
1579
-		mkdir $PANDORA_CFG_DIR 2> /dev/null
1580
-		if [ "$DISTRO" = "FreeBSD" ]
1581
-		then
1582
-			if [ -e $PANDORA_CFG_FILE ]
1583
-			then
1584
-				OLDFILENAMETMP=`date +"%Y-%m-%d"`
1585
-				echo "Old installation detected, backing up pandora_server.conf.$ODFILENAMETMP"
1586
-				mv $PANDORA_CFG_FILE $PANDORA_CFG_FILE.$OLDFILENAMETMP
1587
-			fi
1588
-			echo cp FreeBSD/pandora_server.conf $PANDORA_CFG_DIR
1589
-                	cp FreeBSD/pandora_server.conf $PANDORA_CFG_DIR
1590
-		elif [ "$DISTRO" = "NetBSD" ]
1591
-		then
1592
-			if [ ! -d $PANDORA_CFG_DIR ]
1593
-			then
1594
-				mkdir -p $PANDORA_CFG_DIR
1595
-			fi
1596
-			if [ -e $PANDORA_CFG_FILE ]
1597
-			then
1598
-				OLDFILENAMETMP=`date +"%Y-%m-%d"`
1599
-				echo "Old installation detected, backing up pandora_server.conf.$ODFILENAMETMP"
1600
-				mv $PANDORA_CFG_FILE $PANDORA_CFG_FILE.$OLDFILENAMETMP
1601
-			fi
1602
-			echo cp NetBSD/pandora_server.conf $PANDORA_CFG_DIR
1603
-			cp NetBSD/pandora_server.conf $PANDORA_CFG_DIR     
1604
 		else
1605
-			if [ -f "$PANDORA_CFG_FILE" ]
1606
-			then
1607
-				echo cp conf/pandora_server.conf.new $PANDORA_CFG_DIR
1608
-				cp conf/pandora_server.conf.new $PANDORA_CFG_DIR
1609
-			else
1610
-			echo cp conf/pandora_server.conf.new $PANDORA_CFG_FILE
1611
-				cp conf/pandora_server.conf.new $PANDORA_CFG_FILE
1612
-			fi
1613
+			echo "Please create the 'pandora' user manually according to your authentication scheme, then start again the installation"
1614
+			echo "Aborting..."
1615
+			exit 1
1616
 		fi
1617
-		chmod 770 $PANDORA_CFG_FILE
1618
+	fi
1619
 
1620
-		echo "Installing Pandora Server manual"
1621
-		if [ "$DISTRO" = "FreeBSD" ]
1622
+	mkdir -p $DESTDIR$PANDORA_SPOOL/data_in 2> /dev/null
1623
+	chmod 770 $DESTDIR$PANDORA_SPOOL/data_in
1624
+	mkdir $DESTDIR$PANDORA_SPOOL/data_in/conf 2> /dev/null
1625
+	chmod 770 $DESTDIR$PANDORA_SPOOL/data_in/conf
1626
+	mkdir $DESTDIR$PANDORA_SPOOL/data_in/md5 2> /dev/null
1627
+	chmod 770 $DESTDIR$PANDORA_SPOOL/data_in/md5
1628
+	mkdir $DESTDIR$PANDORA_SPOOL/data_in/collections 2> /dev/null
1629
+	chmod 770 $DESTDIR$PANDORA_SPOOL/data_in/collections
1630
+	mkdir $DESTDIR$PANDORA_SPOOL/data_in/netflow 2> /dev/null
1631
+	chmod 770 $DESTDIR$PANDORA_SPOOL/data_in/netflow
1632
+	mkdir -p $DESTDIR$PANDORA_LOG 2> /dev/null	
1633
+
1634
+	echo "Giving proper permission to /var/spool/pandora"
1635
+	for group in "www-data" wwwrun www apache
1636
+	do
1637
+		IDGROUP=`id -g "$group" 2> /dev/null`
1638
+		if [ $? -eq 0 ]
1639
 		then
1640
-			cp man/man1/pandora_server.1.gz /usr/local/man/man1
1641
-		else
1642
-			cp man/man1/pandora_server.1.gz /usr/share/man/man1
1643
+			GROUPNAME=`grep ":$IDGROUP:" /etc/group | awk -F":" '{print $1}'`
1644
+			break
1645
 		fi
1646
+	done
1647
+	if [ -z "$GROUPNAME" ]
1648
+	then
1649
+		echo "No web server user found, some functionality might not perform correctly"
1650
+		GROUPNAME=0
1651
+	fi
1652
+	# when fakeroot installation, this can fail
1653
+	chown -R pandora:$GROUPNAME $DESTDIR$PANDORA_SPOOL 2>/dev/null
1654
 		
1655
-		if [ "$LINUX" = "YES" ]
1656
-		then
1657
-			echo "Copying the daemon script into /etc/init.d/pandora_server"
1658
-			cp util/pandora_server /etc/init.d/		
1659
-			
1660
-			if [ "$DISTRO" = "UBUNTU" ] || [ "$DISTRO" = "DEBIAN" ]
1661
-			then
1662
-			
1663
-				echo "Linking startup script to /etc/rc2.d"
1664
-				update-rc.d pandora_server defaults
1665
-			else
1666
-				if [ "$DISTRO" = "SUSE" ]
1667
-				then
1668
-					echo "Creating startup daemons"
1669
-					insserv pandora_server
1670
-				else
1671
-					# Pandora FMS Server install (Other Distros)
1672
-					INITLV=`cat /etc/inittab | grep "[0-9]\:initdefault" | cut -f 2 -d ":"`
1673
-					if [ -z "$INITLV" ]
1674
-					then
1675
-						INITLV=2
1676
-					fi
1677
-					echo "Linking startup script to /etc/rc.d/rc$INITLV.d"
1678
-					ln -s $PANDORA_SERVER /etc/rc.d/rc$INITLV.d/S90pandora_server
1679
-				fi
1680
-			fi
1681
-		else
1682
-			if [ "$DISTRO" = "FreeBSD" ]
1683
-			then
1684
-				echo "Copying the daemon script into $PANDORA_SERVER"
1685
-				cp FreeBSD/pandora_server $PANDORA_SERVER 
1686
-				chmod 555 $PANDORA_SERVER
1687
-                        fi
1688
-			if [ "$DISTRO" = "NetBSD" ]
1689
-			then
1690
-				echo "Copying the daemon script into $PANDORA_SERVER"
1691
-				cp NetBSD/pandora_server $PANDORA_SERVER 
1692
-				chmod 555 $PANDORA_SERVER
1693
-			fi
1694
-		fi
1695
+	echo "Creating setup directory in $PANDORA_CFG_DIR"
1696
+	mkdir -p $DESTDIR$PANDORA_CFG_DIR 2> /dev/null
1697
+	if [ -f "$DESTDIR$PANDORA_CFG_FILE" ]
1698
+	then
1699
+		echo cp $PANDORA_CFG_FILE_DIST $DESTDIR$PANDORA_CFG_DIR
1700
+		cp $PANDORA_CFG_FILE_DIST $DESTDIR$PANDORA_CFG_DIR
1701
+	else
1702
+		echo cp $PANDORA_CFG_FILE_DIST $DESTDIR$PANDORA_CFG_FILE
1703
+		cp $PANDORA_CFG_FILE_DIST $DESTDIR$PANDORA_CFG_FILE
1704
+		chmod 770 $DESTDIR$PANDORA_CFG_FILE
1705
+	fi
1706
 
1707
-		if [ -d /etc/logrotate.d ]; then
1708
-			echo "Creating logrotate.d entry for Pandora FMS log management"
1709
-			cp util/pandora_logrotate /etc/logrotate.d/pandora
1710
-		else
1711
-			echo "Please add a log rotation schedule manually to your log rotation daemon (if any)"
1712
-		fi
1713
+	echo "Installing Pandora Server manual"
1714
+	cp man/man1/pandora_server.1.gz $DESTDIR$MANDIR
1715
+
1716
+	install_startup_script -s 90 $PANDORA_INIT_SCRIPT
1717
+
1718
+	if [ -d /etc/logrotate.d ]
1719
+	then
1720
+		[ -d $DESTDIR/etc/logrotate.d ] && mkdir -p $DESTDIR/etc/logrotate.d
1721
+		echo "Creating logrotate.d entry for Pandora FMS log management"
1722
+		cp util/pandora_logrotate $DESTDIR/etc/logrotate.d/pandora
1723
+	else
1724
+		echo "Please add a log rotation schedule manually to your log rotation daemon (if any)"
1725
+	fi
1726
 	
1727
-		if [ "$LINUX" = "YES" ]
1728
-		then
1729
-			if [ "$SECOPT" != "--no-tentacle" ]
1730
-			then
1731
-				if [ "$DISTRO" = "UBUNTU" ] || [ "$DISTRO" = "DEBIAN" ]
1732
-				then
1733
-					# Tentacle server install (Ubuntu)
1734
-					echo "Installing tentacle server"
1735
-					cp bin/tentacle_server /usr/bin
1736
-					chown pandora /usr/bin/tentacle_server
1737
-					cp util/tentacle_serverd $TENTACLE_SERVER
1738
-   					update-rc.d tentacle_serverd defaults
1739
-				else
1740
-					if [ "$DISTRO" = "SUSE" ]
1741
-					then
1742
-						echo "Creating Tentacle startup daemon"
1743
-						cp bin/tentacle_server /usr/bin
1744
-						chown pandora /usr/bin/tentacle_server
1745
-						cp util/tentacle_serverd /etc/init.d/tentacle_serverd
1746
-						insserv tentacle_serverd
1747
-					else
1748
-						# Tentacle server install (Other Distros)
1749
-						echo "Installing tentacle server in /etc/rc.d/rc$INITLV.d/S80tentacle_serverd"
1750
-						cp bin/tentacle_server /usr/bin
1751
-						chown pandora /usr/bin/tentacle_server
1752
-						cp util/tentacle_serverd /etc/init.d/tentacle_serverd
1753
-						ln -s $TENTACLE_SERVER /etc/rc.d/rc$INITLV.d/S80tentacle_serverd
1754
-					fi
1755
-				fi
1756
+	if [ $WITHOUT_TENTACLE -eq 0 ]
1757
+	then
1758
+		# tentacle_server is already installed by "make install"
1759
+		install_startup_script -s 80 $TENTACLE_INIT_SCRIPT
1760
+		
1761
+		echo "Installing Tentacle Server manual"
1762
+		cp man/man1/tentacle_server.1.gz $DESTDIR$MANDIR
1763
+	fi
1764
 
1765
-				echo "Installing Tentacle Server manual"
1766
-				cp man/man1/tentacle_server.1.gz /usr/share/man/man1
1767
-			fi
1768
-		else
1769
-			if [ "$SECOPT" != "--no-tentacle" ]
1770
-			then
1771
-				if [ "$DISTRO" = "FreeBSD" ]
1772
-				then
1773
-					echo "Installing tentacle server"
1774
-					cp bin/tentacle_server /usr/local/bin
1775
-					chown pandora /usr/local/bin/tentacle_server
1776
-					chmod 555 /usr/local/bin/tentacle_server
1777
-					cp FreeBSD/tentacle_server $TENTACLE_SERVER
1778
-					chmod 555 $TENTACLE_SERVER
1779
-					echo "Installing Tentacle Server manual"
1780
-					cp man/man1/tentacle_server.1.gz /usr/local/man/man1
1781
-				fi
1782
-				if [ "$DISTRO" = "NetBSD" ]
1783
-				then
1784
-					echo "Installing tentacle server"
1785
-					cp bin/tentacle_server /usr/local/bin
1786
-					chown pandora /usr/local/bin/tentacle_server
1787
-					chmod 555 /usr/local/bin/tentacle_server
1788
-					cp NetBSD/tentacle_server $TENTACLE_SERVER
1789
-					chmod 555 $TENTACLE_SERVER
1790
-					echo "Installing Tentacle Server manual"
1791
-					cp man/man1/tentacle_server.1.gz /usr/share/man/man1
1792
-				fi
1793
-			fi
1794
-		fi
1795
+	echo "Creating Pandora FMS distribution directory in $PANDORA_HOME"
1796
+	mkdir -p $DESTDIR$PANDORA_HOME 2> /dev/null
1797
+	cp -R util $DESTDIR$PANDORA_HOME
1798
+	find $DESTDIR$PANDORA_HOME -type l -delete
1799
 
1800
-		echo "Creating Pandora FMS distribution directory in $PANDORA_HOME"
1801
-		mkdir $PANDORA_HOME 2> /dev/null
1802
-		if [ ! -d $PANDORA_HOME ]
1803
+	# install cron job
1804
+	if [ -d /etc/cron.hourly ]
1805
+	then
1806
+		[ ! -d $DESTDIR/etc/cron.hourly ] && mkdir -p $DESTDIR/etc/cron.hourly
1807
+		echo "Creating the Cron script to run Pandora DB tool each hour"
1808
+		echo "#!/bin/bash" > $DESTDIR/etc/cron.hourly/pandora_db	
1809
+		echo "perl $PANDORA_HOME/util/pandora_db.pl /etc/pandora/pandora_server.conf" >> /etc/cron.hourly/pandora_db	
1810
+		chmod +x /etc/cron.hourly/pandora_db
1811
+	elif [ "$DISTRO" = "FreeBSD" ] || [ "$DISTRO" = "NetBSD" ]
1812
+	then
1813
+		if [ "$DESTDIR" ]
1814
 		then
1815
-			mkdir -p $PANDORA_HOME
1816
-		fi
1817
-		cp -R util $PANDORA_HOME
1818
-		
1819
-		if [ -d /etc/cron.hourly ]
1820
-		then
1821
-			echo "Creating the Cron script to run Pandora DB tool each hour"
1822
-			echo "#!/bin/bash" > /etc/cron.hourly/pandora_db	
1823
-			echo "perl /usr/share/pandora_server/util/pandora_db.pl /etc/pandora/pandora_server.conf" >> /etc/cron.hourly/pandora_db	
1824
-			chmod +x /etc/cron.hourly/pandora_db
1825
+			echo "Skip adding cron entry for pandora_db.pl when performing fakeroot installation."
1826
 		else
1827
-			if [ "$DISTRO" = "FreeBSD" -o "$DISTRO" = "NetBSD" ]
1828
+			grep pandora_db.pl /etc/crontab > /dev/null 2>&1
1829
+			if [ $? -ne 0 ]
1830
 			then
1831
-				grep pandora_db.pl /etc/crontab > /dev/null 2>&1
1832
-				if [ $? -ne 0 ]
1833
-				then
1834
-					echo "# Pandora FMS" >> /etc/crontab
1835
-					echo "2	*	*	*	*	root	perl /usr/local/share/pandora_server/util/pandora_db.pl /usr/local/etc/pandora/pandora_server.conf" >> /etc/crontab
1836
-				else
1837
-					echo "The crontab for pandora_db.pl is already configured."
1838
-				fi
1839
+				echo "# Pandora FMS" >> /etc/crontab
1840
+				echo "2	*	*	*	*	root	perl $PANDORA_HOME/util/pandora_db.pl $PANDORA_CFG_FILE" >> /etc/crontab
1841
 			else
1842
-				echo "You're probably not using cron for automatic scheduling. You should schedule the following command to run frequently (hourly) on your master server:"
1843
-				echo "	perl /usr/share/pandora_server/util/pandora_db.pl /etc/pandora/pandora_server.conf"
1844
+				echo "The crontab for pandora_db.pl is already configured."
1845
 			fi
1846
 		fi
1847
-		echo
1848
-		echo "Now you have to edit your $PANDORA_CFG_FILE file to change the database password (default is pandora) with the one set in include/config.php of your Pandora FMS Console."
1849
-		echo "After setting password you can start your Pandora FMS Server!!"
1850
-		rm output
1851
+	else
1852
+		echo "You're probably not using cron for automatic scheduling. You should schedule the following command to run frequently (hourly) on your master server:"
1853
+		echo "	perl $PANDORA_HOME/util/pandora_db.pl $PANDORA_CFG_FILE"
1854
+	fi
1855
+	echo
1856
+	echo "Now you have to edit your $PANDORA_CFG_FILE file to change the database password (default is pandora) with the one set in include/config.php of your Pandora FMS Console."
1857
+	echo "After setting password you can start your Pandora FMS Server!!"
1858
 
1859
-		if [ -d "/etc/logrotate.d" ]
1860
-		then
1861
-			echo "Managing Pandora FMS logs with logrotate (Distro independent)"
1862
-			cp -aRf util/pandora_logrotate /etc/logrotate.d/pandora
1863
-		fi
1864
+	if [ "$DISTRO" = "FreeBSD" ] || [ "$DISTRO" = "NetBSD" ]
1865
+	then
1866
+		echo " "
1867
+		echo "Define '$PANDORA_RC_VAR=\"YES\"' in /etc/rc.conf to enable pandora server daemon."
1868
+		[ "$WITHOUT_TENTACLE" = 0 ] && \
1869
+			echo "Define '$TENTACLE_RC_VAR=\"YES\"' in /etc/rc.conf to enable tentacle server daemon."
1870
+    fi
1871
+}
1872
 
1873
-		if [ "$DISTRO" = "FreeBSD" ]
1874
-		then
1875
-			echo " "
1876
-			echo "Define 'pandora_server_enable=\"YES\"' in /etc/rc.conf to enable pandora server daemon."
1877
-			echo "Define 'tentacle_server_enable=\"YES\"' in /etc/rc.conf to enable tentacle server daemon."
1878
-		fi
1879
+uninstall () {
1880
+	set_global_vars
1881
 
1882
-		if [ "$DISTRO" = "NetBSD" ]
1883
-		then
1884
-			echo " "
1885
-			echo "Define 'pandora_server=\"YES\"' in /etc/rc.conf to enable pandora server daemon."
1886
-			echo "Define 'tentacle_server=\"YES\"' in /etc/rc.conf to enable tentacle server daemon."
1887
-                fi
1888
-
1889
+	if [ "$LINUX" != NO ] || [ "$DISTRO" != "FreeBSD" ] || [ "$DISTRO" != "NetBSD" ]
1890
+	then
1891
+		echo "This is not a Linux-based distro. Uninstaller is currently not working for your OS"
1892
+		exit 1
1893
 	fi
1894
 
1895
-}
1896
-
1897
-uninstall_bsd () {
1898
-	if [ "$DISTRO" = "FreeBSD" ]
1899
+	echo "Removing PERL libs and man files"
1900
+	
1901
+	PERL_SITELIB=/usr/lib/perl5
1902
+	if [ "$DISTRO" != "FreeBSD" ] || [ "$DISTRO" != "NetBSD" ]
1903
 	then
1904
-		PANDORA_SPOOL=/var/spool/pandora
1905
-		PANDORA_HOME=/usr/local/share/pandora_server
1906
-		PANDORA_CFG_DIR=/usr/local/etc/pandora
1907
-		PANDORA_LOG=/var/log/pandora
1908
-		PANDORA_SERVER=/usr/local/etc/rc.d/pandora_server
1909
-		TENTACLE_SERVER=/usr/local/etc/rc.d/tentacle_server
1910
-		PANDORA_CFG_FILE=/usr/local/etc/pandora/pandora_server.conf
1911
-		TMP_CRONTAB=/tmp/crontab.tmp
1912
-	else
1913
-		PANDORA_SPOOL=/var/spool/pandora
1914
-		PANDORA_HOME=/usr/local/share/pandora_server
1915
-		PANDORA_CFG_DIR=/usr/local/etc/pandora
1916
-		PANDORA_LOG=/var/log/pandora
1917
-		PANDORA_SERVER=/etc/rc.d/pandora_server
1918
-		TENTACLE_SERVER=/etc/rc.d/tentacle_server
1919
-		PANDORA_CFG_FILE=/usr/local/etc/pandora/pandora_server.conf
1920
-		TMP_CRONTAB=/tmp/crontab.tmp
1921
-        fi
1922
+		PERL_SITELIB=$(eval $($PERL -V:sitelib);echo $sitelib);
1923
+	fi
1924
+	PERL_SITEMAN3DIR=`eval \`$PERL -V:siteman3dir\`;echo $siteman3dir`;
1925
 
1926
-	echo "Removing PERL libs"
1927
-	rm -rf /usr/lib/perl5/PandoraFMS/
1928
+	[ -d $DESTDIR/$PERL_SITELIB/PandoraFMS ] && rm -rf $DESTDIR/$PERL_SITELIB/PandoraFMS
1929
+	rm -f $DESTDIR/$PERL_SITEMAN3DIR/PandoraFMS::* 2>/dev/null
1930
 
1931
-	echo "Removing Pandora Servers"
1932
-	rm -Rf $PANDORA_SPOOL/data_in/
1933
 
1934
-	echo "If the user Pandora is not being used for any other operations, please delete using the following commands:"
1935
-	echo "  rmuser pandora"
1936
-
1937
-	rm -Rf $PANDORA_LOG 2> /dev/null
1938
-	rm -Rf $PANDORA_CFG_FILE 2> /dev/null
1939
-	rm -Rf $PANDORA_SERVER 2> /dev/null
1940
-	rm -Rf $PANDORA_HOME
1941
-	rm -Rf $PANDORA_SERVER
1942
-	rm -Rf $TENTACLE_SERVER
1943
-
1944
-	cat /etc/crontab | grep -v "Pandora FMS" | grep -v "pandora_db.pl" > $TMP_CRONTAB
1945
-	cp $TMP_CRONTAB /etc/crontab
1946
-	rm $TMP_CRONTAB
1947
-
1948
-	echo "Done"
1949
-	exit
1950
-}
1951
-
1952
-uninstall () {
1953
-	GET_DISTRO="`get_distro`"
1954
-	DISTRO=`echo $GET_DISTRO | cut -f 1 -d ":"`
1955
-	if [ "`uname -s`" != "Linux" ]; then
1956
-		if [ "$DISTRO" = "FreeBSD" -o "$DISTRO" = "NetBSD" ]
1957
-		then
1958
-			uninstall_bsd
1959
-		else
1960
-			echo "This is not a Linux-based distro. Uninstaller is currently not working for your OS"
1961
-		fi
1962
-	fi
1963
-
1964
-	echo "Removing PERL libs"
1965
-	rm -rf /usr/lib/perl5/PandoraFMS/
1966
-
1967
 	echo "Removing Pandora Servers"
1968
-	if [ -d $PANDORA_SPOOL/data_out ]; then
1969
-		rm -Rf $PANDORA_SPOOL/data_in
1970
+	if [ -d $DESTDIR$PANDORA_SPOOL/data_out ]; then
1971
+		rm -Rf $DESTDIR$PANDORA_SPOOL/data_in
1972
 	else
1973
-		rm -Rf $PANDORA_SPOOL
1974
+		rm -Rf $DESTDIR$PANDORA_SPOOL
1975
 	fi
1976
 
1977
 	echo "If the user Pandora is not being used for any other operations, please delete using the following commands:"
1978
-	echo "	userdel pandora"
1979
-	echo "	rm -Rf /home/pandora/"
1980
+	if [ "$DISTRO" != "FreeBSD" ] || [ "$DISTRO" != "NetBSD" ]
1981
+	then
1982
+		echo "  rmuser pandora"
1983
+	else
1984
+		echo "	userdel pandora"
1985
+		echo "	rm -Rf /home/pandora/"
1986
+	fi
1987
 
1988
 	## Just to clarify here. Some people (like me) are using the pandora user 
1989
 	## for other purposes and/or using an LDAP-based user management
1990
 	## I would hate to have a script clear out this users' information without any notification
1991
 
1992
-	rm -Rf $PANDORA_LOG 2> /dev/null 
1993
-	rm -Rf $PANDORA_CFG_FILE 2> /dev/null
1994
-	rm -Rf "$PANDORA_CFG_FILE.new" 2> /dev/null
1995
-	rm -Rf $PANDORA_SERVER 2> /dev/null 
1996
-	rm -Rf /usr/bin/pandora_server 2> /dev/null
1997
-	rm -Rf /usr/bin/pandora_exec 2> /dev/null
1998
-	rm -Rf $PANDORA_HOME
1999
-	rm -Rf /etc/cron.hourly/pandora_db
2000
-	rm -Rf /etc/logrotate.d/pandora
2001
-	if [ "$DISTRO" = "UBUNTU" ] || [ "$DISTRO" = "DEBIAN" ]
2002
+
2003
+	rm -Rf $DESTDIR$PANDORA_LOG 2> /dev/null 
2004
+	rm -f  $DESTDIR$PANDORA_CFG_FILE 2> /dev/null
2005
+	rm -f  "$DESTDIR$PANDORA_CFG_FILE.new" 2> /dev/null
2006
+	rm -f  $DESTDIR$PANDORA_SERVER 2> /dev/null 
2007
+	rm -f  $DESTDIR$PREFIX/bin/pandora_server 2> /dev/null
2008
+	rm -f  $DESTDIR$PREFIX/bin/pandora_exec 2> /dev/null
2009
+	rm -f  $DESTDIR$PREFIX/bin/tentacle_server 2> /dev/null
2010
+	rm -Rf $DESTDIR$PANDORA_HOME
2011
+	rm -f  $DESTDIR/etc/cron.hourly/pandora_db
2012
+	rm -f  $DESTDIR/etc/logrotate.d/pandora
2013
+	if [ "$DESTDIR" ]
2014
 	then
2015
+		# do nothing with "fakeroot" uninstallation
2016
+		:
2017
+	elif [ "$DISTRO" = "UBUNTU" ] || [ "$DISTRO" = "DEBIAN" ]
2018
+	then
2019
 		update-rc.d -f pandora_server remove
2020
 		update-rc.d -f tentacle_serverd remove
2021
+	elif  [ "$DISTRO" != "FreeBSD" ] || [ "$DISTRO" != "NetBSD" ]
2022
+	then
2023
+		TMP_CRONTAB=/tmp/crontab.tmp
2024
+		egrep -v "Pandora FMS|pandora_db.pl" /etc/crontab > $TMP_CRONTAB
2025
+		cp $TMP_CRONTAB /etc/crontab
2026
+		rm $TMP_CRONTAB
2027
 	fi
2028
-	rm -Rf /etc/rc2.d/S90pandora_server 2> /dev/null 
2029
-	rm -Rf /etc/rc.d/rc3.d/S90pandora_server 2> /dev/null 
2030
-	rm -Rf /usr/share/man/man1/pandora_server.1.gz 2>/dev/null
2031
-	rm -Rf /usr/share/man/man1/tentacle_server.1.gz 2>/dev/null
2032
+	rm -f $DESTDIR/etc/rc2.d/S90pandora_server 2> /dev/null 
2033
+	rm -f $DESTDIR/etc/rc.d/rc3.d/S90pandora_server 2> /dev/null 
2034
+	rm -f $DESTDIR/etc/rc2.d/S80tentacle_serverd 2> /dev/null 
2035
+	rm -f $DESTDIR/etc/rc.d/rc3.d/S80tentacle_serverd 2> /dev/null 
2036
+	rm -f $DESTDIR$MANDIR/pandora_server.1.gz 2>/dev/null
2037
+	rm -f $DESTDIR$MANDIR/tentacle_server.1.gz 2>/dev/null
2038
 	echo "Done"
2039
 }
2040
 
2041
@@ -595,24 +478,25 @@
2042
 	echo " "
2043
 	echo "  --force         Ignore dependency problems and do the install"
2044
 	echo "	--no-tentacle	Skip tentacle server installation (by default tentacle server installed)"
2045
+	echo "	--destdir DIR	Specify root directory for \"fakeroot\" installation"
2046
 	echo " "
2047
 }
2048
 
2049
 # Script banner at start
2050
 echo " "
2051
-echo "Pandora FMS 5.0 Server Installer (c) 2008-2013 Artica ST"
2052
+echo "Pandora FMS 5.1 Server Installer (c) 2008-2014 Artica ST"
2053
 echo "This program is licensed under GPL2 Terms. http://pandorafms.com"
2054
 echo " "
2055
 
2056
 case "$MODE" in
2057
 
2058
 '--install')
2059
-	install
2060
+	install "$@"
2061
 	exit
2062
 	;;
2063
 
2064
 '--uninstall')
2065
-	uninstall
2066
+	uninstall "$@"
2067
 	exit
2068
 	;;
2069
 
2070
Index: lib/PandoraFMS/SNMPServer.pm
2071
===================================================================
2072
--- lib/PandoraFMS/SNMPServer.pm	(revision 10314)
2073
+++ lib/PandoraFMS/SNMPServer.pm	(working copy)
2074
@@ -25,6 +25,7 @@
2075
 use Thread::Semaphore;
2076
 
2077
 use Time::Local;
2078
+use Time::HiRes qw(usleep);
2079
 use XML::Simple;
2080
 
2081
 # Default lib dir for RPM and DEB packages
2082
@@ -33,21 +34,27 @@
2083
 use PandoraFMS::Tools;
2084
 use PandoraFMS::DB;
2085
 use PandoraFMS::Core;
2086
-use PandoraFMS::Server;
2087
+use PandoraFMS::ProducerConsumerServer;
2088
 
2089
-# Inherits from PandoraFMS::Server
2090
-our @ISA = qw(PandoraFMS::Server);
2091
+# Inherits from PandoraFMS::ProducerConsumerServer
2092
+our @ISA = qw(PandoraFMS::ProducerConsumerServer);
2093
 
2094
-# Tells the server to keep running
2095
-my $RUN :shared;
2096
+# Global variables
2097
+my @TaskQueue :shared;
2098
+my %PendingTasks :shared;
2099
+my $Sem :shared;
2100
+my $TaskSem :shared;
2101
 
2102
 # Trap statistics by agent
2103
 my %AGENTS = ();
2104
 
2105
+# Index file management
2106
+my ($IDX_FILE, $LAST_LINE, $LAST_SIZE) = ();
2107
+
2108
 ########################################################################################
2109
 # SNMP Server class constructor.
2110
 ########################################################################################
2111
-sub new ($$;$) {
2112
+sub new ($$$) {
2113
 	my ($class, $config, $dbh) = @_;
2114
 
2115
 	return undef unless $config->{'snmpconsole'} == 1;
2116
@@ -57,15 +64,46 @@
2117
 		return undef;
2118
 	}
2119
 	
2120
+	# Wait for the SNMP log file to be available
2121
+	my $log_file = $config->{'snmp_logfile'};
2122
+	sleep ($config->{'server_threshold'}) if (! -e $log_file);
2123
+	if (!open (SNMPLOGFILE, $log_file)) {
2124
+		logger ($config, ' [E] Could not open the SNMP log file ' . $config->{'snmp_logfile'} . ".", 1);
2125
+		print_message ($config, ' [E] Could not open the SNMP log file ' . $config->{'snmp_logfile'} . ".", 1);
2126
+		return 1;
2127
+	}
2128
+
2129
+	# Process index file, if available
2130
+	($IDX_FILE, $LAST_LINE, $LAST_SIZE) = ($log_file . '.index', 0, 0);
2131
+	if (-e  $IDX_FILE) {
2132
+		open (INDEXFILE, $IDX_FILE) or return;
2133
+		my $idx_data = <INDEXFILE>;
2134
+		close INDEXFILE;
2135
+		($LAST_LINE, $LAST_SIZE) = split(/\s+/, $idx_data);
2136
+	}
2137
+	my $log_size = (stat ($log_file))[7];
2138
+
2139
+	# New SNMP log file found
2140
+	if ($log_size < $LAST_SIZE) {
2141
+		unlink ($IDX_FILE);
2142
+		($LAST_LINE, $LAST_SIZE) = (0, 0);
2143
+	}
2144
+
2145
+	# Skip already processed lines
2146
+	readline SNMPLOGFILE for (1..$LAST_LINE);
2147
+	
2148
+	# Initialize semaphores and queues
2149
+	@TaskQueue = ();
2150
+	%PendingTasks = ();
2151
+	$Sem = Thread::Semaphore->new;
2152
+	$TaskSem = Thread::Semaphore->new (0);
2153
+
2154
 	# Call the constructor of the parent class
2155
-	my $self = $class->SUPER::new($config, 2, $dbh);
2156
+	my $self = $class->SUPER::new($config, 2, \&PandoraFMS::SNMPServer::data_producer, \&PandoraFMS::SNMPServer::data_consumer, $dbh);
2157
 
2158
 	# Save the path of snmptrapd
2159
 	$self->{'snmp_trapd'} = $config->{'snmp_trapd'};
2160
 
2161
-	# Run!
2162
-	$RUN = 1;
2163
-
2164
     bless $self, $class;
2165
     return $self;
2166
 }
2167
@@ -77,242 +115,219 @@
2168
 	my $self = shift;
2169
 	my $pa_config = $self->getConfig ();
2170
 
2171
-	print_message ($pa_config, " [*] Starting Pandora FMS SNMP Console.", 1);
2172
-	$self->SUPER::run (\&PandoraFMS::SNMPServer::pandora_snmptrapd);
2173
+	print_message ($pa_config, " [*] Starting Pandora FMS SNMP Console.", 2);
2174
+	
2175
+	# Set the initial date for storm protection.
2176
+	$pa_config->{"__storm_ref__"} = time();
2177
+
2178
+	# This is the only server that reads from disk instead of from the DB. No need for a higher server threshold.
2179
+	$pa_config->{'server_threshold'} = 1;
2180
+
2181
+	$self->setNumThreads ($pa_config->{'snmpconsole_threads'});
2182
+	$self->SUPER::run (\@TaskQueue, \%PendingTasks, $Sem, $TaskSem);
2183
 }
2184
 
2185
-##########################################################################
2186
-# Process SNMP log file.
2187
-##########################################################################
2188
-sub pandora_snmptrapd {
2189
+###############################################################################
2190
+# Data producer.
2191
+###############################################################################
2192
+sub data_producer ($) {
2193
 	my $self = shift;
2194
-	my $pa_config = $self->getConfig ();
2195
+	my ($pa_config, $dbh) = ($self->getConfig (), $self->getDBH ());
2196
 
2197
-	my $dbh;
2198
-	eval {
2199
-		# Connect to the DB
2200
-		$dbh = db_connect ($pa_config->{'dbengine'}, $pa_config->{'dbname'}, $pa_config->{'dbhost'},
2201
-							  $pa_config->{'dbport'}, $pa_config->{'dbuser'}, $pa_config->{'dbpass'});
2202
-		$self->setDBH ($dbh);
2203
+	my @tasks;
2204
+	
2205
+	# Slave server
2206
+	if ($pa_config->{'pandora_master'} == 0 && get_db_value ($dbh, 'SELECT name FROM tserver WHERE name = ANY(SELECT name FROM tserver WHERE status = 0)') == undef) {
2207
+		return @tasks;
2208
+	}
2209
 
2210
-		# Wait for the SNMP log file to be available
2211
-		my $log_file = $pa_config->{'snmp_logfile'};
2212
-		sleep ($pa_config->{'server_threshold'}) while (! -e $log_file);	
2213
-		open (SNMPLOGFILE, $log_file) or return;
2214
+	# Reset storm protection counters
2215
+	my $curr_time = time ();
2216
+	if ($pa_config->{"__storm_ref__"} + $pa_config->{"snmp_storm_timeout"} < $curr_time) {
2217
+		$pa_config->{"__storm_ref__"} = $curr_time;
2218
+		%AGENTS = ();
2219
+	}
2220
 
2221
-		# Process index file, if available
2222
-		my ($idx_file, $last_line, $last_size) = ($log_file . '.index', 0, 0);
2223
-		if (-e  $idx_file) {
2224
-			open (INDEXFILE, $idx_file) or return;
2225
-			my $idx_data = <INDEXFILE>;
2226
-			close INDEXFILE;
2227
-			($last_line, $last_size) = split(/\s+/, $idx_data);
2228
-		}
2229
+	while (my $line = <SNMPLOGFILE>) {
2230
+		$LAST_LINE++;
2231
+		$LAST_SIZE = (stat ($pa_config->{'snmp_logfile'}))[7];
2232
+		chomp ($line);
2233
 
2234
-		my $log_size = (stat ($log_file))[7];
2235
+		# Update index file
2236
+		open INDEXFILE, '>' . $IDX_FILE;
2237
+		print INDEXFILE $LAST_LINE . ' ' . $LAST_SIZE;
2238
+		close INDEXFILE;
2239
 
2240
-		# New SNMP log file found
2241
-		if ($log_size < $last_size) {
2242
-			unlink ($idx_file);
2243
-			($last_line, $last_size) = (0, 0);
2244
+		# Skip lines other than SNMP Trap logs
2245
+		next unless ($line =~ m/^SNMPv[12]\[\*\*\]/);
2246
+
2247
+		# Storm protection.
2248
+		my ($ver, $date, $time, $source, $null) = split(/\[\*\*\]/, $line, 5);
2249
+		next unless defined ($source);
2250
+		if (! defined ($AGENTS{$source})) {
2251
+			$AGENTS{$source}{'count'} = 1;
2252
+			$AGENTS{$source}{'event'} = 0;
2253
+		} else {
2254
+			$AGENTS{$source}{'count'} += 1;
2255
 		}
2256
-
2257
-		# Skip already processed lines
2258
-		readline SNMPLOGFILE for (1..$last_line);
2259
-
2260
-		# Main loop
2261
-		my $storm_ref = time ();
2262
-		while ($RUN == 1) {
2263
-			
2264
-			# Reset storm protection counters
2265
-			my $curr_time = time ();
2266
-			if ($storm_ref + $pa_config->{"snmp_storm_timeout"} < $curr_time) {
2267
-				$storm_ref = $curr_time;
2268
-				%AGENTS = ();
2269
+		if ($pa_config->{'snmp_storm_protection'} > 0 && $AGENTS{$source}{'count'} > $pa_config->{'snmp_storm_protection'}) {
2270
+			if ($AGENTS{$source}{'event'} == 0) {
2271
+				pandora_event ($pa_config, "Too many traps coming from $source. Silenced for " . int ($pa_config->{"snmp_storm_timeout"} / 60) . " minutes.", 0, 0, 4, 0, 0, 'system', 0, $dbh);
2272
 			}
2273
+			$AGENTS{$source}{'event'} = 1;
2274
+			next;
2275
+		}
2276
 
2277
-			while (my $line = <SNMPLOGFILE>) {
2278
-				$last_line++;
2279
-				$last_size = (stat ($log_file))[7];
2280
-				chomp ($line);
2281
+		push (@tasks, $line);
2282
+	}
2283
 
2284
-				# Update index file
2285
-				open INDEXFILE, '>' . $idx_file;
2286
-				print INDEXFILE $last_line . ' ' . $last_size;
2287
-				close INDEXFILE;
2288
+	return @tasks;
2289
+}
2290
 
2291
-				# Skip lines other than SNMP Trap logs
2292
-				next unless ($line =~ m/^SNMPv[12]\[\*\*\]/);
2293
+###############################################################################
2294
+# Data consumer.
2295
+###############################################################################
2296
+sub data_consumer ($$) {
2297
+	my ($self, $task) = @_;
2298
 
2299
-				(my $trap_ver, $line) = split(/\[\*\*\]/, $line, 2);
2300
+	pandora_snmptrapd ($self->getConfig (), $task, $self->getServerID (), $self->getDBH ());
2301
+}
2302
 
2303
-				# Process SNMP filter
2304
-				next if (matches_filter ($dbh, $pa_config, $line) == 1);
2305
+##########################################################################
2306
+# Process SNMP log file.
2307
+##########################################################################
2308
+sub pandora_snmptrapd {
2309
+	my ($pa_config, $line, $server_id, $dbh) = @_;
2310
 
2311
-				logger($pa_config, "Reading trap '$line'", 10);
2312
-				my ($date, $time, $source, $oid, $type, $type_desc, $value, $data) = ('', '', '', '', '', '', '', '');
2313
+	(my $trap_ver, $line) = split(/\[\*\*\]/, $line, 2);
2314
 
2315
-				if ($trap_ver eq "SNMPv1") {
2316
-					($date, $time, $source, $oid, $type, $type_desc, $value, $data) = split(/\[\*\*\]/, $line, 8);
2317
+	# Process SNMP filter
2318
+	next if (matches_filter ($dbh, $pa_config, $line) == 1);
2319
 
2320
-					$value = limpia_cadena ($value);
2321
+	logger($pa_config, "Reading trap '$line'", 10);
2322
+	my ($date, $time, $source, $oid, $type, $type_desc, $value, $data) = ('', '', '', '', '', '', '', '');
2323
 
2324
-					# Try to save as much information as possible if the trap could not be parsed
2325
-					$oid = $type_desc if ($oid eq '' || $oid eq '.');
2326
+	if ($trap_ver eq "SNMPv1") {
2327
+		($date, $time, $source, $oid, $type, $type_desc, $value, $data) = split(/\[\*\*\]/, $line, 8);
2328
 
2329
-				} elsif ($trap_ver eq "SNMPv2") {
2330
-					($date, $time, $source, $data) = split(/\[\*\*\]/, $line, 4);
2331
-					my @data = split(/\t/, $data);
2332
+		$value = limpia_cadena ($value);
2333
 
2334
-					shift @data; # Drop unused 1st data.
2335
-					$oid = shift @data;
2336
+		# Try to save as much information as possible if the trap could not be parsed
2337
+		$oid = $type_desc if ($oid eq '' || $oid eq '.');
2338
 
2339
-					if (!defined($oid)) {
2340
-						logger($pa_config, "[W] snmpTrapOID not found (Illegal SNMPv2 trap?)", 1);
2341
-						next;
2342
-					}
2343
-					$oid =~ s/.* = OID: //;
2344
-					$data = join("\t", @data);
2345
-				}
2346
+	} elsif ($trap_ver eq "SNMPv2") {
2347
+		($date, $time, $source, $data) = split(/\[\*\*\]/, $line, 4);
2348
+		my @data = split(/\t/, $data);
2349
 
2350
-				if ($trap_ver eq "SNMPv2" || $pa_config->{'snmp_pdu_address'} eq '1' ) {
2351
-					# extract IP address from %b part:
2352
-					#  * destination part (->[dest_ip]:dest_port) appears in Net-SNMP > 5.3
2353
-					#  * protocol name (TCP: or UDP:) and bracketted IP addr w/ port number appear in
2354
-					#    Net-SNMP > 5.1 (Net-SNMP 5.1 has IP addr only).
2355
-					#  * port number is signed (often negative) in Net-SNMP 5.2
2356
-					$source =~ s/(?:(?:TCP|UDP):\s*)?\[?([^] ]+)\]?(?::-?\d+)?(?:\s*->.*)?$/$1/;
2357
-				}
2358
+		shift @data; # Drop unused 1st data.
2359
+		$oid = shift @data;
2360
 
2361
-				my $timestamp = $date . ' ' . $time;
2362
-				my ($custom_oid, $custom_type, $custom_value) = ('', '', '');
2363
+		if (!defined($oid)) {
2364
+			logger($pa_config, "[W] snmpTrapOID not found (Illegal SNMPv2 trap?)", 1);
2365
+			next;
2366
+		}
2367
+		$oid =~ s/.* = OID: //;
2368
+		$data = join("\t", @data);
2369
+	}
2370
 
2371
-				# custom_type, custom_value is not used since 4.0 version, all custom data goes on custom_oid
2372
-				$custom_oid = $data;
2373
+	if ($trap_ver eq "SNMPv2" || $pa_config->{'snmp_pdu_address'} eq '1' ) {
2374
+		# extract IP address from %b part:
2375
+		#  * destination part (->[dest_ip]:dest_port) appears in Net-SNMP > 5.3
2376
+		#  * protocol name (TCP: or UDP:) and bracketted IP addr w/ port number appear in
2377
+		#    Net-SNMP > 5.1 (Net-SNMP 5.1 has IP addr only).
2378
+		#  * port number is signed (often negative) in Net-SNMP 5.2
2379
+		$source =~ s/(?:(?:TCP|UDP):\s*)?\[?([^] ]+)\]?(?::-?\d+)?(?:\s*->.*)?$/$1/;
2380
+	}
2381
 
2382
-				# Storm protection
2383
-				if (! defined ($AGENTS{$source})) {
2384
-					$AGENTS{$source}{'count'} = 1;
2385
-					$AGENTS{$source}{'event'} = 0;
2386
-				} else {
2387
-					$AGENTS{$source}{'count'} += 1;
2388
-				}
2389
-				if ($pa_config->{'snmp_storm_protection'} > 0 && $AGENTS{$source}{'count'} > $pa_config->{'snmp_storm_protection'}) {
2390
-					if ($AGENTS{$source}{'event'} == 0) {
2391
-						pandora_event ($pa_config, "Too many traps coming from $source. Silenced for " . int ($pa_config->{"snmp_storm_timeout"} / 60) . " minutes.", 0, 0, 4, 0, 0, 'system', 0, $dbh);
2392
-					}
2393
-					$AGENTS{$source}{'event'} = 1;
2394
-					next;
2395
-				}
2396
+	my $timestamp = $date . ' ' . $time;
2397
+	my ($custom_oid, $custom_type, $custom_value) = ('', '', '');
2398
 
2399
-				#Trap forwarding
2400
-				if ($pa_config->{'snmp_forward_trap'}==1) {
2401
-					my $trap_data_string = "";
2402
+	# custom_type, custom_value is not used since 4.0 version, all custom data goes on custom_oid
2403
+	$custom_oid = $data;
2404
 
2405
-					#We loop through all the custom data of the received trap, creating the $trap_data_string string to forward the trap properly
2406
-					while ($data =~ /([\.\d]+)\s=\s([^:]+):\s([\S ]+)/g) {
2407
-						my ($trap_data, $trap_type, $trap_value) = ($1, $2, $3);
2408
-						if ($trap_type eq "INTEGER") {
2409
-							#FIX for translated traps from IF-MIB.txt MIB
2410
-							$trap_value =~ s/\D//g;
2411
-							$trap_data_string = $trap_data_string . "$trap_data i $trap_value ";
2412
-						}
2413
-						elsif ($trap_type eq "UNSIGNED"){
2414
-							$trap_data_string = $trap_data_string . "$trap_data u $trap_value ";
2415
-						}
2416
-                                                elsif ($trap_type eq "COUNTER32"){
2417
-                                                        $trap_data_string = $trap_data_string . "$trap_data c $trap_value ";
2418
-                                                }
2419
-                                                elsif ($trap_type eq "STRING"){
2420
-                                                        $trap_data_string = $trap_data_string . "$trap_data s $trap_value ";
2421
-                                                }
2422
-                                                elsif ($trap_type eq "HEX STRING"){
2423
-                                                        $trap_data_string = $trap_data_string . "$trap_data x $trap_value ";
2424
-                                                }
2425
-                                                elsif ($trap_type eq "DECIMAL STRING"){
2426
-                                                        $trap_data_string = $trap_data_string . "$trap_data d $trap_value ";
2427
-                                                }
2428
-                                                elsif ($trap_type eq "NULLOBJ"){
2429
-                                                        $trap_data_string = $trap_data_string . "$trap_data n $trap_value ";
2430
-                                                }
2431
-                                                elsif ($trap_type eq "OBJID"){
2432
-                                                        $trap_data_string = $trap_data_string . "$trap_data o $trap_value ";
2433
-                                                }
2434
-                                                elsif ($trap_type eq "TIMETICKS"){
2435
-                                                        $trap_data_string = $trap_data_string . "$trap_data t $trap_value ";
2436
-                                                }
2437
-                                                elsif ($trap_type eq "IPADDRESS"){
2438
-                                                        $trap_data_string = $trap_data_string . "$trap_data a $trap_value ";
2439
-                                                }
2440
-						elsif ($trap_type eq "BITS"){
2441
-                                                        $trap_data_string = $trap_data_string . "$trap_data b $trap_value ";
2442
-                                                }
2443
-					}
2444
+	#Trap forwarding
2445
+	if ($pa_config->{'snmp_forward_trap'}==1) {
2446
+		my $trap_data_string = "";
2447
 
2448
-					#We distinguish between the three different kinds of SNMP forwarding
2449
-					if ($pa_config->{'snmp_forward_version'} eq '3') {
2450
-						system("snmptrap -v $pa_config->{'snmp_forward_version'} -n \"\" -a $pa_config->{'snmp_forward_authProtocol'} -A $pa_config->{'snmp_forward_authPassword'} -x $pa_config->{'snmp_forward_privProtocol'} -X $pa_config->{'snmp_forward_privPassword'} -l $pa_config->{'snmp_forward_secLevel'} -u $pa_config->{'snmp_forward_secName'} -e $pa_config->{'snmp_forward_engineid'} $pa_config->{'snmp_forward_ip'} '' $oid $trap_data_string");
2451
-					}
2452
-					elsif ($pa_config->{'snmp_forward_version'} eq '2' || $pa_config->{'snmp_forward_version'} eq '2c') {
2453
-						system("snmptrap -v 2c -n \"\" -c $pa_config->{'snmp_forward_community'} $pa_config->{'snmp_forward_ip'} '' $oid $trap_data_string");
2454
-					}
2455
-					elsif ($pa_config->{'snmp_forward_version'} eq '1') {
2456
-						#Because of tne SNMP v1 protocol, we must perform additional steps for creating the trap
2457
-						my $value_sending = "";
2458
-						my $type_sending = "";
2459
+		#We loop through all the custom data of the received trap, creating the $trap_data_string string to forward the trap properly
2460
+		while ($data =~ /([\.\d]+)\s=\s([^:]+):\s([\S ]+)/g) {
2461
+			my ($trap_data, $trap_type, $trap_value) = ($1, $2, $3);
2462
+			if ($trap_type eq "INTEGER") {
2463
+				#FIX for translated traps from IF-MIB.txt MIB
2464
+				$trap_value =~ s/\D//g;
2465
+				$trap_data_string = $trap_data_string . "$trap_data i $trap_value ";
2466
+			}
2467
+			elsif ($trap_type eq "UNSIGNED"){
2468
+				$trap_data_string = $trap_data_string . "$trap_data u $trap_value ";
2469
+			}
2470
+			elsif ($trap_type eq "COUNTER32"){
2471
+			        $trap_data_string = $trap_data_string . "$trap_data c $trap_value ";
2472
+			}
2473
+			elsif ($trap_type eq "STRING"){
2474
+			        $trap_data_string = $trap_data_string . "$trap_data s $trap_value ";
2475
+			}
2476
+			elsif ($trap_type eq "HEX STRING"){
2477
+			        $trap_data_string = $trap_data_string . "$trap_data x $trap_value ";
2478
+			}
2479
+			elsif ($trap_type eq "DECIMAL STRING"){
2480
+			        $trap_data_string = $trap_data_string . "$trap_data d $trap_value ";
2481
+			}
2482
+			elsif ($trap_type eq "NULLOBJ"){
2483
+			        $trap_data_string = $trap_data_string . "$trap_data n $trap_value ";
2484
+			}
2485
+			elsif ($trap_type eq "OBJID"){
2486
+			        $trap_data_string = $trap_data_string . "$trap_data o $trap_value ";
2487
+			}
2488
+			elsif ($trap_type eq "TIMETICKS"){
2489
+			        $trap_data_string = $trap_data_string . "$trap_data t $trap_value ";
2490
+			}
2491
+			elsif ($trap_type eq "IPADDRESS"){
2492
+			        $trap_data_string = $trap_data_string . "$trap_data a $trap_value ";
2493
+			}
2494
+			elsif ($trap_type eq "BITS"){
2495
+			        $trap_data_string = $trap_data_string . "$trap_data b $trap_value ";
2496
+			}
2497
+		}
2498
 
2499
-						if ($value eq ''){
2500
-							$value_sending = "\"\"";
2501
-						}
2502
-						else {
2503
-							$value_sending = $value;
2504
-							$value_sending =~ s/[\$#@~!&*()\[\];.,:?^ `\\\/]+//g;
2505
-						}
2506
-						if ($type eq ''){
2507
-							$type_sending = "\"\"";
2508
-						}
2509
-						else{
2510
-							$type_sending = $type;
2511
-						}
2512
+		#We distinguish between the three different kinds of SNMP forwarding
2513
+		if ($pa_config->{'snmp_forward_version'} eq '3') {
2514
+			system("snmptrap -v $pa_config->{'snmp_forward_version'} -n \"\" -a $pa_config->{'snmp_forward_authProtocol'} -A $pa_config->{'snmp_forward_authPassword'} -x $pa_config->{'snmp_forward_privProtocol'} -X $pa_config->{'snmp_forward_privPassword'} -l $pa_config->{'snmp_forward_secLevel'} -u $pa_config->{'snmp_forward_secName'} -e $pa_config->{'snmp_forward_engineid'} $pa_config->{'snmp_forward_ip'} '' $oid $trap_data_string");
2515
+		}
2516
+		elsif ($pa_config->{'snmp_forward_version'} eq '2' || $pa_config->{'snmp_forward_version'} eq '2c') {
2517
+			system("snmptrap -v 2c -n \"\" -c $pa_config->{'snmp_forward_community'} $pa_config->{'snmp_forward_ip'} '' $oid $trap_data_string");
2518
+		}
2519
+		elsif ($pa_config->{'snmp_forward_version'} eq '1') {
2520
+			#Because of tne SNMP v1 protocol, we must perform additional steps for creating the trap
2521
+			my $value_sending = "";
2522
+			my $type_sending = "";
2523
 
2524
-						system("snmptrap -v 1 -c $pa_config->{'snmp_forward_community'} $pa_config->{'snmp_forward_ip'} $oid \"\" $type_sending $value_sending \"\" $trap_data_string");
2525
-					}
2526
-				}
2527
+			if ($value eq ''){
2528
+				$value_sending = "\"\"";
2529
+			}
2530
+			else {
2531
+				$value_sending = $value;
2532
+				$value_sending =~ s/[\$#@~!&*()\[\];.,:?^ `\\\/]+//g;
2533
+			}
2534
+			if ($type eq ''){
2535
+				$type_sending = "\"\"";
2536
+			}
2537
+			else{
2538
+				$type_sending = $type;
2539
+			}
2540
 
2541
-				# Insert the trap into the DB
2542
-				if (! defined(enterprise_hook ('snmp_insert_trap', [$pa_config, $source, $oid, $type, $value, $custom_oid, $custom_value, $custom_type, $timestamp, $self->getServerID (), $dbh]))) {
2543
-					my $trap_id = db_insert ($dbh, 'id_trap', 'INSERT INTO ttrap (timestamp, source, oid, type, value, oid_custom, value_custom,  type_custom) VALUES (?, ?, ?, ?, ?, ?, ?, ?)',
2544
-											 $timestamp, $source, $oid, $type, $value, $custom_oid, $custom_value, $custom_type);
2545
-					logger ($pa_config, "Received SNMP Trap from $source", 4);
2546
-
2547
-					# Evaluate alerts for this trap
2548
-					pandora_evaluate_snmp_alerts ($pa_config, $trap_id, $source, $oid, $type, $oid, $value, $custom_oid, $dbh);
2549
-				}
2550
-			}
2551
-			
2552
-			sleep ($pa_config->{'server_threshold'});
2553
+			system("snmptrap -v 1 -c $pa_config->{'snmp_forward_community'} $pa_config->{'snmp_forward_ip'} $oid \"\" $type_sending $value_sending \"\" $trap_data_string");
2554
 		}
2555
-	};
2556
-
2557
-	if ($@) {
2558
-		$self->setErrStr ($@);
2559
 	}
2560
 
2561
-	db_disconnect ($dbh);
2562
-}
2563
+	# Insert the trap into the DB
2564
+	if (! defined(enterprise_hook ('snmp_insert_trap', [$pa_config, $source, $oid, $type, $value, $custom_oid, $custom_value, $custom_type, $timestamp, $server_id, $dbh]))) {
2565
+		my $trap_id = db_insert ($dbh, 'id_trap', 'INSERT INTO ttrap (timestamp, source, oid, type, value, oid_custom, value_custom,  type_custom) VALUES (?, ?, ?, ?, ?, ?, ?, ?)',
2566
+								 $timestamp, $source, $oid, $type, $value, $custom_oid, $custom_value, $custom_type);
2567
+		logger ($pa_config, "Received SNMP Trap from $source", 4);
2568
 
2569
-########################################################################################
2570
-# Stop the server, killing snmptrapd before.
2571
-########################################################################################
2572
-sub stop () {
2573
-	my $self = shift;
2574
-
2575
-	if ($self->{'snmp_trapd'} ne 'manual') {
2576
-		system ("kill -9 `cat /var/run/pandora_snmptrapd.pid 2>$DEVNULL`");
2577
-		unlink ('/var/run/pandora_snmptrapd.pid');
2578
+		# Evaluate alerts for this trap
2579
+		pandora_evaluate_snmp_alerts ($pa_config, $trap_id, $source, $oid, $type, $oid, $value, $custom_oid, $dbh);
2580
 	}
2581
-	
2582
-	$self->SUPER::stop ();
2583
 }
2584
 
2585
 ########################################################################################
2586
@@ -328,14 +343,14 @@
2587
 		my $eval_result;
2588
 
2589
 		# eval protects against server down (by invalid regular expressions)
2590
-                $eval_result = eval {
2591
+	    $eval_result = eval {
2592
 		     $string =~ m/$regexp/i ;
2593
      	        };
2594
 
2595
-                if ($eval_result) {
2596
-                        logger($pa_config, "Trap '$string' matches filter '$regexp'. Discarding...", 10);
2597
-                        return 1;
2598
-                }
2599
+	    if ($eval_result) {
2600
+		logger($pa_config, "Trap '$string' matches filter '$regexp'. Discarding...", 10);
2601
+		return 1;
2602
+	    }
2603
 
2604
 	}
2605
 	
2606
@@ -393,7 +408,7 @@
2607
 		print_message ($config, " [E] Could not start snmptrapd.", 1);
2608
 		return 1;
2609
 	}
2610
-	
2611
+
2612
 	return 0;
2613
 }
2614
 
2615
@@ -403,7 +418,10 @@
2616
 sub DESTROY {
2617
 	my $self = shift;
2618
 	
2619
-	$RUN = 0;
2620
+	if ($self->{'snmp_trapd'} ne 'manual') {
2621
+		system ("kill -9 `cat /var/run/pandora_snmptrapd.pid 2>$DEVNULL`");
2622
+		unlink ('/var/run/pandora_snmptrapd.pid');
2623
+	}
2624
 }
2625
 
2626
 1;
2627
Index: lib/PandoraFMS/Config.pm
2628
===================================================================
2629
--- lib/PandoraFMS/Config.pm	(revision 10314)
2630
+++ lib/PandoraFMS/Config.pm	(working copy)
2631
@@ -248,6 +248,9 @@
2632
 	$pa_config->{"snmp_pdu_address"} = 0; # 5.0
2633
 	$pa_config->{"snmp_storm_protection"} = 0; # 5.0
2634
 	$pa_config->{"snmp_storm_timeout"} = 600; # 5.0
2635
+	$pa_config->{"snmpconsole_threads"} = 1; # 5.1
2636
+	$pa_config->{"translate_variable_bindings"} = 0; # 5.1
2637
+	$pa_config->{"translate_enterprise_strings"} = 1; # 5.1
2638
 	
2639
 	# Internal MTA for alerts, each server need its own config.
2640
 	$pa_config->{"mta_address"} = '127.0.0.1'; # Introduced on 2.0
2641
@@ -261,6 +264,7 @@
2642
 
2643
 	# nmap for recon OS fingerprinting and tcpscan (optional)
2644
 	$pa_config->{"nmap"} = "/usr/bin/nmap";
2645
+	$pa_config->{"nmap_timing_template"} = 2; # > 5.1
2646
 
2647
 	# braa for enterprise snmp server
2648
 	$pa_config->{"braa"} = "/usr/bin/braa";
2649
@@ -465,6 +469,15 @@
2650
 		elsif ($parametro =~ m/^snmp_storm_timeout\s+(\d+)/i) { 
2651
 			$pa_config->{'snmp_storm_timeout'}= clean_blank($1); 
2652
 		}
2653
+		elsif ($parametro =~ m/^snmpconsole_threads\s+(\d+)/i) { 
2654
+			$pa_config->{'snmpconsole_threads'}= clean_blank($1); 
2655
+		}
2656
+		elsif ($parametro =~ m/^translate_variable_bindings\s+([0-1])/i) { 
2657
+			$pa_config->{'translate_variable_bindings'}= clean_blank($1); 
2658
+		}
2659
+		elsif ($parametro =~ m/^translate_enterprise_strings\s+([0-1])/i) { 
2660
+			$pa_config->{'translate_enterprise_strings'}= clean_blank($1); 
2661
+		}
2662
 		elsif ($parametro =~ m/^dbengine\s(.*)/i) { 
2663
 			$pa_config->{'dbengine'}= clean_blank($1); 
2664
 		}
2665
@@ -595,6 +608,9 @@
2666
 		elsif ($parametro =~ m/^nmap\s(.*)/i) {
2667
 			$pa_config->{'nmap'}= clean_blank($1); 
2668
 		}
2669
+		elsif ($parametro =~ m/^nmap_timing_template\s([0-9]*)/i) {
2670
+			$pa_config->{'nmap_timing_template'}= clean_blank($1); 
2671
+		}
2672
 		elsif ($parametro =~ m/^braa\s(.*)/i) {
2673
 			$pa_config->{'braa'}= clean_blank($1); 
2674
 		}
2675
Index: lib/PandoraFMS/NetworkServer.pm
2676
===================================================================
2677
--- lib/PandoraFMS/NetworkServer.pm	(revision 10314)
2678
+++ lib/PandoraFMS/NetworkServer.pm	(working copy)
2679
@@ -25,6 +25,7 @@
2680
 use Thread::Semaphore;
2681
 
2682
 use IO::Socket::INET6;
2683
+use IO::Select;
2684
 use HTML::Entities;
2685
 use POSIX qw(strftime);
2686
 
2687
@@ -170,100 +171,103 @@
2688
 		$retries = $pa_config->{'tcp_checks'};
2689
 	}
2690
 	
2691
-    $tcp_send = decode_entities($tcp_send);
2692
-    $tcp_rcv = decode_entities($tcp_rcv);
2693
+	$tcp_send = decode_entities($tcp_send);
2694
+	$tcp_rcv = decode_entities($tcp_rcv);
2695
 
2696
-        my $counter; 
2697
-        for ($counter =0; $counter < $retries; $counter++){
2698
-	        my $temp; my $temp2;
2699
-	        my $tam;
2700
-	        my $handle=IO::Socket::INET6->new(
2701
-		        Proto=>"tcp",
2702
-		        PeerAddr=>$ip_target,
2703
-		        Timeout=>$timeout,
2704
-		        PeerPort=>$tcp_port,
2705
+	my $counter; 
2706
+	for ($counter =0; $counter < $retries; $counter++){
2707
+		my $temp; my $temp2;
2708
+		my $tam;
2709
+		my $handle=IO::Socket::INET6->new(
2710
+			Proto=>"tcp",
2711
+			PeerAddr=>$ip_target,
2712
+			Timeout=>$timeout,
2713
+			PeerPort=>$tcp_port,
2714
 			Multihomed=>1,
2715
-		        Blocking=>0 ); # Non blocking !!, very important !
2716
-		        
2717
-	        if (defined ($handle)){
2718
+			Blocking=>0 ); # Non blocking !!, very important !
2719
+			
2720
+		if (defined ($handle)){
2721
 			# Multi request patch, submitted by Glen Eustace (new zealand)
2722
 			my @tcp_send = split( /\|/, $tcp_send );
2723
 			my @tcp_rcv  = split( /\|/, $tcp_rcv );
2724
 
2725
+			# Add server socket to select queue
2726
+			my $select = IO::Select->new ();
2727
+			$select->add ($handle);
2728
+
2729
 next_pair:
2730
 			$tcp_send = shift( @tcp_send );
2731
 			$tcp_rcv  = shift( @tcp_rcv );
2732
 
2733
-		        if  ((defined ($tcp_send)) && ($tcp_send ne "")){ # its Expected to sending data ?
2734
-			        # Send data
2735
-			        $handle->autoflush(1);
2736
-			        $tcp_send =~ s/\^M/\r\n/g;
2737
-			        # Replace Carriage rerturn and line feed
2738
-			        $handle->send($tcp_send);
2739
-		        }
2740
-		        # we expect to receive data ? (non proc types)
2741
-		        if ((defined ($tcp_rcv) && $tcp_rcv ne "") || (($id_tipo_modulo == 10) || ($id_tipo_modulo ==8) || ($id_tipo_modulo == 11))) {
2742
-			        # Receive data, non-blocking !!!! (VERY IMPORTANT!)
2743
-			        $temp2 = "";
2744
-			        for ($tam=0; $tam<$timeout; $tam++){
2745
-				        $handle->recv($temp,16000,0x40);
2746
-				        $temp2 = $temp2.$temp;
2747
-				        if ($temp ne ""){
2748
-					        $tam++; # If doesnt receive data, increase counter
2749
-				        }
2750
-				        sleep(1);
2751
-			        }
2752
-			        if ($id_tipo_modulo == 9){ # only for TCP Proc
2753
-				        if ($temp2 =~ /$tcp_rcv/i){ # String match !
2754
+			if  ((defined ($tcp_send)) && ($tcp_send ne "")){ # its Expected to sending data ?
2755
+				# Send data
2756
+				$handle->autoflush(1);
2757
+				$tcp_send =~ s/\^M/\r\n/g;
2758
+				# Replace Carriage rerturn and line feed
2759
+				$handle->send($tcp_send);
2760
+			}
2761
+			# we expect to receive data ? (non proc types)
2762
+			if ((defined ($tcp_rcv) && $tcp_rcv ne "") || (($id_tipo_modulo == 10) || ($id_tipo_modulo ==8) || ($id_tipo_modulo == 11))) {
2763
+				# Receive data, non-blocking !!!! (VERY IMPORTANT!)
2764
+				$temp2 = "";
2765
+				for ($tam = 0; $tam < $timeout; $tam ++) {
2766
+					if ($select->can_read (1)) {
2767
+						my $read = sysread ($handle, $temp, 16000);
2768
+						last if (! defined ($read) || $read == 0); # No more data or something went wrong
2769
+						$temp2 = $temp2.$temp;
2770
+					}
2771
+				}
2772
+				if ($id_tipo_modulo == 9){ # only for TCP Proc
2773
+					if ($temp2 =~ /$tcp_rcv/i){ # String match !
2774
 						if ( @tcp_send ) { # still more pairs
2775
 							goto next_pair;
2776
 						}
2777
- 					        $$module_data = 1;
2778
-					        $$module_result = 0;
2779
-					        $counter = $retries;
2780
-				        } else {
2781
-					        $$module_data = 0;
2782
-					        $$module_result = 0;
2783
-					        $counter = $retries;
2784
-				        }
2785
-			        } elsif ($id_tipo_modulo == 10 ){ # TCP String (no int conversion)!
2786
-				        $$module_data = $temp2;
2787
-				        $$module_result =0;
2788
-			        } else { # TCP Data numeric (inc or data)
2789
-				        if ($temp2 ne ""){
2790
-					        if ($temp2 =~ /[A-Za-z\.\,\-\/\\\(\)\[\]]/){
2791
-						        $$module_result = 1;
2792
-						        $$module_data = 0; # invalid data
2793
-						        $counter = $retries;
2794
-					        } else {
2795
-						        $$module_data = int($temp2);
2796
-						        $$module_result = 0; # Successful
2797
-						        $counter = $retries;
2798
-					        }
2799
-				        } else {
2800
-						        $$module_result = 1; 
2801
-						        $$module_data = 0; # invalid data
2802
-						        $counter = $retries;
2803
-					        }
2804
-			        }
2805
-		        } else { # No expected data to receive, if connected and tcp_proc type successful
2806
-			        if ($id_tipo_modulo == 9){ # TCP Proc
2807
-				        $$module_result = 0;
2808
-				        $$module_data = 1;
2809
-				        $counter = $retries;
2810
-			        }
2811
-		        }
2812
-		        $handle->close();
2813
-		        undef ($handle);
2814
-	        } else { # Cannot connect (open sock failed)
2815
-		        $$module_result = 1; # Fail
2816
-		        if ($id_tipo_modulo == 9){ # TCP Proc
2817
-			        $$module_result = 0;
2818
-			        $$module_data = 0; # Failed, but data exists
2819
-			        $counter = $retries;
2820
-		        }
2821
-	        }
2822
-        }
2823
+						$$module_data = 1;
2824
+						$$module_result = 0;
2825
+						$counter = $retries;
2826
+					} else {
2827
+						$$module_data = 0;
2828
+						$$module_result = 0;
2829
+						$counter = $retries;
2830
+					}
2831
+				} elsif ($id_tipo_modulo == 10 ){ # TCP String (no int conversion)!
2832
+					$$module_data = $temp2;
2833
+					$$module_result =0;
2834
+				} else { # TCP Data numeric (inc or data)
2835
+					if ($temp2 ne ""){
2836
+						if ($temp2 =~ /[A-Za-z\.\,\-\/\\\(\)\[\]]/){
2837
+							$$module_result = 1;
2838
+							$$module_data = 0; # invalid data
2839
+							$counter = $retries;
2840
+						} else {
2841
+							$$module_data = int($temp2);
2842
+							$$module_result = 0; # Successful
2843
+							$counter = $retries;
2844
+						}
2845
+					} else {
2846
+						$$module_result = 1; 
2847
+						$$module_data = 0; # invalid data
2848
+						$counter = $retries;
2849
+					}
2850
+				}
2851
+			} else { # No expected data to receive, if connected and tcp_proc type successful
2852
+				if ($id_tipo_modulo == 9){ # TCP Proc
2853
+					$$module_result = 0;
2854
+					$$module_data = 1;
2855
+					$counter = $retries;
2856
+				}
2857
+			}
2858
+			$handle->close();
2859
+			undef ($handle);
2860
+		} else { # Cannot connect (open sock failed)
2861
+			$$module_result = 1; # Fail
2862
+			if ($id_tipo_modulo == 9){ # TCP Proc
2863
+				$$module_result = 0;
2864
+				$$module_data = 0; # Failed, but data exists
2865
+				$counter = $retries;
2866
+			}
2867
+		}
2868
+	}
2869
 }
2870
 
2871
 ###############################################################################
2872
@@ -352,7 +356,7 @@
2873
 
2874
 	return (undef, 0) unless ($snmp_oid ne '');
2875
 	if ($snmp_oid =~ m/[a-zA-Z]/) {
2876
-		$snmp_oid = translate_obj ($pa_config, $dbh, $snmp_oid, );
2877
+		$snmp_oid = translate_obj ($pa_config, $dbh, $snmp_oid);
2878
 		
2879
 		# Could not translate OID, disable the module
2880
 		if (! defined ($snmp_oid) || $snmp_oid eq '') {
2881
Index: lib/PandoraFMS/GIS.pm
2882
===================================================================
2883
--- lib/PandoraFMS/GIS.pm	(revision 10314)
2884
+++ lib/PandoraFMS/GIS.pm	(working copy)
2885
@@ -146,12 +146,24 @@
2886
 ##########################################################################
2887
 sub get_reverse_geoip_sql($$$) {
2888
 	my ($pa_config,$ip_addr, $dbh) = @_;
2889
-
2890
-	my $id_range =  get_db_value($dbh, 'SELECT `id_range` FROM tgis_reverse_geoip_ranges WHERE INET_ATON(?) >= `first_IP_decimal` AND INET_ATON(?) <= `last_IP_decimal` LIMIT 1', $ip_addr, $ip_addr);
2891
-    if (defined($id_range)) {
2892
-    	logger($pa_config,"Range id of '$ip_addr' is '$id_range'", 8);
2893
-        my $region_info = get_db_single_row($dbh, 'SELECT * FROM tgis_reverse_geoip_info WHERE `id_range` = ?',$id_range);
2894
-       	logger($pa_config, "region info of id_range '$id_range' is: country:".$region_info->{'country_name'}." region:".$region_info->{'region'}." city:".$region_info->{'city'}." longitude:".$region_info->{'longitude'}." latitude:".$region_info->{'longitude'}, 8);
2895
+	
2896
+	my $id_range =  get_db_value($dbh,
2897
+		'SELECT ' . $RDBMS_QUOTE . 'id_range' . $RDBMS_QUOTE . '
2898
+		FROM tgis_reverse_geoip_ranges
2899
+		WHERE INET_ATON(?) >=  ' . $RDBMS_QUOTE . 'first_IP_decimal' . $RDBMS_QUOTE . '
2900
+			AND INET_ATON(?) <=  ' . $RDBMS_QUOTE . 'last_IP_decimal ' . $RDBMS_QUOTE . '
2901
+			LIMIT 1', $ip_addr, $ip_addr);
2902
+	
2903
+	if (defined($id_range)) {
2904
+		logger($pa_config,"Range id of '$ip_addr' is '$id_range'", 8);
2905
+		my $region_info = get_db_single_row($dbh,
2906
+			'SELECT *
2907
+			FROM tgis_reverse_geoip_info
2908
+			WHERE  ' . $RDBMS_QUOTE . 'id_range ' . $RDBMS_QUOTE . ' = ?',
2909
+			$id_range);
2910
+		
2911
+		logger($pa_config, "region info of id_range '$id_range' is: country:".$region_info->{'country_name'}." region:".$region_info->{'region'}." city:".$region_info->{'city'}." longitude:".$region_info->{'longitude'}." latitude:".$region_info->{'longitude'}, 8);
2912
+		
2913
 		return $region_info;
2914
 	}
2915
 	return undef;
2916
Index: lib/PandoraFMS/DB.pm
2917
===================================================================
2918
--- lib/PandoraFMS/DB.pm	(revision 10314)
2919
+++ lib/PandoraFMS/DB.pm	(working copy)
2920
@@ -86,14 +86,18 @@
2921
 		get_agentmodule_data
2922
 		$RDBMS
2923
 		$RDBMS_QUOTE
2924
+		$RDBMS_QUOTE_STRING
2925
 	);
2926
 
2927
 # Relational database management system in use
2928
 our $RDBMS = '';
2929
 
2930
-# Character used to quote reserved words in the current RDBMS
2931
+# For fields, character used to quote reserved words in the current RDBMS
2932
 our $RDBMS_QUOTE = '';
2933
 
2934
+# For strings, Character used to quote in the current RDBMS
2935
+our $RDBMS_QUOTE_STRING = '';
2936
+
2937
 ##########################################################################
2938
 ## Connect to the DB.
2939
 ##########################################################################
2940
@@ -103,7 +107,8 @@
2941
 	if ($rdbms eq 'mysql') {
2942
 		$RDBMS = 'mysql';
2943
 		$RDBMS_QUOTE = '`';
2944
-	
2945
+		$RDBMS_QUOTE_STRING = '"';
2946
+		
2947
 		# Connect to MySQL
2948
 		my $dbh = DBI->connect("DBI:mysql:$db_name:$db_host:$db_port", $db_user, $db_pass, { RaiseError => 1, AutoCommit => 1 });
2949
 		return undef unless defined ($dbh);
2950
@@ -119,15 +124,18 @@
2951
 	elsif ($rdbms eq 'postgresql') {
2952
 		$RDBMS = 'postgresql';
2953
 		$RDBMS_QUOTE = '"';
2954
+		$RDBMS_QUOTE_STRING = "'";
2955
 		
2956
 		# Connect to PostgreSQL
2957
 		my $dbh = DBI->connect("DBI:Pg:dbname=$db_name;host=$db_host;port=$db_port", $db_user, $db_pass, { RaiseError => 1, AutoCommit => 1 });
2958
 		return undef unless defined ($dbh);
2959
 		
2960
 		return $dbh;
2961
-	} elsif ($rdbms eq 'oracle') {
2962
+	}
2963
+	elsif ($rdbms eq 'oracle') {
2964
 		$RDBMS = 'oracle';
2965
 		$RDBMS_QUOTE = '"';
2966
+		$RDBMS_QUOTE_STRING = '"';
2967
 		
2968
 		# Connect to Oracle
2969
 		my $dbh = DBI->connect("DBI:Oracle:dbname=$db_name;host=$db_host;port=$db_port;sid=pandora", $db_user, $db_pass, { RaiseError => 1, AutoCommit => 1 });
2970
@@ -641,6 +649,7 @@
2971
 	my ($dbh, $index, $query, @values) = @_;
2972
 	my $insert_id = undef;
2973
 	
2974
+	
2975
 	# MySQL
2976
 	if ($RDBMS eq 'mysql') {
2977
 		$dbh->do($query, undef, @values);
2978
@@ -684,9 +693,9 @@
2979
 	return defined ($rc) ? $rc : -1;
2980
 }
2981
 
2982
-##########################################################################
2983
+########################################################################
2984
 ## SQL insert. Returns the ID of the inserted row.
2985
-##########################################################################
2986
+########################################################################
2987
 sub db_process_insert($$$$;@) {
2988
 	my ($dbh, $index, $table, $parameters, @values) = @_;
2989
 	
2990
@@ -711,10 +720,14 @@
2991
 	}
2992
 	$wildcards = '('.$wildcards.')';
2993
 	
2994
-	my $columns_string = join('`,`',@columns_array);
2995
+	my $columns_string = join($RDBMS_QUOTE . ',' . $RDBMS_QUOTE,
2996
+		@columns_array);
2997
 	
2998
-	my $res = db_insert ($dbh, $index, "INSERT INTO $table (`".$columns_string."`) VALUES ".$wildcards, @values_array);
2999
+	my $res = db_insert ($dbh,
3000
+		$index,
3001
+		"INSERT INTO $table (" . $RDBMS_QUOTE . $columns_string . $RDBMS_QUOTE . ") VALUES " . $wildcards, @values_array);
3002
 	
3003
+	
3004
 	return $res;
3005
 }
3006
 
3007
@@ -740,7 +753,8 @@
3008
 		if ($i > 0 && $i <= $#values_array) {
3009
 			$fields = $fields.',';
3010
 		}
3011
-		$fields = $fields." `$columns_array[$i]` = ?";
3012
+		$fields = $fields .
3013
+			" " . $RDBMS_QUOTE . "$columns_array[$i]" . $RDBMS_QUOTE . " = ?";
3014
 	}
3015
 	
3016
 	push(@values_array, $where_value);
3017
@@ -752,28 +766,30 @@
3018
 	return $res;
3019
 }
3020
 
3021
-##########################################################################
3022
+########################################################################
3023
 # Add the given address to taddress.
3024
-##########################################################################
3025
+########################################################################
3026
 sub add_address ($$) {
3027
 	my ($dbh, $ip_address) = @_;
3028
-
3029
+	
3030
 	return db_insert ($dbh, 'id_a', 'INSERT INTO taddress (ip) VALUES (?)', $ip_address);
3031
 }
3032
 
3033
-##########################################################################
3034
+########################################################################
3035
 # Assign the new address to the agent
3036
-##########################################################################
3037
+########################################################################
3038
 sub add_new_address_agent ($$$) {
3039
 	my ($dbh, $addr_id, $agent_id) = @_;
3040
 	
3041
-	db_do ($dbh, 'INSERT INTO taddress_agent (`id_a`, `id_agent`)
3042
+	db_do ($dbh, 'INSERT INTO taddress_agent (' .
3043
+		$RDBMS_QUOTE . 'id_a' . $RDBMS_QUOTE . ', ' .
3044
+		$RDBMS_QUOTE. 'id_agent' . $RDBMS_QUOTE. ')
3045
 		VALUES (?, ?)', $addr_id, $agent_id);
3046
 }
3047
 
3048
-##########################################################################
3049
+########################################################################
3050
 # Return the ID of the given address, -1 if it does not exist.
3051
-##########################################################################
3052
+########################################################################
3053
 sub get_addr_id ($$) {
3054
 	my ($dbh, $addr) = @_;
3055
 	
3056
@@ -825,9 +841,9 @@
3057
 	return (defined ($id_ag)) ? $id_ag : 0;
3058
 }
3059
 
3060
-##########################################################################
3061
+########################################################################
3062
 ## Quote the given string. 
3063
-##########################################################################
3064
+########################################################################
3065
 sub db_string ($) {
3066
 	my $string = shift;
3067
 	
3068
@@ -856,7 +872,10 @@
3069
 sub get_alert_template_name ($$) {
3070
 	my ($dbh, $alert_id) = @_;
3071
 	
3072
-	return get_db_value ($dbh, "SELECT name FROM talert_templates, talert_template_modules WHERE talert_templates.id = talert_template_modules.id_alert_template AND talert_template_modules.id = ?", $alert_id);
3073
+	return get_db_value ($dbh, "SELECT name
3074
+		FROM talert_templates, talert_template_modules
3075
+		WHERE talert_templates.id = talert_template_modules.id_alert_template
3076
+			AND talert_template_modules.id = ?", $alert_id);
3077
 }
3078
 
3079
 ########################################################################
3080
@@ -865,9 +884,8 @@
3081
 sub db_concat ($$) {
3082
 	my ($element1, $element2) = @_;
3083
 	
3084
-	return " concat(" . $element1 . ", ' '," . $element2 . ") " if ($RDBMS eq 'mysql');
3085
-	
3086
 	return " " . $element1 . " || ' ' || " . $element2 . " " if ($RDBMS eq 'oracle' or $RDBMS eq 'postgresql');
3087
+	return " concat(" . $element1 . ", ' '," . $element2 . ") ";
3088
 }
3089
 
3090
 ########################################################################
3091
@@ -906,18 +924,18 @@
3092
 ########################################################################
3093
 sub db_update_get_values ($) {
3094
 	my ($set_ref) = @_;
3095
-
3096
+	
3097
 	my $set = '';
3098
 	my @values;
3099
 	while (my ($key, $value) = each (%{$set_ref})) {
3100
-
3101
-			# Not value for the given column
3102
-			next if (! defined ($value));
3103
-
3104
-			$set .= "$key = ?,";
3105
-			push (@values, $value);
3106
+		
3107
+		# Not value for the given column
3108
+		next if (! defined ($value));
3109
+		
3110
+		$set .= "$key = ?,";
3111
+		push (@values, $value);
3112
 	}
3113
-
3114
+	
3115
 	# Remove the last ,
3116
 	chop ($set);
3117
 	
3118
@@ -929,34 +947,34 @@
3119
 ########################################################################
3120
 sub db_insert_get_values ($) {
3121
 	my ($insert_ref) = @_;
3122
-
3123
+	
3124
 	my $columns = '(';
3125
 	my @values;
3126
 	while (my ($key, $value) = each (%{$insert_ref})) {
3127
-
3128
-			# Not value for the given column
3129
-			next if (! defined ($value));
3130
-
3131
-			$columns .= $PandoraFMS::DB::RDBMS_QUOTE . "$key" . $PandoraFMS::DB::RDBMS_QUOTE . ",";
3132
-			push (@values, $value);
3133
+		
3134
+		# Not value for the given column
3135
+		next if (! defined ($value));
3136
+		
3137
+		$columns .= $PandoraFMS::DB::RDBMS_QUOTE . "$key" . $PandoraFMS::DB::RDBMS_QUOTE . ",";
3138
+		push (@values, $value);
3139
 	}
3140
-
3141
+	
3142
 	# Remove the last , and close the parentheses
3143
 	chop ($columns);
3144
 	$columns .= ')';
3145
 	
3146
-	# No columns		
3147
+	# No columns
3148
 	if ($columns eq '()') {
3149
 		return;
3150
 	}
3151
-
3152
+	
3153
 	# Add placeholders for the values
3154
 	$columns .= ' VALUES (' . ("?," x ($#values + 1));
3155
-
3156
+	
3157
 	# Remove the last , and close the parentheses
3158
 	chop ($columns);
3159
 	$columns .= ')';
3160
-		
3161
+	
3162
 	return ($columns, \@values);
3163
 }
3164
 
3165
@@ -973,7 +991,7 @@
3166
 	my $sth = $dbh->prepare('SELECT GET_LOCK(?, ?)');
3167
 	$sth->execute($lock_name, $lock_timeout);
3168
 	my ($lock) = $sth->fetchrow;
3169
-
3170
+	
3171
 	# Something went wrong
3172
 	return 0 if (! defined ($lock));
3173
 	
3174
Index: lib/PandoraFMS/Core.pm
3175
===================================================================
3176
--- lib/PandoraFMS/Core.pm	(revision 10314)
3177
+++ lib/PandoraFMS/Core.pm	(working copy)
3178
@@ -511,6 +511,9 @@
3179
 		my $critical_instructions = get_db_value ($dbh, 'SELECT critical_instructions FROM tagente_modulo WHERE id_agente_modulo = ?', $alert->{'id_agent_module'});
3180
 		my $warning_instructions = get_db_value ($dbh, 'SELECT warning_instructions FROM tagente_modulo WHERE id_agente_modulo = ?', $alert->{'id_agent_module'});
3181
 		my $unknown_instructions = get_db_value ($dbh, 'SELECT unknown_instructions FROM tagente_modulo WHERE id_agente_modulo = ?', $alert->{'id_agent_module'});
3182
+
3183
+		$alert->{'critical_instructions'} = $critical_instructions;
3184
+		$alert->{'warning_instructions'} = $warning_instructions;
3185
 		
3186
 		# Generate an event
3187
 		if ($table eq 'tevent_alert') {
3188
@@ -666,6 +669,14 @@
3189
 		return;
3190
 	}
3191
 
3192
+	# Critical_instructions, warning_instructions, unknown_instructions
3193
+	my $critical_instructions = get_db_value ($dbh, 'SELECT critical_instructions FROM tagente_modulo WHERE id_agente_modulo = ?', $alert->{'id_agent_module'});
3194
+	my $warning_instructions = get_db_value ($dbh, 'SELECT warning_instructions FROM tagente_modulo WHERE id_agente_modulo = ?', $alert->{'id_agent_module'});
3195
+	my $unknown_instructions = get_db_value ($dbh, 'SELECT unknown_instructions FROM tagente_modulo WHERE id_agente_modulo = ?', $alert->{'id_agent_module'});
3196
+
3197
+	$alert->{'critical_instructions'} = $critical_instructions;
3198
+	$alert->{'warning_instructions'} = $warning_instructions;
3199
+
3200
 	# Execute actions
3201
 	my $event_generated = 0;
3202
 	foreach my $action (@actions) {
3203
@@ -692,11 +703,6 @@
3204
 		}
3205
 	}
3206
 	
3207
-	# Critical_instructions, warning_instructions, unknown_instructions
3208
-	my $critical_instructions = get_db_value ($dbh, 'SELECT critical_instructions FROM tagente_modulo WHERE id_agente_modulo = ?', $alert->{'id_agent_module'});
3209
-	my $warning_instructions = get_db_value ($dbh, 'SELECT warning_instructions FROM tagente_modulo WHERE id_agente_modulo = ?', $alert->{'id_agent_module'});
3210
-	my $unknown_instructions = get_db_value ($dbh, 'SELECT unknown_instructions FROM tagente_modulo WHERE id_agente_modulo = ?', $alert->{'id_agent_module'});
3211
-	
3212
 	# Generate an event	only if an event has not already been generated by an alert action
3213
 	if ($event_generated == 0) {
3214
 
3215
@@ -840,6 +846,8 @@
3216
 				_alert_times_fired_ => $alert->{'times_fired'},
3217
 				_alert_priority_ => $alert->{'priority'},
3218
 				_alert_text_severity_ => get_priority_name($alert->{'priority'}),
3219
+				_alert_critical_instructions_ => $alert->{'critical_instructions'},
3220
+				_alert_warning_instructions_ => $alert->{'warning_instructions'},
3221
 				_groupcontact_ => (defined ($group)) ? $group->{'contact'} : '',
3222
 				_groupother_ => (defined ($group)) ? $group->{'other'} : '',
3223
 				_module_ => (defined ($module)) ? $module->{'nombre'} : '',
3224
@@ -1095,6 +1103,11 @@
3225
 		$min_ff_event = $module->{'min_ff_event_warning'} if ($new_status == 2);
3226
 	}
3227
 	
3228
+	# replace $new_status with $last_known_status when recovering from 'unknown'
3229
+	if ($status == 3) {
3230
+		$new_status = $last_known_status;
3231
+	}
3232
+
3233
 	if ($last_status == $new_status) {
3234
 		
3235
 		# Avoid overflows
3236
@@ -1124,17 +1137,24 @@
3237
 		# Update module status count
3238
 		pandora_mark_agent_for_module_update ($dbh, $agent->{'id_agente'});
3239
 	}
3240
-	# Set not-init modules to normal even if min_ff_event is not matched the first time they receive data
3241
+	# Set not-init modules to normal status even if min_ff_event is not matched the first time they receive data.
3242
+	# if critical or warning status, just pass through here and wait the time min_ff_event will be matched.
3243
 	elsif ($status == 4) {
3244
-		$new_status = 0;
3245
-		
3246
+		generate_status_event ($pa_config, $processed_data, $agent, $module, 0, $status, $last_known_status, $dbh);
3247
+		$status = 0;
3248
+
3249
+		# Update module status count
3250
+		pandora_mark_agent_for_module_update ($dbh, $agent->{'id_agente'});
3251
+	}
3252
+	# If unknown modules receive data, restore status even if min_ff_event is not matched.
3253
+	elsif ($status == 3) {
3254
 		generate_status_event ($pa_config, $processed_data, $agent, $module, $new_status, $status, $last_known_status, $dbh);
3255
 		$status = $new_status;
3256
 
3257
 		# Update module status count
3258
 		pandora_mark_agent_for_module_update ($dbh, $agent->{'id_agente'});
3259
 	}
3260
-		
3261
+
3262
 	$last_status = $new_status;
3263
 		
3264
 	# tagente_estado.last_try defaults to NULL, should default to '1970-01-01 00:00:00'
3265
@@ -1193,8 +1213,10 @@
3266
 	# Stop executed downtimes (enable agents and disable_agents_alerts)
3267
 	my @downtimes = get_db_rows($dbh, 'SELECT *
3268
 		FROM tplanned_downtime
3269
-		WHERE type_downtime != "quiet" AND type_execution="once"
3270
-			AND executed = 1 AND date_to <= ?', $utimestamp);
3271
+		WHERE type_downtime != ' . $RDBMS_QUOTE_STRING. 'quiet' . $RDBMS_QUOTE_STRING. '
3272
+			AND type_execution = ' . $RDBMS_QUOTE_STRING. 'once' . $RDBMS_QUOTE_STRING. '
3273
+			AND executed = 1
3274
+			AND date_to <= ?', $utimestamp);
3275
 	
3276
 	foreach my $downtime (@downtimes) {
3277
 		
3278
@@ -1226,7 +1248,8 @@
3279
 	# Start pending downtimes (disable agents and disable_agents_alerts)
3280
 	my @downtimes = get_db_rows($dbh, 'SELECT *
3281
 		FROM tplanned_downtime
3282
-		WHERE type_downtime != "quiet" AND type_execution="once"
3283
+		WHERE type_downtime != ' . $RDBMS_QUOTE_STRING . 'quiet' . $RDBMS_QUOTE_STRING . '
3284
+			AND type_execution = ' . $RDBMS_QUOTE_STRING . 'once' . $RDBMS_QUOTE_STRING . '
3285
 			AND executed = 0 AND date_from <= ?
3286
 			AND date_to >= ?', $utimestamp, $utimestamp);
3287
 	
3288
@@ -1423,7 +1446,8 @@
3289
 	# Stop pending downtimes
3290
 	my @downtimes = get_db_rows($dbh, 'SELECT *
3291
 		FROM tplanned_downtime
3292
-		WHERE type_downtime = "quiet" AND type_execution="once"
3293
+		WHERE type_downtime = ' . $RDBMS_QUOTE_STRING . 'quiet' . $RDBMS_QUOTE_STRING . '
3294
+			AND type_execution = ' . $RDBMS_QUOTE_STRING. 'once' . $RDBMS_QUOTE_STRING . '
3295
 			AND executed = 1 AND date_to <= ?', $utimestamp);
3296
 	
3297
 	foreach my $downtime (@downtimes) {
3298
@@ -1463,7 +1487,8 @@
3299
 	# Start pending downtimes
3300
 	my @downtimes = get_db_rows($dbh, 'SELECT *
3301
 		FROM tplanned_downtime
3302
-		WHERE type_downtime = "quiet" AND type_execution="once"
3303
+		WHERE type_downtime = ' . $RDBMS_QUOTE_STRING . 'quiet' . $RDBMS_QUOTE_STRING . '
3304
+			AND type_execution = ' . $RDBMS_QUOTE_STRING . 'once' . $RDBMS_QUOTE_STRING . '
3305
 			AND executed = 0 AND date_from <= ?
3306
 			AND date_to >= ?', $utimestamp, $utimestamp);
3307
 	
3308
@@ -1517,7 +1542,7 @@
3309
 	# Start pending downtimes
3310
 	my @downtimes = get_db_rows($dbh, 'SELECT *
3311
 		FROM tplanned_downtime
3312
-		WHERE type_periodicity="monthly"
3313
+		WHERE type_periodicity = ' . $RDBMS_QUOTE_STRING . 'monthly' . $RDBMS_QUOTE_STRING . '
3314
 			AND executed = 0
3315
 			AND periodically_day_from <= ?
3316
 			AND periodically_day_to >= ?', 
3317
@@ -1619,9 +1644,9 @@
3318
 	# Start pending downtimes
3319
 	my @downtimes = get_db_rows($dbh, 'SELECT *
3320
 		FROM tplanned_downtime
3321
-		WHERE type_periodicity = "monthly"
3322
+		WHERE type_periodicity = ' . $RDBMS_QUOTE_STRING . 'monthly' . $RDBMS_QUOTE_STRING . '
3323
 			AND executed = 1
3324
-			AND type_execution <> "once"');
3325
+			AND type_execution <> ' . $RDBMS_QUOTE_STRING . 'once' . $RDBMS_QUOTE_STRING);
3326
 	
3327
 	foreach my $downtime (@downtimes) {
3328
 		#Convert to identical type.
3329
@@ -1695,18 +1720,18 @@
3330
 	# Start pending downtimes
3331
 	my @downtimes = get_db_rows($dbh, 'SELECT *
3332
 		FROM tplanned_downtime
3333
-		WHERE type_periodicity="weekly"
3334
+		WHERE type_periodicity = ' . $RDBMS_QUOTE_STRING . 'weekly' . $RDBMS_QUOTE_STRING . '
3335
 			AND executed = 0');
3336
 	
3337
 	foreach my $downtime (@downtimes) {
3338
 		my $across_date = $downtime->{'periodically_time_from'} gt $downtime->{'periodically_time_to'} ? 1 : 0 ;
3339
 		$found = 0;
3340
-
3341
+		
3342
 		if ($across_date && ($time lt $downtime->{'periodically_time_to'})) {
3343
-                        $number_day_week--;
3344
-                        $number_day_week = 6 if ($number_day_week == -1);
3345
-                }
3346
-
3347
+			$number_day_week--;
3348
+			$number_day_week = 6 if ($number_day_week == -1);
3349
+		}
3350
+		
3351
 		if (($number_day_week == 1) &&
3352
 			($downtime->{'monday'})) {
3353
 				$found = 1;
3354
@@ -1817,8 +1842,8 @@
3355
 	# Start pending downtimes
3356
 	my @downtimes = get_db_rows($dbh, 'SELECT *
3357
 		FROM tplanned_downtime
3358
-		WHERE type_periodicity = "weekly"
3359
-			AND type_execution <> "once"
3360
+		WHERE type_periodicity = ' . $RDBMS_QUOTE_STRING . 'weekly' . $RDBMS_QUOTE_STRING . '
3361
+			AND type_execution <> ' . $RDBMS_QUOTE_STRING . 'once' . $RDBMS_QUOTE_STRING . '
3362
 			AND executed = 1');
3363
 	
3364
 	foreach my $downtime (@downtimes) {
3365
@@ -2137,7 +2162,7 @@
3366
 Create a template module.
3367
 
3368
 =cut
3369
-##########################################################################
3370
+########################################################################
3371
 sub pandora_create_template_module ($$$$;$$$) {
3372
 	my ($pa_config, $dbh, $id_agent_module, $id_alert_template, $id_policy_alerts, $disabled, $standby) = @_;
3373
 	
3374
@@ -2146,16 +2171,27 @@
3375
 	$standby = 0 unless defined $standby;
3376
 	
3377
 	my $module_name = get_module_name($dbh, $id_agent_module);
3378
-	return db_insert ($dbh, 'id', "INSERT INTO talert_template_modules (`id_agent_module`, `id_alert_template`, `id_policy_alerts`, `disabled`, `standby`, `last_reference`) VALUES (?, ?, ?, ?, ?, ?)", $id_agent_module, $id_alert_template, $id_policy_alerts, $disabled, $standby, time);
3379
+	
3380
+	return db_insert ($dbh,
3381
+		'id',
3382
+		"INSERT INTO talert_template_modules(
3383
+			" . $RDBMS_QUOTE . "id_agent_module" . $RDBMS_QUOTE . ",
3384
+			" . $RDBMS_QUOTE . "id_alert_template" . $RDBMS_QUOTE . ",
3385
+			" . $RDBMS_QUOTE . "id_policy_alerts" . $RDBMS_QUOTE . ",
3386
+			" . $RDBMS_QUOTE . "disabled" . $RDBMS_QUOTE . ",
3387
+			" . $RDBMS_QUOTE . "standby" . $RDBMS_QUOTE . ",
3388
+			" . $RDBMS_QUOTE . "last_reference" . $RDBMS_QUOTE . ")
3389
+		VALUES (?, ?, ?, ?, ?, ?)",
3390
+		$id_agent_module, $id_alert_template, $id_policy_alerts, $disabled, $standby, time);
3391
 }
3392
 
3393
-##########################################################################
3394
+########################################################################
3395
 =head2 C<< pandora_update_template_module(I<$pa_config>, I<$dbh>, I<$id_alert>, I<$id_policy_alerts>, I<$disabled>, I<$standby>) >>
3396
 
3397
 Update a template module.
3398
 
3399
 =cut
3400
-##########################################################################
3401
+########################################################################
3402
 
3403
 sub pandora_update_template_module ($$$;$$$) {
3404
 	my ($pa_config, $dbh, $id_alert, $id_policy_alerts, $disabled, $standby) = @_;
3405
@@ -2164,16 +2200,22 @@
3406
 	$disabled = 0 unless defined $disabled;
3407
 	$standby = 0 unless defined $standby;
3408
 	
3409
-	db_do ($dbh, "UPDATE talert_template_modules SET `id_policy_alerts` = ?, `disabled` =  ?, `standby` = ? WHERE id = ?", $id_policy_alerts, $disabled, $standby, $id_alert);
3410
+	db_do ($dbh,
3411
+		"UPDATE talert_template_modules
3412
+		SET " . $RDBMS_QUOTE . "id_policy_alerts" . $RDBMS_QUOTE . " = ?,
3413
+			" . $RDBMS_QUOTE . "disabled" . $RDBMS_QUOTE . " =  ?,
3414
+			" . $RDBMS_QUOTE . "standby" . $RDBMS_QUOTE . " = ?
3415
+		WHERE id = ?",
3416
+		$id_policy_alerts, $disabled, $standby, $id_alert);
3417
 }
3418
 
3419
-##########################################################################
3420
+########################################################################
3421
 =head2 C<< pandora_create_template_module_action(I<$pa_config>, I<$parameters>, I<$dbh>) >>
3422
 
3423
 Create a template action.
3424
 
3425
 =cut
3426
-##########################################################################
3427
+########################################################################
3428
 sub pandora_create_template_module_action ($$$) {
3429
 	my ($pa_config, $parameters, $dbh) = @_;
3430
 	
3431
@@ -2184,26 +2226,26 @@
3432
 	return $action_id;
3433
 }
3434
 
3435
-##########################################################################
3436
+########################################################################
3437
 =head2 C<< pandora_delete_all_template_module_actions(I<$dbh>, I<$template_module_id>) >>
3438
 
3439
 Delete all actions of policy template module.
3440
 
3441
 =cut
3442
-##########################################################################
3443
+########################################################################
3444
 sub pandora_delete_all_template_module_actions ($$) {
3445
 	my ($dbh, $template_module_id) = @_;
3446
 	
3447
 	return db_do ($dbh, 'DELETE FROM talert_template_module_actions WHERE id_alert_template_module = ?', $template_module_id);
3448
 }
3449
 
3450
-##########################################################################
3451
+########################################################################
3452
 =head2 C<< pandora_update_agent_address(I<$pa_config>, I<$agent_id>, I<$address>, I<$dbh>) >>
3453
 
3454
 Update the address of an agent.
3455
 
3456
 =cut
3457
-##########################################################################
3458
+########################################################################
3459
 sub pandora_update_agent_address ($$$$$) {
3460
 	my ($pa_config, $agent_id, $agent_name, $address, $dbh) = @_;
3461
 	
3462
@@ -2298,9 +2340,13 @@
3463
 		$status = 0;
3464
 	}
3465
 	
3466
-	my $module_id = db_insert($dbh, 'id_agente_modulo', 'INSERT INTO tagente_modulo (id_agente, id_tipo_modulo, nombre, max, min, post_process, descripcion, module_interval, id_modulo)
3467
-		VALUES (?, ?, ?, ?, ?, ?, ?, ?, 1)', $agent_id, $module_type_id, safe_input($module_name), $max, $min, $post_process, $description, $interval);
3468
-	db_do ($dbh, 'INSERT INTO tagente_estado (id_agente_modulo, id_agente, estado, last_status, last_known_status, last_try) VALUES (?, ?, ?, ?, ?, \'1970-01-01 00:00:00\')', $module_id, $agent_id, $status, $status, $status);
3469
+	my $module_id = db_insert($dbh, 'id_agente_modulo',
3470
+		'INSERT INTO tagente_modulo (id_agente, id_tipo_modulo, nombre, max, min, post_process, descripcion, module_interval, id_modulo, critical_instructions, warning_instructions, unknown_instructions, disabled_types_event, module_macros)
3471
+		VALUES (?, ?, ?, ?, ?, ?, ?, ?, 1, \'\', \'\', \'\', \'\', \'\')',
3472
+		$agent_id, $module_type_id, safe_input($module_name), $max, $min, $post_process, $description, $interval);
3473
+	db_do ($dbh, 'INSERT INTO tagente_estado (id_agente_modulo, id_agente, estado, last_status, last_known_status, last_try, datos)
3474
+		VALUES (?, ?, ?, ?, ?, \'1970-01-01 00:00:00\', \'\')',
3475
+		$module_id, $agent_id, $status, $status, $status);
3476
 	
3477
 	# Update the module status count. When the module is created disabled dont do it
3478
 	pandora_mark_agent_for_module_update ($dbh, $agent_id);
3479
@@ -2400,7 +2446,18 @@
3480
 	delete $parameters->{'type'};
3481
 	delete $parameters->{'datalist'};
3482
 	delete $parameters->{'status'};
3483
-	
3484
+	if (defined $parameters->{'id_os'}) {
3485
+		delete $parameters->{'id_os'};
3486
+	}
3487
+	if (defined $parameters->{'os_version'}) {
3488
+		delete $parameters->{'os_version'};
3489
+	}
3490
+	if (defined $parameters->{'id_os'}) {
3491
+		delete $parameters->{'id'};
3492
+	}
3493
+	if (defined $parameters->{'id_network_component_group'}) {
3494
+		delete $parameters->{'id_network_component_group'};
3495
+	}
3496
 	my $module_id = db_process_insert($dbh, 'id_agente_modulo',
3497
 		'tagente_modulo', $parameters);
3498
 	
3499
@@ -2409,7 +2466,7 @@
3500
 		$status = 0;
3501
 	}
3502
 	
3503
-	db_do ($dbh, 'INSERT INTO tagente_estado (id_agente_modulo, id_agente, estado, last_status, last_known_status, last_try) VALUES (?, ?, ?, ?, ?, \'1970-01-01 00:00:00\')', $module_id, $parameters->{'id_agente'}, $status, $status, $status);
3504
+	db_do ($dbh, 'INSERT INTO tagente_estado (id_agente_modulo, id_agente, estado, last_status, last_known_status, last_try, datos) VALUES (?, ?, ?, ?, ?, \'1970-01-01 00:00:00\', \'\')', $module_id, $parameters->{'id_agente'}, $status, $status, $status);
3505
 	
3506
 	# Update the module status count. When the module is created disabled dont do it
3507
 	pandora_mark_agent_for_module_update ($dbh, $parameters->{'id_agente'});
3508
@@ -2495,8 +2552,16 @@
3509
 	}
3510
 	
3511
 	foreach my $tag_name (split (',', $serialized_tags)) {
3512
-		my $tag_id = get_db_value ($dbh, "SELECT id_tag FROM ttag WHERE name = ?", $tag_name);
3513
-		db_insert ($dbh, 'id_tag', "INSERT INTO ttag_module (`id_tag`, `id_agente_modulo`) VALUES (?, ?)", $tag_id, $id_agent_module);
3514
+		my $tag_id = get_db_value ($dbh,
3515
+			"SELECT id_tag FROM ttag WHERE name = ?", $tag_name);
3516
+		
3517
+		db_insert ($dbh,
3518
+			'id_tag',
3519
+			"INSERT INTO ttag_module(
3520
+				" . $RDBMS_QUOTE . "id_tag" . $RDBMS_QUOTE . ",
3521
+				" . $RDBMS_QUOTE . "id_agente_modulo" . $RDBMS_QUOTE . ")
3522
+			VALUES (?, ?)",
3523
+			$tag_id, $id_agent_module);
3524
 	}
3525
 }
3526
 
3527
@@ -3385,6 +3450,19 @@
3528
 		return;
3529
 	}
3530
 
3531
+	# disable event just recovering from 'Unknown' without status change
3532
+	if($last_status == 3 && $status == $last_known_status && $module->{'disabled_types_event'} ) {
3533
+		my $disabled_types_event;
3534
+		eval {
3535
+			local $SIG{__DIE__};
3536
+			$disabled_types_event = decode_json($module->{'disabled_types_event'});
3537
+		};
3538
+		
3539
+		if ($disabled_types_event->{'going_unknown'}) {
3540
+			return;
3541
+		}
3542
+	}
3543
+
3544
 	# Mark as "validated" any previous event for this module
3545
 	pandora_validate_event ($pa_config, $module->{'id_agente_modulo'}, $dbh);
3546
 	
3547
@@ -3968,33 +4046,46 @@
3548
 		                                       AND estado = 3");
3549
 		$agents_unknown = 0 if (!defined($agents_unknown));
3550
 	}
3551
-
3552
+	
3553
 	my $queued_modules = get_db_value ($dbh, "SELECT SUM(queued_modules) FROM tserver WHERE name = '".$pa_config->{"servername"}."'");
3554
-
3555
-	if (!defined($queued_modules)){
3556
+	
3557
+	if (!defined($queued_modules)) {
3558
 		$queued_modules = 0;
3559
 	}
3560
-
3561
-	my $dbmaintance = get_db_value ($dbh, "SELECT COUNT(*) FROM tconfig WHERE token = 'db_maintance' AND value > UNIX_TIMESTAMP() - 86400");
3562
-
3563
+	
3564
+	my $dbmaintance;
3565
+	if ($RDBMS eq 'postgresql') {
3566
+		$dbmaintance = get_db_value ($dbh,
3567
+			"SELECT COUNT(*)
3568
+			FROM tconfig
3569
+			WHERE token = 'db_maintance'
3570
+				AND NULLIF(value, '')::int > UNIX_TIMESTAMP() - 86400");
3571
+	}
3572
+	else {
3573
+		$dbmaintance = get_db_value ($dbh,
3574
+			"SELECT COUNT(*)
3575
+			FROM tconfig
3576
+			WHERE token = 'db_maintance' AND value > UNIX_TIMESTAMP() - 86400");
3577
+	}
3578
+	
3579
 	$xml_output .=" <module>";
3580
 	$xml_output .=" <name>Database Maintenance</name>";
3581
 	$xml_output .=" <type>generic_proc</type>";
3582
 	$xml_output .=" <data>$dbmaintance</data>";
3583
 	$xml_output .=" </module>";
3584
-
3585
+	
3586
 	$xml_output .=" <module>";
3587
 	$xml_output .=" <name>Queued_Modules</name>";
3588
 	$xml_output .=" <type>generic_data</type>";
3589
 	$xml_output .=" <data>$queued_modules</data>";
3590
 	$xml_output .=" </module>";
3591
-
3592
+	
3593
 	$xml_output .=" <module>";
3594
 	$xml_output .=" <name>Agents_Unknown</name>";
3595
 	$xml_output .=" <type>generic_data</type>";
3596
 	$xml_output .=" <data>$agents_unknown</data>";
3597
 	$xml_output .=" </module>";
3598
-
3599
+	
3600
 	$xml_output .=" <module>";
3601
 	$xml_output .=" <name>System_Load_AVG</name>";
3602
 	$xml_output .=" <type>generic_data</type>";
3603
Index: lib/PandoraFMS/ReconServer.pm
3604
===================================================================
3605
--- lib/PandoraFMS/ReconServer.pm	(revision 10314)
3606
+++ lib/PandoraFMS/ReconServer.pm	(working copy)
3607
@@ -141,9 +141,11 @@
3608
 	}
3609
 
3610
 	# Call nmap
3611
+	my $timeout = $pa_config->{'networktimeout'}*1000;
3612
+	my $nmap_args  = '-nsP -PE --max-retries '.$pa_config->{'icmp_checks'}.' --host-timeout '.$timeout.' -T'.$pa_config->{'nmap_timing_template'};
3613
 	my $np = new PandoraFMS::NmapParser;
3614
 	eval {
3615
-		$np->parsescan($pa_config->{'nmap'},'-nsP', ($task->{'subnet'}));
3616
+		$np->parsescan($pa_config->{'nmap'}, $nmap_args, ($task->{'subnet'}));
3617
 	};
3618
 	if ($@) {
3619
 		update_recon_task ($dbh, $task_id, -1);
3620
@@ -262,7 +264,7 @@
3621
 			}
3622
 		}
3623
 		# End of GIS code -----------------------------      
3624
-		else {	
3625
+		else {
3626
 			# Create a new agent
3627
 			$agent_id = pandora_create_agent ($pa_config, $pa_config->{'servername'},
3628
 					                                  $host_name, $addr, $task->{'id_group'},
3629
@@ -274,7 +276,7 @@
3630
 			logger($pa_config, "Error creating agent '$host_name'.", 3);
3631
 			next;
3632
 		}
3633
-
3634
+		
3635
 		# Add the new address if it does not exist
3636
 		my $addr_id = get_addr_id ($dbh, $addr);
3637
 		$addr_id = add_address ($dbh, $addr) unless ($addr_id > 0);
3638
@@ -282,14 +284,15 @@
3639
 			logger($pa_config, "Could not add address '$addr' for host '$host_name'.", 3);
3640
 			next;
3641
 		}
3642
-
3643
+		
3644
 		# Assign the new address to the agent
3645
 		my $agent_addr_id = get_agent_addr_id ($dbh, $addr_id, $agent_id);
3646
 		if ($agent_addr_id <= 0) {
3647
-			db_do ($dbh, 'INSERT INTO taddress_agent (`id_a`, `id_agent`)
3648
-		                  VALUES (?, ?)', $addr_id, $agent_id);
3649
+			db_do ($dbh, 'INSERT INTO taddress_agent (' . $RDBMS_QUOTE . 'id_a' . $RDBMS_QUOTE . ', ' .
3650
+				$RDBMS_QUOTE . 'id_agent' . $RDBMS_QUOTE . ')
3651
+				VALUES (?, ?)', $addr_id, $agent_id);
3652
 		}
3653
-
3654
+		
3655
 		# Create network profile modules for the agent
3656
 		create_network_profile_modules ($pa_config, $dbh, $agent_id, $task->{'id_network_profile'}, $addr, $task->{'snmp_community'});
3657
 		
3658
@@ -309,9 +312,9 @@
3659
 		$text .= "\n\nThis is the list of IP addresses found: \n\n$added_hosts";
3660
 		pandora_create_incident ($pa_config, $dbh, "[RECON] New hosts detected", $text, 0, 0, 'Pandora FMS Recon Server', $task->{'id_group'});
3661
 	}
3662
-
3663
+	
3664
 	logger($pa_config, "Finished recon task for net " . $task->{'subnet'} . ".", 10);
3665
-
3666
+	
3667
 	# Mark recon task as done
3668
 	update_recon_task ($dbh, $task_id, -1);
3669
 }
3670
@@ -324,9 +327,11 @@
3671
 	my ($pa_config, $host, $dbh, $group, $max_depth, $resolve, $os_detect) = @_;
3672
 	
3673
 	# Call nmap
3674
+	my $timeout = $pa_config->{'networktimeout'}*1000;
3675
+	my $nmap_args  = '-nsP -PE --traceroute --max-retries '.$pa_config->{'icmp_checks'}.' --host-timeout '.$timeout.' -T'.$pa_config->{'nmap_timing_template'};
3676
 	my $np = new PandoraFMS::NmapParser;
3677
 	eval {
3678
-		$np->parsescan($pa_config->{'nmap'},'-nsP --traceroute', ($host));
3679
+		$np->parsescan($pa_config->{'nmap'}, $nmap_args, ($host));
3680
 	};
3681
 	if ($@) {
3682
 		return 0;
3683
@@ -388,12 +393,13 @@
3684
 		if ($os_detect == 1) {
3685
 			$id_os = guess_os ($pa_config, $dbh, $host_addr);
3686
 		}
3687
-	
3688
+		
3689
 		# Create the host
3690
 		my $agent_id = pandora_create_agent ($pa_config, $pa_config->{'servername'}, $host_name, $host_addr, $group, $parent_id, $id_os, '', 300, $dbh);
3691
 		$agent_id = 0 unless defined ($parent_id);
3692
-		db_do ($dbh, 'INSERT INTO taddress_agent (`id_a`, `id_agent`)
3693
-			          VALUES (?, ?)', $addr_id, $agent_id);
3694
+		db_do ($dbh, 'INSERT INTO taddress_agent (' . $RDBMS_QUOTE . 'id_a' . $RDBMS_QUOTE . ',' .
3695
+			$RDBMS_QUOTE . 'id_agent' . $RDBMS_QUOTE . ')
3696
+			VALUES (?, ?)', $addr_id, $agent_id);
3697
 		
3698
 		# Move to the next host
3699
 		$parent_id = $agent_id;
3700
@@ -417,9 +423,9 @@
3701
 # Guess OS using xprobe2.
3702
 ##########################################################################
3703
 sub guess_os {
3704
-    my ($pa_config, $dbh, $host) = @_;
3705
-    
3706
-    # Use xprobe2 if available
3707
+	my ($pa_config, $dbh, $host) = @_;
3708
+	
3709
+	# Use xprobe2 if available
3710
 	my $xprobe = $pa_config->{'xprobe2'};
3711
 	if (-e $xprobe){
3712
 			my $output = `$xprobe $host 2>$DEVNULL | grep 'Running OS' | head -1`;
3713
Index: lib/PandoraFMS/DataServer.pm
3714
===================================================================
3715
--- lib/PandoraFMS/DataServer.pm	(revision 10314)
3716
+++ lib/PandoraFMS/DataServer.pm	(working copy)
3717
@@ -528,7 +528,7 @@
3718
 	            'str_warning' => '', 'str_critical' => '', 'critical_instructions' => '', 'warning_instructions' => '',
3719
 	            'unknown_instructions' => '', 'tags' => '', 'critical_inverse' => 0, 'warning_inverse' => 0, 'quiet' => 0,
3720
 	            'module_ff_interval' => 0};
3721
-
3722
+	
3723
 	# Other tags will be saved here
3724
 	$module_conf->{'extended_info'} = '';
3725
 	
3726
@@ -539,8 +539,8 @@
3727
 		} else {
3728
 			$module_conf->{'extended_info'} .= "$tag: " . get_tag_value ($data, $tag, '') . '<br/>';
3729
 		}
3730
-	}	
3731
-		
3732
+	}
3733
+	
3734
 	# Description XML tag and column name don't match
3735
 	$module_conf->{'descripcion'} = $module_conf->{'description'};
3736
 	$module_conf->{'descripcion'} = '' unless defined ($module_conf->{'descripcion'});
3737
@@ -549,14 +549,21 @@
3738
 	# Name XML tag and column name don't match
3739
 	$module_conf->{'nombre'} = safe_input($module_name);
3740
 	delete $module_conf->{'name'};
3741
-
3742
+	
3743
 	# Calculate the module interval in seconds
3744
 	$module_conf->{'module_interval'} = 1 unless defined ($module_conf->{'module_interval'});
3745
 	$module_conf->{'module_interval'} *= $interval if (defined ($module_conf->{'module_interval'}));
3746
-
3747
+	
3748
 	# Allow , as a decimal separator
3749
 	$module_conf->{'post_process'} =~ s/,/./ if (defined ($module_conf->{'post_process'}));
3750
 
3751
+	# avoid NULL columns
3752
+	$module_conf->{'critical_instructions'} = '' unless defined ($module_conf->{'critical_instructions'});
3753
+	$module_conf->{'warning_instructions'} = '' unless defined ($module_conf->{'warning_instructions'});
3754
+	$module_conf->{'unknown_instructions'} = '' unless defined ($module_conf->{'unknown_instructions'});
3755
+	$module_conf->{'disabled_types_event'} = '' unless defined ($module_conf->{'disabled_types_event'});
3756
+	$module_conf->{'module_macros'} = '' unless defined ($module_conf->{'module_macros'});
3757
+	
3758
 	# Get module data or create it if it does not exist
3759
 	$ModuleSem->down ();
3760
 	my $module = get_db_single_row ($dbh, 'SELECT * FROM tagente_modulo WHERE id_agente = ? AND ' . db_text ('nombre') . ' = ?', $agent->{'id_agente'}, safe_input($module_name));
3761
@@ -568,14 +575,14 @@
3762
 			$ModuleSem->up ();
3763
 			return;
3764
 		}
3765
-
3766
+		
3767
 		# Is the agent learning?
3768
 		if ($agent->{'modo'} ne '1') {
3769
 			logger($pa_config, "Learning mode disabled. Skipping module '$module_name' agent '$agent_name'.", 10);
3770
 			$ModuleSem->up ();
3771
 			return;
3772
 		}
3773
-
3774
+		
3775
 		# Get the module type
3776
 		$module_conf->{'id_tipo_modulo'} = get_module_id ($dbh, $module_type);
3777
 		if ($module_conf->{'id_tipo_modulo'} <= 0) {
3778
@@ -583,16 +590,16 @@
3779
 			$ModuleSem->up ();
3780
 			return;
3781
 		}
3782
-	
3783
+		
3784
 		# The group name has to be translated to a group ID
3785
 		if (defined $module_conf->{'module_group'}) {
3786
 			$module_conf->{'id_module_group'} = get_module_group_id ($dbh, $module_conf->{'module_group'});
3787
 			delete $module_conf->{'module_group'};
3788
 		}
3789
-
3790
+		
3791
 		$module_conf->{'id_modulo'} = 1;
3792
 		$module_conf->{'id_agente'} = $agent->{'id_agente'};
3793
-
3794
+		
3795
 		my $module_tags = undef;
3796
 		if(defined ($module_conf->{'tags'})) {
3797
 			$module_tags = $module_conf->{'tags'};
3798
@@ -601,7 +608,7 @@
3799
 		
3800
 		# Create the module
3801
 		my $module_id = pandora_create_module_from_hash ($pa_config, $module_conf, $dbh);
3802
-
3803
+		
3804
 		$module = get_db_single_row ($dbh, 'SELECT * FROM tagente_modulo WHERE id_agente = ? AND ' . db_text('nombre') . ' = ?', $agent->{'id_agente'}, safe_input($module_name));
3805
 		if (! defined ($module)) {
3806
 			logger($pa_config, "Could not create module '$module_name' for agent '$agent_name'.", 3);
3807
@@ -626,7 +633,8 @@
3808
 			}
3809
 		}
3810
 		
3811
-	} else {
3812
+	}
3813
+	else {
3814
 		# Control NULL columns
3815
 		$module->{'descripcion'} = '' unless defined ($module->{'descripcion'});
3816
 		$module->{'extended_info'} = '' unless defined ($module->{'extended_info'});
3817
@@ -649,15 +657,15 @@
3818
 	if ($agent->{'modo'} eq '1' && $policy_linked == 0) {
3819
 		update_module_configuration ($pa_config, $dbh, $module, $module_conf);
3820
 	}
3821
-
3822
+	
3823
 	$ModuleSem->up ();
3824
-
3825
+	
3826
 	# Module disabled!
3827
 	if ($module->{'disabled'} eq '1') {
3828
 		logger($pa_config, "Skipping disabled module '$module_name' agent '$agent_name'.", 10);
3829
 		return;
3830
 	}
3831
-
3832
+	
3833
 	# Parse the timestamp and process the module
3834
 	if ($timestamp !~ /(\d+)\/(\d+)\/(\d+) +(\d+):(\d+):(\d+)/ &&
3835
 		$timestamp !~ /(\d+)\-(\d+)\-(\d+) +(\d+):(\d+):(\d+)/) {
3836
Index: bin/pandora_server
3837
===================================================================
3838
--- bin/pandora_server	(revision 10314)
3839
+++ bin/pandora_server	(working copy)
3840
@@ -47,11 +47,22 @@
3841
 my @Servers;
3842
 my $DBH;
3843
 my $RUN :shared = 1;
3844
+my $MainThread = threads->self;
3845
 
3846
 ########################################################################################
3847
 # Server shutdown. Handler to do a controlled shutdown.
3848
 ########################################################################################
3849
 sub pandora_shutdown () {
3850
+	my $signal = shift;
3851
+
3852
+	logger (\%Config, 'Pandora FMS Server \'' . $Config{'servername'} . '\' Caught SIG' . $signal . ' by thread(' . threads->self()->tid() . ')', 10);
3853
+
3854
+	if (!threads->self->equal($MainThread)) {
3855
+		# deliver signal to the main thread since no other threads than main thread
3856
+		# could disconnet $DBH properly
3857
+		$MainThread->kill($signal);
3858
+		return;
3859
+	}
3860
 	logger (\%Config, 'Pandora FMS Server \'' . $Config{'servername'} . '\' Shutdown by signal ', 1);
3861
 	
3862
 	# Stop servers
3863
Index: pandora_server.redhat.spec
3864
===================================================================
3865
--- pandora_server.redhat.spec	(revision 10314)
3866
+++ pandora_server.redhat.spec	(working copy)
3867
@@ -28,6 +28,7 @@
3868
 Requires:           perl-NetAddr-IP net-snmp net-tools
3869
 Requires:           perl-IO-Socket-INET6 perl-Socket6 perl-Net-Telnet
3870
 Requires:           nmap wmic sudo perl-JSON
3871
+Requires:           perl-Time-HiRes
3872
 
3873
 %description
3874
 Pandora FMS is a monitoring system for big IT environments. It uses remote tests, or local agents to grab information. Pandora supports all standard OS (Linux, AIX, HP-UX, Solaris and Windows XP,2000/2003), and support multiple setups in HA enviroments.
3875
Index: FreeBSD/pandora_server.conf.new
3876
===================================================================
3877
--- FreeBSD/pandora_server.conf.new	(revision 0)
3878
+++ FreeBSD/pandora_server.conf.new	(revision 10417)
3879
@@ -0,0 +1,442 @@
3880
+#############################################################################
3881
+# Pandora FMS Server Parameters
3882
+# Pandora FMS, the Flexible Monitoring System.
3883
+# Version 5.1BETA1
3884
+# Licensed under GPL license v2,
3885
+# (c) 2003-2014 Artica Soluciones Tecnologicas
3886
+# http://www.pandorafms.com
3887
+# Please change it for your setup needs
3888
+#############################################################################
3889
+
3890
+# Servername: Name of this server
3891
+# if not given, it takes hostname. It's preferable to setup one
3892
+# because machine name could change by some reason.
3893
+
3894
+#servername greystone
3895
+
3896
+# incomingdir:  Defines directory where incoming data packets are stored
3897
+# You could set directory relative to base path or absolute, starting with /
3898
+
3899
+incomingdir /var/spool/pandora/data_in
3900
+
3901
+# log_file: Main logfile for pandora_server
3902
+# You could set file relative to base path or absolute, starting with /
3903
+
3904
+log_file /var/log/pandora/pandora_server.log
3905
+
3906
+# Log file for Pandora FMS SNMP console. Its generated by NetSNMP Trap daemon
3907
+
3908
+snmp_logfile /var/log/pandora/pandora_snmptrap.log
3909
+
3910
+# Error logfile: aux logfile for pandora_server errors (in Daemon mode)
3911
+# You could set file relative to base path or absolute, starting with /
3912
+
3913
+errorlog_file /var/log/pandora/pandora_server.error
3914
+
3915
+# daemon: Runs in daemon mode (background) if 1, if 0 runs in foreground 
3916
+# this could be also configured on commandline with -D option
3917
+
3918
+# daemon 1
3919
+
3920
+# dbengine: mysql, postgresql or oracle (mysql by default)
3921
+
3922
+dbengine mysql
3923
+
3924
+# Database credentials. A VERY important configuration.
3925
+# This must be the same credentials used by your Pandora FMS Console
3926
+# but could be different if your console is not running in the same
3927
+# host than the server. Check your console setup in /include/config.php
3928
+
3929
+# dbname: Database name (pandora by default)
3930
+
3931
+dbname pandora
3932
+
3933
+# dbuser:  Database user name (pandora by default)
3934
+
3935
+dbuser pandora
3936
+
3937
+# dbpass: Database password
3938
+
3939
+dbpass pandora
3940
+
3941
+# dbhost: Database hostname or IP address
3942
+
3943
+dbhost 127.0.0.1
3944
+
3945
+# dbport: Database port number
3946
+# Default value depends on the dbengine (mysql: 3306, postgresql: 5432, oracle: 1521)
3947
+
3948
+#dbport 3306
3949
+
3950
+# By default, parent agent will not be updated
3951
+
3952
+#update_parent 0
3953
+
3954
+# verbosity: level of detail on errors/messages (0 default, 1 verbose, 2 debug.... 10 noisy)
3955
+# -v in command line (verbose) or -d (debug). Set this to 10 when try to locate problems and
3956
+# set to 0 or 1 on production enviroments.
3957
+
3958
+verbosity 1
3959
+
3960
+# Master Server, 1 if master server (normal mode), 0 for slave mode (slave in multi-server setup)
3961
+
3962
+master 1
3963
+
3964
+# Activate Pandora SNMP console (depending on snmptrapd)
3965
+
3966
+snmpconsole 0
3967
+
3968
+# snmptrapd will ignore authenticationFailure traps if set to 1.
3969
+
3970
+snmp_ignore_authfailure 1
3971
+
3972
+# snmptrapd will read the PDU source address instead of the agent-addr field is set to 1.
3973
+
3974
+snmp_pdu_address 0
3975
+
3976
+# Activate (1) Pandora Network Server 
3977
+
3978
+networkserver 1
3979
+
3980
+# Activate (1) Pandora Data Server
3981
+
3982
+dataserver 1
3983
+
3984
+# Activate (1) Pandora FMS Recon server
3985
+
3986
+reconserver 1
3987
+
3988
+# pluginserver : 1 or 0. Set to 1 to activate plugin server with this setup
3989
+
3990
+pluginserver 1 
3991
+
3992
+# Pandora FMS Plugin exec tool filepath (by default at /usr/local/bin)
3993
+
3994
+plugin_exec /usr/local/bin/gtimeout
3995
+
3996
+# predictionserver : 1 or 0. Set to 1 to activate prediction server with this setup
3997
+# DISABLED BY DEFAULT 
3998
+
3999
+predictionserver 0
4000
+
4001
+# wmiserver : 1 or 0. Set to 1 to activate WMI server with this setup
4002
+# DISABLED BY DEFAULT
4003
+
4004
+wmiserver 1
4005
+
4006
+# wmic: Needed by Pandora FMS wmi server.
4007
+
4008
+wmi_client /usr/local/bin/wmic
4009
+
4010
+# Network timeout (in seconds) for timeout in network connections for Network agents
4011
+
4012
+network_timeout 4
4013
+
4014
+# Server keepalive (in seconds)
4015
+
4016
+server_keepalive 45
4017
+
4018
+# Server Threshold: defines number of seconds of main loop (in sec)
4019
+
4020
+server_threshold 5
4021
+
4022
+# Network threads: Do not set too high (~40). Each threads make a network module check.
4023
+
4024
+network_threads 4
4025
+
4026
+# icmp_checks x : defines number of pings for each icmp_proc module type. at least one of 
4027
+# that ping should be 1 to report 1
4028
+
4029
+icmp_checks 1
4030
+
4031
+# tcp specific options :
4032
+# tcp_checks: number of tcp retries if first attempt fails.
4033
+# tcp_timeout: specific timeout for tcp connections
4034
+
4035
+tcp_checks 1
4036
+tcp_timeout 10
4037
+
4038
+# snmp specific options :
4039
+# snmp_checks: number of snmp request retries if first attempt fails.
4040
+# snmp_timeout: specific timeout for snmp request.
4041
+
4042
+snmp_checks 1
4043
+snmp_timeout 4
4044
+
4045
+# snmp_proc_deadresponse 1 (default): Return DOWN if cannot contact 
4046
+# or receive NULL from a SNMP PROC module.
4047
+
4048
+snmp_proc_deadresponse 1
4049
+
4050
+# plugin_threads: Specify number of plugin server threads for processing plugin calls
4051
+
4052
+plugin_threads 1
4053
+
4054
+# plugin_timeout: Specify number of seconds calling plugin exec waiting for response
4055
+# after this time, call is aborted and result is "unknown".
4056
+
4057
+plugin_timeout 12
4058
+
4059
+# wmi_timeout : specific timeout for wmi request.
4060
+
4061
+wmi_timeout 7
4062
+
4063
+# wmi_threads: Specify number of WMI server threads for processing WMI remote calls
4064
+
4065
+wmi_threads 1
4066
+
4067
+# recon_threads. Each thread will scan a different scantask.
4068
+
4069
+recon_threads 1
4070
+
4071
+# dataserver_threads: Number of threads for data server (XML processing threads)
4072
+
4073
+dataserver_threads 1
4074
+
4075
+# mta_address: External Mailer (MTA) IP Address to be used by Pandora FMS internal email capabilities
4076
+
4077
+mta_address localhost
4078
+
4079
+# mta_port, this is the mail server port (default 25)
4080
+
4081
+#mta_port 25
4082
+
4083
+# mta_user MTA User (if needed for auth, FQD or simple user, depending on your server)
4084
+
4085
+#mta_user myuser@mydomain.com
4086
+
4087
+# mta_pass MTA Pass (if needed for auth)
4088
+
4089
+#mta_pass mypassword
4090
+
4091
+# mta_auth MTA Auth system (if needed, it supports LOGIN, PLAIN, CRAM-MD5, DIGEST-MD)
4092
+
4093
+#mta_auth LOGIN
4094
+
4095
+# mta_from Email address that sends the mail, by default is pandora@localhost 
4096
+#           probably you need to change it to avoid problems with your antispam
4097
+
4098
+#mta_from Pandora FMS <pandora@mydomain.com>
4099
+
4100
+# Set 1 if want eMail deliver alert in separate mail  (default). 
4101
+# Set 0 if want eMail deliver shared mail by all destination.
4102
+mail_in_separate 1
4103
+
4104
+
4105
+# xprobe2: Optional package to detect OS types using advanced TCP/IP 
4106
+# fingerprinting tecniques, much more accurates than stadard nmap.
4107
+# If not provided, nmap is used insted xprobe2
4108
+
4109
+xprobe2 /usr/local/bin/xprobe2
4110
+
4111
+# nmap: If provided, is used to detect OS type with recon server using 
4112
+# advanded OS fingerprint technique. Xprobe2 gives more accurate results
4113
+# Nmap is also used to do TCP port scanning in detected host.
4114
+
4115
+nmap /usr/local/bin/nmap
4116
+
4117
+# snmpget: Needed to do SNMP checks. By default is on /usr/local/bin/snmpget
4118
+
4119
+snmpget /usr/local/bin/snmpget
4120
+
4121
+# snmp_trapd: Needed by Pandora FMS SNMP console.
4122
+
4123
+snmp_trapd /usr/local/sbin/snmptrapd
4124
+
4125
+# Location of the braa binary needed by the Enterprise SNMP Server (/usr/local/bin/braa by default) (PANDORA FMS ENTERPRISE ONLY).
4126
+
4127
+braa /usr/local/bin/braa
4128
+
4129
+# Number of retries before braa hands a module over to the Network Server (PANDORA FMS ENTERPRISE ONLY).
4130
+
4131
+braa_retries 3
4132
+
4133
+# Default group id for new agents created with Pandora FMS Data Server
4134
+
4135
+autocreate_group 2
4136
+
4137
+# Set to 1 if want to autocreate agents with Pandora FMS Data Server, 
4138
+# set to 0 to disable (for security purposes, for example).
4139
+
4140
+autocreate 1
4141
+
4142
+# max_log_size: Specify max size of Pandora FMS server log file (1MB by default). If
4143
+# log file grows above this limit, is renamed to "pandora_server.log.old".
4144
+
4145
+max_log_size 65536
4146
+
4147
+# max_queue_files (500 by default)
4148
+# When server have more than max_queue_files in incoming directory, skips the read   
4149
+# the directory to avoid filesystem overhead.
4150
+
4151
+max_queue_files 500
4152
+
4153
+# Use the XML file last modification time as timestamp.
4154
+# use_xml_timestamp 1
4155
+
4156
+# Pandora FMS will autorestart itself each XXX seconds, use this if you experience problems with 
4157
+# shutting down threads, or other stability problems.
4158
+
4159
+# auto_restart 86400
4160
+
4161
+# Pandora FMS will restart after restart_delay seconds on critical errors.
4162
+
4163
+restart 1
4164
+restart_delay 60
4165
+
4166
+# More information about GIS Setup in /usr/share/pandora_server/util/gis.README
4167
+# Flag to activate GIS (positional information for agents and maps) 
4168
+# by default it is desactivated
4169
+
4170
+#activate_gis 0
4171
+
4172
+# Radius of error in meters to consider two gis locations as the same location.
4173
+
4174
+#location_error 50
4175
+
4176
+# Recon reverse geolocation mode [disabled, sql, file]
4177
+#   disabled    The recon task doesn't try to geolocate the ip discovered.
4178
+#   sql         The recon task trys to query the SQL database to geolocate the 
4179
+#               ip discovered
4180
+#   file        The recon task trys to find the geolocation information of the 
4181
+#               ip discovered in the file indicated in the 
4182
+#                recon_reverse_geolocation_file parameter 
4183
+
4184
+# recon_reverse_geolocation_mode disabled
4185
+
4186
+# Recon reverse geolocation file. This is the database with the reverse 
4187
+# geolocation information using MaxMind GPL GeoLiteCity.dat format).
4188
+
4189
+#recon_reverse_geolocation_file /usr/local/share/GeoIP/GeoIPCity.dat
4190
+
4191
+# Radius (in meters) of the circle in where the agents will be place randomly 
4192
+# when finded by a recon task. Center of the circle is guessed 
4193
+# by geolocating the IP.
4194
+#recon_location_scatter_radius 1000
4195
+
4196
+# Pandora Server self-monitoring (embedded agent) (by default enabled)
4197
+
4198
+self_monitoring 1
4199
+
4200
+# Update parent from the agent xml
4201
+
4202
+#update_parent 1
4203
+#
4204
+#
4205
+# This enable realtime reverse geocoding using Google Maps public api.
4206
+# This requires internet access, and could have performance penalties processing GIS
4207
+# information due the connetion needed to resolve all GIS input.
4208
+# NOTE: If you dont pay the service to google, they will ban your IP in a few days.
4209
+
4210
+# google_maps_description 1
4211
+
4212
+# This enable realtime reverse geocoding using Openstreet Maps public api.
4213
+# This requires internet access, and could have performance penalties processing GIS
4214
+# information due the connetion needed to resolve all GIS input.
4215
+# You can alter the code to use a local (your own) openstreet maps server.
4216
+
4217
+# openstreetmaps_description 1
4218
+
4219
+# Enable (1) or disable (0) Pandora FMS Event Web Server (PANDORA FMS ENTERPRISE ONLY).
4220
+
4221
+webserver 1
4222
+
4223
+# Number of threads for the Web Server (PANDORA FMS ENTERPRISE ONLY).
4224
+
4225
+web_threads 1
4226
+
4227
+# Enable (1) or disable (0) Pandora FMS Inventory Server (PANDORA FMS ENTERPRISE ONLY).
4228
+
4229
+inventoryserver 1
4230
+
4231
+# Number of threads for the Web Server (PANDORA FMS ENTERPRISE ONLY).
4232
+
4233
+inventory_threads 1
4234
+
4235
+# Enable (1) or disable (0) Pandora FMS Export Server (PANDORA FMS ENTERPRISE ONLY).
4236
+
4237
+exportserver 0
4238
+
4239
+# Number of threads for the Export Server (PANDORA FMS ENTERPRISE ONLY).
4240
+
4241
+export_threads 1
4242
+
4243
+# Enable (1) or disable (0) Pandora FMS Event Server (PANDORA FMS ENTERPRISE ONLY).
4244
+
4245
+eventserver 0
4246
+
4247
+# Event Server event window in seconds (3600 by default) (PANDORA FMS ENTERPRISE ONLY).
4248
+
4249
+event_window 3600
4250
+
4251
+# Enable (1) or disable (0) Pandora FMS Enterprise ICMP Server (PANDORA FMS ENTERPRISE ONLY).
4252
+# You need nmap 5.20 or higher in order to use this !
4253
+
4254
+icmpserver 1
4255
+
4256
+# Number of threads for the Enterprise ICMP Server (PANDORA FMS ENTERPRISE ONLY).
4257
+
4258
+icmp_threads 1
4259
+
4260
+# Enable (1) or disable (0) Pandora FMS Enterprise SNMP Server (PANDORA FMS ENTERPRISE ONLY).
4261
+# Check braa tool is running and operative.
4262
+
4263
+snmpserver 1
4264
+
4265
+# Number of threads for the Enterprise SNMP Server (PANDORA FMS ENTERPRISE ONLY).
4266
+
4267
+snmp_threads 1
4268
+
4269
+# Block size for block producer/consumer servers, that is, the number of modules
4270
+# per block (20 by default) (PANDORA FMS ENTERPRISE ONLY).
4271
+
4272
+block_size 20
4273
+
4274
+# Path to the netflow daemon nfcapd.
4275
+
4276
+netflow_daemon /usr/local/bin/nfcapd
4277
+
4278
+# If set to 1, process XML data files in a stack instead of a queue. 0 by default.
4279
+# WARNING: Incremental modules will not work properly if dataserver_lifo is set to 1!!!
4280
+
4281
+dataserver_lifo 0
4282
+
4283
+# If set to 1, the policy manager is enabled and the server is listening the policy queue. 
4284
+# 0 by default (PANDORA FMS ENTERPRISE ONLY) 
4285
+
4286
+policy_manager 1
4287
+
4288
+# If set to 1, the event replicate process is enabled. 0 by default. (PANDORA FMS ENTERPRISE ONLY) 
4289
+# WARNING: This process doesn't do anything if is not properly configured from the console setup 
4290
+
4291
+event_replication 0
4292
+
4293
+# If set to 1, new events validate older event for the same module. This will
4294
+# affect the performance of the server. This was the "normal behaviour" on previous (4.x) versions.
4295
+# disable only if you really know what you are doing !!.
4296
+
4297
+event_auto_validation 1
4298
+
4299
+# If defined, events generated by Pandora FMS will be written to the specified text file.
4300
+#event_file /var/log/pandora/pandora_events.txt
4301
+
4302
+# Set the maximum number of traps that will be processed from a single source in a
4303
+# configured time interval.
4304
+snmp_storm_protection 25
4305
+
4306
+# Time interval for snmp_storm protection (in seconds).
4307
+snmp_storm_timeout 10
4308
+
4309
+# Default texts for some events. The macros _module_ and _data_ are supported.
4310
+#text_going_down_normal Module '_module_' is going to NORMAL (_data_)
4311
+#text_going_up_critical Module '_module_' is going to CRITICAL (_data_)
4312
+#text_going_up_warning Module '_module_' is going to WARNING (_data_)
4313
+#text_going_down_warning Module '_module_' is going to WARNING (_data_)
4314
+#text_going_unknown Module '_module_' is going to UNKNOWN
4315
+
4316
+# Events older that the specified time (in seconds) will be auto-validated. Set to 0 to disable this feature.
4317
+event_expiry_time 0
4318
+
4319
+# Only events more recent than the specified time window (in seconds) will be auto-validated. This value must
4320
+# be greater than event_expiry_time.
4321
+#event_expiry_window 86400
4322
Index: FreeBSD/tentacle_server
4323
===================================================================
4324
--- FreeBSD/tentacle_server	(revision 10314)
4325
+++ FreeBSD/tentacle_server	(working copy)
4326
@@ -18,28 +18,27 @@
4327
 . "/etc/rc.subr"
4328
 
4329
 name="tentacle_server"
4330
-rcvar=`set_rcvar`
4331
+rcvar=tentacle_server_enable
4332
 
4333
 # read configuration and set defaults
4334
 tentacle_server_enable=${tentacle_server_enable:-"NO"}
4335
-tentacle_server_flags=${tentacle_server_flags:-"-a 0.0.0.0 -p 41121 -s /var/spool/pandora/data_in -i.*\.conf:conf\;.*\.md5:md5\;.*\.zip:collections -d"}
4336
+tentacle_server_flags=${tentacle_server_flags:-'-a 0.0.0.0 -p 41121 -s /var/spool/pandora/data_in -i.*\.conf:conf\;.*\.md5:md5\;.*\.zip:collections -d'}
4337
 tentacle_server_user=${tentacle_server_user:-"pandora"}
4338
 load_rc_config $name
4339
 
4340
 PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin
4341
 
4342
 command=/usr/local/bin/${name}
4343
+command_interpreter=/usr/local/bin/perl
4344
+procname=$command
4345
+pidfile=/var/run/$name.pid
4346
 
4347
-pidfile=/var/run/$name.pid
4348
 start_postcmd=start_postcmd
4349
 stop_postcmd=stop_postcmd
4350
 
4351
-procname="/usr/bin/perl"
4352
-
4353
 start_postcmd()
4354
 {
4355
-	TENTACLE_PID=`pgrep -f -j none "$procname $command"`
4356
-	echo $TENTACLE_PID > $pidfile
4357
+	pgrep -f -j none "^$command_interpreter $command" > $pidfile
4358
 }
4359
 
4360
 stop_postcmd()
4361
Index: FreeBSD/pandora_server
4362
===================================================================
4363
--- FreeBSD/pandora_server	(revision 10314)
4364
+++ FreeBSD/pandora_server	(working copy)
4365
@@ -3,6 +3,7 @@
4366
 # **********************************************************************
4367
 # Pandora FMS Server Daemon launcher for FreeBSD
4368
 # (c) 2010 Junichi Satoh <junichi@rworks.jp>
4369
+# (c) 2014 Koichiro Kikuchi <koichiro@rworks.jp>
4370
 #
4371
 # **********************************************************************
4372
 
4373
@@ -10,27 +11,65 @@
4374
 # REQUIRE: LOGIN mysql
4375
 # KEYWORD: shutdown
4376
 
4377
-# Add the following line to /etc/rc.conf to enable `pandora_server':
4378
+# Add the following lines to /etc/rc.conf to enable pandora_server:
4379
+# pandora_server_enable (bool):  Set to "YES" to enable pandora_server (default: NO)
4380
+# pandora_server_profiles (str): Define your profiles here (default: "")
4381
 #
4382
-# pandora_server_enable="YES"
4383
-#
4384
 
4385
 . "/etc/rc.subr"
4386
 
4387
+PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin
4388
+
4389
 name="pandora_server"
4390
-rcvar=`set_rcvar`
4391
+rcvar=pandora_server_enable
4392
 
4393
-# read configuration and set defaults
4394
-pandora_server_enable=${pandora_server_enable:-"NO"}
4395
+: ${pandora_server_enable:=NO}
4396
+: ${pandora_server_configfile:=/usr/local/etc/pandora/pandora_server.conf}
4397
+
4398
+command=/usr/local/bin/${name}
4399
+command_args="-D"
4400
+command_interpreter=/usr/local/bin/perl
4401
+_pidprefix=/var/run/$name
4402
+pidfile=${_pidprefix}.pid
4403
+required_files="$pandora_server_configfile"
4404
+
4405
 load_rc_config $name
4406
 
4407
-PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin
4408
+if [ "$2" ]; then
4409
+	profile="$2"
4410
+	if [ "$pandora_server_profiles" ]; then
4411
+		pidfile="${_pidprefix}.${profile}.pid"
4412
+		eval pandora_server_configfile="\${pandora_server_${profile}_configfile:-}"
4413
+		if [ -z "$pandora_server_configfile" ]; then
4414
+			echo "You must define a configuration file (pandora_server_${profile}_configfile)"
4415
+			exit 1
4416
+		fi
4417
+		required_files="$pandora_server_configfile"
4418
+		eval pandora_server_enable="\${pandora_server_${profile}_enable:-$pandora_server_enable}"
4419
+		eval pandora_server_flags="\${pandora_server_${profile}_flags:-$pandora_server_flags}"
4420
+		eval pidfile="\${pandora_server_${profile}_pidfile:-$pidfile}"
4421
+	else
4422
+		echo "$0: extra argument ignored"
4423
+	fi
4424
+elif [ "${pandora_server_profiles}" ] && [ "$1" ]; then
4425
+	for profile in ${pandora_server_profiles}; do
4426
+		eval _enable="\${pandora_server_${profile}_enable}"
4427
+		case "${_enable:-${pandora_server_enable}}" in
4428
+		[Yy][Ee][Ss]);;
4429
+		*) continue;;
4430
+		esac
4431
+		echo "===> pandora_server profile: ${profile}"
4432
+		/usr/local/etc/rc.d/pandora_server $1 ${profile}
4433
+		retcode="$?"
4434
+		if [ "0${retcode}" -ne 0 ]; then
4435
+			failed="${profile} (${retcode}) ${failed:-}"
4436
+		else
4437
+			success="${profile} ${success:-}"
4438
+		fi
4439
+	done
4440
+	exit 0
4441
+fi
4442
 
4443
-pidfile=/var/run/$name.pid
4444
-command=/usr/local/bin/${name}
4445
-command_args="-D -P ${pidfile} /usr/local/etc/pandora/pandora_server.conf"
4446
-required_files="/usr/local/etc/pandora/pandora_server.conf"
4447
+pandora_server_flags="$pandora_server_flags -P $pidfile $pandora_server_configfile"
4448
 
4449
-procname="/usr/local/bin/perl"
4450
-
4451
 run_rc_command "$1"
4452
Index: FreeBSD/pandora_server.conf
4453
===================================================================
4454
--- FreeBSD/pandora_server.conf	(revision 10314)
4455
+++ FreeBSD/pandora_server.conf	(working copy)
4456
@@ -1,442 +0,0 @@
4457
-#############################################################################
4458
-# Pandora FMS Server Parameters
4459
-# Pandora FMS, the Flexible Monitoring System.
4460
-# Version 5.1BETA1
4461
-# Licensed under GPL license v2,
4462
-# (c) 2003-2014 Artica Soluciones Tecnologicas
4463
-# http://www.pandorafms.com
4464
-# Please change it for your setup needs
4465
-#############################################################################
4466
-
4467
-# Servername: Name of this server
4468
-# if not given, it takes hostname. It's preferable to setup one
4469
-# because machine name could change by some reason.
4470
-
4471
-#servername greystone
4472
-
4473
-# incomingdir:  Defines directory where incoming data packets are stored
4474
-# You could set directory relative to base path or absolute, starting with /
4475
-
4476
-incomingdir /var/spool/pandora/data_in
4477
-
4478
-# log_file: Main logfile for pandora_server
4479
-# You could set file relative to base path or absolute, starting with /
4480
-
4481
-log_file /var/log/pandora/pandora_server.log
4482
-
4483
-# Log file for Pandora FMS SNMP console. Its generated by NetSNMP Trap daemon
4484
-
4485
-snmp_logfile /var/log/pandora/pandora_snmptrap.log
4486
-
4487
-# Error logfile: aux logfile for pandora_server errors (in Daemon mode)
4488
-# You could set file relative to base path or absolute, starting with /
4489
-
4490
-errorlog_file /var/log/pandora/pandora_server.error
4491
-
4492
-# daemon: Runs in daemon mode (background) if 1, if 0 runs in foreground 
4493
-# this could be also configured on commandline with -D option
4494
-
4495
-# daemon 1
4496
-
4497
-# dbengine: mysql, postgresql or oracle (mysql by default)
4498
-
4499
-dbengine mysql
4500
-
4501
-# Database credentials. A VERY important configuration.
4502
-# This must be the same credentials used by your Pandora FMS Console
4503
-# but could be different if your console is not running in the same
4504
-# host than the server. Check your console setup in /include/config.php
4505
-
4506
-# dbname: Database name (pandora by default)
4507
-
4508
-dbname pandora
4509
-
4510
-# dbuser:  Database user name (pandora by default)
4511
-
4512
-dbuser pandora
4513
-
4514
-# dbpass: Database password
4515
-
4516
-dbpass pandora
4517
-
4518
-# dbhost: Database hostname or IP address
4519
-
4520
-dbhost 127.0.0.1
4521
-
4522
-# dbport: Database port number
4523
-# Default value depends on the dbengine (mysql: 3306, postgresql: 5432, oracle: 1521)
4524
-
4525
-#dbport 3306
4526
-
4527
-# By default, parent agent will not be updated
4528
-
4529
-#update_parent 0
4530
-
4531
-# verbosity: level of detail on errors/messages (0 default, 1 verbose, 2 debug.... 10 noisy)
4532
-# -v in command line (verbose) or -d (debug). Set this to 10 when try to locate problems and
4533
-# set to 0 or 1 on production enviroments.
4534
-
4535
-verbosity 1
4536
-
4537
-# Master Server, 1 if master server (normal mode), 0 for slave mode (slave in multi-server setup)
4538
-
4539
-master 1
4540
-
4541
-# Activate Pandora SNMP console (depending on snmptrapd)
4542
-
4543
-snmpconsole 0
4544
-
4545
-# snmptrapd will ignore authenticationFailure traps if set to 1.
4546
-
4547
-snmp_ignore_authfailure 1
4548
-
4549
-# snmptrapd will read the PDU source address instead of the agent-addr field is set to 1.
4550
-
4551
-snmp_pdu_address 0
4552
-
4553
-# Activate (1) Pandora Network Server 
4554
-
4555
-networkserver 1
4556
-
4557
-# Activate (1) Pandora Data Server
4558
-
4559
-dataserver 1
4560
-
4561
-# Activate (1) Pandora FMS Recon server
4562
-
4563
-reconserver 1
4564
-
4565
-# pluginserver : 1 or 0. Set to 1 to activate plugin server with this setup
4566
-
4567
-pluginserver 1 
4568
-
4569
-# Pandora FMS Plugin exec tool filepath (by default at /usr/local/bin)
4570
-
4571
-plugin_exec /usr/local/bin/gtimeout
4572
-
4573
-# predictionserver : 1 or 0. Set to 1 to activate prediction server with this setup
4574
-# DISABLED BY DEFAULT 
4575
-
4576
-predictionserver 0
4577
-
4578
-# wmiserver : 1 or 0. Set to 1 to activate WMI server with this setup
4579
-# DISABLED BY DEFAULT
4580
-
4581
-wmiserver 1
4582
-
4583
-# wmic: Needed by Pandora FMS wmi server.
4584
-
4585
-wmi_client /usr/local/bin/wmic
4586
-
4587
-# Network timeout (in seconds) for timeout in network connections for Network agents
4588
-
4589
-network_timeout 4
4590
-
4591
-# Server keepalive (in seconds)
4592
-
4593
-server_keepalive 45
4594
-
4595
-# Server Threshold: defines number of seconds of main loop (in sec)
4596
-
4597
-server_threshold 5
4598
-
4599
-# Network threads: Do not set too high (~40). Each threads make a network module check.
4600
-
4601
-network_threads 4
4602
-
4603
-# icmp_checks x : defines number of pings for each icmp_proc module type. at least one of 
4604
-# that ping should be 1 to report 1
4605
-
4606
-icmp_checks 1
4607
-
4608
-# tcp specific options :
4609
-# tcp_checks: number of tcp retries if first attempt fails.
4610
-# tcp_timeout: specific timeout for tcp connections
4611
-
4612
-tcp_checks 1
4613
-tcp_timeout 10
4614
-
4615
-# snmp specific options :
4616
-# snmp_checks: number of snmp request retries if first attempt fails.
4617
-# snmp_timeout: specific timeout for snmp request.
4618
-
4619
-snmp_checks 1
4620
-snmp_timeout 4
4621
-
4622
-# snmp_proc_deadresponse 1 (default): Return DOWN if cannot contact 
4623
-# or receive NULL from a SNMP PROC module.
4624
-
4625
-snmp_proc_deadresponse 1
4626
-
4627
-# plugin_threads: Specify number of plugin server threads for processing plugin calls
4628
-
4629
-plugin_threads 1
4630
-
4631
-# plugin_timeout: Specify number of seconds calling plugin exec waiting for response
4632
-# after this time, call is aborted and result is "unknown".
4633
-
4634
-plugin_timeout 12
4635
-
4636
-# wmi_timeout : specific timeout for wmi request.
4637
-
4638
-wmi_timeout 7
4639
-
4640
-# wmi_threads: Specify number of WMI server threads for processing WMI remote calls
4641
-
4642
-wmi_threads 1
4643
-
4644
-# recon_threads. Each thread will scan a different scantask.
4645
-
4646
-recon_threads 1
4647
-
4648
-# dataserver_threads: Number of threads for data server (XML processing threads)
4649
-
4650
-dataserver_threads 1
4651
-
4652
-# mta_address: External Mailer (MTA) IP Address to be used by Pandora FMS internal email capabilities
4653
-
4654
-mta_address localhost
4655
-
4656
-# mta_port, this is the mail server port (default 25)
4657
-
4658
-#mta_port 25
4659
-
4660
-# mta_user MTA User (if needed for auth, FQD or simple user, depending on your server)
4661
-
4662
-#mta_user myuser@mydomain.com
4663
-
4664
-# mta_pass MTA Pass (if needed for auth)
4665
-
4666
-#mta_pass mypassword
4667
-
4668
-# mta_auth MTA Auth system (if needed, it supports LOGIN, PLAIN, CRAM-MD5, DIGEST-MD)
4669
-
4670
-#mta_auth LOGIN
4671
-
4672
-# mta_from Email address that sends the mail, by default is pandora@localhost 
4673
-#           probably you need to change it to avoid problems with your antispam
4674
-
4675
-#mta_from Pandora FMS <pandora@mydomain.com>
4676
-
4677
-# Set 1 if want eMail deliver alert in separate mail  (default). 
4678
-# Set 0 if want eMail deliver shared mail by all destination.
4679
-mail_in_separate 1
4680
-
4681
-
4682
-# xprobe2: Optional package to detect OS types using advanced TCP/IP 
4683
-# fingerprinting tecniques, much more accurates than stadard nmap.
4684
-# If not provided, nmap is used insted xprobe2
4685
-
4686
-xprobe2 /usr/local/bin/xprobe2
4687
-
4688
-# nmap: If provided, is used to detect OS type with recon server using 
4689
-# advanded OS fingerprint technique. Xprobe2 gives more accurate results
4690
-# Nmap is also used to do TCP port scanning in detected host.
4691
-
4692
-nmap /usr/local/bin/nmap
4693
-
4694
-# snmpget: Needed to do SNMP checks. By default is on /usr/local/bin/snmpget
4695
-
4696
-snmpget /usr/local/bin/snmpget
4697
-
4698
-# snmp_trapd: Needed by Pandora FMS SNMP console.
4699
-
4700
-snmp_trapd /usr/local/sbin/snmptrapd
4701
-
4702
-# Location of the braa binary needed by the Enterprise SNMP Server (/usr/local/bin/braa by default) (PANDORA FMS ENTERPRISE ONLY).
4703
-
4704
-braa /usr/local/bin/braa
4705
-
4706
-# Number of retries before braa hands a module over to the Network Server (PANDORA FMS ENTERPRISE ONLY).
4707
-
4708
-braa_retries 3
4709
-
4710
-# Default group id for new agents created with Pandora FMS Data Server
4711
-
4712
-autocreate_group 2
4713
-
4714
-# Set to 1 if want to autocreate agents with Pandora FMS Data Server, 
4715
-# set to 0 to disable (for security purposes, for example).
4716
-
4717
-autocreate 1
4718
-
4719
-# max_log_size: Specify max size of Pandora FMS server log file (1MB by default). If
4720
-# log file grows above this limit, is renamed to "pandora_server.log.old".
4721
-
4722
-max_log_size 65536
4723
-
4724
-# max_queue_files (500 by default)
4725
-# When server have more than max_queue_files in incoming directory, skips the read   
4726
-# the directory to avoid filesystem overhead.
4727
-
4728
-max_queue_files 500
4729
-
4730
-# Use the XML file last modification time as timestamp.
4731
-# use_xml_timestamp 1
4732
-
4733
-# Pandora FMS will autorestart itself each XXX seconds, use this if you experience problems with 
4734
-# shutting down threads, or other stability problems.
4735
-
4736
-# auto_restart 86400
4737
-
4738
-# Pandora FMS will restart after restart_delay seconds on critical errors.
4739
-
4740
-restart 1
4741
-restart_delay 60
4742
-
4743
-# More information about GIS Setup in /usr/share/pandora_server/util/gis.README
4744
-# Flag to activate GIS (positional information for agents and maps) 
4745
-# by default it is desactivated
4746
-
4747
-#activate_gis 0
4748
-
4749
-# Radius of error in meters to consider two gis locations as the same location.
4750
-
4751
-#location_error 50
4752
-
4753
-# Recon reverse geolocation mode [disabled, sql, file]
4754
-#   disabled    The recon task doesn't try to geolocate the ip discovered.
4755
-#   sql         The recon task trys to query the SQL database to geolocate the 
4756
-#               ip discovered
4757
-#   file        The recon task trys to find the geolocation information of the 
4758
-#               ip discovered in the file indicated in the 
4759
-#                recon_reverse_geolocation_file parameter 
4760
-
4761
-# recon_reverse_geolocation_mode disabled
4762
-
4763
-# Recon reverse geolocation file. This is the database with the reverse 
4764
-# geolocation information using MaxMind GPL GeoLiteCity.dat format).
4765
-
4766
-#recon_reverse_geolocation_file /usr/local/share/GeoIP/GeoIPCity.dat
4767
-
4768
-# Radius (in meters) of the circle in where the agents will be place randomly 
4769
-# when finded by a recon task. Center of the circle is guessed 
4770
-# by geolocating the IP.
4771
-#recon_location_scatter_radius 1000
4772
-
4773
-# Pandora Server self-monitoring (embedded agent) (by default enabled)
4774
-
4775
-self_monitoring 1
4776
-
4777
-# Update parent from the agent xml
4778
-
4779
-#update_parent 1
4780
-#
4781
-#
4782
-# This enable realtime reverse geocoding using Google Maps public api.
4783
-# This requires internet access, and could have performance penalties processing GIS
4784
-# information due the connetion needed to resolve all GIS input.
4785
-# NOTE: If you dont pay the service to google, they will ban your IP in a few days.
4786
-
4787
-# google_maps_description 1
4788
-
4789
-# This enable realtime reverse geocoding using Openstreet Maps public api.
4790
-# This requires internet access, and could have performance penalties processing GIS
4791
-# information due the connetion needed to resolve all GIS input.
4792
-# You can alter the code to use a local (your own) openstreet maps server.
4793
-
4794
-# openstreetmaps_description 1
4795
-
4796
-# Enable (1) or disable (0) Pandora FMS Event Web Server (PANDORA FMS ENTERPRISE ONLY).
4797
-
4798
-webserver 1
4799
-
4800
-# Number of threads for the Web Server (PANDORA FMS ENTERPRISE ONLY).
4801
-
4802
-web_threads 1
4803
-
4804
-# Enable (1) or disable (0) Pandora FMS Inventory Server (PANDORA FMS ENTERPRISE ONLY).
4805
-
4806
-inventoryserver 1
4807
-
4808
-# Number of threads for the Web Server (PANDORA FMS ENTERPRISE ONLY).
4809
-
4810
-inventory_threads 1
4811
-
4812
-# Enable (1) or disable (0) Pandora FMS Export Server (PANDORA FMS ENTERPRISE ONLY).
4813
-
4814
-exportserver 0
4815
-
4816
-# Number of threads for the Export Server (PANDORA FMS ENTERPRISE ONLY).
4817
-
4818
-export_threads 1
4819
-
4820
-# Enable (1) or disable (0) Pandora FMS Event Server (PANDORA FMS ENTERPRISE ONLY).
4821
-
4822
-eventserver 0
4823
-
4824
-# Event Server event window in seconds (3600 by default) (PANDORA FMS ENTERPRISE ONLY).
4825
-
4826
-event_window 3600
4827
-
4828
-# Enable (1) or disable (0) Pandora FMS Enterprise ICMP Server (PANDORA FMS ENTERPRISE ONLY).
4829
-# You need nmap 5.20 or higher in order to use this !
4830
-
4831
-icmpserver 1
4832
-
4833
-# Number of threads for the Enterprise ICMP Server (PANDORA FMS ENTERPRISE ONLY).
4834
-
4835
-icmp_threads 1
4836
-
4837
-# Enable (1) or disable (0) Pandora FMS Enterprise SNMP Server (PANDORA FMS ENTERPRISE ONLY).
4838
-# Check braa tool is running and operative.
4839
-
4840
-snmpserver 1
4841
-
4842
-# Number of threads for the Enterprise SNMP Server (PANDORA FMS ENTERPRISE ONLY).
4843
-
4844
-snmp_threads 1
4845
-
4846
-# Block size for block producer/consumer servers, that is, the number of modules
4847
-# per block (20 by default) (PANDORA FMS ENTERPRISE ONLY).
4848
-
4849
-block_size 20
4850
-
4851
-# Path to the netflow daemon nfcapd.
4852
-
4853
-netflow_daemon /usr/local/bin/nfcapd
4854
-
4855
-# If set to 1, process XML data files in a stack instead of a queue. 0 by default.
4856
-# WARNING: Incremental modules will not work properly if dataserver_lifo is set to 1!!!
4857
-
4858
-dataserver_lifo 0
4859
-
4860
-# If set to 1, the policy manager is enabled and the server is listening the policy queue. 
4861
-# 0 by default (PANDORA FMS ENTERPRISE ONLY) 
4862
-
4863
-policy_manager 1
4864
-
4865
-# If set to 1, the event replicate process is enabled. 0 by default. (PANDORA FMS ENTERPRISE ONLY) 
4866
-# WARNING: This process doesn't do anything if is not properly configured from the console setup 
4867
-
4868
-event_replication 0
4869
-
4870
-# If set to 1, new events validate older event for the same module. This will
4871
-# affect the performance of the server. This was the "normal behaviour" on previous (4.x) versions.
4872
-# disable only if you really know what you are doing !!.
4873
-
4874
-event_auto_validation 1
4875
-
4876
-# If defined, events generated by Pandora FMS will be written to the specified text file.
4877
-#event_file /var/log/pandora/pandora_events.txt
4878
-
4879
-# Set the maximum number of traps that will be processed from a single source in a
4880
-# configured time interval.
4881
-snmp_storm_protection 25
4882
-
4883
-# Time interval for snmp_storm protection (in seconds).
4884
-snmp_storm_timeout 10
4885
-
4886
-# Default texts for some events. The macros _module_ and _data_ are supported.
4887
-#text_going_down_normal Module '_module_' is going to NORMAL (_data_)
4888
-#text_going_up_critical Module '_module_' is going to CRITICAL (_data_)
4889
-#text_going_up_warning Module '_module_' is going to WARNING (_data_)
4890
-#text_going_down_warning Module '_module_' is going to WARNING (_data_)
4891
-#text_going_unknown Module '_module_' is going to UNKNOWN
4892
-
4893
-# Events older that the specified time (in seconds) will be auto-validated. Set to 0 to disable this feature.
4894
-event_expiry_time 0
4895
-
4896
-# Only events more recent than the specified time window (in seconds) will be auto-validated. This value must
4897
-# be greater than event_expiry_time.
4898
-#event_expiry_window 86400
4899
Index: util/trap_rate.sh
4900
===================================================================
4901
--- util/trap_rate.sh	(revision 0)
4902
+++ util/trap_rate.sh	(revision 10417)
4903
@@ -0,0 +1,49 @@
4904
+#!/bin/bash
4905
+# Calculate the rate of SNMP traps received by snmptrapd.
4906
+TEMP_FILE="/tmp/trap_rate.tmp"
4907
+COUNT="100"
4908
+
4909
+# Parse command line arguments
4910
+if [ "$1" == "" ]; then
4911
+	echo "Usage: $0 <path to pandora_server.conf> [trap count]"
4912
+	exit 1
4913
+fi
4914
+
4915
+if [ "$2" != "" ]; then
4916
+        COUNT="$2"
4917
+fi
4918
+
4919
+# Read the SNMP log file and generate the temporary file
4920
+SNMP_LOG=`grep snmp_logfile $1 | cut -d' ' -f2`
4921
+if [ ! -f "$SNMP_LOG" ]; then
4922
+	echo "SNMP log file $SNMP_LOG does not exists or is not readable."
4923
+	exit 1
4924
+fi
4925
+grep "SNMPv" "$SNMP_LOG" | tail -$COUNT | cut -d']' -f 3 | cut -d'[' -f 1 > "$TEMP_FILE"
4926
+
4927
+# Get the newest trap
4928
+START=`head -1 "$TEMP_FILE"`
4929
+if [ "$START" == "" ]; then
4930
+	echo "START: 0 END: 0 TRAPS RECEIVED: 0 RATE: 0 traps/s"
4931
+	exit 0
4932
+fi
4933
+
4934
+# Get the oldest trap
4935
+END=`tail -1 "$TEMP_FILE"`
4936
+if [ "$END" == "" ]; then
4937
+	echo "START: 0 END: 0 TRAPS RECEIVED: 0 RATE: 0 traps/s"
4938
+	exit 0
4939
+fi
4940
+
4941
+# Get the trap count
4942
+COUNT=`cat "$SNMP_LOG" | wc -l`
4943
+
4944
+# Calculate the trap rate
4945
+START_UTIME=`date +"%s" -d"$START"`
4946
+END_UTIME=`date +"%s" -d"$END"`
4947
+ELAPSED=$(($END_UTIME - $START_UTIME))
4948
+RATE=`bc -l <<< "$COUNT / $ELAPSED"`
4949
+
4950
+echo "START: $START END: $END TRAPS RECEIVED: $COUNT RATE: $RATE traps/s"
4951
+rm -f "$TEMP_FILE"
4952
+
4953
4954
Property changes on: util/trap_rate.sh
4955
___________________________________________________________________
4956
Added: svn:executable
4957
## -0,0 +1 ##
4958
+*
4959
\ No newline at end of property
4960
Index: util/plugin/snmp_remote.pl
4961
===================================================================
4962
--- util/plugin/snmp_remote.pl	(revision 10314)
4963
+++ util/plugin/snmp_remote.pl	(working copy)
4964
@@ -1,5 +1,5 @@
4965
 #!/usr/bin/perl
4966
-#---------------------------------------------------------------------------
4967
+#-----------------------------------------------------------------------
4968
 # SNMP remote plugin 
4969
 # Depending on the configuration returns the result of these modules:
4970
 # - % Memory Use
4971
@@ -11,7 +11,7 @@
4972
 # Copyright (C) 2013 mario.pulido@artica.es
4973
 #
4974
 # License: GPLv2+
4975
-#---------------------------------------------------------------------------
4976
+#-----------------------------------------------------------------------
4977
 # This program is free software; you can redistribute it and/or
4978
 # modify it under the terms of the GNU General Public License
4979
 # as published by the Free Software Foundation; either version 2
4980
@@ -23,111 +23,249 @@
4981
 # GNU General Public License for more details.
4982
 #
4983
 # GPL License: http://www.gnu.org/licenses/gpl.txt
4984
-#---------------------------------------------------------------------------
4985
+#-----------------------------------------------------------------------
4986
 
4987
 use strict;
4988
 use Getopt::Std;
4989
 
4990
 my $VERSION = 'v1r1';
4991
 
4992
-#-----------------------------------------------------------------------------
4993
+#-----------------------------------------------------------------------
4994
 # HELP
4995
-#-----------------------------------------------------------------------------
4996
+#-----------------------------------------------------------------------
4997
 
4998
-if ($#ARGV == -1 )
4999
-{
5000
-		print "-H, --host=STRING\n";
5001
-		print "\tHost IP\n";
5002
-		print "-c, --community=STRING\n";
5003
-		print "\tSnmp Community\n";
5004
-		print "-m, --module=STRING\n";
5005
-		print "\tDefine module (memuse|diskuse|process|cpuload) \n";
5006
-		print "-d, --disk=STRING\n";
5007
-		print "\tDefine disk name (C:, D: in Windows) or mount point (Linux)(only in diskuse module)\n";
5008
-		print "-p, --process=STRING\n";
5009
-		print "\tProcess or service name (only in process module)\n";
5010
-		print "\n";
5011
-        print "Example of use \n";
5012
-        print "perl snmp_remoto.pl -H host -c community -m (memuse|diskuse|process|cpuload) [-p process -d disk] \n";
5013
-        print "Version=$VERSION";
5014
-        exit;
5015
+if ($#ARGV == -1 ) {
5016
+	print "-H, --host=STRING\n";
5017
+	print "\tHost IP\n";
5018
+	
5019
+	print "-c, --community=STRING\n";
5020
+	print "\tSnmp Community\n";
5021
+	
5022
+	print "-m, --module=STRING\n";
5023
+	print "\tDefine module (memuse|diskuse|process|cpuload) \n";
5024
+	
5025
+	print "-d, --disk=STRING\n";
5026
+	print "\tDefine disk name (C:, D: in Windows) or mount point (Linux)(only in diskuse module)\n";
5027
+	
5028
+	print "-p, --process=STRING\n";
5029
+	print "\tProcess or service name (only in process module)\n";
5030
+	
5031
+	print "-v, --version=NUMBER\n";
5032
+	print "\tVersion of protocol\n";
5033
+	
5034
+	print "-u, --user=STRING\n";
5035
+	print "\tAuth user\n";
5036
+	
5037
+	print "-A, --auth=STRING\n";
5038
+	print "\tAuth pass\n";
5039
+	
5040
+	print "-l, --level=STRING\n";
5041
+	print "\tSecurity level\n";
5042
+	
5043
+	print "-a STRING\n";
5044
+	print "\tAuth method\n";
5045
+	
5046
+	print "-x STRING\n";
5047
+	print "\tPrivacy method\n";
5048
+	
5049
+	print "-X STRING\n";
5050
+	print "\tPrivacy pass\n";
5051
+	
5052
+	print "\n";
5053
+	print "Example of use \n";
5054
+	print "perl snmp_remoto.pl -H host -c community -m (memuse|diskuse|process|cpuload) [-p process -d disk] \n";
5055
+	print "Version=$VERSION";
5056
+	exit;
5057
 }
5058
 
5059
-my ( $host, $community, $module, $disk, $process ) = &options;
5060
+my ($host,
5061
+	$community,
5062
+	$module,
5063
+	$disk,
5064
+	$process,
5065
+	$version,
5066
+	$user,
5067
+	$pass,
5068
+	$auth_method,
5069
+	$privacy_method,
5070
+	$privacy_pass ) = &options;
5071
 
5072
-#-------------------------------------------------------------------------------------
5073
+#-----------------------------------------------------------------------
5074
 # OPTIONS
5075
-#-------------------------------------------------------------------------------------
5076
-
5077
+#-----------------------------------------------------------------------
5078
 sub options {
5079
-
5080
-    # Get and check args
5081
-    my %opts;
5082
-    getopt( 'Hcmdp', \%opts );
5083
-
5084
-	$opts{"H"} = 0   unless ( exists( $opts{"H"} ) );
5085
-	$opts{"c"} = 0   unless ( exists( $opts{"c"} ) );
5086
-	$opts{"m"} = 0   unless ( exists( $opts{"m"} ) );
5087
-	$opts{"d"} = "/"   unless ( exists( $opts{"d"} ) );
5088
-	$opts{"p"} = 0   unless ( exists( $opts{"p"} ) );
5089
-    return ( $opts{"H"}, $opts{"c"}, $opts{"m"}, $opts{"d"}, $opts {"p"});
5090
+	
5091
+	# Get and check args
5092
+	my %opts;
5093
+	getopt( 'HcmdpvuAlaxX', \%opts );
5094
+	
5095
+	#~ ' -u ' . $snmp3_auth_user .
5096
+	#~ ' -A ' . $snmp3_auth_pass .
5097
+	#~ ' -l ' . $snmp3_security_level .
5098
+	#~ ' -a ' . $snmp3_auth_method .
5099
+	#~ ' -x ' . $snmp3_privacy_method .
5100
+	#~ ' -X' $snmp3_privacy_pass;
5101
+	
5102
+	$opts{"H"} = 0		unless ( exists( $opts{"H"} ) );
5103
+	$opts{"c"} = 0		unless ( exists( $opts{"c"} ) );
5104
+	$opts{"m"} = 0		unless ( exists( $opts{"m"} ) );
5105
+	$opts{"d"} = "/"	unless ( exists( $opts{"d"} ) );
5106
+	$opts{"p"} = 0		unless ( exists( $opts{"p"} ) );
5107
+	$opts{"p"} = 0		unless ( exists( $opts{"p"} ) );
5108
+	$opts{"v"} = 2		unless ( exists( $opts{"v"} ) );
5109
+	$opts{"u"} = ""		unless ( exists( $opts{"u"} ) );
5110
+	$opts{"A"} = ""		unless ( exists( $opts{"A"} ) );
5111
+	$opts{"l"} = "noAuthNoPriv"		unless ( exists( $opts{"l"} ) );
5112
+	$opts{"a"} = ""		unless ( exists( $opts{"a"} ) );
5113
+	$opts{"x"} = ""		unless ( exists( $opts{"x"} ) );
5114
+	$opts{"X"} = ""		unless ( exists( $opts{"X"} ) );
5115
+	
5116
+	return ( $opts{"H"},
5117
+		$opts{"c"},
5118
+		$opts{"m"},
5119
+		$opts{"d"},
5120
+		$opts {"p"},
5121
+		$opts{"v"},
5122
+		$opts{"u"},
5123
+		$opts{"A"},
5124
+		$opts{"l"},
5125
+		$opts{"a"},
5126
+		$opts{"x"},
5127
+		$opts{"X"});
5128
 }
5129
 
5130
-#--------------------------------------------------------------------------------------------------
5131
+#-----------------------------------------------------------------------
5132
 # Module % Memory use
5133
-#--------------------------------------------------------------------------------------------------
5134
+#-----------------------------------------------------------------------
5135
+if ($module eq "memuse") {
5136
+	my $memuse = 0;
5137
+	my $command_line_parammeters;
5138
+	
5139
+	if ($version == 3) {
5140
+		if ($auth_method eq 'authNoPriv') {
5141
+			$command_line_parammeters = "-v 3 -u $user -a $privacy_method -A $pass -l $auth_method $host";
5142
+		}
5143
+		elsif  ($auth_method eq "noAuthNoPriv") {
5144
+			$command_line_parammeters = "-v 3 -u $user -l $auth_method $host";
5145
+		}
5146
+		else {
5147
+			$command_line_parammeters = "-v 3 -u $user -a $privacy_method -A $pass -l $auth_method -x $privacy_method -X $privacy_pass $host";
5148
+		}
5149
+	}
5150
+	else {
5151
+		$command_line_parammeters = "-v 1 -c $community $host";
5152
+	}
5153
+	
5154
+	my $memid = `snmpwalk -On $command_line_parammeters  .1.3.6.1.2.1.25.2.3.1.3 | grep Physical | head -1 | gawk '{print \$1}' | gawk -F "." '{print \$13}' | tr -d "\r"`;
5155
+	my $memtot = `snmpget $command_line_parammeters  .1.3.6.1.2.1.25.2.3.1.5.$memid ` ;
5156
+	my $memtot2 = `echo "$memtot" | gawk '{print \$4}'`;
5157
+	my $memfree = `snmpget $command_line_parammeters  .1.3.6.1.2.1.25.2.3.1.6.$memid` ;
5158
+	my $memfree2 = `echo "$memfree" | gawk '{print \$4}'`;
5159
+	
5160
+	$memuse = ($memfree2) * 100 / $memtot2;
5161
+	
5162
+	printf("%.2f", $memuse);
5163
+}
5164
 
5165
-if ($module eq "memuse"){ 
5166
-						my $memid = `snmpwalk -On -v 1 -c $community $host .1.3.6.1.2.1.25.2.3.1.3 | grep Physical | head -1 | gawk '{print \$1}' | gawk -F "." '{print \$13}' | tr -d "\r"`;
5167
-						my $memtot = `snmpget -v 1 -c $community $host .1.3.6.1.2.1.25.2.3.1.5.$memid ` ;
5168
-						my $memtot2 = `echo "$memtot" | gawk '{print \$4}'`;
5169
-						my $memfree = `snmpget -v 1 -c $community $host .1.3.6.1.2.1.25.2.3.1.6.$memid` ;
5170
-						my $memfree2 = `echo "$memfree" | gawk '{print \$4}'`;
5171
-						my $memuse = ($memfree2)*100/$memtot2;
5172
-						printf("%.2f", $memuse);
5173
-					    }
5174
-#--------------------------------------------------------------------------------------------------
5175
+#-----------------------------------------------------------------------
5176
 # Module % Disk use
5177
-#-------------------------------------------------------------------------------------------------- 					  
5178
-if ($module eq "diskuse"){
5179
-						my $diskid = `snmpwalk -On -v 1 -c $community $host .1.3.6.1.2.1.25.2.3.1.3 | grep "$disk" | head -1 | gawk '{print \$1}' | gawk -F "." '{print \$13}' | tr -d "\r"`;
5180
-						my $disktot = `snmpget -v 1 -c $community $host .1.3.6.1.2.1.25.2.3.1.5.$diskid ` ;
5181
-						my $disktot2 = `echo "$disktot" | gawk '{print \$4}'`;
5182
-						
5183
-						if($disktot2 == 0) {
5184
-							print 0;
5185
-						}
5186
-						else {
5187
-							my $diskfree = `snmpget -v 1 -c $community $host .1.3.6.1.2.1.25.2.3.1.6.$diskid` ;
5188
-							my $diskfree2 = `echo "$diskfree" | gawk '{print \$4}'`;
5189
-							my $diskuse = ($disktot2 - $diskfree2)*100/$disktot2;
5190
-							printf("%.2f", $diskuse);
5191
-						}
5192
-					    }
5193
-					    
5194
-#--------------------------------------------------------------------------------------------------
5195
+#-----------------------------------------------------------------------
5196
+if ($module eq "diskuse") {
5197
+	my $diskuse = 0;
5198
+	my $command_line_parammeters;
5199
+	
5200
+	if ($version == 3) {
5201
+		if ($auth_method eq 'authNoPriv') {
5202
+			$command_line_parammeters = "-v 3 -u $user -a $privacy_method -A $pass -l $auth_method $host";
5203
+		}
5204
+		elsif  ($auth_method eq "noAuthNoPriv") {
5205
+			$command_line_parammeters = "-v 3 -u $user -l $auth_method $host";
5206
+		}
5207
+		else {
5208
+			$command_line_parammeters = "-v 3 -u $user -a $privacy_method -A $pass -l $auth_method -x $privacy_method -X $privacy_pass $host";
5209
+		}
5210
+	}
5211
+	else {
5212
+		$command_line_parammeters = "-v 1 -c $community $host";
5213
+	}
5214
+	
5215
+	my $diskid = `snmpwalk -On $command_line_parammeters .1.3.6.1.2.1.25.2.3.1.3 | grep "$disk" | head -1 | gawk '{print \$1}' | gawk -F "." '{print \$13}' | tr -d "\r"`;
5216
+	my $disktot = `snmpget $command_line_parammeters .1.3.6.1.2.1.25.2.3.1.5.$diskid ` ;
5217
+	my $disktot2 = `echo "$disktot" | gawk '{print \$4}'`;
5218
+	
5219
+	if ($disktot2 == 0) {
5220
+		$diskuse = 0;
5221
+	}
5222
+	else {
5223
+		my $diskfree = `snmpget $command_line_parammeters .1.3.6.1.2.1.25.2.3.1.6.$diskid` ;
5224
+		my $diskfree2 = `echo "$diskfree" | gawk '{print \$4}'`;
5225
+		
5226
+		$diskuse = ($disktot2 - $diskfree2) * 100 / $disktot2;
5227
+	}
5228
+	
5229
+	printf("%.2f", $diskuse);
5230
+}
5231
+
5232
+#-----------------------------------------------------------------------
5233
 # Module Process Status
5234
-#--------------------------------------------------------------------------------------------------	
5235
-				    
5236
-if ($module eq "process"){
5237
-						my $status = `snmpwalk -v 2c -c $community $host  1.3.6.1.2.1.25.4.2.1.2 | grep "$process" | head -1 | wc -l`;
5238
-						print $status;
5239
-					    }
5240
-#--------------------------------------------------------------------------------------------------
5241
+#-----------------------------------------------------------------------
5242
+if ($module eq "process") {
5243
+	my $status = 0;
5244
+	my $command_line_parammeters;
5245
+	
5246
+	if ($version == 3) {
5247
+		if ($auth_method eq 'authNoPriv') {
5248
+			$command_line_parammeters = "-v 3 -u $user -a $privacy_method -A $pass -l $auth_method $host";
5249
+		}
5250
+		elsif  ($auth_method eq "noAuthNoPriv") {
5251
+			$command_line_parammeters = "-v 3 -u $user -l $auth_method $host";
5252
+		}
5253
+		else {
5254
+			$command_line_parammeters = "-v 3 -u $user -a $privacy_method -A $pass -l $auth_method -x $privacy_method -X $privacy_pass $host";
5255
+		}
5256
+	}
5257
+	else {
5258
+		$command_line_parammeters = "-v 2c -c $community $host";
5259
+	}
5260
+	
5261
+	$status = `snmpwalk $command_line_parammeters  1.3.6.1.2.1.25.4.2.1.2 | grep "$process" | head -1 | wc -l`;
5262
+	
5263
+	print $status;
5264
+}
5265
+
5266
+#-----------------------------------------------------------------------
5267
 # Module % Cpu Load
5268
-#--------------------------------------------------------------------------------------------------
5269
+#-----------------------------------------------------------------------
5270
+if ($module eq "cpuload") {
5271
+	my $cputotal = 0;
5272
+	my $command_line_parammeters;
5273
+	
5274
+	if ($version == 3) {
5275
+		if ($auth_method eq 'authNoPriv') {
5276
+			$command_line_parammeters = "-v 3 -u $user -a $privacy_method -A $pass -l $auth_method $host";
5277
+		}
5278
+		elsif  ($auth_method eq "noAuthNoPriv") {
5279
+			$command_line_parammeters = "-v 3 -u $user -l $auth_method $host";
5280
+		}
5281
+		else {
5282
+			$command_line_parammeters = "-v 3 -u $user -a $privacy_method -A $pass -l $auth_method -x $privacy_method -X $privacy_pass $host";
5283
+		}
5284
+	}
5285
+	else {
5286
+		$command_line_parammeters = "-v 1 -c $community $host";
5287
+	}
5288
+	
5289
+	my $cpuload = `snmpwalk $command_line_parammeters .1.3.6.1.2.1.25.3.3.1.2 | gawk '{print \$4}' `;
5290
+	my @cpuload = split(/\n/, $cpuload);
5291
+	my $sum;
5292
+	my $counter = 0;
5293
+	foreach my $val(@cpuload) {
5294
+		$sum = $sum + $val;
5295
+		$counter++;
5296
+	}
5297
+	
5298
+	$cputotal = $sum/$counter;
5299
+	
5300
+	print $cputotal;
5301
+}
5302
 
5303
-if ($module eq "cpuload"){
5304
-						my $cpuload = `snmpwalk -v 1 -c $community $host .1.3.6.1.2.1.25.3.3.1.2 | gawk '{print \$4}' `;
5305
-						my @cpuload = split(/\n/, $cpuload);
5306
-						my $sum;
5307
-						my $counter = 0;
5308
-						foreach my $val(@cpuload){
5309
-												$sum = $sum+$val;
5310
-												$counter ++;
5311
-					                             }
5312
-						my $cputotal = $sum/$counter;
5313
-						print $cputotal;
5314
-							
5315
-					    }
5316
-
5317
Index: util/pandora_db.pl
5318
===================================================================
5319
--- util/pandora_db.pl	(revision 10314)
5320
+++ util/pandora_db.pl	(working copy)
5321
@@ -547,7 +547,9 @@
5322
  	foreach my $param ('dbuser', 'dbpass', 'dbname', 'dbhost', 'log_file') {
5323
 		die ("[ERROR] Bad config values. Make sure " . $conf->{'_pandora_path'} . " is a valid config file.\n\n") unless defined ($conf->{$param});
5324
  	}
5325
+	$conf->{'dbengine'} = 'mysql' unless defined ($conf->{'dbengine'});
5326
 	$conf->{'dbport'} = '3306' unless defined ($conf->{'dbport'});
5327
+	$conf->{'claim_back_snmp_modules'} = '1' unless defined ($conf->{'claim_back_snmp_modules'});
5328
 
5329
 	# Read additional tokens from the DB
5330
 	my $dbh = db_connect ('mysql', $conf->{'dbname'}, $conf->{'dbhost'}, $conf->{'dbport'}, $conf->{'dbuser'}, $conf->{'dbpass'});
5331
Index: util/pandora_revent_create.pl
5332
===================================================================
5333
--- util/pandora_revent_create.pl	(revision 10314)
5334
+++ util/pandora_revent_create.pl	(working copy)
5335
@@ -232,9 +232,9 @@
5336
 			$i++;
5337
 		}
5338
 
5339
-		$data_event = $event_name.",".$id_group.",".$id_agent.",".$status.",".$id_user.",".$event_type.",".$criticity.",".$id_agent_module.",".$id_alert_am.",".$critical_instructions.",".$warning_instructions.",".$unknown_instructions.",".$user_comment.",".$owner_user.",".$source.",".$tags;
5340
+		$data_event = $event_name."|".$id_group."|".$id_agent."|".$status."|".$id_user."|".$event_type."|".$criticity."|".$id_agent_module."|".$id_alert_am."|".$critical_instructions."|".$warning_instructions."|".$unknown_instructions."|".$user_comment."|".$owner_user."|".$source."|".$tags;
5341
 
5342
-		$call_api = $api_path.'?op=set&op2=create_event&id='.$event_name.'&other='.$data_event.'&other_mode=url_encode_separator_,&apipass='.$api_pass.'&user='.$db_user.'&pass='.$db_pass;
5343
+		$call_api = $api_path.'?op=set&op2=create_event&id='.$event_name.'&other='.$data_event.'&other_mode=url_encode_separator_|&apipass='.$api_pass.'&user='.$db_user.'&pass='.$db_pass;
5344
 
5345
 		#DEBUG TRACE#
5346
 
5347
Index: util/pandora_manage.pl
5348
===================================================================
5349
--- util/pandora_manage.pl	(revision 10314)
5350
+++ util/pandora_manage.pl	(working copy)
5351
@@ -29,6 +29,10 @@
5352
 use PandoraFMS::Core;
5353
 use PandoraFMS::Config;
5354
 
5355
+# To handle 'UTF-8' encoded string in command like arguments (similar to "-CA" option for perl)
5356
+use Encode::Locale;
5357
+Encode::Locale::decode_argv;
5358
+
5359
 # version: define current version
5360
 my $version = "5.1 PS140630";
5361
 
5362
@@ -128,6 +132,8 @@
5363
 	help_screen_line('--create_special_day', "<special_day> <same_day> <description> <group>", 'Create special day');
5364
 	help_screen_line('--delete_special_day', '<special_day>', 'Delete special day');
5365
 	help_screen_line('--update_special_day', "<special_day> <field_to_change> <new_value>", 'Update a field of a special day');
5366
+	help_screen_line('--create_data_module_from_local_component', '<agent_name> <component_name>', "Create a new data \n\t  module from a local component");
5367
+	help_screen_line('--create_local_component', "<component_name> <data> [<description> <id_os> <os_version> \n\t  <id_network_component_group> <type> <min> <max> <module_interval> <id_module_group> <history_data> <min_warning> \n\t <max_warning> <str_warning> <min_critical> <max_critical>\n\t  <str_critical> <min_ff_event> <post_process> <unit>\n\t  <wizard_level> <critical_instructions>\n\t  <warning_instructions> <unknown_instructions> <critical_inverse>\n\t  <warning_inverse> <id_category> <disabled_types_event>\n\t  <tags> <min_ff_event_normal> <min_ff_event_warning>\n\t  <min_ff_event_critical> <each_ff> <ff_timeout>]", 'Create local component');
5368
 
5369
 	print "\nUSERS:\n\n" unless $param ne '';
5370
     help_screen_line('--create_user', '<user_name> <user_password> <is_admin> [<comments>]', 'Create user');
5371
@@ -3885,6 +3891,14 @@
5372
 			param_check($ltotal, 1);
5373
 			cli_delete_special_day();
5374
 		}
5375
+		elsif ($param eq '--create_data_module_from_local_component') {
5376
+			param_check($ltotal, 2);
5377
+			cli_create_data_module_from_local_component();
5378
+		}
5379
+		elsif ($param eq '--create_local_component') {
5380
+			param_check($ltotal, 35, 33);
5381
+			cli_create_local_component();
5382
+		}
5383
 		else {
5384
 			print_log "[ERROR] Invalid option '$param'.\n\n";
5385
 			$param = '';
5386
@@ -3980,3 +3994,110 @@
5387
 		pandora_delete_graph_source($id_graph, $dbh, $module);
5388
 	}
5389
 }
5390
+
5391
+##############################################################################
5392
+# Return local component id given the name
5393
+##############################################################################
5394
+
5395
+sub pandora_get_local_component_id($$) {
5396
+	my ($dbh,$name) = @_;
5397
+	
5398
+	my $lc_id = get_db_value($dbh, 'SELECT id FROM tlocal_component WHERE name = ?',safe_input($name));
5399
+	
5400
+	return defined ($lc_id) ? $lc_id : -1;
5401
+}
5402
+
5403
+##############################################################################
5404
+# Create data module from local component.
5405
+# Related option: --create_data_module_from_local_component
5406
+##############################################################################
5407
+
5408
+sub cli_create_data_module_from_local_component() {
5409
+	my ($agent_name, $component_name) = @ARGV[2..3];
5410
+	
5411
+	my $agent_id = get_agent_id($dbh,$agent_name);
5412
+	exist_check($agent_id,'agent',$agent_name);
5413
+		
5414
+	my $lc_id = pandora_get_local_component_id($dbh, $component_name);
5415
+	exist_check($lc_id,'local component',$component_name);
5416
+	
5417
+	my $module_exists = get_agent_module_id($dbh, $component_name, $agent_id);
5418
+	non_exist_check($module_exists, 'module name', $component_name);
5419
+	
5420
+	# Get local component data
5421
+	my $component = get_db_single_row ($dbh, 'SELECT * FROM tlocal_component WHERE id = ?', $lc_id);
5422
+	
5423
+	#~ pandora_create_module_from_local_component ($conf, $component, $agent_id, $dbh);
5424
+	enterprise_hook('pandora_create_module_from_local_component',[$conf, $component, $agent_id, $dbh]);
5425
+}
5426
+
5427
+##############################################################################
5428
+# Create local component.
5429
+# Related option: --create_local_component
5430
+##############################################################################
5431
+
5432
+sub cli_create_local_component() {
5433
+
5434
+	my ($component_name, $data, $description, $id_os, $os_version, $id_network_component_group, $type,
5435
+		$min,$max,$module_interval, $id_module_group, $history_data, $min_warning, $max_warning, $str_warning,
5436
+		$min_critical, $max_critical, $str_critical, $min_ff_event, $post_process, $unit, $wizard_level,
5437
+	    $critical_instructions, $warning_instructions, $unknown_instructions, $critical_inverse, $warning_inverse,
5438
+	    $id_category, $tags, $disabled_types_event, $min_ff_event_normal, $min_ff_event_warning, $min_ff_event_critical,
5439
+	    $each_ff, $ff_timeout) = @ARGV[2..37];
5440
+	
5441
+	my %parameters;
5442
+	
5443
+	$parameters{'name'} = safe_input($component_name);
5444
+	my $data_aux = safe_input($data);
5445
+	$data_aux =~ s/&#92;n/&#x0a;/g;
5446
+	$parameters{'data'} = $data_aux;
5447
+	$parameters{'description'} = safe_input($description) unless !defined ($description);
5448
+	$parameters{'id_os'} = $id_os unless !defined ($id_os);
5449
+	$parameters{'type'} = $type unless !defined ($type);
5450
+	if (defined $id_network_component_group) {
5451
+		$parameters{'id_network_component_group'} = $id_network_component_group;
5452
+	} else {
5453
+		$parameters{'id_network_component_group'} = 1;
5454
+	}
5455
+	$parameters{'max'} = $max unless !defined ($max);
5456
+	$parameters{'min'} = $min unless !defined ($min);
5457
+	$parameters{'module_interval'} = $module_interval unless !defined ($module_interval);
5458
+	$parameters{'id_module_group'} = $id_module_group unless !defined ($id_module_group);
5459
+	$parameters{'history_data'} = safe_input($history_data) unless !defined ($history_data);
5460
+	$parameters{'min_warning'} = $min_warning unless !defined ($min_warning);
5461
+	$parameters{'max_warning'} = $max_warning unless !defined ($max_warning);
5462
+	$parameters{'str_warning'} = $str_warning unless !defined ($str_warning);
5463
+	$parameters{'min_critical'} = $min_critical unless !defined ($min_critical);
5464
+	$parameters{'max_critical'} = $max_critical unless !defined ($max_critical);
5465
+	$parameters{'str_critical'} = $str_critical unless !defined ($str_critical);
5466
+	$parameters{'min_ff_event'} = $min_ff_event unless !defined ($min_ff_event);
5467
+	$parameters{'post_process'} = $post_process unless !defined ($post_process);
5468
+	$parameters{'unit'} = $unit  unless !defined ($unit);
5469
+	$parameters{'wizard_level'} = $wizard_level unless !defined ($wizard_level);
5470
+	$parameters{'critical_instructions'} = safe_input($critical_instructions) unless !defined ($critical_instructions);
5471
+	$parameters{'warning_instructions'} = safe_input($warning_instructions) unless !defined ($warning_instructions);
5472
+	$parameters{'unknown_instructions'} = safe_input($unknown_instructions) unless !defined ($unknown_instructions);
5473
+	$parameters{'critical_inverse'} = $critical_inverse unless !defined ($critical_inverse);
5474
+	$parameters{'warning_inverse'} = $warning_inverse unless !defined ($warning_inverse);
5475
+	$parameters{'id_category'} = $id_category unless !defined ($id_category);
5476
+	$parameters{'tags'} = safe_input($tags) unless !defined ($tags);
5477
+
5478
+	my $disabled_types_event_hash = {};
5479
+	if ($disabled_types_event) {
5480
+		$disabled_types_event_hash->{'going_unknown'} = 0;
5481
+	}
5482
+	else {
5483
+		$disabled_types_event_hash->{'going_unknown'} = 1;
5484
+	}
5485
+	my $disabled_types_event_json = encode_json($disabled_types_event_hash);
5486
+	$parameters{'disabled_types_event'} = $disabled_types_event_json unless !defined ($disabled_types_event);
5487
+	
5488
+	$parameters{'min_ff_event_normal'} = $min_ff_event_normal unless !defined ($min_ff_event_normal);
5489
+	$parameters{'min_ff_event_warning'} = $min_ff_event_warning unless !defined ($min_ff_event_warning);
5490
+	$parameters{'min_ff_event_critical'} = $min_ff_event_critical unless !defined ($min_ff_event_critical);
5491
+	$parameters{'each_ff'} = $each_ff unless !defined ($each_ff);
5492
+	$parameters{'ff_timeout'} = $ff_timeout unless !defined ($ff_timeout);
5493
+	
5494
+	my $component_id = enterprise_hook('pandora_create_local_component_from_hash',[$conf, \%parameters, $dbh]);
5495
+
5496
+}
5497
Index: util/recon_scripts/wmi-recon.pl
5498
===================================================================
5499
--- util/recon_scripts/wmi-recon.pl	(revision 10314)
5500
+++ util/recon_scripts/wmi-recon.pl	(working copy)
5501
@@ -27,8 +27,9 @@
5502
 			'daemon' => 0,
5503
 			'PID' => '',
5504
 			'pandora_path' => '/usr/local/etc/pandora/pandora_server.conf',
5505
-			'ping_timeout' => 2,
5506
-			'ping_retries' => 1,
5507
+			'networktimeout' => 2,
5508
+			'icmp_checks' => 1,
5509
+			'nmap_timing_template' => 2,
5510
 			'wmi_client' => '/usr/local/bin/wmic');
5511
 } else {
5512
 	%CONF = ('quiet' => 0,
5513
@@ -36,8 +37,9 @@
5514
 			'daemon' => 0,
5515
 			'PID' => '',
5516
 			'pandora_path' => '/etc/pandora/pandora_server.conf',
5517
-			'ping_timeout' => 2,
5518
-			'ping_retries' => 1,
5519
+			'networktimeout' => 2,
5520
+			'icmp_checks' => 1,
5521
+			'nmap_timing_template' => 2,
5522
 			'wmi_client' => '/usr/bin/wmic');
5523
 }
5524
 
5525
@@ -106,10 +108,10 @@
5526
 	my ($task, $function) = @_;
5527
 
5528
 	# Timeout in ms.
5529
-	my $timeout = $CONF{'ping_timeout'} * 1000;
5530
+	my $timeout = $CONF{'networktimeout'} * 1000;
5531
 
5532
 	# Added -PE to make nmap behave like ping and avoid confusion if ICMP traffic is blocked.
5533
-	my $nmap_args = '-nsP -PE --max-retries ' . $CONF{'ping_retries'} . ' --host-timeout ' . $timeout;
5534
+	my $nmap_args = '-nsP -PE --max-retries ' . $CONF{'icmp_checks'} . ' --host-timeout '.$timeout.' -T'.$CONF{'nmap_timing_template'};
5535
 
5536
 	# Scan the network.
5537
 	my $np = new PandoraFMS::NmapParser;
5538
Index: util/recon_scripts/snmp-recon.pl
5539
===================================================================
5540
--- util/recon_scripts/snmp-recon.pl	(revision 10314)
5541
+++ util/recon_scripts/snmp-recon.pl	(working copy)
5542
@@ -35,8 +35,9 @@
5543
 	%CONF = (
5544
 		'nmap' => '/usr/local/bin/nmap',
5545
 		'pandora_path' => '/usr/local/etc/pandora/pandora_server.conf',
5546
-		'ping_retries' => 1,
5547
-		'ping_timeout' => 2,
5548
+		'icmp_checks' => 1,
5549
+		'networktimeout' => 2,
5550
+		'nmap_timing_template' => 2,
5551
 		'PID' => '',
5552
 		'quiet' => 1,
5553
 	);
5554
@@ -44,8 +45,9 @@
5555
 	%CONF = (
5556
 		'nmap' => '/usr/bin/nmap',
5557
 		'pandora_path' => '/etc/pandora/pandora_server.conf',
5558
-		'ping_retries' => 1,
5559
-		'ping_timeout' => 2,
5560
+		'icmp_checks' => 1,
5561
+		'networktimeout' => 2,
5562
+		'nmap_timing_template' => 2,
5563
 		'PID' => '',
5564
 		'quiet' => 1,
5565
 	);
5566
@@ -861,9 +863,11 @@
5567
 	return unless defined($agent);
5568
 
5569
 	# Perform a traceroute.
5570
+	my $timeout = $CONF{'networktimeout'}*1000;
5571
+	my $nmap_args  = '-nsP -PE --traceroute --max-retries '.$CONF{'icmp_checks'}.' --host-timeout '.$timeout.' -T'.$CONF{'nmap_timing_template'};
5572
 	my $np = new PandoraFMS::NmapParser;
5573
 	eval {
5574
-		$np->parsescan($CONF{'nmap'}, '-nsP --traceroute', ($host));
5575
+		$np->parsescan($CONF{'nmap'}, $nmap_args, ($host));
5576
 	};
5577
 	return if ($@);
5578
 	
5579
@@ -930,10 +934,11 @@
5580
 
5581
 # Populate ARP caches.
5582
 message("Populating ARP caches...");
5583
-my $timeout = $CONF{'ping_timeout'} * 1000; # Convert the timeout from s to ms.
5584
+my $timeout = $CONF{'networktimeout'} * 1000; # Convert the timeout from s to ms.
5585
+my $nmap_args  = '-nsP --send-ip --max-retries '.$CONF{'icmp_checks'}.' --host-timeout '.$timeout.' -T'.$CONF{'nmap_timing_template'};
5586
 my $np = new PandoraFMS::NmapParser;
5587
 if ($#SUBNETS >= 0) {
5588
-	$np->parsescan($CONF{'nmap'}, '-nsP --send-ip --max-retries ' . $CONF{'ping_retries'} . ' --host-timeout ' . $timeout, @SUBNETS);
5589
+	$np->parsescan($CONF{'nmap'}, $nmap_args, @SUBNETS);
5590
 }
5591
 
5592
 # Find routers.
(-)b/net-mgmt/pandorafms_server/pkg-plist (-4 / +8 lines)
Lines 44-49 man/man1/tentacle_server.1.gz Link Here
44
%%DATADIR%%/util/esx_trap_manager.pl
44
%%DATADIR%%/util/esx_trap_manager.pl
45
%%DATADIR%%/util/gis.README
45
%%DATADIR%%/util/gis.README
46
%%DATADIR%%/util/gpx2pandora_agent_data.pl
46
%%DATADIR%%/util/gpx2pandora_agent_data.pl
47
%%DATADIR%%/util/integria_rticket.pl
48
%%DATADIR%%/util/integrity_check
47
%%DATADIR%%/util/n2p.README
49
%%DATADIR%%/util/n2p.README
48
%%DATADIR%%/util/n2p.pl
50
%%DATADIR%%/util/n2p.pl
49
%%DATADIR%%/util/pandora2ast/GPL
51
%%DATADIR%%/util/pandora2ast/GPL
Lines 96-101 man/man1/tentacle_server.1.gz Link Here
96
%%DATADIR%%/util/plugin/multicast.pl
98
%%DATADIR%%/util/plugin/multicast.pl
97
%%DATADIR%%/util/plugin/mysql_plugin.sh
99
%%DATADIR%%/util/plugin/mysql_plugin.sh
98
%%DATADIR%%/util/plugin/openvpn_pandoraplugin.pl
100
%%DATADIR%%/util/plugin/openvpn_pandoraplugin.pl
101
%%DATADIR%%/util/plugin/packet_loss.sh
99
%%DATADIR%%/util/plugin/pandora_inventory_change.README
102
%%DATADIR%%/util/plugin/pandora_inventory_change.README
100
%%DATADIR%%/util/plugin/pandora_inventory_change.pl
103
%%DATADIR%%/util/plugin/pandora_inventory_change.pl
101
%%DATADIR%%/util/plugin/pandora_loadgen.pl
104
%%DATADIR%%/util/plugin/pandora_loadgen.pl
Lines 108-123 man/man1/tentacle_server.1.gz Link Here
108
%%DATADIR%%/util/recon_scripts/ipmi-recon.pl
111
%%DATADIR%%/util/recon_scripts/ipmi-recon.pl
109
%%DATADIR%%/util/recon_scripts/snmp-recon.pl
112
%%DATADIR%%/util/recon_scripts/snmp-recon.pl
110
%%DATADIR%%/util/recon_scripts/wmi-recon.pl
113
%%DATADIR%%/util/recon_scripts/wmi-recon.pl
114
%%DATADIR%%/util/snmptrap_gen.sh
111
%%DATADIR%%/util/tentacle_serverd
115
%%DATADIR%%/util/tentacle_serverd
112
%%DATADIR%%/util/trap_rate.sh
116
%%DATADIR%%/util/trap_rate.sh
113
%%DATADIR%%/util/udp_client.pl
117
%%DATADIR%%/util/udp_client.pl
114
%%DATADIR%%/util/windows.README
118
%%DATADIR%%/util/windows.README
115
@dirrmtry %%SITE_PERL%%/%%PERL_ARCH%%/auto/PandoraFMS
119
@dirrmtry %%SITE_PERL%%/%%PERL_ARCH%%/auto/PandoraFMS
116
@dirrm %%SITE_PERL%%/PandoraFMS/Traceroute
120
@dir %%SITE_PERL%%/PandoraFMS/Traceroute
117
@dirrmtry %%SITE_PERL%%/PandoraFMS
121
@dirrmtry %%SITE_PERL%%/PandoraFMS
118
@dirrm %%DATADIR%%/util/plugin/babel_plugin
122
@dir %%DATADIR%%/util/plugin/babel_plugin
119
@dirrm %%DATADIR%%/util/plugin/integria_plugin
123
@dir %%DATADIR%%/util/plugin/integria_plugin
120
@dirrm %%DATADIR%%/util/pandora2ast
124
@dir %%DATADIR%%/util/pandora2ast
121
@dirrmtry %%DATADIR%%/util/plugin
125
@dirrmtry %%DATADIR%%/util/plugin
122
@dirrmtry %%DATADIR%%/util/recon_scripts
126
@dirrmtry %%DATADIR%%/util/recon_scripts
123
@dirrmtry %%DATADIR%%/util
127
@dirrmtry %%DATADIR%%/util

Return to bug 194859