Index: m4/lua.m4
===================================================================
--- m4/lua.m4	(revision 0)
+++ m4/lua.m4	(revision 305)
@@ -0,0 +1,53 @@
+AC_DEFUN([LUA_CHECK_CONFIG],
+[
+  AC_ARG_WITH(lua,[If you want to check for Lua support:
+AC_HELP_STRING([--with-lua@<:@=DIR@:>@],[Include Lua support @<:@default=no@:>@.  DIR is the Lua base install directry, default is to search common locations for Lua files.])
+],[ if test "$withval" = "no"; then
+	want_lua="no"
+	_liblua_with="no"
+  elif test "$withval" = "yes"; then
+	want_lua="yes"
+	_liblua_with="yes"
+  else
+	want_lua="yes"
+	_liblua_with=$withval
+  fi
+],[_liblua_with=ifelse([$1],,[no],[$1])])
+
+if test "x$_liblua_with" != "xno"; then
+	if test "$_liblua_with" = "yes"; then
+		PKG_CHECK_MODULES([LLUA],[lua],
+			[LUA_INCDIR=$LLUA_CPPFLAGS
+			 LUA_LIBDIR=$LLUA_LIBS
+			 LUA_LIBS="-llua"],
+			[found_lua="no"])
+	else
+		AC_MSG_CHECKING(for Lua support)
+		if test -f $_liblua_with/include/lua.h; then
+			LUA_INCDIR=-I$_liblua_with/include
+			LUA_LIBDIR=-L$_liblua_with/lib
+			LUA_LIBS="-llua"
+			AC_MSG_RESULT(yes)
+		else
+			found_lua="no"
+			AC_MSG_RESULT(no)
+		fi
+	fi
+
+	if test "x$found_lua" != "xno"; then
+
+		LUA_CPPFLAGS="$LUA_INCDIR"
+		LUA_LDFLAGS="$LUA_LIBDIR"
+
+		found_lua="yes"
+		AC_DEFINE(HAVE_LUA,1,[Define to 1 if Lua library should be enabled.])
+	fi
+fi
+
+AC_SUBST(LUA_CPPFLAGS)
+AC_SUBST(LUA_LDFLAGS)
+AC_SUBST(LUA_LIBS)
+
+unset _liblua_with
+])dnl
+
Index: configure
===================================================================
--- configure	(revision 302)
+++ configure	(working copy)
@@ -602,6 +602,8 @@
 LDAP_CPPFLAGS
 WITH_ODBC_FALSE
 WITH_ODBC_TRUE
+LUA_FALSE
+LUA_TRUE
 JABBER_FALSE
 JABBER_TRUE
 PROXY_LIBS
@@ -638,6 +640,11 @@
 JABBER_CPPFLAGS
 IKSEMEL_LIBS
 IKSEMEL_CFLAGS
+LUA_LIBS
+LUA_LDFLAGS
+LUA_CPPFLAGS
+LLUA_LIBS
+LLUA_CFLAGS
 PKG_CONFIG
 DB_LIBS
 DB_LDFLAGS
@@ -775,6 +782,7 @@
 with_oracle_lib
 with_pgsql
 with_sqlite3
+with_lua
 with_jabber
 with_libcurl
 with_iodbc
@@ -795,6 +803,8 @@
 CPPFLAGS
 CPP
 PKG_CONFIG
+LLUA_CFLAGS
+LLUA_LIBS
 IKSEMEL_CFLAGS
 IKSEMEL_LIBS'
 
@@ -1444,7 +1454,12 @@
                           specify path to pg_config
   --with-sqlite3[=ARG]    use SQLite 3 library [default=no], optionally
                           specify the prefix for sqlite3 library
+If you want to check for Lua support:
+  --with-lua[=DIR]        Include Lua support [default=no]. DIR is the Lua
+                          base install directry, default is to search common
+                          locations for Lua files.
 
+
 If you want to use Jabber protocol for messaging:
   --with-jabber[=DIR]     Include Jabber support [default=no]. DIR is the
                           iksemel library install directory.
@@ -1496,6 +1511,8 @@
               you have headers in a nonstandard directory <include dir>
   CPP         C preprocessor
   PKG_CONFIG  path to pkg-config utility
+  LLUA_CFLAGS C compiler flags for LLUA, overriding pkg-config
+  LLUA_LIBS   linker flags for LLUA, overriding pkg-config
   IKSEMEL_CFLAGS
               C compiler flags for IKSEMEL, overriding pkg-config
   IKSEMEL_LIBS
@@ -8185,6 +8202,144 @@
 fi
 
 
+# Check whether --with-lua was given.
+if test "${with_lua+set}" = set; then :
+  withval=$with_lua;  if test "$withval" = "no"; then
+	want_lua="no"
+	_liblua_with="no"
+  elif test "$withval" = "yes"; then
+	want_lua="yes"
+	_liblua_with="yes"
+  else
+	want_lua="yes"
+	_liblua_with=$withval
+  fi
+
+else
+  _liblua_with=no
+fi
+
+
+if test "x$_liblua_with" != "xno"; then
+	if test "$_liblua_with" = "yes"; then
+
+pkg_failed=no
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for LLUA" >&5
+$as_echo_n "checking for LLUA... " >&6; }
+
+if test -n "$LLUA_CFLAGS"; then
+    pkg_cv_LLUA_CFLAGS="$LLUA_CFLAGS"
+ elif test -n "$PKG_CONFIG"; then
+    if test -n "$PKG_CONFIG" && \
+    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"lua\""; } >&5
+  ($PKG_CONFIG --exists --print-errors "lua") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+  pkg_cv_LLUA_CFLAGS=`$PKG_CONFIG --cflags "lua" 2>/dev/null`
+else
+  pkg_failed=yes
+fi
+ else
+    pkg_failed=untried
+fi
+if test -n "$LLUA_LIBS"; then
+    pkg_cv_LLUA_LIBS="$LLUA_LIBS"
+ elif test -n "$PKG_CONFIG"; then
+    if test -n "$PKG_CONFIG" && \
+    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"lua\""; } >&5
+  ($PKG_CONFIG --exists --print-errors "lua") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+  pkg_cv_LLUA_LIBS=`$PKG_CONFIG --libs "lua" 2>/dev/null`
+else
+  pkg_failed=yes
+fi
+ else
+    pkg_failed=untried
+fi
+
+
+
+if test $pkg_failed = yes; then
+
+if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
+        _pkg_short_errors_supported=yes
+else
+        _pkg_short_errors_supported=no
+fi
+        if test $_pkg_short_errors_supported = yes; then
+	        LLUA_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "lua" 2>&1`
+        else
+	        LLUA_PKG_ERRORS=`$PKG_CONFIG --print-errors "lua" 2>&1`
+        fi
+	# Put the nasty error message in config.log where it belongs
+	echo "$LLUA_PKG_ERRORS" >&5
+
+	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+                found_lua="no"
+elif test $pkg_failed = untried; then
+	found_lua="no"
+else
+	LLUA_CFLAGS=$pkg_cv_LLUA_CFLAGS
+	LLUA_LIBS=$pkg_cv_LLUA_LIBS
+        { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+	LUA_INCDIR=$LLUA_CPPFLAGS
+			 LUA_LIBDIR=$LLUA_LIBS
+			 LUA_LIBS="-llua"
+fi
+	else
+		{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for Lua support" >&5
+$as_echo_n "checking for Lua support... " >&6; }
+		if test -f $_liblua_with/include/lua.h; then
+			LUA_INCDIR=-I$_liblua_with/include
+			LUA_LIBDIR=-L$_liblua_with/lib
+			LUA_LIBS="-llua"
+			{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+		else
+			found_lua="no"
+			{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+		fi
+	fi
+
+	if test "x$found_lua" != "xno"; then
+
+		LUA_CPPFLAGS="$LUA_INCDIR"
+		LUA_LDFLAGS="$LUA_LIBDIR"
+
+		found_lua="yes"
+
+$as_echo "#define HAVE_LUA 1" >>confdefs.h
+
+	fi
+fi
+
+
+
+
+
+unset _liblua_with
+
+	if test "x$want_lua" = "xyes"; then
+		if test "x$found_lua" != "xyes"; then
+			as_fn_error "Lua library not found" "$LINENO" 5
+		else
+			have_lua="yes"
+		fi
+	fi
+
+        CFLAGS="${CFLAGS} ${LUA_CPPFLAGS}"
+	SERVER_LDFLAGS="${SERVER_LDFLAGS} ${LUA_LDFLAGS}"
+	SERVER_LIBS="${SERVER_LIBS} ${LUA_LIBS}"
+
+
+
+
 # Check whether --with-jabber was given.
 if test "${with_jabber+set}" = set; then :
   withval=$with_jabber;
@@ -8211,11 +8366,10 @@
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for IKSEMEL" >&5
 $as_echo_n "checking for IKSEMEL... " >&6; }
 
-if test -n "$PKG_CONFIG"; then
-    if test -n "$IKSEMEL_CFLAGS"; then
-        pkg_cv_IKSEMEL_CFLAGS="$IKSEMEL_CFLAGS"
-    else
-        if test -n "$PKG_CONFIG" && \
+if test -n "$IKSEMEL_CFLAGS"; then
+    pkg_cv_IKSEMEL_CFLAGS="$IKSEMEL_CFLAGS"
+ elif test -n "$PKG_CONFIG"; then
+    if test -n "$PKG_CONFIG" && \
     { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"iksemel\""; } >&5
   ($PKG_CONFIG --exists --print-errors "iksemel") 2>&5
   ac_status=$?
@@ -8225,15 +8379,13 @@
 else
   pkg_failed=yes
 fi
-    fi
-else
-	pkg_failed=untried
+ else
+    pkg_failed=untried
 fi
-if test -n "$PKG_CONFIG"; then
-    if test -n "$IKSEMEL_LIBS"; then
-        pkg_cv_IKSEMEL_LIBS="$IKSEMEL_LIBS"
-    else
-        if test -n "$PKG_CONFIG" && \
+if test -n "$IKSEMEL_LIBS"; then
+    pkg_cv_IKSEMEL_LIBS="$IKSEMEL_LIBS"
+ elif test -n "$PKG_CONFIG"; then
+    if test -n "$PKG_CONFIG" && \
     { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"iksemel\""; } >&5
   ($PKG_CONFIG --exists --print-errors "iksemel") 2>&5
   ac_status=$?
@@ -8243,9 +8395,8 @@
 else
   pkg_failed=yes
 fi
-    fi
-else
-	pkg_failed=untried
+ else
+    pkg_failed=untried
 fi
 
 
@@ -8258,9 +8409,9 @@
         _pkg_short_errors_supported=no
 fi
         if test $_pkg_short_errors_supported = yes; then
-	        IKSEMEL_PKG_ERRORS=`$PKG_CONFIG --short-errors --errors-to-stdout --print-errors "iksemel"`
+	        IKSEMEL_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "iksemel" 2>&1`
         else
-	        IKSEMEL_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "iksemel"`
+	        IKSEMEL_PKG_ERRORS=`$PKG_CONFIG --print-errors "iksemel" 2>&1`
         fi
 	# Put the nasty error message in config.log where it belongs
 	echo "$IKSEMEL_PKG_ERRORS" >&5
@@ -9967,6 +10118,14 @@
   JABBER_FALSE=
 fi
 
+ if test "x$found_lua" = "xyes"; then
+  LUA_TRUE=
+  LUA_FALSE='#'
+else
+  LUA_TRUE='#'
+  LUA_FALSE=
+fi
+
  if test "x$have_odbc" != "xno"; then
   WITH_ODBC_TRUE=
   WITH_ODBC_FALSE='#'
@@ -10439,7 +10598,7 @@
 
 
 
-ac_config_files="$ac_config_files Makefile create/Makefile misc/Makefile src/Makefile src/libs/Makefile src/libs/zbxlog/Makefile src/libs/zbxalgo/Makefile src/libs/zbxmemory/Makefile src/libs/zbxcrypto/Makefile src/libs/zbxconf/Makefile src/libs/zbxdbcache/Makefile src/libs/zbxdbhigh/Makefile src/libs/zbxmedia/Makefile src/libs/zbxsysinfo/Makefile src/libs/zbxcommon/Makefile src/libs/zbxsysinfo/common/Makefile src/libs/zbxsysinfo/simple/Makefile src/libs/zbxsysinfo/linux/Makefile src/libs/zbxsysinfo/aix/Makefile src/libs/zbxsysinfo/freebsd/Makefile src/libs/zbxsysinfo/hpux/Makefile src/libs/zbxsysinfo/openbsd/Makefile src/libs/zbxsysinfo/osx/Makefile src/libs/zbxsysinfo/solaris/Makefile src/libs/zbxsysinfo/osf/Makefile src/libs/zbxsysinfo/netbsd/Makefile src/libs/zbxsysinfo/unknown/Makefile src/libs/zbxnix/Makefile src/libs/zbxsys/Makefile src/libs/zbxcomms/Makefile src/libs/zbxcommshigh/Makefile src/libs/zbxdb/Makefile src/libs/zbxjson/Makefile src/libs/zbxserver/Makefile src/libs/zbxicmpping/Makefile src/libs/zbxexec/Makefile src/libs/zbxself/Makefile src/zabbix_agent/Makefile src/zabbix_get/Makefile src/zabbix_sender/Makefile src/zabbix_server/Makefile src/zabbix_server/alerter/Makefile src/zabbix_server/dbsyncer/Makefile src/zabbix_server/dbconfig/Makefile src/zabbix_server/discoverer/Makefile src/zabbix_server/housekeeper/Makefile src/zabbix_server/httppoller/Makefile src/zabbix_server/nodewatcher/Makefile src/zabbix_server/pinger/Makefile src/zabbix_server/poller/Makefile src/zabbix_server/timer/Makefile src/zabbix_server/trapper/Makefile src/zabbix_server/utils/Makefile src/zabbix_server/watchdog/Makefile src/zabbix_server/escalator/Makefile src/zabbix_server/proxypoller/Makefile src/zabbix_server/selfmon/Makefile src/zabbix_proxy/Makefile src/zabbix_proxy/heart/Makefile src/zabbix_proxy/housekeeper/Makefile src/zabbix_proxy/proxyconfig/Makefile src/zabbix_proxy/datasender/Makefile upgrades/Makefile man/Makefile"
+ac_config_files="$ac_config_files Makefile create/Makefile misc/Makefile src/Makefile src/libs/Makefile src/libs/zbxlog/Makefile src/libs/zbxalgo/Makefile src/libs/zbxmemory/Makefile src/libs/zbxcrypto/Makefile src/libs/zbxconf/Makefile src/libs/zbxdbcache/Makefile src/libs/zbxdbhigh/Makefile src/libs/zbxmedia/Makefile src/libs/zbxsysinfo/Makefile src/libs/zbxcommon/Makefile src/libs/zbxsysinfo/common/Makefile src/libs/zbxsysinfo/simple/Makefile src/libs/zbxsysinfo/linux/Makefile src/libs/zbxsysinfo/aix/Makefile src/libs/zbxsysinfo/freebsd/Makefile src/libs/zbxsysinfo/hpux/Makefile src/libs/zbxsysinfo/openbsd/Makefile src/libs/zbxsysinfo/osx/Makefile src/libs/zbxsysinfo/solaris/Makefile src/libs/zbxsysinfo/osf/Makefile src/libs/zbxsysinfo/netbsd/Makefile src/libs/zbxsysinfo/unknown/Makefile src/libs/zbxnix/Makefile src/libs/zbxsys/Makefile src/libs/zbxcomms/Makefile src/libs/zbxcommshigh/Makefile src/libs/zbxdb/Makefile src/libs/zbxjson/Makefile src/libs/zbxserver/Makefile src/libs/zbxicmpping/Makefile src/libs/zbxexec/Makefile src/libs/zbxself/Makefile src/libs/zbxlua/Makefile src/zabbix_agent/Makefile src/zabbix_get/Makefile src/zabbix_sender/Makefile src/zabbix_server/Makefile src/zabbix_server/alerter/Makefile src/zabbix_server/dbsyncer/Makefile src/zabbix_server/dbconfig/Makefile src/zabbix_server/discoverer/Makefile src/zabbix_server/housekeeper/Makefile src/zabbix_server/httppoller/Makefile src/zabbix_server/nodewatcher/Makefile src/zabbix_server/pinger/Makefile src/zabbix_server/poller/Makefile src/zabbix_server/timer/Makefile src/zabbix_server/trapper/Makefile src/zabbix_server/utils/Makefile src/zabbix_server/watchdog/Makefile src/zabbix_server/escalator/Makefile src/zabbix_server/proxypoller/Makefile src/zabbix_server/selfmon/Makefile src/zabbix_proxy/Makefile src/zabbix_proxy/heart/Makefile src/zabbix_proxy/housekeeper/Makefile src/zabbix_proxy/proxyconfig/Makefile src/zabbix_proxy/datasender/Makefile upgrades/Makefile man/Makefile"
 
 cat >confcache <<\_ACEOF
 # This file is a shell script that caches the results of configure
@@ -10570,6 +10729,10 @@
   as_fn_error "conditional \"JABBER\" was never defined.
 Usually this means the macro was only invoked conditionally." "$LINENO" 5
 fi
+if test -z "${LUA_TRUE}" && test -z "${LUA_FALSE}"; then
+  as_fn_error "conditional \"LUA\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
 if test -z "${WITH_ODBC_TRUE}" && test -z "${WITH_ODBC_FALSE}"; then
   as_fn_error "conditional \"WITH_ODBC\" was never defined.
 Usually this means the macro was only invoked conditionally." "$LINENO" 5
@@ -11210,6 +11373,7 @@
     "src/libs/zbxicmpping/Makefile") CONFIG_FILES="$CONFIG_FILES src/libs/zbxicmpping/Makefile" ;;
     "src/libs/zbxexec/Makefile") CONFIG_FILES="$CONFIG_FILES src/libs/zbxexec/Makefile" ;;
     "src/libs/zbxself/Makefile") CONFIG_FILES="$CONFIG_FILES src/libs/zbxself/Makefile" ;;
+    "src/libs/zbxlua/Makefile") CONFIG_FILES="$CONFIG_FILES src/libs/zbxlua/Makefile" ;;
     "src/zabbix_agent/Makefile") CONFIG_FILES="$CONFIG_FILES src/zabbix_agent/Makefile" ;;
     "src/zabbix_get/Makefile") CONFIG_FILES="$CONFIG_FILES src/zabbix_get/Makefile" ;;
     "src/zabbix_sender/Makefile") CONFIG_FILES="$CONFIG_FILES src/zabbix_sender/Makefile" ;;
@@ -11974,6 +12138,7 @@
     With database:         ${have_db}
     WEB Monitoring via:    ${have_web_monitoring}
     Native Jabber:         ${have_jabber}
+    Lua support:           ${have_lua}
     SNMP:                  ${have_snmp}
     IPMI:                  ${have_ipmi}
     SSH:                   ${have_ssh2}
Index: Makefile.in
===================================================================
--- Makefile.in	(revision 302)
+++ Makefile.in	(working copy)
@@ -48,9 +48,9 @@
 	$(top_srcdir)/m4/jabber.m4 $(top_srcdir)/m4/ldap.m4 \
 	$(top_srcdir)/m4/libcurl.m4 $(top_srcdir)/m4/libiodbc.m4 \
 	$(top_srcdir)/m4/libssh2.m4 $(top_srcdir)/m4/libunixodbc.m4 \
-	$(top_srcdir)/m4/netsnmp.m4 $(top_srcdir)/m4/openipmi.m4 \
-	$(top_srcdir)/m4/resolv.m4 $(top_srcdir)/m4/ucdsnmp.m4 \
-	$(top_srcdir)/configure.in
+	$(top_srcdir)/m4/lua.m4 $(top_srcdir)/m4/netsnmp.m4 \
+	$(top_srcdir)/m4/openipmi.m4 $(top_srcdir)/m4/resolv.m4 \
+	$(top_srcdir)/m4/ucdsnmp.m4 $(top_srcdir)/configure.in
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
@@ -159,7 +159,12 @@
 LIBCURL_LIBS = @LIBCURL_LIBS@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
+LLUA_CFLAGS = @LLUA_CFLAGS@
+LLUA_LIBS = @LLUA_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LUA_CPPFLAGS = @LUA_CPPFLAGS@
+LUA_LDFLAGS = @LUA_LDFLAGS@
+LUA_LIBS = @LUA_LIBS@
 MAKEINFO = @MAKEINFO@
 MKDIR_P = @MKDIR_P@
 MYSQL_CFLAGS = @MYSQL_CFLAGS@
Index: include/zbxlua.h
===================================================================
--- include/zbxlua.h	(revision 0)
+++ include/zbxlua.h	(revision 306)
@@ -0,0 +1,18 @@
+#ifndef ZABBIX_ZBX_LUA_H
+#define ZABBIX_ZBX_LUA_H
+
+#include "dbcache.h"
+#include "zbxtypes.h"
+
+int execute_lua(lua_State* L,char* params,DC_ITEM *item);
+lua_State *init_lua_env();
+
+#ifdef HAVE___VA_ARGS__
+#	define lua_error(L, fmt, ...) __lua_error(L, ZBX_CONST_STRING(fmt), ##__VA_ARGS__)
+#else
+#	define zbx_error __zbx_zbx_error
+#endif /* HAVE___VA_ARGS__ */
+
+void __lua_error(lua_State *L,const char *fmt, ...);
+
+#endif
Index: include/lua_cfg.h
===================================================================
--- include/lua_cfg.h	(revision 0)
+++ include/lua_cfg.h	(revision 305)
@@ -0,0 +1,8 @@
+#ifndef ZABBIX_LUA_CFG_H
+#define ZABBIX_LUA_CFG_H
+
+extern char *CONFIG_LUA_SCRIPT_LIBRARY;
+extern char CONFIG_LUA_CHECK_PERMISSIONS;
+extern char *CONFIG_LUA_DEFAULT_USER;
+
+#endif
\ No newline at end of file
Index: include/dbcache.h
===================================================================
--- include/dbcache.h	(revision 302)
+++ include/dbcache.h	(working copy)
@@ -34,7 +34,8 @@
 #define	ZBX_POLLER_TYPE_UNREACHABLE	1
 #define	ZBX_POLLER_TYPE_IPMI		2
 #define	ZBX_POLLER_TYPE_PINGER		3
-#define	ZBX_POLLER_TYPE_COUNT		4	/* number of poller types */
+#define ZBX_POLLER_TYPE_LUA  4
+#define	ZBX_POLLER_TYPE_COUNT		5	/* number of poller types */
 
 extern char	*CONFIG_FILE;
 extern int	CONFIG_TIMEOUT;
@@ -53,6 +54,7 @@
 extern int	CONFIG_HISTSYNCER_FORKS;
 extern int	CONFIG_PROXYCONFIG_FREQUENCY;
 extern int	CONFIG_PROXYDATA_FREQUENCY;
+extern int	CONFIG_LUA_POLLER_FORKS;
 
 DC_HOST
 {
Index: include/config.h.in
===================================================================
--- include/config.h.in	(revision 302)
+++ include/config.h.in	(working copy)
@@ -168,6 +168,9 @@
 /* Define to 1 if format '%qu' exists. */
 #undef HAVE_LONG_LONG_QU
 
+/* Define to 1 if Lua library should be enabled. */
+#undef HAVE_LUA
+
 /* Define to 1 if you have the <mach/host_info.h> header file. */
 #undef HAVE_MACH_HOST_INFO_H
 
Index: include/zbxself.h
===================================================================
--- include/zbxself.h	(revision 302)
+++ include/zbxself.h	(working copy)
@@ -47,7 +47,8 @@
 #define ZBX_PROCESS_TYPE_CONFSYNCER	16
 #define ZBX_PROCESS_TYPE_HEARTBEAT	17
 #define ZBX_PROCESS_TYPE_SELFMON	18
-#define ZBX_PROCESS_TYPE_COUNT		19	/* number of process types */
+#define ZBX_PROCESS_TYPE_LUA		19
+#define ZBX_PROCESS_TYPE_COUNT		20	/* number of process types */
 #define ZBX_PROCESS_TYPE_UNKNOWN	255
 
 #define ZBX_AGGR_FUNC_ONE		0
Index: include/common.h
===================================================================
--- include/common.h	(revision 302)
+++ include/common.h	(working copy)
@@ -119,7 +119,7 @@
 #define	APPLICATION_NAME	"Zabbix Agent"
 #define	ZABBIX_REVDATE		"15 April 2011"
 #define	ZABBIX_VERSION		"1.8.5"
-#define	ZABBIX_REVISION		"19050"
+#define	ZABBIX_REVISION		"19050-lua"
 
 #if defined(_WINDOWS)
 #define	ZBX_SERVICE_NAME_LEN	64
@@ -175,7 +175,8 @@
 	ITEM_TYPE_IPMI,
 	ITEM_TYPE_SSH,
 	ITEM_TYPE_TELNET,
-	ITEM_TYPE_CALCULATED
+	ITEM_TYPE_CALCULATED,
+  ITEM_TYPE_LUA
 } zbx_item_type_t;
 
 typedef enum
Index: include/zbx_lua_types.h
===================================================================
--- include/zbx_lua_types.h	(revision 0)
+++ include/zbx_lua_types.h	(revision 305)
@@ -0,0 +1,14 @@
+#ifndef ZBX_LUA_TYPES_H
+#define ZBX_LUA_TYPES_H
+
+#include <lua.h>
+#include "common.h"
+#include "zbxtypes.h"
+
+int is_lua_uint64(lua_State *L, int index);
+zbx_uint64_t checkuint64(lua_State* L, int index);
+int create_uint64(lua_State* L, zbx_uint64_t val);
+int uint64_tostring (lua_State* L);
+
+int luaopen_uint64 (lua_State* L);
+#endif
\ No newline at end of file
Index: configure.in
===================================================================
--- configure.in	(revision 302)
+++ configure.in	(working copy)
@@ -1074,6 +1074,21 @@
 	
 	PROXY_LDFLAGS="${PROXY_LDFLAGS} ${DB_LDFLAGS}"
 	PROXY_LIBS="${PROXY_LIBS} ${DB_LIBS}"
+
+	dnl Checking for Lua
+	LUA_CHECK_CONFIG()
+	if test "x$want_lua" = "xyes"; then
+		if test "x$found_lua" != "xyes"; then
+			AC_MSG_ERROR([Lua library not found])
+		else
+			have_lua="yes"
+		fi
+	fi
+
+        CFLAGS="${CFLAGS} ${LUA_CPPFLAGS}"
+	SERVER_LDFLAGS="${SERVER_LDFLAGS} ${LUA_LDFLAGS}"
+	SERVER_LIBS="${SERVER_LIBS} ${LUA_LIBS}"
+
 	
 	dnl Checking for Jabber libraries
 	JABBER_CHECK_CONFIG()
@@ -1234,6 +1249,7 @@
 fi
 
 AM_CONDITIONAL(JABBER,  test "x$found_jabber" = "xyes")
+AM_CONDITIONAL(LUA, test "x$found_lua" = "xyes")
 AM_CONDITIONAL(WITH_ODBC, test "x$have_odbc" != "xno")
 
 found_ldap="no"
@@ -1398,6 +1414,7 @@
 	src/libs/zbxicmpping/Makefile
 	src/libs/zbxexec/Makefile
 	src/libs/zbxself/Makefile
+	src/libs/zbxlua/Makefile
 	src/zabbix_agent/Makefile
 	src/zabbix_get/Makefile
 	src/zabbix_sender/Makefile
@@ -1446,6 +1463,7 @@
     With database:         ${have_db}
     WEB Monitoring via:    ${have_web_monitoring}
     Native Jabber:         ${have_jabber}
+    Lua support:           ${have_lua}
     SNMP:                  ${have_snmp}
     IPMI:                  ${have_ipmi}
     SSH:                   ${have_ssh2}
Index: bootstrap.sh
===================================================================
--- bootstrap.sh	(revision 0)
+++ bootstrap.sh	(revision 305)
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+# Run this script to generate 'configure'
+
+aclocal -I m4
+autoconf
+autoheader
+automake -a
+automake
Index: src/zabbix_sender/Makefile.in
===================================================================
--- src/zabbix_sender/Makefile.in	(revision 302)
+++ src/zabbix_sender/Makefile.in	(working copy)
@@ -46,9 +46,9 @@
 	$(top_srcdir)/m4/jabber.m4 $(top_srcdir)/m4/ldap.m4 \
 	$(top_srcdir)/m4/libcurl.m4 $(top_srcdir)/m4/libiodbc.m4 \
 	$(top_srcdir)/m4/libssh2.m4 $(top_srcdir)/m4/libunixodbc.m4 \
-	$(top_srcdir)/m4/netsnmp.m4 $(top_srcdir)/m4/openipmi.m4 \
-	$(top_srcdir)/m4/resolv.m4 $(top_srcdir)/m4/ucdsnmp.m4 \
-	$(top_srcdir)/configure.in
+	$(top_srcdir)/m4/lua.m4 $(top_srcdir)/m4/netsnmp.m4 \
+	$(top_srcdir)/m4/openipmi.m4 $(top_srcdir)/m4/resolv.m4 \
+	$(top_srcdir)/m4/ucdsnmp.m4 $(top_srcdir)/configure.in
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 mkinstalldirs = $(install_sh) -d
@@ -127,7 +127,12 @@
 LIBCURL_LIBS = @LIBCURL_LIBS@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
+LLUA_CFLAGS = @LLUA_CFLAGS@
+LLUA_LIBS = @LLUA_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LUA_CPPFLAGS = @LUA_CPPFLAGS@
+LUA_LDFLAGS = @LUA_LDFLAGS@
+LUA_LIBS = @LUA_LIBS@
 MAKEINFO = @MAKEINFO@
 MKDIR_P = @MKDIR_P@
 MYSQL_CFLAGS = @MYSQL_CFLAGS@
Index: src/zabbix_proxy/housekeeper/Makefile.in
===================================================================
--- src/zabbix_proxy/housekeeper/Makefile.in	(revision 302)
+++ src/zabbix_proxy/housekeeper/Makefile.in	(working copy)
@@ -45,9 +45,9 @@
 	$(top_srcdir)/m4/jabber.m4 $(top_srcdir)/m4/ldap.m4 \
 	$(top_srcdir)/m4/libcurl.m4 $(top_srcdir)/m4/libiodbc.m4 \
 	$(top_srcdir)/m4/libssh2.m4 $(top_srcdir)/m4/libunixodbc.m4 \
-	$(top_srcdir)/m4/netsnmp.m4 $(top_srcdir)/m4/openipmi.m4 \
-	$(top_srcdir)/m4/resolv.m4 $(top_srcdir)/m4/ucdsnmp.m4 \
-	$(top_srcdir)/configure.in
+	$(top_srcdir)/m4/lua.m4 $(top_srcdir)/m4/netsnmp.m4 \
+	$(top_srcdir)/m4/openipmi.m4 $(top_srcdir)/m4/resolv.m4 \
+	$(top_srcdir)/m4/ucdsnmp.m4 $(top_srcdir)/configure.in
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 mkinstalldirs = $(install_sh) -d
@@ -121,7 +121,12 @@
 LIBCURL_LIBS = @LIBCURL_LIBS@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
+LLUA_CFLAGS = @LLUA_CFLAGS@
+LLUA_LIBS = @LLUA_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LUA_CPPFLAGS = @LUA_CPPFLAGS@
+LUA_LDFLAGS = @LUA_LDFLAGS@
+LUA_LIBS = @LUA_LIBS@
 MAKEINFO = @MAKEINFO@
 MKDIR_P = @MKDIR_P@
 MYSQL_CFLAGS = @MYSQL_CFLAGS@
Index: src/zabbix_proxy/Makefile.in
===================================================================
--- src/zabbix_proxy/Makefile.in	(revision 302)
+++ src/zabbix_proxy/Makefile.in	(working copy)
@@ -46,9 +46,9 @@
 	$(top_srcdir)/m4/jabber.m4 $(top_srcdir)/m4/ldap.m4 \
 	$(top_srcdir)/m4/libcurl.m4 $(top_srcdir)/m4/libiodbc.m4 \
 	$(top_srcdir)/m4/libssh2.m4 $(top_srcdir)/m4/libunixodbc.m4 \
-	$(top_srcdir)/m4/netsnmp.m4 $(top_srcdir)/m4/openipmi.m4 \
-	$(top_srcdir)/m4/resolv.m4 $(top_srcdir)/m4/ucdsnmp.m4 \
-	$(top_srcdir)/configure.in
+	$(top_srcdir)/m4/lua.m4 $(top_srcdir)/m4/netsnmp.m4 \
+	$(top_srcdir)/m4/openipmi.m4 $(top_srcdir)/m4/resolv.m4 \
+	$(top_srcdir)/m4/ucdsnmp.m4 $(top_srcdir)/configure.in
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 mkinstalldirs = $(install_sh) -d
@@ -195,7 +195,12 @@
 LIBCURL_LIBS = @LIBCURL_LIBS@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
+LLUA_CFLAGS = @LLUA_CFLAGS@
+LLUA_LIBS = @LLUA_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LUA_CPPFLAGS = @LUA_CPPFLAGS@
+LUA_LDFLAGS = @LUA_LDFLAGS@
+LUA_LIBS = @LUA_LIBS@
 MAKEINFO = @MAKEINFO@
 MKDIR_P = @MKDIR_P@
 MYSQL_CFLAGS = @MYSQL_CFLAGS@
Index: src/zabbix_proxy/heart/Makefile.in
===================================================================
--- src/zabbix_proxy/heart/Makefile.in	(revision 302)
+++ src/zabbix_proxy/heart/Makefile.in	(working copy)
@@ -45,9 +45,9 @@
 	$(top_srcdir)/m4/jabber.m4 $(top_srcdir)/m4/ldap.m4 \
 	$(top_srcdir)/m4/libcurl.m4 $(top_srcdir)/m4/libiodbc.m4 \
 	$(top_srcdir)/m4/libssh2.m4 $(top_srcdir)/m4/libunixodbc.m4 \
-	$(top_srcdir)/m4/netsnmp.m4 $(top_srcdir)/m4/openipmi.m4 \
-	$(top_srcdir)/m4/resolv.m4 $(top_srcdir)/m4/ucdsnmp.m4 \
-	$(top_srcdir)/configure.in
+	$(top_srcdir)/m4/lua.m4 $(top_srcdir)/m4/netsnmp.m4 \
+	$(top_srcdir)/m4/openipmi.m4 $(top_srcdir)/m4/resolv.m4 \
+	$(top_srcdir)/m4/ucdsnmp.m4 $(top_srcdir)/configure.in
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 mkinstalldirs = $(install_sh) -d
@@ -121,7 +121,12 @@
 LIBCURL_LIBS = @LIBCURL_LIBS@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
+LLUA_CFLAGS = @LLUA_CFLAGS@
+LLUA_LIBS = @LLUA_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LUA_CPPFLAGS = @LUA_CPPFLAGS@
+LUA_LDFLAGS = @LUA_LDFLAGS@
+LUA_LIBS = @LUA_LIBS@
 MAKEINFO = @MAKEINFO@
 MKDIR_P = @MKDIR_P@
 MYSQL_CFLAGS = @MYSQL_CFLAGS@
Index: src/zabbix_proxy/proxyconfig/Makefile.in
===================================================================
--- src/zabbix_proxy/proxyconfig/Makefile.in	(revision 302)
+++ src/zabbix_proxy/proxyconfig/Makefile.in	(working copy)
@@ -45,9 +45,9 @@
 	$(top_srcdir)/m4/jabber.m4 $(top_srcdir)/m4/ldap.m4 \
 	$(top_srcdir)/m4/libcurl.m4 $(top_srcdir)/m4/libiodbc.m4 \
 	$(top_srcdir)/m4/libssh2.m4 $(top_srcdir)/m4/libunixodbc.m4 \
-	$(top_srcdir)/m4/netsnmp.m4 $(top_srcdir)/m4/openipmi.m4 \
-	$(top_srcdir)/m4/resolv.m4 $(top_srcdir)/m4/ucdsnmp.m4 \
-	$(top_srcdir)/configure.in
+	$(top_srcdir)/m4/lua.m4 $(top_srcdir)/m4/netsnmp.m4 \
+	$(top_srcdir)/m4/openipmi.m4 $(top_srcdir)/m4/resolv.m4 \
+	$(top_srcdir)/m4/ucdsnmp.m4 $(top_srcdir)/configure.in
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 mkinstalldirs = $(install_sh) -d
@@ -121,7 +121,12 @@
 LIBCURL_LIBS = @LIBCURL_LIBS@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
+LLUA_CFLAGS = @LLUA_CFLAGS@
+LLUA_LIBS = @LLUA_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LUA_CPPFLAGS = @LUA_CPPFLAGS@
+LUA_LDFLAGS = @LUA_LDFLAGS@
+LUA_LIBS = @LUA_LIBS@
 MAKEINFO = @MAKEINFO@
 MKDIR_P = @MKDIR_P@
 MYSQL_CFLAGS = @MYSQL_CFLAGS@
Index: src/zabbix_proxy/datasender/Makefile.in
===================================================================
--- src/zabbix_proxy/datasender/Makefile.in	(revision 302)
+++ src/zabbix_proxy/datasender/Makefile.in	(working copy)
@@ -45,9 +45,9 @@
 	$(top_srcdir)/m4/jabber.m4 $(top_srcdir)/m4/ldap.m4 \
 	$(top_srcdir)/m4/libcurl.m4 $(top_srcdir)/m4/libiodbc.m4 \
 	$(top_srcdir)/m4/libssh2.m4 $(top_srcdir)/m4/libunixodbc.m4 \
-	$(top_srcdir)/m4/netsnmp.m4 $(top_srcdir)/m4/openipmi.m4 \
-	$(top_srcdir)/m4/resolv.m4 $(top_srcdir)/m4/ucdsnmp.m4 \
-	$(top_srcdir)/configure.in
+	$(top_srcdir)/m4/lua.m4 $(top_srcdir)/m4/netsnmp.m4 \
+	$(top_srcdir)/m4/openipmi.m4 $(top_srcdir)/m4/resolv.m4 \
+	$(top_srcdir)/m4/ucdsnmp.m4 $(top_srcdir)/configure.in
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 mkinstalldirs = $(install_sh) -d
@@ -121,7 +121,12 @@
 LIBCURL_LIBS = @LIBCURL_LIBS@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
+LLUA_CFLAGS = @LLUA_CFLAGS@
+LLUA_LIBS = @LLUA_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LUA_CPPFLAGS = @LUA_CPPFLAGS@
+LUA_LDFLAGS = @LUA_LDFLAGS@
+LUA_LIBS = @LUA_LIBS@
 MAKEINFO = @MAKEINFO@
 MKDIR_P = @MKDIR_P@
 MYSQL_CFLAGS = @MYSQL_CFLAGS@
Index: src/Makefile.in
===================================================================
--- src/Makefile.in	(revision 302)
+++ src/Makefile.in	(working copy)
@@ -44,9 +44,9 @@
 	$(top_srcdir)/m4/jabber.m4 $(top_srcdir)/m4/ldap.m4 \
 	$(top_srcdir)/m4/libcurl.m4 $(top_srcdir)/m4/libiodbc.m4 \
 	$(top_srcdir)/m4/libssh2.m4 $(top_srcdir)/m4/libunixodbc.m4 \
-	$(top_srcdir)/m4/netsnmp.m4 $(top_srcdir)/m4/openipmi.m4 \
-	$(top_srcdir)/m4/resolv.m4 $(top_srcdir)/m4/ucdsnmp.m4 \
-	$(top_srcdir)/configure.in
+	$(top_srcdir)/m4/lua.m4 $(top_srcdir)/m4/netsnmp.m4 \
+	$(top_srcdir)/m4/openipmi.m4 $(top_srcdir)/m4/resolv.m4 \
+	$(top_srcdir)/m4/ucdsnmp.m4 $(top_srcdir)/configure.in
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 mkinstalldirs = $(install_sh) -d
@@ -142,7 +142,12 @@
 LIBCURL_LIBS = @LIBCURL_LIBS@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
+LLUA_CFLAGS = @LLUA_CFLAGS@
+LLUA_LIBS = @LLUA_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LUA_CPPFLAGS = @LUA_CPPFLAGS@
+LUA_LDFLAGS = @LUA_LDFLAGS@
+LUA_LIBS = @LUA_LIBS@
 MAKEINFO = @MAKEINFO@
 MKDIR_P = @MKDIR_P@
 MYSQL_CFLAGS = @MYSQL_CFLAGS@
Index: src/zabbix_server/housekeeper/Makefile.in
===================================================================
--- src/zabbix_server/housekeeper/Makefile.in	(revision 302)
+++ src/zabbix_server/housekeeper/Makefile.in	(working copy)
@@ -45,9 +45,9 @@
 	$(top_srcdir)/m4/jabber.m4 $(top_srcdir)/m4/ldap.m4 \
 	$(top_srcdir)/m4/libcurl.m4 $(top_srcdir)/m4/libiodbc.m4 \
 	$(top_srcdir)/m4/libssh2.m4 $(top_srcdir)/m4/libunixodbc.m4 \
-	$(top_srcdir)/m4/netsnmp.m4 $(top_srcdir)/m4/openipmi.m4 \
-	$(top_srcdir)/m4/resolv.m4 $(top_srcdir)/m4/ucdsnmp.m4 \
-	$(top_srcdir)/configure.in
+	$(top_srcdir)/m4/lua.m4 $(top_srcdir)/m4/netsnmp.m4 \
+	$(top_srcdir)/m4/openipmi.m4 $(top_srcdir)/m4/resolv.m4 \
+	$(top_srcdir)/m4/ucdsnmp.m4 $(top_srcdir)/configure.in
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 mkinstalldirs = $(install_sh) -d
@@ -121,7 +121,12 @@
 LIBCURL_LIBS = @LIBCURL_LIBS@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
+LLUA_CFLAGS = @LLUA_CFLAGS@
+LLUA_LIBS = @LLUA_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LUA_CPPFLAGS = @LUA_CPPFLAGS@
+LUA_LDFLAGS = @LUA_LDFLAGS@
+LUA_LIBS = @LUA_LIBS@
 MAKEINFO = @MAKEINFO@
 MKDIR_P = @MKDIR_P@
 MYSQL_CFLAGS = @MYSQL_CFLAGS@
Index: src/zabbix_server/timer/Makefile.in
===================================================================
--- src/zabbix_server/timer/Makefile.in	(revision 302)
+++ src/zabbix_server/timer/Makefile.in	(working copy)
@@ -45,9 +45,9 @@
 	$(top_srcdir)/m4/jabber.m4 $(top_srcdir)/m4/ldap.m4 \
 	$(top_srcdir)/m4/libcurl.m4 $(top_srcdir)/m4/libiodbc.m4 \
 	$(top_srcdir)/m4/libssh2.m4 $(top_srcdir)/m4/libunixodbc.m4 \
-	$(top_srcdir)/m4/netsnmp.m4 $(top_srcdir)/m4/openipmi.m4 \
-	$(top_srcdir)/m4/resolv.m4 $(top_srcdir)/m4/ucdsnmp.m4 \
-	$(top_srcdir)/configure.in
+	$(top_srcdir)/m4/lua.m4 $(top_srcdir)/m4/netsnmp.m4 \
+	$(top_srcdir)/m4/openipmi.m4 $(top_srcdir)/m4/resolv.m4 \
+	$(top_srcdir)/m4/ucdsnmp.m4 $(top_srcdir)/configure.in
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 mkinstalldirs = $(install_sh) -d
@@ -121,7 +121,12 @@
 LIBCURL_LIBS = @LIBCURL_LIBS@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
+LLUA_CFLAGS = @LLUA_CFLAGS@
+LLUA_LIBS = @LLUA_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LUA_CPPFLAGS = @LUA_CPPFLAGS@
+LUA_LDFLAGS = @LUA_LDFLAGS@
+LUA_LIBS = @LUA_LIBS@
 MAKEINFO = @MAKEINFO@
 MKDIR_P = @MKDIR_P@
 MYSQL_CFLAGS = @MYSQL_CFLAGS@
Index: src/zabbix_server/Makefile.in
===================================================================
--- src/zabbix_server/Makefile.in	(revision 302)
+++ src/zabbix_server/Makefile.in	(working copy)
@@ -46,9 +46,9 @@
 	$(top_srcdir)/m4/jabber.m4 $(top_srcdir)/m4/ldap.m4 \
 	$(top_srcdir)/m4/libcurl.m4 $(top_srcdir)/m4/libiodbc.m4 \
 	$(top_srcdir)/m4/libssh2.m4 $(top_srcdir)/m4/libunixodbc.m4 \
-	$(top_srcdir)/m4/netsnmp.m4 $(top_srcdir)/m4/openipmi.m4 \
-	$(top_srcdir)/m4/resolv.m4 $(top_srcdir)/m4/ucdsnmp.m4 \
-	$(top_srcdir)/configure.in
+	$(top_srcdir)/m4/lua.m4 $(top_srcdir)/m4/netsnmp.m4 \
+	$(top_srcdir)/m4/openipmi.m4 $(top_srcdir)/m4/resolv.m4 \
+	$(top_srcdir)/m4/ucdsnmp.m4 $(top_srcdir)/configure.in
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 mkinstalldirs = $(install_sh) -d
@@ -93,7 +93,8 @@
 	$(top_srcdir)/src/libs/zbxserver/libzbxserver.a \
 	$(top_srcdir)/src/libs/zbxicmpping/libzbxicmpping.a \
 	$(top_srcdir)/src/libs/zbxdbhigh/libzbxdbhigh.a \
-	$(top_srcdir)/src/libs/zbxdb/libzbxdb.a
+	$(top_srcdir)/src/libs/zbxdb/libzbxdb.a \
+	$(top_srcdir)/src/libs/zbxlua/libzbxlua.a
 zabbix_server_LINK = $(CCLD) $(zabbix_server_CFLAGS) $(CFLAGS) \
 	$(zabbix_server_LDFLAGS) $(LDFLAGS) -o $@
 DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include
@@ -194,7 +195,12 @@
 LIBCURL_LIBS = @LIBCURL_LIBS@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
+LLUA_CFLAGS = @LLUA_CFLAGS@
+LLUA_LIBS = @LLUA_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LUA_CPPFLAGS = @LUA_CPPFLAGS@
+LUA_LDFLAGS = @LUA_LDFLAGS@
+LUA_LIBS = @LUA_LIBS@
 MAKEINFO = @MAKEINFO@
 MKDIR_P = @MKDIR_P@
 MYSQL_CFLAGS = @MYSQL_CFLAGS@
@@ -370,6 +376,7 @@
 	$(top_srcdir)/src/libs/zbxicmpping/libzbxicmpping.a \
 	$(top_srcdir)/src/libs/zbxdbhigh/libzbxdbhigh.a \
 	$(top_srcdir)/src/libs/zbxdb/libzbxdb.a \
+	$(top_srcdir)/src/libs/zbxlua/libzbxlua.a \
 	@SERVER_LIBS@
 
 zabbix_server_LDFLAGS = \
Index: src/zabbix_server/pinger/Makefile.in
===================================================================
--- src/zabbix_server/pinger/Makefile.in	(revision 302)
+++ src/zabbix_server/pinger/Makefile.in	(working copy)
@@ -45,9 +45,9 @@
 	$(top_srcdir)/m4/jabber.m4 $(top_srcdir)/m4/ldap.m4 \
 	$(top_srcdir)/m4/libcurl.m4 $(top_srcdir)/m4/libiodbc.m4 \
 	$(top_srcdir)/m4/libssh2.m4 $(top_srcdir)/m4/libunixodbc.m4 \
-	$(top_srcdir)/m4/netsnmp.m4 $(top_srcdir)/m4/openipmi.m4 \
-	$(top_srcdir)/m4/resolv.m4 $(top_srcdir)/m4/ucdsnmp.m4 \
-	$(top_srcdir)/configure.in
+	$(top_srcdir)/m4/lua.m4 $(top_srcdir)/m4/netsnmp.m4 \
+	$(top_srcdir)/m4/openipmi.m4 $(top_srcdir)/m4/resolv.m4 \
+	$(top_srcdir)/m4/ucdsnmp.m4 $(top_srcdir)/configure.in
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 mkinstalldirs = $(install_sh) -d
@@ -121,7 +121,12 @@
 LIBCURL_LIBS = @LIBCURL_LIBS@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
+LLUA_CFLAGS = @LLUA_CFLAGS@
+LLUA_LIBS = @LLUA_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LUA_CPPFLAGS = @LUA_CPPFLAGS@
+LUA_LDFLAGS = @LUA_LDFLAGS@
+LUA_LIBS = @LUA_LIBS@
 MAKEINFO = @MAKEINFO@
 MKDIR_P = @MKDIR_P@
 MYSQL_CFLAGS = @MYSQL_CFLAGS@
Index: src/zabbix_server/server.c
===================================================================
--- src/zabbix_server/server.c	(revision 302)
+++ src/zabbix_server/server.c	(working copy)
@@ -26,6 +26,7 @@
 #include "log.h"
 #include "zbxgetopt.h"
 #include "mutexs.h"
+#include "lua_cfg.h"  /* needed to bind config option */
 
 #include "sysinfo.h"
 #include "zbxserver.h"
@@ -116,6 +117,7 @@
 int	CONFIG_WATCHDOG_FORKS		= 1;
 int	CONFIG_DATASENDER_FORKS		= 0;
 int	CONFIG_HEARTBEAT_FORKS		= 0;
+int CONFIG_LUA_POLLER_FORKS		= 1;
 
 int	CONFIG_LISTEN_PORT		= 10051;
 char	*CONFIG_LISTEN_IP		= NULL;
@@ -162,7 +164,11 @@
 int	CONFIG_NODE_NOHISTORY		= 0;
 
 char	*CONFIG_SSH_KEY_LOCATION	= NULL;
+char	*CONFIG_LUA_SCRIPT_LIBRARY = NULL;
+char	*CONFIG_LUA_DEFAULT_USER = NULL;
 
+char CONFIG_LUA_CHECK_PERMISSIONS = 0;
+
 int	CONFIG_LOG_SLOW_QUERIES		= 0;	/* ms; 0 - disable */
 
 /* Global variable to control if we should write warnings to log[] */
@@ -304,6 +310,15 @@
 			TYPE_INT,	PARM_OPT,	1,			SEC_PER_WEEK},
 		{"ProxyDataFrequency",		&CONFIG_PROXYDATA_FREQUENCY,		NULL,
 			TYPE_INT,	PARM_OPT,	1,			SEC_PER_HOUR},
+/* Lua Config Options */
+		{"StartLUAPollers",			&CONFIG_LUA_POLLER_FORKS,			NULL,
+			TYPE_INT,	PARM_OPT,	0,			10},
+		{"LuaScriptLibrary",		&CONFIG_LUA_SCRIPT_LIBRARY,			NULL,
+			TYPE_STRING,PARM_OPT,	0,			0},
+		{"LuaCheckPermissions",		&CONFIG_LUA_CHECK_PERMISSIONS,		NULL,
+			TYPE_INT,	PARM_OPT,	0,			0},
+		{"LuaDefaltUser",			&CONFIG_LUA_DEFAULT_USER,			NULL,
+			TYPE_STRING,PARM_OPT,	0,			0},
 		{NULL}
 	};
 
@@ -359,6 +374,11 @@
 
 	if (1 == CONFIG_DISABLE_HOUSEKEEPING)
 		CONFIG_HOUSEKEEPER_FORKS = 0;
+	
+	if (CONFIG_LUA_DEFAULT_USER == NULL)
+	{
+		CONFIG_LUA_DEFAULT_USER = strdup("guest");
+	}
 }
 
 /******************************************************************************
@@ -489,6 +509,12 @@
 #else
 #	define IPV6_FEATURE_STATUS " NO"
 #endif
+#ifdef HAVE_LUA
+#	define LUA_FEATURE_STATUS "YES"
+#else
+#	define LUA_FEATURE_STATUS " NO"
+#endif	
+	
 
 	zabbix_log(LOG_LEVEL_INFORMATION, "Starting Zabbix Server. Zabbix %s (revision %s).",
 			ZABBIX_VERSION, ZABBIX_REVISION);
@@ -499,6 +525,7 @@
 	zabbix_log(LOG_LEVEL_INFORMATION, "WEB monitoring:            " LIBCURL_FEATURE_STATUS);
 	zabbix_log(LOG_LEVEL_INFORMATION, "Jabber notifications:      " JABBER_FEATURE_STATUS);
 	zabbix_log(LOG_LEVEL_INFORMATION, "Ez Texting notifications:  " LIBCURL_FEATURE_STATUS);
+	zabbix_log(LOG_LEVEL_INFORMATION, "LUA Scripting:             " LUA_FEATURE_STATUS);
 	zabbix_log(LOG_LEVEL_INFORMATION, "ODBC:                      " ODBC_FEATURE_STATUS);
 	zabbix_log(LOG_LEVEL_INFORMATION, "SSH2 support:              " SSH2_FEATURE_STATUS);
 	zabbix_log(LOG_LEVEL_INFORMATION, "IPv6 support:              " IPV6_FEATURE_STATUS);
@@ -552,7 +579,7 @@
 			+ CONFIG_HOUSEKEEPER_FORKS + CONFIG_TIMER_FORKS + CONFIG_NODEWATCHER_FORKS
 			+ CONFIG_HTTPPOLLER_FORKS + CONFIG_DISCOVERER_FORKS + CONFIG_HISTSYNCER_FORKS
 			+ CONFIG_ESCALATOR_FORKS + CONFIG_IPMIPOLLER_FORKS + CONFIG_PROXYPOLLER_FORKS
-			+ CONFIG_SELFMON_FORKS;
+			+ CONFIG_SELFMON_FORKS + CONFIG_LUA_POLLER_FORKS;
 	threads = calloc(threads_num, sizeof(pid_t));
 
 	if (CONFIG_TRAPPER_FORKS > 0)
@@ -569,7 +596,7 @@
 			+ CONFIG_HOUSEKEEPER_FORKS + CONFIG_TIMER_FORKS + CONFIG_NODEWATCHER_FORKS
 			+ CONFIG_HTTPPOLLER_FORKS + CONFIG_DISCOVERER_FORKS + CONFIG_HISTSYNCER_FORKS
 			+ CONFIG_ESCALATOR_FORKS + CONFIG_IPMIPOLLER_FORKS + CONFIG_PROXYPOLLER_FORKS
-			+ CONFIG_SELFMON_FORKS; i++)
+			+ CONFIG_SELFMON_FORKS + CONFIG_LUA_POLLER_FORKS; i++)
 	{
 		if (0 == (pid = zbx_fork()))
 		{
@@ -870,6 +897,31 @@
 
 		main_selfmon_loop();
 	}
+	else if (server_num <= CONFIG_CONFSYNCER_FORKS + CONFIG_POLLER_FORKS
+			 + CONFIG_UNREACHABLE_POLLER_FORKS + CONFIG_TRAPPER_FORKS
+			 + CONFIG_PINGER_FORKS + CONFIG_ALERTER_FORKS
+			 + CONFIG_HOUSEKEEPER_FORKS + CONFIG_TIMER_FORKS
+			 + CONFIG_NODEWATCHER_FORKS + CONFIG_HTTPPOLLER_FORKS
+			 + CONFIG_DISCOVERER_FORKS + CONFIG_HISTSYNCER_FORKS
+			 + CONFIG_ESCALATOR_FORKS + CONFIG_IPMIPOLLER_FORKS
+			 + CONFIG_PROXYPOLLER_FORKS + CONFIG_SELFMON_FORKS
+			 + CONFIG_LUA_POLLER_FORKS)
+	{
+		process_type = ZBX_PROCESS_TYPE_LUA;
+		process_num = server_num - CONFIG_CONFSYNCER_FORKS - CONFIG_POLLER_FORKS
+		- CONFIG_UNREACHABLE_POLLER_FORKS - CONFIG_TRAPPER_FORKS
+		- CONFIG_PINGER_FORKS - CONFIG_ALERTER_FORKS
+		- CONFIG_HOUSEKEEPER_FORKS - CONFIG_TIMER_FORKS
+		- CONFIG_NODEWATCHER_FORKS - CONFIG_HTTPPOLLER_FORKS
+		- CONFIG_DISCOVERER_FORKS - CONFIG_HISTSYNCER_FORKS
+		- CONFIG_ESCALATOR_FORKS - CONFIG_IPMIPOLLER_FORKS
+		- CONFIG_PROXYPOLLER_FORKS - CONFIG_SELFMON_FORKS;
+		
+		zabbix_log(LOG_LEVEL_WARNING, "server %d started [%s]",
+				server_num, get_process_type_string(process_type));
+		
+		main_poller_loop(ZBX_PROCESS_SERVER, ZBX_POLLER_TYPE_LUA);
+	}
 
 	return SUCCEED;
 }
Index: src/zabbix_server/poller/checks_lua.c
===================================================================
--- src/zabbix_server/poller/checks_lua.c	(revision 0)
+++ src/zabbix_server/poller/checks_lua.c	(revision 309)
@@ -0,0 +1,78 @@
+#include "log.h"
+#include "common.h"
+#include "zlog.h"
+#include "dbcache.h"
+
+#include "lua.h"
+#include "zbxlua.h"
+#include "checks_lua.h"
+
+#define LUA_KEY "lua"
+
+/******************************************************************************
+ *                                                                            *
+ * Function: get_lua_item                                                     *
+ *                                                                            *
+ * Purpose: Wrapper to the execute_string function in zbxlua.                 *
+ *                                                                            *
+ * Parameters: Lua State, Pointer to information about the item               *
+ *             Pointer to the return (result)                                 *
+ *                                                                            *
+ * Return value: Success/Fail                                                 *
+ *                                                                            *
+ * Author: Andrew Nelson                                                      *
+ *                                                                            *
+ * Comments:                                                                  *
+ *                                                                            *
+ ******************************************************************************/
+
+int get_lua_item(lua_State *L, DC_ITEM *item, AGENT_RESULT *result)
+{
+	const char* _name="get_lua_item";
+	double sec;
+  int ret = SUCCEED;
+	const char *str=NULL;
+	char params[MAX_STRING_LEN], cmd[MAX_STRING_LEN];
+
+	sec = zbx_time();
+
+	parse_command(item->key, cmd, sizeof(cmd), params, sizeof(params));
+	
+	zabbix_log(LOG_LEVEL_DEBUG,"[%s] Executing Lua script itemid:%d  script:%s",_name,item->itemid,item->params_orig);
+
+  if (item->params_orig)
+	{
+		ret=execute_lua(L,params,item);
+		str = lua_tostring(L, -1);  /* pull the resultant string from the Lua stack */
+	}
+	else
+	{
+		ret=FAIL;
+		str="NO SCRIPT FOUND";
+	}
+
+	if (ret==SUCCEED)
+	{
+		zabbix_log(LOG_LEVEL_DEBUG,"[%s] Lua return val: %s",_name, str);
+
+		if (SUCCEED!=set_result_type(result, item->value_type, item->data_type, (char*) str))
+			ret = NOTSUPPORTED;
+	}
+	else
+	{
+		if (str==NULL)
+			SET_MSG_RESULT(result, strdup("Null Value Returned"));
+		else
+			SET_MSG_RESULT(result, strdup(str));   /* kick back the error message */
+
+		zabbix_log(LOG_LEVEL_WARNING, "[%s] Lua execute error: %s",_name, str);  
+
+		ret = NOTSUPPORTED;
+	}
+
+	sec = zbx_time() - sec;
+
+	zabbix_log(LOG_LEVEL_WARNING, "[%s] "ZBX_FS_DBL" seconds to execute Lua script itemid:%d  script:%s",_name, sec,item->itemid,item->params_orig);
+
+	return ret;
+}
Index: src/zabbix_server/poller/Makefile.in
===================================================================
--- src/zabbix_server/poller/Makefile.in	(revision 302)
+++ src/zabbix_server/poller/Makefile.in	(working copy)
@@ -45,9 +45,9 @@
 	$(top_srcdir)/m4/jabber.m4 $(top_srcdir)/m4/ldap.m4 \
 	$(top_srcdir)/m4/libcurl.m4 $(top_srcdir)/m4/libiodbc.m4 \
 	$(top_srcdir)/m4/libssh2.m4 $(top_srcdir)/m4/libunixodbc.m4 \
-	$(top_srcdir)/m4/netsnmp.m4 $(top_srcdir)/m4/openipmi.m4 \
-	$(top_srcdir)/m4/resolv.m4 $(top_srcdir)/m4/ucdsnmp.m4 \
-	$(top_srcdir)/configure.in
+	$(top_srcdir)/m4/lua.m4 $(top_srcdir)/m4/netsnmp.m4 \
+	$(top_srcdir)/m4/openipmi.m4 $(top_srcdir)/m4/resolv.m4 \
+	$(top_srcdir)/m4/ucdsnmp.m4 $(top_srcdir)/configure.in
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 mkinstalldirs = $(install_sh) -d
@@ -59,13 +59,22 @@
 ARFLAGS = cru
 libzbxpoller_a_AR = $(AR) $(ARFLAGS)
 libzbxpoller_a_LIBADD =
+am__libzbxpoller_a_SOURCES_DIST = checks_agent.c checks_agent.h \
+	checks_internal.c checks_internal.h checks_simple.c \
+	checks_simple.h checks_snmp.c checks_snmp.h checks_db.c \
+	checks_db.h checks_aggregate.c checks_aggregate.h \
+	checks_external.c checks_external.h checks_ipmi.c \
+	checks_ipmi.h checks_ssh.c checks_ssh.h checks_telnet.c \
+	checks_telnet.h checks_calculated.c checks_calculated.h \
+	poller.c poller.h checks_lua.c checks_lua.h
+@LUA_TRUE@am__objects_1 = checks_lua.$(OBJEXT)
 am_libzbxpoller_a_OBJECTS = checks_agent.$(OBJEXT) \
 	checks_internal.$(OBJEXT) checks_simple.$(OBJEXT) \
 	checks_snmp.$(OBJEXT) checks_db.$(OBJEXT) \
 	checks_aggregate.$(OBJEXT) checks_external.$(OBJEXT) \
 	checks_ipmi.$(OBJEXT) checks_ssh.$(OBJEXT) \
 	checks_telnet.$(OBJEXT) checks_calculated.$(OBJEXT) \
-	poller.$(OBJEXT)
+	poller.$(OBJEXT) $(am__objects_1)
 libzbxpoller_a_OBJECTS = $(am_libzbxpoller_a_OBJECTS)
 DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include
 depcomp = $(SHELL) $(top_srcdir)/depcomp
@@ -76,7 +85,7 @@
 CCLD = $(CC)
 LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
 SOURCES = $(libzbxpoller_a_SOURCES)
-DIST_SOURCES = $(libzbxpoller_a_SOURCES)
+DIST_SOURCES = $(am__libzbxpoller_a_SOURCES_DIST)
 ETAGS = etags
 CTAGS = ctags
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
@@ -127,7 +136,12 @@
 LIBCURL_LIBS = @LIBCURL_LIBS@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
+LLUA_CFLAGS = @LLUA_CFLAGS@
+LLUA_LIBS = @LLUA_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LUA_CPPFLAGS = @LUA_CPPFLAGS@
+LUA_LDFLAGS = @LUA_LDFLAGS@
+LUA_LIBS = @LUA_LIBS@
 MAKEINFO = @MAKEINFO@
 MKDIR_P = @MKDIR_P@
 MYSQL_CFLAGS = @MYSQL_CFLAGS@
@@ -239,6 +253,7 @@
 top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
 noinst_LIBRARIES = libzbxpoller.a
+@LUA_TRUE@LUA_SOURCES = checks_lua.c checks_lua.h 
 libzbxpoller_a_SOURCES = \
 	checks_agent.c checks_agent.h \
 	checks_internal.c checks_internal.h \
@@ -251,7 +266,8 @@
 	checks_ssh.c checks_ssh.h \
 	checks_telnet.c checks_telnet.h \
 	checks_calculated.c checks_calculated.h \
-	poller.c poller.h
+	poller.c poller.h \
+  $(LUA_SOURCES)
 
 all: all-am
 
@@ -308,6 +324,7 @@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/checks_external.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/checks_internal.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/checks_ipmi.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/checks_lua.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/checks_simple.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/checks_snmp.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/checks_ssh.Po@am__quote@
Index: src/zabbix_server/poller/checks_lua.h
===================================================================
--- src/zabbix_server/poller/checks_lua.h	(revision 0)
+++ src/zabbix_server/poller/checks_lua.h	(revision 306)
@@ -0,0 +1,7 @@
+#include "common.h"
+#include "dbcache.h"
+
+#include "lua.h"
+
+
+int get_lua_item(lua_State *L, DC_ITEM *item, AGENT_RESULT *result);
Index: src/zabbix_server/poller/Makefile.am
===================================================================
--- src/zabbix_server/poller/Makefile.am	(revision 302)
+++ src/zabbix_server/poller/Makefile.am	(working copy)
@@ -2,6 +2,10 @@
 
 noinst_LIBRARIES = libzbxpoller.a
 
+if LUA
+LUA_SOURCES = checks_lua.c checks_lua.h 
+endif
+
 libzbxpoller_a_SOURCES = \
 	checks_agent.c checks_agent.h \
 	checks_internal.c checks_internal.h \
@@ -14,4 +18,6 @@
 	checks_ssh.c checks_ssh.h \
 	checks_telnet.c checks_telnet.h \
 	checks_calculated.c checks_calculated.h \
-	poller.c poller.h
+	poller.c poller.h \
+  $(LUA_SOURCES)
+
Index: src/zabbix_server/poller/poller.c
===================================================================
--- src/zabbix_server/poller/poller.c	(revision 302)
+++ src/zabbix_server/poller/poller.c	(working copy)
@@ -42,6 +42,12 @@
 #include "checks_telnet.h"
 #include "checks_calculated.h"
 
+#ifdef HAVE_LUA
+#include "lua.h"
+#include "zbxlua.h"
+#include "checks_lua.h"
+#endif  /* HAVE_LUA */
+
 #define MAX_REACHABLE_ITEMS	64
 #define MAX_UNREACHABLE_ITEMS	1	/* must not be greater than MAX_REACHABLE_ITEMS to avoid buffer overflow */
 
@@ -49,6 +55,10 @@
 extern unsigned char	process_type;
 extern int		process_num;
 
+#ifdef HAVE_LUA
+lua_State* L=NULL;
+#endif
+
 static int	get_value(DC_ITEM *item, AGENT_RESULT *result)
 {
 	const char	*__function_name = "get_value";
@@ -120,6 +130,14 @@
 		case ITEM_TYPE_CALCULATED:
 			res = get_value_calculated(item, result);
 			break;
+		case ITEM_TYPE_LUA:
+#ifdef HAVE_LUA
+			res = get_lua_item(L,item,result);
+			break;	
+#else
+			SET_MSG_RESULT(result, strdup("Support for LUA parameters was not compiled in"));
+			res=NOTSUPPORTED;
+#endif
 		default:
 			SET_MSG_RESULT(result, zbx_dsprintf(NULL, "Not supported item type:%d", item->type));
 			res = NOTSUPPORTED;
@@ -701,6 +719,14 @@
 
 	zbx_setproctitle("%s [connecting to the database]", get_process_type_string(process_type));
 
+	#ifdef HAVE_LUA
+	if (poller_type==ZBX_POLLER_TYPE_LUA)
+	{
+		zabbix_log(LOG_LEVEL_DEBUG, "Poller is type Lua, setting up");
+		L=init_lua_env();
+	}
+	#endif
+
 	DBconnect(ZBX_DB_CONNECT_NORMAL);
 
 	for (;;)
@@ -717,6 +743,10 @@
 		nextcheck = DCconfig_get_poller_nextcheck(poller_type);
 		sleeptime = calculate_sleeptime(nextcheck, POLLER_DELAY);
 
+#ifndef HAVE_LUA
+		if (poller_type==POLLER_TYPE_LUA)
+			sleeptime=sleeptime*2;   /* if lua support not compiled in, double sleep time */
+#endif
 		zbx_sleep_loop(sleeptime);
 	}
 }
Index: src/zabbix_server/httppoller/Makefile.in
===================================================================
--- src/zabbix_server/httppoller/Makefile.in	(revision 302)
+++ src/zabbix_server/httppoller/Makefile.in	(working copy)
@@ -45,9 +45,9 @@
 	$(top_srcdir)/m4/jabber.m4 $(top_srcdir)/m4/ldap.m4 \
 	$(top_srcdir)/m4/libcurl.m4 $(top_srcdir)/m4/libiodbc.m4 \
 	$(top_srcdir)/m4/libssh2.m4 $(top_srcdir)/m4/libunixodbc.m4 \
-	$(top_srcdir)/m4/netsnmp.m4 $(top_srcdir)/m4/openipmi.m4 \
-	$(top_srcdir)/m4/resolv.m4 $(top_srcdir)/m4/ucdsnmp.m4 \
-	$(top_srcdir)/configure.in
+	$(top_srcdir)/m4/lua.m4 $(top_srcdir)/m4/netsnmp.m4 \
+	$(top_srcdir)/m4/openipmi.m4 $(top_srcdir)/m4/resolv.m4 \
+	$(top_srcdir)/m4/ucdsnmp.m4 $(top_srcdir)/configure.in
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 mkinstalldirs = $(install_sh) -d
@@ -122,7 +122,12 @@
 LIBCURL_LIBS = @LIBCURL_LIBS@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
+LLUA_CFLAGS = @LLUA_CFLAGS@
+LLUA_LIBS = @LLUA_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LUA_CPPFLAGS = @LUA_CPPFLAGS@
+LUA_LDFLAGS = @LUA_LDFLAGS@
+LUA_LIBS = @LUA_LIBS@
 MAKEINFO = @MAKEINFO@
 MKDIR_P = @MKDIR_P@
 MYSQL_CFLAGS = @MYSQL_CFLAGS@
Index: src/zabbix_server/alerter/Makefile.in
===================================================================
--- src/zabbix_server/alerter/Makefile.in	(revision 302)
+++ src/zabbix_server/alerter/Makefile.in	(working copy)
@@ -45,9 +45,9 @@
 	$(top_srcdir)/m4/jabber.m4 $(top_srcdir)/m4/ldap.m4 \
 	$(top_srcdir)/m4/libcurl.m4 $(top_srcdir)/m4/libiodbc.m4 \
 	$(top_srcdir)/m4/libssh2.m4 $(top_srcdir)/m4/libunixodbc.m4 \
-	$(top_srcdir)/m4/netsnmp.m4 $(top_srcdir)/m4/openipmi.m4 \
-	$(top_srcdir)/m4/resolv.m4 $(top_srcdir)/m4/ucdsnmp.m4 \
-	$(top_srcdir)/configure.in
+	$(top_srcdir)/m4/lua.m4 $(top_srcdir)/m4/netsnmp.m4 \
+	$(top_srcdir)/m4/openipmi.m4 $(top_srcdir)/m4/resolv.m4 \
+	$(top_srcdir)/m4/ucdsnmp.m4 $(top_srcdir)/configure.in
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 mkinstalldirs = $(install_sh) -d
@@ -121,7 +121,12 @@
 LIBCURL_LIBS = @LIBCURL_LIBS@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
+LLUA_CFLAGS = @LLUA_CFLAGS@
+LLUA_LIBS = @LLUA_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LUA_CPPFLAGS = @LUA_CPPFLAGS@
+LUA_LDFLAGS = @LUA_LDFLAGS@
+LUA_LIBS = @LUA_LIBS@
 MAKEINFO = @MAKEINFO@
 MKDIR_P = @MKDIR_P@
 MYSQL_CFLAGS = @MYSQL_CFLAGS@
Index: src/zabbix_server/proxypoller/Makefile.in
===================================================================
--- src/zabbix_server/proxypoller/Makefile.in	(revision 302)
+++ src/zabbix_server/proxypoller/Makefile.in	(working copy)
@@ -45,9 +45,9 @@
 	$(top_srcdir)/m4/jabber.m4 $(top_srcdir)/m4/ldap.m4 \
 	$(top_srcdir)/m4/libcurl.m4 $(top_srcdir)/m4/libiodbc.m4 \
 	$(top_srcdir)/m4/libssh2.m4 $(top_srcdir)/m4/libunixodbc.m4 \
-	$(top_srcdir)/m4/netsnmp.m4 $(top_srcdir)/m4/openipmi.m4 \
-	$(top_srcdir)/m4/resolv.m4 $(top_srcdir)/m4/ucdsnmp.m4 \
-	$(top_srcdir)/configure.in
+	$(top_srcdir)/m4/lua.m4 $(top_srcdir)/m4/netsnmp.m4 \
+	$(top_srcdir)/m4/openipmi.m4 $(top_srcdir)/m4/resolv.m4 \
+	$(top_srcdir)/m4/ucdsnmp.m4 $(top_srcdir)/configure.in
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 mkinstalldirs = $(install_sh) -d
@@ -121,7 +121,12 @@
 LIBCURL_LIBS = @LIBCURL_LIBS@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
+LLUA_CFLAGS = @LLUA_CFLAGS@
+LLUA_LIBS = @LLUA_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LUA_CPPFLAGS = @LUA_CPPFLAGS@
+LUA_LDFLAGS = @LUA_LDFLAGS@
+LUA_LIBS = @LUA_LIBS@
 MAKEINFO = @MAKEINFO@
 MKDIR_P = @MKDIR_P@
 MYSQL_CFLAGS = @MYSQL_CFLAGS@
Index: src/zabbix_server/utils/Makefile.in
===================================================================
--- src/zabbix_server/utils/Makefile.in	(revision 302)
+++ src/zabbix_server/utils/Makefile.in	(working copy)
@@ -45,9 +45,9 @@
 	$(top_srcdir)/m4/jabber.m4 $(top_srcdir)/m4/ldap.m4 \
 	$(top_srcdir)/m4/libcurl.m4 $(top_srcdir)/m4/libiodbc.m4 \
 	$(top_srcdir)/m4/libssh2.m4 $(top_srcdir)/m4/libunixodbc.m4 \
-	$(top_srcdir)/m4/netsnmp.m4 $(top_srcdir)/m4/openipmi.m4 \
-	$(top_srcdir)/m4/resolv.m4 $(top_srcdir)/m4/ucdsnmp.m4 \
-	$(top_srcdir)/configure.in
+	$(top_srcdir)/m4/lua.m4 $(top_srcdir)/m4/netsnmp.m4 \
+	$(top_srcdir)/m4/openipmi.m4 $(top_srcdir)/m4/resolv.m4 \
+	$(top_srcdir)/m4/ucdsnmp.m4 $(top_srcdir)/configure.in
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 mkinstalldirs = $(install_sh) -d
@@ -121,7 +121,12 @@
 LIBCURL_LIBS = @LIBCURL_LIBS@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
+LLUA_CFLAGS = @LLUA_CFLAGS@
+LLUA_LIBS = @LLUA_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LUA_CPPFLAGS = @LUA_CPPFLAGS@
+LUA_LDFLAGS = @LUA_LDFLAGS@
+LUA_LIBS = @LUA_LIBS@
 MAKEINFO = @MAKEINFO@
 MKDIR_P = @MKDIR_P@
 MYSQL_CFLAGS = @MYSQL_CFLAGS@
Index: src/zabbix_server/watchdog/Makefile.in
===================================================================
--- src/zabbix_server/watchdog/Makefile.in	(revision 302)
+++ src/zabbix_server/watchdog/Makefile.in	(working copy)
@@ -45,9 +45,9 @@
 	$(top_srcdir)/m4/jabber.m4 $(top_srcdir)/m4/ldap.m4 \
 	$(top_srcdir)/m4/libcurl.m4 $(top_srcdir)/m4/libiodbc.m4 \
 	$(top_srcdir)/m4/libssh2.m4 $(top_srcdir)/m4/libunixodbc.m4 \
-	$(top_srcdir)/m4/netsnmp.m4 $(top_srcdir)/m4/openipmi.m4 \
-	$(top_srcdir)/m4/resolv.m4 $(top_srcdir)/m4/ucdsnmp.m4 \
-	$(top_srcdir)/configure.in
+	$(top_srcdir)/m4/lua.m4 $(top_srcdir)/m4/netsnmp.m4 \
+	$(top_srcdir)/m4/openipmi.m4 $(top_srcdir)/m4/resolv.m4 \
+	$(top_srcdir)/m4/ucdsnmp.m4 $(top_srcdir)/configure.in
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 mkinstalldirs = $(install_sh) -d
@@ -121,7 +121,12 @@
 LIBCURL_LIBS = @LIBCURL_LIBS@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
+LLUA_CFLAGS = @LLUA_CFLAGS@
+LLUA_LIBS = @LLUA_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LUA_CPPFLAGS = @LUA_CPPFLAGS@
+LUA_LDFLAGS = @LUA_LDFLAGS@
+LUA_LIBS = @LUA_LIBS@
 MAKEINFO = @MAKEINFO@
 MKDIR_P = @MKDIR_P@
 MYSQL_CFLAGS = @MYSQL_CFLAGS@
Index: src/zabbix_server/nodewatcher/Makefile.in
===================================================================
--- src/zabbix_server/nodewatcher/Makefile.in	(revision 302)
+++ src/zabbix_server/nodewatcher/Makefile.in	(working copy)
@@ -45,9 +45,9 @@
 	$(top_srcdir)/m4/jabber.m4 $(top_srcdir)/m4/ldap.m4 \
 	$(top_srcdir)/m4/libcurl.m4 $(top_srcdir)/m4/libiodbc.m4 \
 	$(top_srcdir)/m4/libssh2.m4 $(top_srcdir)/m4/libunixodbc.m4 \
-	$(top_srcdir)/m4/netsnmp.m4 $(top_srcdir)/m4/openipmi.m4 \
-	$(top_srcdir)/m4/resolv.m4 $(top_srcdir)/m4/ucdsnmp.m4 \
-	$(top_srcdir)/configure.in
+	$(top_srcdir)/m4/lua.m4 $(top_srcdir)/m4/netsnmp.m4 \
+	$(top_srcdir)/m4/openipmi.m4 $(top_srcdir)/m4/resolv.m4 \
+	$(top_srcdir)/m4/ucdsnmp.m4 $(top_srcdir)/configure.in
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 mkinstalldirs = $(install_sh) -d
@@ -123,7 +123,12 @@
 LIBCURL_LIBS = @LIBCURL_LIBS@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
+LLUA_CFLAGS = @LLUA_CFLAGS@
+LLUA_LIBS = @LLUA_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LUA_CPPFLAGS = @LUA_CPPFLAGS@
+LUA_LDFLAGS = @LUA_LDFLAGS@
+LUA_LIBS = @LUA_LIBS@
 MAKEINFO = @MAKEINFO@
 MKDIR_P = @MKDIR_P@
 MYSQL_CFLAGS = @MYSQL_CFLAGS@
Index: src/zabbix_server/selfmon/Makefile.in
===================================================================
--- src/zabbix_server/selfmon/Makefile.in	(revision 302)
+++ src/zabbix_server/selfmon/Makefile.in	(working copy)
@@ -45,9 +45,9 @@
 	$(top_srcdir)/m4/jabber.m4 $(top_srcdir)/m4/ldap.m4 \
 	$(top_srcdir)/m4/libcurl.m4 $(top_srcdir)/m4/libiodbc.m4 \
 	$(top_srcdir)/m4/libssh2.m4 $(top_srcdir)/m4/libunixodbc.m4 \
-	$(top_srcdir)/m4/netsnmp.m4 $(top_srcdir)/m4/openipmi.m4 \
-	$(top_srcdir)/m4/resolv.m4 $(top_srcdir)/m4/ucdsnmp.m4 \
-	$(top_srcdir)/configure.in
+	$(top_srcdir)/m4/lua.m4 $(top_srcdir)/m4/netsnmp.m4 \
+	$(top_srcdir)/m4/openipmi.m4 $(top_srcdir)/m4/resolv.m4 \
+	$(top_srcdir)/m4/ucdsnmp.m4 $(top_srcdir)/configure.in
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 mkinstalldirs = $(install_sh) -d
@@ -121,7 +121,12 @@
 LIBCURL_LIBS = @LIBCURL_LIBS@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
+LLUA_CFLAGS = @LLUA_CFLAGS@
+LLUA_LIBS = @LLUA_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LUA_CPPFLAGS = @LUA_CPPFLAGS@
+LUA_LDFLAGS = @LUA_LDFLAGS@
+LUA_LIBS = @LUA_LIBS@
 MAKEINFO = @MAKEINFO@
 MKDIR_P = @MKDIR_P@
 MYSQL_CFLAGS = @MYSQL_CFLAGS@
Index: src/zabbix_server/discoverer/Makefile.in
===================================================================
--- src/zabbix_server/discoverer/Makefile.in	(revision 302)
+++ src/zabbix_server/discoverer/Makefile.in	(working copy)
@@ -45,9 +45,9 @@
 	$(top_srcdir)/m4/jabber.m4 $(top_srcdir)/m4/ldap.m4 \
 	$(top_srcdir)/m4/libcurl.m4 $(top_srcdir)/m4/libiodbc.m4 \
 	$(top_srcdir)/m4/libssh2.m4 $(top_srcdir)/m4/libunixodbc.m4 \
-	$(top_srcdir)/m4/netsnmp.m4 $(top_srcdir)/m4/openipmi.m4 \
-	$(top_srcdir)/m4/resolv.m4 $(top_srcdir)/m4/ucdsnmp.m4 \
-	$(top_srcdir)/configure.in
+	$(top_srcdir)/m4/lua.m4 $(top_srcdir)/m4/netsnmp.m4 \
+	$(top_srcdir)/m4/openipmi.m4 $(top_srcdir)/m4/resolv.m4 \
+	$(top_srcdir)/m4/ucdsnmp.m4 $(top_srcdir)/configure.in
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 mkinstalldirs = $(install_sh) -d
@@ -121,7 +121,12 @@
 LIBCURL_LIBS = @LIBCURL_LIBS@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
+LLUA_CFLAGS = @LLUA_CFLAGS@
+LLUA_LIBS = @LLUA_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LUA_CPPFLAGS = @LUA_CPPFLAGS@
+LUA_LDFLAGS = @LUA_LDFLAGS@
+LUA_LIBS = @LUA_LIBS@
 MAKEINFO = @MAKEINFO@
 MKDIR_P = @MKDIR_P@
 MYSQL_CFLAGS = @MYSQL_CFLAGS@
Index: src/zabbix_server/Makefile.am
===================================================================
--- src/zabbix_server/Makefile.am	(revision 302)
+++ src/zabbix_server/Makefile.am	(working copy)
@@ -67,6 +67,7 @@
 	$(top_srcdir)/src/libs/zbxicmpping/libzbxicmpping.a \
 	$(top_srcdir)/src/libs/zbxdbhigh/libzbxdbhigh.a \
 	$(top_srcdir)/src/libs/zbxdb/libzbxdb.a \
+	$(top_srcdir)/src/libs/zbxlua/libzbxlua.a \
 	@SERVER_LIBS@
 
 zabbix_server_LDFLAGS = \
Index: src/zabbix_server/dbsyncer/Makefile.in
===================================================================
--- src/zabbix_server/dbsyncer/Makefile.in	(revision 302)
+++ src/zabbix_server/dbsyncer/Makefile.in	(working copy)
@@ -45,9 +45,9 @@
 	$(top_srcdir)/m4/jabber.m4 $(top_srcdir)/m4/ldap.m4 \
 	$(top_srcdir)/m4/libcurl.m4 $(top_srcdir)/m4/libiodbc.m4 \
 	$(top_srcdir)/m4/libssh2.m4 $(top_srcdir)/m4/libunixodbc.m4 \
-	$(top_srcdir)/m4/netsnmp.m4 $(top_srcdir)/m4/openipmi.m4 \
-	$(top_srcdir)/m4/resolv.m4 $(top_srcdir)/m4/ucdsnmp.m4 \
-	$(top_srcdir)/configure.in
+	$(top_srcdir)/m4/lua.m4 $(top_srcdir)/m4/netsnmp.m4 \
+	$(top_srcdir)/m4/openipmi.m4 $(top_srcdir)/m4/resolv.m4 \
+	$(top_srcdir)/m4/ucdsnmp.m4 $(top_srcdir)/configure.in
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 mkinstalldirs = $(install_sh) -d
@@ -121,7 +121,12 @@
 LIBCURL_LIBS = @LIBCURL_LIBS@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
+LLUA_CFLAGS = @LLUA_CFLAGS@
+LLUA_LIBS = @LLUA_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LUA_CPPFLAGS = @LUA_CPPFLAGS@
+LUA_LDFLAGS = @LUA_LDFLAGS@
+LUA_LIBS = @LUA_LIBS@
 MAKEINFO = @MAKEINFO@
 MKDIR_P = @MKDIR_P@
 MYSQL_CFLAGS = @MYSQL_CFLAGS@
Index: src/zabbix_server/dbconfig/Makefile.in
===================================================================
--- src/zabbix_server/dbconfig/Makefile.in	(revision 302)
+++ src/zabbix_server/dbconfig/Makefile.in	(working copy)
@@ -45,9 +45,9 @@
 	$(top_srcdir)/m4/jabber.m4 $(top_srcdir)/m4/ldap.m4 \
 	$(top_srcdir)/m4/libcurl.m4 $(top_srcdir)/m4/libiodbc.m4 \
 	$(top_srcdir)/m4/libssh2.m4 $(top_srcdir)/m4/libunixodbc.m4 \
-	$(top_srcdir)/m4/netsnmp.m4 $(top_srcdir)/m4/openipmi.m4 \
-	$(top_srcdir)/m4/resolv.m4 $(top_srcdir)/m4/ucdsnmp.m4 \
-	$(top_srcdir)/configure.in
+	$(top_srcdir)/m4/lua.m4 $(top_srcdir)/m4/netsnmp.m4 \
+	$(top_srcdir)/m4/openipmi.m4 $(top_srcdir)/m4/resolv.m4 \
+	$(top_srcdir)/m4/ucdsnmp.m4 $(top_srcdir)/configure.in
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 mkinstalldirs = $(install_sh) -d
@@ -121,7 +121,12 @@
 LIBCURL_LIBS = @LIBCURL_LIBS@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
+LLUA_CFLAGS = @LLUA_CFLAGS@
+LLUA_LIBS = @LLUA_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LUA_CPPFLAGS = @LUA_CPPFLAGS@
+LUA_LDFLAGS = @LUA_LDFLAGS@
+LUA_LIBS = @LUA_LIBS@
 MAKEINFO = @MAKEINFO@
 MKDIR_P = @MKDIR_P@
 MYSQL_CFLAGS = @MYSQL_CFLAGS@
Index: src/zabbix_server/escalator/Makefile.in
===================================================================
--- src/zabbix_server/escalator/Makefile.in	(revision 302)
+++ src/zabbix_server/escalator/Makefile.in	(working copy)
@@ -45,9 +45,9 @@
 	$(top_srcdir)/m4/jabber.m4 $(top_srcdir)/m4/ldap.m4 \
 	$(top_srcdir)/m4/libcurl.m4 $(top_srcdir)/m4/libiodbc.m4 \
 	$(top_srcdir)/m4/libssh2.m4 $(top_srcdir)/m4/libunixodbc.m4 \
-	$(top_srcdir)/m4/netsnmp.m4 $(top_srcdir)/m4/openipmi.m4 \
-	$(top_srcdir)/m4/resolv.m4 $(top_srcdir)/m4/ucdsnmp.m4 \
-	$(top_srcdir)/configure.in
+	$(top_srcdir)/m4/lua.m4 $(top_srcdir)/m4/netsnmp.m4 \
+	$(top_srcdir)/m4/openipmi.m4 $(top_srcdir)/m4/resolv.m4 \
+	$(top_srcdir)/m4/ucdsnmp.m4 $(top_srcdir)/configure.in
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 mkinstalldirs = $(install_sh) -d
@@ -121,7 +121,12 @@
 LIBCURL_LIBS = @LIBCURL_LIBS@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
+LLUA_CFLAGS = @LLUA_CFLAGS@
+LLUA_LIBS = @LLUA_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LUA_CPPFLAGS = @LUA_CPPFLAGS@
+LUA_LDFLAGS = @LUA_LDFLAGS@
+LUA_LIBS = @LUA_LIBS@
 MAKEINFO = @MAKEINFO@
 MKDIR_P = @MKDIR_P@
 MYSQL_CFLAGS = @MYSQL_CFLAGS@
Index: src/zabbix_server/trapper/Makefile.in
===================================================================
--- src/zabbix_server/trapper/Makefile.in	(revision 302)
+++ src/zabbix_server/trapper/Makefile.in	(working copy)
@@ -45,9 +45,9 @@
 	$(top_srcdir)/m4/jabber.m4 $(top_srcdir)/m4/ldap.m4 \
 	$(top_srcdir)/m4/libcurl.m4 $(top_srcdir)/m4/libiodbc.m4 \
 	$(top_srcdir)/m4/libssh2.m4 $(top_srcdir)/m4/libunixodbc.m4 \
-	$(top_srcdir)/m4/netsnmp.m4 $(top_srcdir)/m4/openipmi.m4 \
-	$(top_srcdir)/m4/resolv.m4 $(top_srcdir)/m4/ucdsnmp.m4 \
-	$(top_srcdir)/configure.in
+	$(top_srcdir)/m4/lua.m4 $(top_srcdir)/m4/netsnmp.m4 \
+	$(top_srcdir)/m4/openipmi.m4 $(top_srcdir)/m4/resolv.m4 \
+	$(top_srcdir)/m4/ucdsnmp.m4 $(top_srcdir)/configure.in
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 mkinstalldirs = $(install_sh) -d
@@ -125,7 +125,12 @@
 LIBCURL_LIBS = @LIBCURL_LIBS@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
+LLUA_CFLAGS = @LLUA_CFLAGS@
+LLUA_LIBS = @LLUA_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LUA_CPPFLAGS = @LUA_CPPFLAGS@
+LUA_LDFLAGS = @LUA_LDFLAGS@
+LUA_LIBS = @LUA_LIBS@
 MAKEINFO = @MAKEINFO@
 MKDIR_P = @MKDIR_P@
 MYSQL_CFLAGS = @MYSQL_CFLAGS@
Index: src/libs/Makefile.in
===================================================================
--- src/libs/Makefile.in	(revision 302)
+++ src/libs/Makefile.in	(working copy)
@@ -44,9 +44,9 @@
 	$(top_srcdir)/m4/jabber.m4 $(top_srcdir)/m4/ldap.m4 \
 	$(top_srcdir)/m4/libcurl.m4 $(top_srcdir)/m4/libiodbc.m4 \
 	$(top_srcdir)/m4/libssh2.m4 $(top_srcdir)/m4/libunixodbc.m4 \
-	$(top_srcdir)/m4/netsnmp.m4 $(top_srcdir)/m4/openipmi.m4 \
-	$(top_srcdir)/m4/resolv.m4 $(top_srcdir)/m4/ucdsnmp.m4 \
-	$(top_srcdir)/configure.in
+	$(top_srcdir)/m4/lua.m4 $(top_srcdir)/m4/netsnmp.m4 \
+	$(top_srcdir)/m4/openipmi.m4 $(top_srcdir)/m4/resolv.m4 \
+	$(top_srcdir)/m4/ucdsnmp.m4 $(top_srcdir)/configure.in
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 mkinstalldirs = $(install_sh) -d
@@ -142,7 +142,12 @@
 LIBCURL_LIBS = @LIBCURL_LIBS@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
+LLUA_CFLAGS = @LLUA_CFLAGS@
+LLUA_LIBS = @LLUA_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LUA_CPPFLAGS = @LUA_CPPFLAGS@
+LUA_LDFLAGS = @LUA_LDFLAGS@
+LUA_LIBS = @LUA_LIBS@
 MAKEINFO = @MAKEINFO@
 MKDIR_P = @MKDIR_P@
 MYSQL_CFLAGS = @MYSQL_CFLAGS@
@@ -265,6 +270,7 @@
 	zbxcomms \
 	zbxcommshigh \
 	zbxlog \
+	zbxlua \
 	zbxnix \
 	zbxconf \
 	zbxsysinfo \
@@ -293,6 +299,7 @@
 @SERVER_TRUE@	zbxmemory \
 @SERVER_TRUE@	zbxserver \
 @SERVER_TRUE@	zbxicmpping \
+@SERVER_TRUE@	zbxlua \
 @SERVER_TRUE@	zbxmedia \
 @SERVER_TRUE@	zbxself
 
Index: src/libs/zbxnix/Makefile.in
===================================================================
--- src/libs/zbxnix/Makefile.in	(revision 302)
+++ src/libs/zbxnix/Makefile.in	(working copy)
@@ -45,9 +45,9 @@
 	$(top_srcdir)/m4/jabber.m4 $(top_srcdir)/m4/ldap.m4 \
 	$(top_srcdir)/m4/libcurl.m4 $(top_srcdir)/m4/libiodbc.m4 \
 	$(top_srcdir)/m4/libssh2.m4 $(top_srcdir)/m4/libunixodbc.m4 \
-	$(top_srcdir)/m4/netsnmp.m4 $(top_srcdir)/m4/openipmi.m4 \
-	$(top_srcdir)/m4/resolv.m4 $(top_srcdir)/m4/ucdsnmp.m4 \
-	$(top_srcdir)/configure.in
+	$(top_srcdir)/m4/lua.m4 $(top_srcdir)/m4/netsnmp.m4 \
+	$(top_srcdir)/m4/openipmi.m4 $(top_srcdir)/m4/resolv.m4 \
+	$(top_srcdir)/m4/ucdsnmp.m4 $(top_srcdir)/configure.in
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 mkinstalldirs = $(install_sh) -d
@@ -122,7 +122,12 @@
 LIBCURL_LIBS = @LIBCURL_LIBS@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
+LLUA_CFLAGS = @LLUA_CFLAGS@
+LLUA_LIBS = @LLUA_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LUA_CPPFLAGS = @LUA_CPPFLAGS@
+LUA_LDFLAGS = @LUA_LDFLAGS@
+LUA_LIBS = @LUA_LIBS@
 MAKEINFO = @MAKEINFO@
 MKDIR_P = @MKDIR_P@
 MYSQL_CFLAGS = @MYSQL_CFLAGS@
Index: src/libs/zbxicmpping/Makefile.in
===================================================================
--- src/libs/zbxicmpping/Makefile.in	(revision 302)
+++ src/libs/zbxicmpping/Makefile.in	(working copy)
@@ -45,9 +45,9 @@
 	$(top_srcdir)/m4/jabber.m4 $(top_srcdir)/m4/ldap.m4 \
 	$(top_srcdir)/m4/libcurl.m4 $(top_srcdir)/m4/libiodbc.m4 \
 	$(top_srcdir)/m4/libssh2.m4 $(top_srcdir)/m4/libunixodbc.m4 \
-	$(top_srcdir)/m4/netsnmp.m4 $(top_srcdir)/m4/openipmi.m4 \
-	$(top_srcdir)/m4/resolv.m4 $(top_srcdir)/m4/ucdsnmp.m4 \
-	$(top_srcdir)/configure.in
+	$(top_srcdir)/m4/lua.m4 $(top_srcdir)/m4/netsnmp.m4 \
+	$(top_srcdir)/m4/openipmi.m4 $(top_srcdir)/m4/resolv.m4 \
+	$(top_srcdir)/m4/ucdsnmp.m4 $(top_srcdir)/configure.in
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 mkinstalldirs = $(install_sh) -d
@@ -121,7 +121,12 @@
 LIBCURL_LIBS = @LIBCURL_LIBS@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
+LLUA_CFLAGS = @LLUA_CFLAGS@
+LLUA_LIBS = @LLUA_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LUA_CPPFLAGS = @LUA_CPPFLAGS@
+LUA_LDFLAGS = @LUA_LDFLAGS@
+LUA_LIBS = @LUA_LIBS@
 MAKEINFO = @MAKEINFO@
 MKDIR_P = @MKDIR_P@
 MYSQL_CFLAGS = @MYSQL_CFLAGS@
Index: src/libs/zbxserver/Makefile.in
===================================================================
--- src/libs/zbxserver/Makefile.in	(revision 302)
+++ src/libs/zbxserver/Makefile.in	(working copy)
@@ -45,9 +45,9 @@
 	$(top_srcdir)/m4/jabber.m4 $(top_srcdir)/m4/ldap.m4 \
 	$(top_srcdir)/m4/libcurl.m4 $(top_srcdir)/m4/libiodbc.m4 \
 	$(top_srcdir)/m4/libssh2.m4 $(top_srcdir)/m4/libunixodbc.m4 \
-	$(top_srcdir)/m4/netsnmp.m4 $(top_srcdir)/m4/openipmi.m4 \
-	$(top_srcdir)/m4/resolv.m4 $(top_srcdir)/m4/ucdsnmp.m4 \
-	$(top_srcdir)/configure.in
+	$(top_srcdir)/m4/lua.m4 $(top_srcdir)/m4/netsnmp.m4 \
+	$(top_srcdir)/m4/openipmi.m4 $(top_srcdir)/m4/resolv.m4 \
+	$(top_srcdir)/m4/ucdsnmp.m4 $(top_srcdir)/configure.in
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 mkinstalldirs = $(install_sh) -d
@@ -121,7 +121,12 @@
 LIBCURL_LIBS = @LIBCURL_LIBS@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
+LLUA_CFLAGS = @LLUA_CFLAGS@
+LLUA_LIBS = @LLUA_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LUA_CPPFLAGS = @LUA_CPPFLAGS@
+LUA_LDFLAGS = @LUA_LDFLAGS@
+LUA_LIBS = @LUA_LIBS@
 MAKEINFO = @MAKEINFO@
 MKDIR_P = @MKDIR_P@
 MYSQL_CFLAGS = @MYSQL_CFLAGS@
Index: src/libs/zbxmemory/Makefile.in
===================================================================
--- src/libs/zbxmemory/Makefile.in	(revision 302)
+++ src/libs/zbxmemory/Makefile.in	(working copy)
@@ -45,9 +45,9 @@
 	$(top_srcdir)/m4/jabber.m4 $(top_srcdir)/m4/ldap.m4 \
 	$(top_srcdir)/m4/libcurl.m4 $(top_srcdir)/m4/libiodbc.m4 \
 	$(top_srcdir)/m4/libssh2.m4 $(top_srcdir)/m4/libunixodbc.m4 \
-	$(top_srcdir)/m4/netsnmp.m4 $(top_srcdir)/m4/openipmi.m4 \
-	$(top_srcdir)/m4/resolv.m4 $(top_srcdir)/m4/ucdsnmp.m4 \
-	$(top_srcdir)/configure.in
+	$(top_srcdir)/m4/lua.m4 $(top_srcdir)/m4/netsnmp.m4 \
+	$(top_srcdir)/m4/openipmi.m4 $(top_srcdir)/m4/resolv.m4 \
+	$(top_srcdir)/m4/ucdsnmp.m4 $(top_srcdir)/configure.in
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 mkinstalldirs = $(install_sh) -d
@@ -121,7 +121,12 @@
 LIBCURL_LIBS = @LIBCURL_LIBS@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
+LLUA_CFLAGS = @LLUA_CFLAGS@
+LLUA_LIBS = @LLUA_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LUA_CPPFLAGS = @LUA_CPPFLAGS@
+LUA_LDFLAGS = @LUA_LDFLAGS@
+LUA_LIBS = @LUA_LIBS@
 MAKEINFO = @MAKEINFO@
 MKDIR_P = @MKDIR_P@
 MYSQL_CFLAGS = @MYSQL_CFLAGS@
Index: src/libs/zbxjson/Makefile.in
===================================================================
--- src/libs/zbxjson/Makefile.in	(revision 302)
+++ src/libs/zbxjson/Makefile.in	(working copy)
@@ -45,9 +45,9 @@
 	$(top_srcdir)/m4/jabber.m4 $(top_srcdir)/m4/ldap.m4 \
 	$(top_srcdir)/m4/libcurl.m4 $(top_srcdir)/m4/libiodbc.m4 \
 	$(top_srcdir)/m4/libssh2.m4 $(top_srcdir)/m4/libunixodbc.m4 \
-	$(top_srcdir)/m4/netsnmp.m4 $(top_srcdir)/m4/openipmi.m4 \
-	$(top_srcdir)/m4/resolv.m4 $(top_srcdir)/m4/ucdsnmp.m4 \
-	$(top_srcdir)/configure.in
+	$(top_srcdir)/m4/lua.m4 $(top_srcdir)/m4/netsnmp.m4 \
+	$(top_srcdir)/m4/openipmi.m4 $(top_srcdir)/m4/resolv.m4 \
+	$(top_srcdir)/m4/ucdsnmp.m4 $(top_srcdir)/configure.in
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 mkinstalldirs = $(install_sh) -d
@@ -121,7 +121,12 @@
 LIBCURL_LIBS = @LIBCURL_LIBS@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
+LLUA_CFLAGS = @LLUA_CFLAGS@
+LLUA_LIBS = @LLUA_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LUA_CPPFLAGS = @LUA_CPPFLAGS@
+LUA_LDFLAGS = @LUA_LDFLAGS@
+LUA_LIBS = @LUA_LIBS@
 MAKEINFO = @MAKEINFO@
 MKDIR_P = @MKDIR_P@
 MYSQL_CFLAGS = @MYSQL_CFLAGS@
Index: src/libs/zbxdbcache/Makefile.in
===================================================================
--- src/libs/zbxdbcache/Makefile.in	(revision 302)
+++ src/libs/zbxdbcache/Makefile.in	(working copy)
@@ -45,9 +45,9 @@
 	$(top_srcdir)/m4/jabber.m4 $(top_srcdir)/m4/ldap.m4 \
 	$(top_srcdir)/m4/libcurl.m4 $(top_srcdir)/m4/libiodbc.m4 \
 	$(top_srcdir)/m4/libssh2.m4 $(top_srcdir)/m4/libunixodbc.m4 \
-	$(top_srcdir)/m4/netsnmp.m4 $(top_srcdir)/m4/openipmi.m4 \
-	$(top_srcdir)/m4/resolv.m4 $(top_srcdir)/m4/ucdsnmp.m4 \
-	$(top_srcdir)/configure.in
+	$(top_srcdir)/m4/lua.m4 $(top_srcdir)/m4/netsnmp.m4 \
+	$(top_srcdir)/m4/openipmi.m4 $(top_srcdir)/m4/resolv.m4 \
+	$(top_srcdir)/m4/ucdsnmp.m4 $(top_srcdir)/configure.in
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 mkinstalldirs = $(install_sh) -d
@@ -122,7 +122,12 @@
 LIBCURL_LIBS = @LIBCURL_LIBS@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
+LLUA_CFLAGS = @LLUA_CFLAGS@
+LLUA_LIBS = @LLUA_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LUA_CPPFLAGS = @LUA_CPPFLAGS@
+LUA_LDFLAGS = @LUA_LDFLAGS@
+LUA_LIBS = @LUA_LIBS@
 MAKEINFO = @MAKEINFO@
 MKDIR_P = @MKDIR_P@
 MYSQL_CFLAGS = @MYSQL_CFLAGS@
Index: src/libs/zbxdbcache/dbconfig.c
===================================================================
--- src/libs/zbxdbcache/dbconfig.c	(revision 302)
+++ src/libs/zbxdbcache/dbconfig.c	(working copy)
@@ -44,6 +44,7 @@
 #define	ZBX_DC_SSHITEM		struct zbx_dc_sshitem
 #define	ZBX_DC_TELNETITEM	struct zbx_dc_telnetitem
 #define	ZBX_DC_CALCITEM		struct zbx_dc_calcitem
+#define ZBX_DC_LUAITEM		struct zbx_dc_luaitem
 
 #define	ZBX_DC_HOST		struct zbx_dc_host
 #define	ZBX_DC_HOST_PH		struct zbx_dc_host_ph
@@ -145,6 +146,13 @@
 	const char	*params;		/* interned; params[ITEM_PARAMS_LEN_MAX];				*/
 };
 
+ZBX_DC_LUAITEM
+{
+	zbx_uint64_t	itemid;
+	const char	*username;
+	const char	*params;
+};
+
 ZBX_DC_HOST
 {
 	zbx_uint64_t	hostid;
@@ -203,6 +211,7 @@
 	zbx_hashset_t		sshitems;
 	zbx_hashset_t		telnetitems;
 	zbx_hashset_t		calcitems;
+	zbx_hashset_t		luaitems;
 	zbx_hashset_t		hosts;
 	zbx_hashset_t		hosts_ph;	/* proxy_hostid, host */
 	zbx_hashset_t		ipmihosts;
@@ -272,6 +281,10 @@
 			if (0 == CONFIG_IPMIPOLLER_FORKS)
 				break;
 			*poller_type = ZBX_POLLER_TYPE_IPMI;
+    case ITEM_TYPE_LUA:
+			if (0 == CONFIG_LUA_POLLER_FORKS)
+				break;
+			*poller_type = ZBX_POLLER_TYPE_LUA;
 			return;
 	}
 
@@ -505,6 +518,7 @@
 	ZBX_DC_SSHITEM		*sshitem;
 	ZBX_DC_TELNETITEM	*telnetitem;
 	ZBX_DC_CALCITEM		*calcitem;
+	ZBX_DC_LUAITEM		*luaitem;
 
 	ZBX_DC_ITEM_HK		*item_hk, item_hk_local;
 
@@ -796,6 +810,24 @@
 			zbx_strpool_release(calcitem->params);
 			zbx_hashset_remove(&config->calcitems, &itemid);
 		}
+		
+		/* Lua items */
+		
+		if (ITEM_TYPE_LUA == item->type)
+		{
+			luaitem = DCfind_id(&config->luaitems, itemid, sizeof(ZBX_DC_LUAITEM), &found);
+			
+			luaitem->itemid = itemid;
+			DCstrpool_replace(found, &luaitem->params, row[19]);
+			DCstrpool_replace(found, &luaitem->username, row[22]);
+
+		}
+		else if (NULL != (luaitem = zbx_hashset_search(&config->luaitems, &itemid)))
+		{
+			zbx_strpool_release(luaitem->params);
+			zbx_strpool_release(luaitem->username);
+			zbx_hashset_remove(&config->luaitems,&itemid);
+		}
 	}
 
 	/* remove deleted or disabled items from buffer */
@@ -908,6 +940,16 @@
 			zbx_strpool_release(calcitem->params);
 			zbx_hashset_remove(&config->calcitems, &itemid);
 		}
+		
+		/* Lua items */
+		
+		if (ITEM_TYPE_LUA == item->type)
+		{
+			luaitem = zbx_hashset_search(&config->luaitems, &itemid);
+			zbx_strpool_release(luaitem->params);
+			zbx_strpool_release(luaitem->username);
+			zbx_hashset_remove(&config->luaitems, &itemid);
+		}
 
 		/* items */
 
@@ -1250,6 +1292,8 @@
 			config->telnetitems.num_data, config->telnetitems.num_slots);
 	zabbix_log(LOG_LEVEL_DEBUG, "%s() calcitems  : %d (%d slots)", __function_name,
 			config->calcitems.num_data, config->calcitems.num_slots);
+	zabbix_log(LOG_LEVEL_DEBUG, "%s() luaitems   : %d (%d slots)", __function_name,
+			config->luaitems.num_data,config->luaitems.num_slots);
 	zabbix_log(LOG_LEVEL_DEBUG, "%s() hosts      : %d (%d slots)", __function_name,
 			config->hosts.num_data, config->hosts.num_slots);
 	zabbix_log(LOG_LEVEL_DEBUG, "%s() hosts_ph   : %d (%d slots)", __function_name,
@@ -1425,6 +1469,7 @@
 	CREATE_HASHSET(config->sshitems);
 	CREATE_HASHSET(config->telnetitems);
 	CREATE_HASHSET(config->calcitems);
+	CREATE_HASHSET(config->luaitems);
 
 	CREATE_HASHSET(config->hosts);
 	CREATE_HASHSET(config->ipmihosts);
@@ -1588,6 +1633,7 @@
 	const ZBX_DC_SSHITEM		*sshitem;
 	const ZBX_DC_TELNETITEM		*telnetitem;
 	const ZBX_DC_CALCITEM		*calcitem;
+	const ZBX_DC_LUAITEM		*luaitem;
 
 	dst_item->itemid = src_item->itemid;
 	dst_item->type = src_item->type;
@@ -1675,6 +1721,15 @@
 			dst_item->params = NULL;
 		}
 		break;
+	case ITEM_TYPE_LUA:
+		if (NULL != (luaitem = zbx_hashset_search(&config->luaitems,&src_item->itemid)))
+		{
+			strscpy(dst_item->params_orig, luaitem->params);
+			strscpy(dst_item->username_orig, luaitem->username);
+			dst_item->params = NULL;
+			dst_item->username=NULL;
+		}
+		break;
 	default:
 		/* nothing to do */;
 	}
Index: src/libs/zbxcommshigh/Makefile.in
===================================================================
--- src/libs/zbxcommshigh/Makefile.in	(revision 302)
+++ src/libs/zbxcommshigh/Makefile.in	(working copy)
@@ -45,9 +45,9 @@
 	$(top_srcdir)/m4/jabber.m4 $(top_srcdir)/m4/ldap.m4 \
 	$(top_srcdir)/m4/libcurl.m4 $(top_srcdir)/m4/libiodbc.m4 \
 	$(top_srcdir)/m4/libssh2.m4 $(top_srcdir)/m4/libunixodbc.m4 \
-	$(top_srcdir)/m4/netsnmp.m4 $(top_srcdir)/m4/openipmi.m4 \
-	$(top_srcdir)/m4/resolv.m4 $(top_srcdir)/m4/ucdsnmp.m4 \
-	$(top_srcdir)/configure.in
+	$(top_srcdir)/m4/lua.m4 $(top_srcdir)/m4/netsnmp.m4 \
+	$(top_srcdir)/m4/openipmi.m4 $(top_srcdir)/m4/resolv.m4 \
+	$(top_srcdir)/m4/ucdsnmp.m4 $(top_srcdir)/configure.in
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 mkinstalldirs = $(install_sh) -d
@@ -121,7 +121,12 @@
 LIBCURL_LIBS = @LIBCURL_LIBS@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
+LLUA_CFLAGS = @LLUA_CFLAGS@
+LLUA_LIBS = @LLUA_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LUA_CPPFLAGS = @LUA_CPPFLAGS@
+LUA_LDFLAGS = @LUA_LDFLAGS@
+LUA_LIBS = @LUA_LIBS@
 MAKEINFO = @MAKEINFO@
 MKDIR_P = @MKDIR_P@
 MYSQL_CFLAGS = @MYSQL_CFLAGS@
Index: src/libs/zbxcomms/Makefile.in
===================================================================
--- src/libs/zbxcomms/Makefile.in	(revision 302)
+++ src/libs/zbxcomms/Makefile.in	(working copy)
@@ -45,9 +45,9 @@
 	$(top_srcdir)/m4/jabber.m4 $(top_srcdir)/m4/ldap.m4 \
 	$(top_srcdir)/m4/libcurl.m4 $(top_srcdir)/m4/libiodbc.m4 \
 	$(top_srcdir)/m4/libssh2.m4 $(top_srcdir)/m4/libunixodbc.m4 \
-	$(top_srcdir)/m4/netsnmp.m4 $(top_srcdir)/m4/openipmi.m4 \
-	$(top_srcdir)/m4/resolv.m4 $(top_srcdir)/m4/ucdsnmp.m4 \
-	$(top_srcdir)/configure.in
+	$(top_srcdir)/m4/lua.m4 $(top_srcdir)/m4/netsnmp.m4 \
+	$(top_srcdir)/m4/openipmi.m4 $(top_srcdir)/m4/resolv.m4 \
+	$(top_srcdir)/m4/ucdsnmp.m4 $(top_srcdir)/configure.in
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 mkinstalldirs = $(install_sh) -d
@@ -121,7 +121,12 @@
 LIBCURL_LIBS = @LIBCURL_LIBS@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
+LLUA_CFLAGS = @LLUA_CFLAGS@
+LLUA_LIBS = @LLUA_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LUA_CPPFLAGS = @LUA_CPPFLAGS@
+LUA_LDFLAGS = @LUA_LDFLAGS@
+LUA_LIBS = @LUA_LIBS@
 MAKEINFO = @MAKEINFO@
 MKDIR_P = @MKDIR_P@
 MYSQL_CFLAGS = @MYSQL_CFLAGS@
Index: src/libs/zbxsys/Makefile.in
===================================================================
--- src/libs/zbxsys/Makefile.in	(revision 302)
+++ src/libs/zbxsys/Makefile.in	(working copy)
@@ -45,9 +45,9 @@
 	$(top_srcdir)/m4/jabber.m4 $(top_srcdir)/m4/ldap.m4 \
 	$(top_srcdir)/m4/libcurl.m4 $(top_srcdir)/m4/libiodbc.m4 \
 	$(top_srcdir)/m4/libssh2.m4 $(top_srcdir)/m4/libunixodbc.m4 \
-	$(top_srcdir)/m4/netsnmp.m4 $(top_srcdir)/m4/openipmi.m4 \
-	$(top_srcdir)/m4/resolv.m4 $(top_srcdir)/m4/ucdsnmp.m4 \
-	$(top_srcdir)/configure.in
+	$(top_srcdir)/m4/lua.m4 $(top_srcdir)/m4/netsnmp.m4 \
+	$(top_srcdir)/m4/openipmi.m4 $(top_srcdir)/m4/resolv.m4 \
+	$(top_srcdir)/m4/ucdsnmp.m4 $(top_srcdir)/configure.in
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 mkinstalldirs = $(install_sh) -d
@@ -121,7 +121,12 @@
 LIBCURL_LIBS = @LIBCURL_LIBS@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
+LLUA_CFLAGS = @LLUA_CFLAGS@
+LLUA_LIBS = @LLUA_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LUA_CPPFLAGS = @LUA_CPPFLAGS@
+LUA_LDFLAGS = @LUA_LDFLAGS@
+LUA_LIBS = @LUA_LIBS@
 MAKEINFO = @MAKEINFO@
 MKDIR_P = @MKDIR_P@
 MYSQL_CFLAGS = @MYSQL_CFLAGS@
Index: src/libs/zbxmedia/Makefile.in
===================================================================
--- src/libs/zbxmedia/Makefile.in	(revision 302)
+++ src/libs/zbxmedia/Makefile.in	(working copy)
@@ -45,9 +45,9 @@
 	$(top_srcdir)/m4/jabber.m4 $(top_srcdir)/m4/ldap.m4 \
 	$(top_srcdir)/m4/libcurl.m4 $(top_srcdir)/m4/libiodbc.m4 \
 	$(top_srcdir)/m4/libssh2.m4 $(top_srcdir)/m4/libunixodbc.m4 \
-	$(top_srcdir)/m4/netsnmp.m4 $(top_srcdir)/m4/openipmi.m4 \
-	$(top_srcdir)/m4/resolv.m4 $(top_srcdir)/m4/ucdsnmp.m4 \
-	$(top_srcdir)/configure.in
+	$(top_srcdir)/m4/lua.m4 $(top_srcdir)/m4/netsnmp.m4 \
+	$(top_srcdir)/m4/openipmi.m4 $(top_srcdir)/m4/resolv.m4 \
+	$(top_srcdir)/m4/ucdsnmp.m4 $(top_srcdir)/configure.in
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 mkinstalldirs = $(install_sh) -d
@@ -124,7 +124,12 @@
 LIBCURL_LIBS = @LIBCURL_LIBS@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
+LLUA_CFLAGS = @LLUA_CFLAGS@
+LLUA_LIBS = @LLUA_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LUA_CPPFLAGS = @LUA_CPPFLAGS@
+LUA_LDFLAGS = @LUA_LDFLAGS@
+LUA_LIBS = @LUA_LIBS@
 MAKEINFO = @MAKEINFO@
 MKDIR_P = @MKDIR_P@
 MYSQL_CFLAGS = @MYSQL_CFLAGS@
Index: src/libs/zbxcrypto/Makefile.in
===================================================================
--- src/libs/zbxcrypto/Makefile.in	(revision 302)
+++ src/libs/zbxcrypto/Makefile.in	(working copy)
@@ -45,9 +45,9 @@
 	$(top_srcdir)/m4/jabber.m4 $(top_srcdir)/m4/ldap.m4 \
 	$(top_srcdir)/m4/libcurl.m4 $(top_srcdir)/m4/libiodbc.m4 \
 	$(top_srcdir)/m4/libssh2.m4 $(top_srcdir)/m4/libunixodbc.m4 \
-	$(top_srcdir)/m4/netsnmp.m4 $(top_srcdir)/m4/openipmi.m4 \
-	$(top_srcdir)/m4/resolv.m4 $(top_srcdir)/m4/ucdsnmp.m4 \
-	$(top_srcdir)/configure.in
+	$(top_srcdir)/m4/lua.m4 $(top_srcdir)/m4/netsnmp.m4 \
+	$(top_srcdir)/m4/openipmi.m4 $(top_srcdir)/m4/resolv.m4 \
+	$(top_srcdir)/m4/ucdsnmp.m4 $(top_srcdir)/configure.in
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 mkinstalldirs = $(install_sh) -d
@@ -121,7 +121,12 @@
 LIBCURL_LIBS = @LIBCURL_LIBS@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
+LLUA_CFLAGS = @LLUA_CFLAGS@
+LLUA_LIBS = @LLUA_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LUA_CPPFLAGS = @LUA_CPPFLAGS@
+LUA_LDFLAGS = @LUA_LDFLAGS@
+LUA_LIBS = @LUA_LIBS@
 MAKEINFO = @MAKEINFO@
 MKDIR_P = @MKDIR_P@
 MYSQL_CFLAGS = @MYSQL_CFLAGS@
Index: src/libs/zbxlog/Makefile.in
===================================================================
--- src/libs/zbxlog/Makefile.in	(revision 302)
+++ src/libs/zbxlog/Makefile.in	(working copy)
@@ -45,9 +45,9 @@
 	$(top_srcdir)/m4/jabber.m4 $(top_srcdir)/m4/ldap.m4 \
 	$(top_srcdir)/m4/libcurl.m4 $(top_srcdir)/m4/libiodbc.m4 \
 	$(top_srcdir)/m4/libssh2.m4 $(top_srcdir)/m4/libunixodbc.m4 \
-	$(top_srcdir)/m4/netsnmp.m4 $(top_srcdir)/m4/openipmi.m4 \
-	$(top_srcdir)/m4/resolv.m4 $(top_srcdir)/m4/ucdsnmp.m4 \
-	$(top_srcdir)/configure.in
+	$(top_srcdir)/m4/lua.m4 $(top_srcdir)/m4/netsnmp.m4 \
+	$(top_srcdir)/m4/openipmi.m4 $(top_srcdir)/m4/resolv.m4 \
+	$(top_srcdir)/m4/ucdsnmp.m4 $(top_srcdir)/configure.in
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 mkinstalldirs = $(install_sh) -d
@@ -121,7 +121,12 @@
 LIBCURL_LIBS = @LIBCURL_LIBS@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
+LLUA_CFLAGS = @LLUA_CFLAGS@
+LLUA_LIBS = @LLUA_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LUA_CPPFLAGS = @LUA_CPPFLAGS@
+LUA_LDFLAGS = @LUA_LDFLAGS@
+LUA_LIBS = @LUA_LIBS@
 MAKEINFO = @MAKEINFO@
 MKDIR_P = @MKDIR_P@
 MYSQL_CFLAGS = @MYSQL_CFLAGS@
Index: src/libs/zbxlua/lua_uint64_lib.c
===================================================================
--- src/libs/zbxlua/lua_uint64_lib.c	(revision 0)
+++ src/libs/zbxlua/lua_uint64_lib.c	(revision 307)
@@ -0,0 +1,115 @@
+#include <lua.h>
+#include <lauxlib.h>
+
+#include "common.h"
+#include "zbxtypes.h"
+
+#include "zbx_lua_types.h"
+
+#include "log.h"
+#include "zlog.h"
+
+/* 
+ * The following code was found at the following url:
+ * http://codepad.org/LZpFrKbT
+ * Thank you to the unknown creator.
+ */
+
+#define U64_STR_LEN 21
+#define U64_LUA_TYPE "uint64"
+
+int is_lua_uint64(lua_State *L, int index)
+{
+	return (lua_isuserdata(L, index) && luaL_checkudata(L, index, U64_LUA_TYPE));
+}
+
+/* get value of Integer userdata or Lua number at index, or die */
+zbx_uint64_t checkuint64(lua_State *L, int index) {
+   if (is_lua_uint64(L, index)) {
+      return *(zbx_uint64_t*)lua_touserdata(L, index);
+   } else if (lua_isnumber(L, index)) {
+      return (zbx_uint64_t) lua_tonumber(L, index);
+   } else {
+      lua_pushstring(L, "Invalid operand. Expected '"U64_LUA_TYPE"' or 'number'");
+      lua_error(L);
+      return 0; /* will never get here */
+   }
+}
+
+int create_uint64(lua_State* L, zbx_uint64_t val) {
+   zbx_uint64_t* ud = lua_newuserdata(L, sizeof(zbx_uint64_t));
+   *ud = val;
+   luaL_getmetatable(L, U64_LUA_TYPE);
+   lua_setmetatable(L, -2);
+   return 1;
+}
+
+static int uint64_new (lua_State* L) { return create_uint64( L, checkuint64(L,1) ); }
+static int uint64_add (lua_State* L) { return create_uint64( L, checkuint64(L,1) + checkuint64(L,2) ); }
+static int uint64_sub (lua_State* L) { return create_uint64( L, checkuint64(L,1) - checkuint64(L,2) ); }
+static int uint64_mul (lua_State* L) { return create_uint64( L, checkuint64(L,1) * checkuint64(L,2) ); }
+static int uint64_div (lua_State* L) { return create_uint64( L, checkuint64(L,1) / checkuint64(L,2) ); }
+static int uint64_mod (lua_State* L) { return create_uint64( L, checkuint64(L,1) % checkuint64(L,2) ); }
+static int uint64_unm (lua_State* L) { return create_uint64( L, -checkuint64(L,1) ); }
+static int uint64_eq  (lua_State* L) { lua_pushboolean( L, checkuint64(L,1) == checkuint64(L,2) ); return 1; }
+static int uint64_lt  (lua_State* L) { lua_pushboolean( L, checkuint64(L,1) <  checkuint64(L,2) ); return 1; }
+static int uint64_le  (lua_State* L) { lua_pushboolean( L, checkuint64(L,1) <= checkuint64(L,2) ); return 1; }
+int uint64_tostring(lua_State* L) 
+{
+	char str[U64_STR_LEN];
+	
+	lua_pop(L,1);
+	lua_pushstring(L, str);
+	return 1;
+}
+int uint64_concat(lua_State* L)
+{
+	char *str1, *str2;
+	char *result;
+	
+	if (is_lua_uint64(L, -1))
+		str2=zbx_dsprintf(NULL,ZBX_FS_UI64,checkuint64(L,-1));
+	else 
+		str2=zbx_dsprintf(NULL,"%s",lua_tostring(L,-1));
+	lua_pop(L,1);
+
+	if (is_lua_uint64(L, -1))
+		str1=zbx_dsprintf(NULL,ZBX_FS_UI64,checkuint64(L,-1));
+	else 
+		str1=zbx_dsprintf(NULL,"%s",lua_tostring(L,-1));
+	
+	lua_pop(L,1);
+
+	result=zbx_dsprintf(NULL,"%s%s",str1,str2);
+	lua_pushstring(L,result);
+
+	zbx_free(result); 
+	zbx_free(str1);  
+	zbx_free(str2);
+	
+	return 1;
+}
+	
+
+int  luaopen_uint64 (lua_State* L) {
+	static const struct luaL_reg uint64_type[] = {
+		{ "__add", uint64_add },
+		{ "__sub", uint64_sub },
+		{ "__mul", uint64_mul },
+		{ "__div", uint64_div },
+		{ "__mod", uint64_mod },
+		{ "__unm", uint64_unm },
+		{ "__eq",  uint64_eq  },
+		{ "__lt",  uint64_lt  },
+		{ "__le",  uint64_le  },
+		{ "__tostring", uint64_tostring},
+		{ "__concat", uint64_concat},
+		{ "new",   uint64_new },
+		NULL, NULL
+	};
+	luaL_newmetatable(L, U64_LUA_TYPE);
+
+	luaL_register(L, NULL, uint64_type);
+
+	return 0;
+}
Index: src/libs/zbxlua/Makefile.in
===================================================================
--- src/libs/zbxlua/Makefile.in	(revision 0)
+++ src/libs/zbxlua/Makefile.in	(revision 305)
@@ -0,0 +1,505 @@
+# Makefile.in generated by automake 1.11.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009  Free Software Foundation,
+# Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+subdir = src/libs/zbxlua
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_ibm_db2.m4 \
+	$(top_srcdir)/m4/ax_lib_mysql.m4 \
+	$(top_srcdir)/m4/ax_lib_oracle_oci.m4 \
+	$(top_srcdir)/m4/ax_lib_postgresql.m4 \
+	$(top_srcdir)/m4/ax_lib_sqlite3.m4 $(top_srcdir)/m4/iconv.m4 \
+	$(top_srcdir)/m4/jabber.m4 $(top_srcdir)/m4/ldap.m4 \
+	$(top_srcdir)/m4/libcurl.m4 $(top_srcdir)/m4/libiodbc.m4 \
+	$(top_srcdir)/m4/libssh2.m4 $(top_srcdir)/m4/libunixodbc.m4 \
+	$(top_srcdir)/m4/lua.m4 $(top_srcdir)/m4/netsnmp.m4 \
+	$(top_srcdir)/m4/openipmi.m4 $(top_srcdir)/m4/resolv.m4 \
+	$(top_srcdir)/m4/ucdsnmp.m4 $(top_srcdir)/configure.in
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+	$(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/include/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+LIBRARIES = $(noinst_LIBRARIES)
+AR = ar
+ARFLAGS = cru
+libzbxlua_a_AR = $(AR) $(ARFLAGS)
+libzbxlua_a_LIBADD =
+am_libzbxlua_a_OBJECTS = zbxlua.$(OBJEXT) lua_uint64_lib.$(OBJEXT)
+libzbxlua_a_OBJECTS = $(am_libzbxlua_a_OBJECTS)
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+SOURCES = $(libzbxlua_a_SOURCES)
+DIST_SOURCES = $(libzbxlua_a_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+ARCH = @ARCH@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DB_CPPFLAGS = @DB_CPPFLAGS@
+DB_LDFLAGS = @DB_LDFLAGS@
+DB_LIBS = @DB_LIBS@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+GREP = @GREP@
+ICONV_CFLAGS = @ICONV_CFLAGS@
+ICONV_LDFLAGS = @ICONV_LDFLAGS@
+IKSEMEL_CFLAGS = @IKSEMEL_CFLAGS@
+IKSEMEL_LIBS = @IKSEMEL_LIBS@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+IODBC_CFLAGS = @IODBC_CFLAGS@
+IODBC_LDFLAGS = @IODBC_LDFLAGS@
+IODBC_LIBS = @IODBC_LIBS@
+JABBER_CPPFLAGS = @JABBER_CPPFLAGS@
+JABBER_LDFLAGS = @JABBER_LDFLAGS@
+JABBER_LIBS = @JABBER_LIBS@
+LDAP_CPPFLAGS = @LDAP_CPPFLAGS@
+LDAP_LDFLAGS = @LDAP_LDFLAGS@
+LDFLAGS = @LDFLAGS@
+LIBCURL_CFLAGS = @LIBCURL_CFLAGS@
+LIBCURL_LDFLAGS = @LIBCURL_LDFLAGS@
+LIBCURL_LIBS = @LIBCURL_LIBS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LLUA_CFLAGS = @LLUA_CFLAGS@
+LLUA_LIBS = @LLUA_LIBS@
+LTLIBOBJS = @LTLIBOBJS@
+LUA_CPPFLAGS = @LUA_CPPFLAGS@
+LUA_LDFLAGS = @LUA_LDFLAGS@
+LUA_LIBS = @LUA_LIBS@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+MYSQL_CFLAGS = @MYSQL_CFLAGS@
+MYSQL_CONFIG = @MYSQL_CONFIG@
+MYSQL_LDFLAGS = @MYSQL_LDFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
+MYSQL_VERSION = @MYSQL_VERSION@
+OBJEXT = @OBJEXT@
+ODBC_CFLAGS = @ODBC_CFLAGS@
+ODBC_LDFLAGS = @ODBC_LDFLAGS@
+ODBC_LIBS = @ODBC_LIBS@
+OPENIPMI_CFLAGS = @OPENIPMI_CFLAGS@
+OPENIPMI_LDFLAGS = @OPENIPMI_LDFLAGS@
+OPENIPMI_LIBS = @OPENIPMI_LIBS@
+ORACLE_CPPFLAGS = @ORACLE_CPPFLAGS@
+ORACLE_LDFLAGS = @ORACLE_LDFLAGS@
+ORACLE_LIBS = @ORACLE_LIBS@
+ORACLE_OCI_CFLAGS = @ORACLE_OCI_CFLAGS@
+ORACLE_OCI_LDFLAGS = @ORACLE_OCI_LDFLAGS@
+ORACLE_OCI_LIBS = @ORACLE_OCI_LIBS@
+ORACLE_OCI_VERSION = @ORACLE_OCI_VERSION@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PG_CONFIG = @PG_CONFIG@
+PKG_CONFIG = @PKG_CONFIG@
+POSTGRESQL_CPPFLAGS = @POSTGRESQL_CPPFLAGS@
+POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@
+POSTGRESQL_VERSION = @POSTGRESQL_VERSION@
+PROXY_LDFLAGS = @PROXY_LDFLAGS@
+PROXY_LIBS = @PROXY_LIBS@
+RANLIB = @RANLIB@
+RESOLV_LIBS = @RESOLV_LIBS@
+SERVER_LDFLAGS = @SERVER_LDFLAGS@
+SERVER_LIBS = @SERVER_LIBS@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SNMP_CFLAGS = @SNMP_CFLAGS@
+SNMP_CPPFLAGS = @SNMP_CPPFLAGS@
+SNMP_LDFLAGS = @SNMP_LDFLAGS@
+SNMP_LIBS = @SNMP_LIBS@
+SQLITE3_CPPFLAGS = @SQLITE3_CPPFLAGS@
+SQLITE3_LDFLAGS = @SQLITE3_LDFLAGS@
+SQLITE3_VERSION = @SQLITE3_VERSION@
+SSH2_CFLAGS = @SSH2_CFLAGS@
+SSH2_LDFLAGS = @SSH2_LDFLAGS@
+SSH2_LIBS = @SSH2_LIBS@
+STRIP = @STRIP@
+UNIXODBC_CFLAGS = @UNIXODBC_CFLAGS@
+UNIXODBC_LDFLAGS = @UNIXODBC_LDFLAGS@
+UNIXODBC_LIBS = @UNIXODBC_LIBS@
+VERSION = @VERSION@
+_libcurl_config = @_libcurl_config@
+_libnetsnmp_config = @_libnetsnmp_config@
+_libodbc_config = @_libodbc_config@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+noinst_LIBRARIES = libzbxlua.a
+libzbxlua_a_SOURCES = zbxlua.c  lua_uint64_lib.c
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .o .obj
+$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
+	@for dep in $?; do \
+	  case '$(am__configure_deps)' in \
+	    *$$dep*) \
+	      ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+	        && { if test -f $@; then exit 0; else break; fi; }; \
+	      exit 1;; \
+	  esac; \
+	done; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/libs/zbxlua/Makefile'; \
+	$(am__cd) $(top_srcdir) && \
+	  $(AUTOMAKE) --gnu src/libs/zbxlua/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+	@case '$?' in \
+	  *config.status*) \
+	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+	  *) \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure:  $(am__configure_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+clean-noinstLIBRARIES:
+	-test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES)
+libzbxlua.a: $(libzbxlua_a_OBJECTS) $(libzbxlua_a_DEPENDENCIES) 
+	-rm -f libzbxlua.a
+	$(libzbxlua_a_AR) libzbxlua.a $(libzbxlua_a_OBJECTS) $(libzbxlua_a_LIBADD)
+	$(RANLIB) libzbxlua.a
+
+mostlyclean-compile:
+	-rm -f *.$(OBJEXT)
+
+distclean-compile:
+	-rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lua_uint64_lib.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/zbxlua.Po@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	mkid -fID $$unique
+tags: TAGS
+
+TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	set x; \
+	here=`pwd`; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	shift; \
+	if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+	  test -n "$$unique" || unique=$$empty_fix; \
+	  if test $$# -gt 0; then \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      "$$@" $$unique; \
+	  else \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      $$unique; \
+	  fi; \
+	fi
+ctags: CTAGS
+CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	test -z "$(CTAGS_ARGS)$$unique" \
+	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+	     $$unique
+
+GTAGS:
+	here=`$(am__cd) $(top_builddir) && pwd` \
+	  && $(am__cd) $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	list='$(DISTFILES)'; \
+	  dist_files=`for file in $$list; do echo $$file; done | \
+	  sed -e "s|^$$srcdirstrip/||;t" \
+	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+	case $$dist_files in \
+	  */*) $(MKDIR_P) `echo "$$dist_files" | \
+			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+			   sort -u` ;; \
+	esac; \
+	for file in $$dist_files; do \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  if test -d $$d/$$file; then \
+	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d "$(distdir)/$$file"; then \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
+	    cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+	  else \
+	    test -f "$(distdir)/$$file" \
+	    || cp -p $$d/$$file "$(distdir)/$$file" \
+	    || exit 1; \
+	  fi; \
+	done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LIBRARIES)
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	  `test -z '$(STRIP)' || \
+	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+	-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-noinstLIBRARIES mostlyclean-am
+
+distclean: distclean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+	distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+	clean-noinstLIBRARIES ctags distclean distclean-compile \
+	distclean-generic distclean-tags distdir dvi dvi-am html \
+	html-am info info-am install install-am install-data \
+	install-data-am install-dvi install-dvi-am install-exec \
+	install-exec-am install-html install-html-am install-info \
+	install-info-am install-man install-pdf install-pdf-am \
+	install-ps install-ps-am install-strip installcheck \
+	installcheck-am installdirs maintainer-clean \
+	maintainer-clean-generic mostlyclean mostlyclean-compile \
+	mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \
+	uninstall-am
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
Index: src/libs/zbxlua/zbxlua.c
===================================================================
--- src/libs/zbxlua/zbxlua.c	(revision 0)
+++ src/libs/zbxlua/zbxlua.c	(revision 308)
@@ -0,0 +1,676 @@
+/*
+ * ** ZABBIX
+ * ** Copyright (C) 2000-2005 SIA Zabbix
+ * **
+ * ** This program is free software; you can redistribute it and/or modify
+ * ** it under the terms of the GNU General Public License as published by
+ * ** the Free Software Foundation; either version 2 of the License, or
+ * ** (at your option) any later version.
+ * **
+ * ** This program is distributed in the hope that it will be useful,
+ * ** but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * ** GNU General Public License for more details.
+ * **
+ * ** You should have received a copy of the GNU General Public License
+ * ** along with this program; if not, write to the Free Software
+ * ** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * **/
+
+#include <time.h>
+
+#include "lua.h"
+#include "lualib.h"
+#include "lauxlib.h"
+
+#include "common.h"
+#include "log.h"
+#include "zlog.h"
+#include "db.h"
+#include "dbcache.h"
+#include "zbxlua.h"
+#include "lua_cfg.h"
+
+#include "zbx_lua_types.h"
+
+typedef struct lua_global_int {
+	const char *name;
+	int val;
+} lua_global_int;
+
+typedef struct lua_global_str {
+	const char *name;
+	const char *val;
+} lua_global_str;
+
+char* username=NULL;
+/*
+
+The following is more notes than anything else.
+Rolled up permissions query:
+
+
+select i.itemid 
+from items i, hosts h, hosts_groups hg, rights r, users_groups ug, users u 
+where i.hostid=h.hostid and h.hostid=hg.hostid and hg.groupid=r.id 
+ and r.groupid=ug.usrgrpid and ug.userid=u.userid 
+ and i.itemid in (22162,22163) and u.alias='nelsonab';
+
+This first creates a temporary table with the items we're interested.
+
+Then the query is run, the query will only return the itemid and the permission 
+available or null (for no intrinsic permissions)
+In the innermost query the username needs to be set.
+
+drop table tmp_items;
+
+CREATE TEMPORARY TABLE tmp_items (itemid int unsigned not null default 0) engine=memory;
+
+INSERT INTO tmp_items
+(itemid)
+VALUES
+(22162),(22163),(22165),(1234);
+
+select i.itemid, i.hostid, ur.permission, ur.alias from
+(select ti.itemid, i.hostid, hg.groupid
+from tmp_items ti
+left join items i on ti.itemid=i.itemid
+left join hosts_groups hg on i.hostid=hg.hostid) i
+left join
+(select r.id, ug.usrgrpid, r.permission, u.alias from rights r
+left join users_groups ug on ug.usrgrpid=r.groupid 
+right join 
+(select alias, userid
+from users where alias='nelsonab') 
+as u on u.userid=ug.userid) 
+as ur on i.groupid=ur.id
+group by itemid
+
+
+
+select a single item and user:
+select i.itemid, i.hostid, ur.permission, ur.alias from
+(select i.itemid, i.hostid, hg.groupid
+from items i
+join hosts_groups hg on i.hostid=hg.hostid
+where i.itemid=22165) i
+left join
+(select r.id, ug.usrgrpid, r.permission, u.alias from rights r
+left join users_groups ug on ug.usrgrpid=r.groupid 
+right join 
+(select alias, userid
+from users where alias='nelsonab') 
+as u on u.userid=ug.userid
+order by r.permission desc) 
+as ur on i.groupid=ur.id
+group by itemid
+
+*/
+
+int check_itemid_read_permission(char* username, int itemid)
+{
+	DB_RESULT result;
+	DB_ROW row;
+	int retval;
+	
+	zabbix_log(LOG_LEVEL_DEBUG,"Startig check_itemid_read_permission  %s:%d",username,itemid);
+	
+	if (CONFIG_LUA_CHECK_PERMISSIONS==0)
+	{ 
+		zabbix_log(LOG_LEVEL_DEBUG,"Permissions skipped (%s:%d)",username,itemid);
+		return SUCCEED;
+	}
+	
+	result = DBselect("select type from users where alias='%s'",username);
+	
+	if (NULL != (row=DBfetch(result)))
+		if (NULL==row[0])
+			return FAIL;  /* user not found, fail */
+		else
+			if (3==atoi(row[0]))
+				return SUCCEED;  /* Zabbix Super Admin has full privs */
+		/* otherwise continue */
+		
+	DBfree_result(result);
+
+	result = DBselect(
+		"select ur.permission from "
+		"(select i.itemid, i.hostid, hg.groupid "
+		"from items i "
+		"join hosts_groups hg on i.hostid=hg.hostid "
+		"where i.itemid=%d) i "
+		"left join "
+		"(select r.id, ug.usrgrpid, r.permission, u.alias from rights r "
+		"left join users_groups ug on ug.usrgrpid=r.groupid "
+		"right join "
+		"(select alias, userid "
+		"from users where alias='%s') "
+		"as u on u.userid=ug.userid "
+		"order by r.permission desc) "
+		"as ur on i.groupid=ur.id "
+		"group by itemid",itemid, username);
+	
+	if (NULL != (row=DBfetch(result)))
+	{
+		if (row[0]==NULL)
+			retval=FAIL;
+		else
+			retval = (atoi(row[0])!=1) ? SUCCEED : FAIL;
+	}
+	else
+	{
+		retval =FAIL;
+	}
+
+	zabbix_log(LOG_LEVEL_DEBUG,"Permissions check for %s on %d: %s",username,itemid,
+		(retval ? "TRUE" : "FAIL"));
+
+	DBfree_result(result);
+	
+	return retval;
+}
+
+int check_hostid_read_permission(char* username, zbx_uint64_t hostid)
+{
+	const char *_name = "check_hostid_read_permission";
+	DB_RESULT result;
+	DB_ROW row;
+	int retval;
+	
+	zabbix_log(LOG_LEVEL_DEBUG,"Startig %s  %s:%llu",_name,username,hostid);
+	
+	if (CONFIG_LUA_CHECK_PERMISSIONS==0)
+	{ 
+		zabbix_log(LOG_LEVEL_DEBUG,"Permissions skipped (%s:%llu)",username,hostid);
+		return SUCCEED;
+	}
+	
+	result = DBselect("select type from users where alias='%s'",username);
+	
+	if (NULL != (row=DBfetch(result)))
+		if (NULL==row[0])
+			return FAIL;  /* user not found, fail */
+		else
+			if (3==atoi(row[0]))
+				return SUCCEED;  /* Zabbix Super Admin has full privs */
+		/* otherwise continue */
+		
+	DBfree_result(result);
+
+	result = DBselect(
+		"select ur.permission from "
+		"(select hg.hostid, hg.groupid "
+		"from hosts_groups hg "
+		"where hg.hostid=%llu) h "
+		"left join "
+		"(select r.id, ug .usrgrpid, r.permission, u.alias from rights r "
+		"left join users_groups ug on ug.usrgrpid=r.groupid "
+		"right join "
+		"(select alias, userid "
+		"from users where alias='%s') "
+		"as u on u.userid=ug.userid "
+		"order by r.permission desc) "
+		"as ur on h.groupid=ur.id "
+		"group by hostid",hostid, username);
+
+	if (NULL != (row=DBfetch(result)))
+	{
+		if (row[0]==NULL)
+			retval=FAIL;
+		else
+			retval = (atoi(row[0])!=1) ? SUCCEED : FAIL;
+	}
+	else
+	{
+		retval =FAIL;
+	}
+
+	zabbix_log(LOG_LEVEL_DEBUG,"Permissions check for %s on %d: %s",username,hostid,
+		(retval ? "TRUE" : "FAIL"));
+
+	DBfree_result(result);
+	
+	return retval;
+}
+
+/*
+ * zbx_uint64_t get_hostid_from_host(char*)
+ * retrieve the hostid from the database for the given string hostid
+ * returns the hostid or FAIL (-1)
+ */
+
+zbx_uint64_t get_hostid_from_host(char* hostname)
+{
+	const char* _name = "get_hostid_from_host";
+	DB_RESULT result;
+	DB_ROW row;
+	zbx_uint64_t retval=0;
+	int success=SUCCEED;
+
+	result = DBselect("select hostid from hosts where host='%s'",hostname);
+
+	if (NULL != (row=DBfetch(result)))
+	{
+		if (NULL==row[0])
+			success=FAIL;  /* hostid not found, fail */
+		else
+			success=str2uint64(row[0],&retval);
+	}
+	else 
+		success=FAIL;
+
+	DBfree_result(result);
+
+	return success==SUCCEED ? retval : FAIL;
+}
+
+/******************************************************************************
+ *                                                                            *
+ * Function: lua_get_item                                                     *
+ *                                                                            *
+ * Purpose: C function called by Lua to retrieve an item's value, and time    *
+ *          of last check                                                     *
+ *                                                                            *
+ * Parameters: L (Lua state to use)                                           *
+ *                                                                            *
+ * Return value:  int, the number of results placed on the stack, should be 2 *
+ *                Lua return should be val, clock in that order               *
+ *                                                                            *
+ * Author: Andrew Nelson                                                      *
+ *                                                                            *
+ * Comments:                                                                  *
+ *           Lua function definition:                                         *
+ *           get_item(itemid,nodeid)                                          *
+ *            - nodeid is optionsal and has a default value of 0              *
+ *                                                                            *
+ ******************************************************************************/
+int lua_item_get_last(lua_State* L)
+{
+	const char* _name="lua_item_get_last";
+	int stack_i = lua_gettop(L);
+	zbx_uint64_t itemid, nodeid;
+	DB_RESULT result;
+	DB_ROW row;
+	
+	nodeid=0;
+	
+	if (lua_gettop(L)<1)
+	{
+		zabbix_log(LOG_LEVEL_ERR,"%s Did not recieve enough values",_name);
+		lua_error(L,"One or more arguments expected");
+	}
+	
+	/* Two parameters (or more) were passed */
+	if (lua_gettop(L)>1)
+	{
+		if (lua_isnumber(L,-1))
+		{
+			nodeid=(zbx_uint64_t)lua_tointeger(L,-1);
+		}else if (is_lua_uint64(L,-1))
+		{
+			nodeid=checkuint64(L,-1);
+		}
+		else
+		{
+			lua_error(L,"[%s] expected to receive a number for nodeid.  received: %s","get_last",lua_tostring(L,-1));
+		}
+		lua_pop(L,1);
+	}
+	
+	/* process itemid parameter */
+	if (lua_isnumber(L,-1))
+	{
+		itemid=(zbx_uint64_t)lua_tointeger(L,-1);
+		zabbix_log(LOG_LEVEL_DEBUG,"[%s] itemid number: %llu",_name,itemid);
+	}else if (is_lua_uint64(L,-1))
+	{
+		itemid=checkuint64(L,-1);		
+		zabbix_log(LOG_LEVEL_DEBUG,"[%s] itemid uint64: %llu",_name,itemid);
+	}
+	else
+	{
+		lua_error(L,"[%s] expected to receive a number for itemid.  received: %s","get_last",lua_tostring(L,-1));
+	}
+	
+	lua_pop(L,1);
+		
+	zabbix_log(LOG_LEVEL_DEBUG,"[%s] itemid: %llu   nodeid:%llu",_name,itemid,nodeid);
+	
+	itemid=nodeid*(10^14)+itemid;   /* nodeids are 14 digits to the left */
+	
+	zabbix_log(LOG_LEVEL_DEBUG,"[%s] final itemid: %llu",_name,itemid);
+	
+	if (check_itemid_read_permission(username,itemid)!=SUCCEED)
+	{
+		lua_error(L, "%s does not have read permission to itemid: %llu",username,itemid);
+	}
+
+	result = DBselect(
+		"select clock,value"
+		" from history_uint"
+		" where itemid=%llu"
+		" order by clock desc"
+		" limit 1",
+		itemid);
+
+	if (NULL != (row=DBfetch(result)))
+	{
+		zabbix_log(LOG_LEVEL_DEBUG,"%s: row[0]:%s  row[1]:%s",_name,row[0],row[1]);
+		lua_pushnumber(L,atoi(row[0]));  /* push clock */		
+		lua_pushnumber(L,atoi(row[1]));  /* push value */
+	}
+	else
+	{
+		zabbix_log(LOG_LEVEL_DEBUG,"%s: no row returned",_name);
+		lua_pushnumber(L,0);
+		lua_pushnumber(L,0);
+	}
+	
+	DBfree_result(result);
+	return 2;  /* Be sure to tell Lua how many items we are returning on the stack */
+}
+
+/*
+ * get_itemid(lua_State)
+ * Retrives the itemid from a given host,key pair
+ * host and key are string values
+ */
+int lua_get_itemid(lua_State *L)
+{
+	const char* _name="lua_get_itemid";
+	char* host;
+	char* key;
+	zbx_uint64_t hostid,itemid;
+	DB_RESULT result;
+	DB_ROW row;
+
+	
+	if (lua_gettop(L)<2)
+	{
+		lua_error(L,"%s expected 2 or more parameters","get_itemid");
+	}
+	
+	key=lua_tostring(L,-1);
+	lua_pop(L,1);
+	
+	host=lua_tostring(L,-1);
+	lua_pop(L,1);
+	
+	zabbix_log(LOG_LEVEL_WARNING,"[%s] Received (host,key) (%s,%s)",_name,host,key);
+	
+	hostid=get_hostid_from_host(host);  /* This can probably be rolled into the query below */
+	zabbix_log(LOG_LEVEL_WARNING,"[%s] hostid: %llu",_name,hostid);
+
+	if (check_hostid_read_permission(username,hostid)!=SUCCEED)
+	{
+		lua_error(L, "%s does not have read permission to itemid: %llu",username,hostid);
+	}
+
+	result = DBselect("select itemid from items where hostid=%llu and key_='%s' limit 1",hostid,key);
+
+	if (NULL != (row=DBfetch(result)))
+	{
+		zabbix_log(LOG_LEVEL_WARNING,"[%s] key:%s",_name,row[0]);
+		str2uint64(row[0],&itemid);
+		create_uint64(L,itemid);  /* push value */		
+	}
+	else
+	{
+		zabbix_log(LOG_LEVEL_WARNING,"[%s] no row returned",_name);
+		create_uint64(L,0);
+	}
+	
+	DBfree_result(result);
+	return 1;  /* Be sure to tell Lua how many items we are returning on the stack */
+}
+
+/*
+ * lua_now(lua_State)
+ * Pushes the current time (in time_t since epoch) to the Lua stack
+ * Returns 1 (number of values pushed to the Lua stack)
+ */
+int lua_now(lua_State *L)
+{
+	time_t seconds;
+	
+	seconds=time(NULL);
+	lua_pushnumber(L,seconds);
+	return 1;
+}
+
+/******************************************************************************
+ *                                                                            *
+ * Function: __lua_error                                                      *
+ *                                                                            *
+ * Purpose: Wrapper for luaL_error and zabbix_log                             *
+ *                                                                            *
+ * Parameters: L (Lua state to use), format string, parameters                *
+ *                                                                            *
+ * Return value:                                                              *
+ *                                                                            *
+ * Author: Andrew Nelson                                                      *
+ *                                                                            *
+ * Comments:                                                                  *
+ *                                                                            *
+ ******************************************************************************/
+void __lua_error(lua_State *L, const char *fmt, ...)
+{
+	va_list args;
+	char *str=NULL;
+	
+	va_start(args,fmt);
+	str=zbx_dvsprintf(str,fmt,args);
+	va_end(args);
+	
+	zabbix_log(LOG_LEVEL_WARNING,"Lua error: %s",str);
+	luaL_error(L, str);
+		
+	zbx_free(str);
+}
+
+/******************************************************************************
+ *                                                                            *
+ * Function: lua_zabbix_log                                                   *
+ *                                                                            *
+ * Purpose: C function wrapper for Lua to zabbix_log                          *
+ *                                                                            *
+ * Parameters: L (Lua state to use)                                           *
+ *                                                                            *
+ * Return value: int, 0 (number of values put on Lua stack)                   *
+ *                                                                            *
+ * Author: Andrew Nelson                                                      *
+ *                                                                            *
+ * Comments:                                                                  *
+ *                                                                            *
+ ******************************************************************************/
+
+int lua_zabbix_log(lua_State* L)
+{
+  int nArgs = lua_gettop(L);
+  int level=lua_tointeger(L,1);
+  const char *s=NULL;
+  s = lua_tostring(L,2);
+	
+  zabbix_log(level,"lua_log: %s",s);
+	
+	return 0;
+}
+
+/******************************************************************************
+ *                                                                            *
+ * Function: execute_lua                                                      *
+ *                                                                            *
+ * Purpose: Executes the Lua script given by item                             *
+ *                                                                            *
+ * Parameters: L (Lua state to use), item                                     *
+ *                                                                            *
+ * Return value: int, returns the result of the lua call, any results of the  *
+ *               Lua call itself will be available on the Lua stack           *
+ *                                                                            *
+ * Author: Andrew Nelson                                                      *
+ *                                                                            *
+ * Comments:                                                                  *
+ *                                                                            *
+ ******************************************************************************/
+int execute_lua(lua_State *L, char *params, DC_ITEM *item)
+{
+	const char* _name="execute_lua";
+	int retval;
+	
+	update_env(L,item);
+	add_parameters(L,params);
+	if (item->username_orig==NULL || strcmp(item->username_orig,"")==0)
+	{
+		zabbix_log(LOG_LEVEL_DEBUG,"[%s] Username not given for Lua script, using: %s",_name,CONFIG_LUA_DEFAULT_USER);
+		username=CONFIG_LUA_DEFAULT_USER;
+	}
+	else
+	{
+		username=item->username_orig;
+		zabbix_log(LOG_LEVEL_DEBUG,"[%s] Executing Lua script as user: %s",_name,username);
+	}
+	zabbix_log(LOG_LEVEL_DEBUG,"[%s] Received parameters: %s",_name,params);
+	zabbix_log(LOG_LEVEL_DEBUG,"[%s] Executing: %s",_name,item->params_orig);
+	
+	retval = luaL_dostring(L,item->params_orig);  /* 0==SUCCEEED */
+	zabbix_log(LOG_LEVEL_DEBUG,"[%s] Retval from luaL_dostring: %s",_name, retval==0 ? "SUCCESS" : "FAIL");
+	
+	if (!lua_isstring(L,-1))  /* Do we have a string on the stack?  If not fix it. */
+	{
+	  if (is_lua_uint64(L,-1))
+			uint64_tostring(L);
+		if (lua_isnoneornil(L,-1))
+		{
+			lua_pushstring(L,"Return value is invalid or nil");
+			retval=FAIL;
+		}
+    else
+		{
+			lua_pushstring(L,"Unknown Lua return type.  Lua script return type must convert to string");
+			retval=FAIL;
+		}
+	}
+	
+	/* return retval if it is not success (0), return 1 if non or nil, return 0 (success) otherwise */
+	if (retval!=FAIL)
+		retval = retval!=SUCCEED ? retval : lua_isnoneornil(L,-1);
+	return retval;
+}
+
+int add_parameters(lua_State *L, char *params)
+{
+	int argc,i;
+	char	param[MAX_STRING_LEN];
+
+	argc = num_param(params);
+
+	lua_pushnumber(L,argc);
+	lua_setglobal(L,"ARGC");
+	
+	lua_newtable(L);
+	for(i=1; i<=argc; i++)
+	{
+		get_param(params,i,param,MAX_STRING_LEN);
+		lua_pushnumber(L,i);
+		lua_pushstring(L,param);
+		lua_settable(L,-3);
+	}
+	lua_setglobal(L,"ARGV");
+}
+
+int update_env(lua_State *L,DC_ITEM *item)
+{
+	
+	lua_pushstring(L,item->host.host);
+	lua_setglobal(L,"zbx_host");
+	
+	lua_pushinteger(L,item->host.hostid);
+	lua_setglobal(L,"zbx_hostid");
+	
+	lua_settop(L, 0);  /* force some garbage collection */
+
+}
+
+/******************************************************************************
+ *                                                                            *
+ * Function: init_lua_env                                                     *
+ *                                                                            *
+ * Purpose: Initialize the Lua environment and set it up with the appropriate *
+ *          basic Zabbix functions and variables.                             *
+ *                                                                            *
+ * Parameters:                                                                *
+ *                                                                            *
+ * Return value: Initialized Lua state                                        *
+ *                                                                            *
+ * Author: Andrew Nelson                                                      *
+ *                                                                            *
+ * Comments:                                                                  *
+ *                                                                            *
+ ******************************************************************************/
+
+lua_State *init_lua_env()
+{
+	const luaL_reg *func;
+	const lua_global_int *globalint;
+	const lua_global_str *globalstr;
+	int result;
+	
+	/* setup a table to make it easier to register functions */
+	static const luaL_reg luafunctions[] =
+	{
+		{ "zabbix_log",				lua_zabbix_log },
+		{ "get_last",				lua_item_get_last },
+		{ "now",					lua_now },
+		{ "get_itemid",				lua_get_itemid },
+		{ NULL,						NULL }
+	};
+
+	/* setup a table to make it easier to register globals */
+
+	static const lua_global_int luaglobalint[] =
+	{
+		{ "LOG_LEVEL_EMPTY",		0 },
+		{ "LOG_LEVEL_CRIT",			1 },
+		{ "LOG_LEVEL_ERR",			2 },
+		{ "LOG_LEVEL_WARNING",		3 },
+		{ "LOG_LEVEL_DEBUG",		4 },
+		{ NULL,						NULL }
+	};
+
+	static const lua_global_str luaglobalstr[] =
+	{
+		{ "TEST_STR",		"test string" },
+		{ NULL, 			NULL }
+	};
+
+	lua_State* L = lua_open();
+
+	luaopen_base(L);
+	luaopen_uint64(L);
+
+	for (globalint = luaglobalint; globalint->name != NULL; globalint++)
+	{
+		lua_pushinteger(L,globalint->val);
+		lua_setglobal(L,globalint->name);
+	}  
+
+	for (globalstr = luaglobalstr; globalstr->name != NULL; globalstr++)
+	{
+		lua_pushstring(L,globalstr->val);
+		lua_setglobal(L,globalstr->name);
+	}  
+
+	for (func = luafunctions; func->func != NULL; func++)
+	{
+		lua_register(L,func->name,func->func);
+	}  
+	
+	if (CONFIG_LUA_SCRIPT_LIBRARY!=NULL)
+		if ((result=luaL_dofile(L, CONFIG_LUA_SCRIPT_LIBRARY))!=0)
+			zabbix_log(LOG_LEVEL_ERR,"Error loading Lua library %s, error #%d  msg:%s",CONFIG_LUA_SCRIPT_LIBRARY,result,lua_tostring(L,-1));
+
+	lua_settop(L,0);
+	
+  return L;
+}
+
Index: src/libs/zbxlua/Makefile.am
===================================================================
--- src/libs/zbxlua/Makefile.am	(revision 0)
+++ src/libs/zbxlua/Makefile.am	(revision 305)
@@ -0,0 +1,5 @@
+## Process this file with automake to produce Makefile.in
+
+noinst_LIBRARIES = libzbxlua.a
+
+libzbxlua_a_SOURCES = zbxlua.c  lua_uint64_lib.c
Index: src/libs/zbxlua/Makefile
===================================================================
--- src/libs/zbxlua/Makefile	(revision 0)
+++ src/libs/zbxlua/Makefile	(revision 305)
@@ -0,0 +1,505 @@
+# Makefile.in generated by automake 1.11.1 from Makefile.am.
+# src/libs/zbxlua/Makefile.  Generated from Makefile.in by configure.
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009  Free Software Foundation,
+# Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+
+
+
+pkgdatadir = $(datadir)/zabbix
+pkgincludedir = $(includedir)/zabbix
+pkglibdir = $(libdir)/zabbix
+pkglibexecdir = $(libexecdir)/zabbix
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = i686-pc-linux-gnu
+host_triplet = i686-pc-linux-gnu
+subdir = src/libs/zbxlua
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_ibm_db2.m4 \
+	$(top_srcdir)/m4/ax_lib_mysql.m4 \
+	$(top_srcdir)/m4/ax_lib_oracle_oci.m4 \
+	$(top_srcdir)/m4/ax_lib_postgresql.m4 \
+	$(top_srcdir)/m4/ax_lib_sqlite3.m4 $(top_srcdir)/m4/iconv.m4 \
+	$(top_srcdir)/m4/jabber.m4 $(top_srcdir)/m4/ldap.m4 \
+	$(top_srcdir)/m4/libcurl.m4 $(top_srcdir)/m4/libiodbc.m4 \
+	$(top_srcdir)/m4/libssh2.m4 $(top_srcdir)/m4/libunixodbc.m4 \
+	$(top_srcdir)/m4/lua.m4 $(top_srcdir)/m4/netsnmp.m4 \
+	$(top_srcdir)/m4/openipmi.m4 $(top_srcdir)/m4/resolv.m4 \
+	$(top_srcdir)/m4/ucdsnmp.m4 $(top_srcdir)/configure.in
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+	$(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/include/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+LIBRARIES = $(noinst_LIBRARIES)
+AR = ar
+ARFLAGS = cru
+libzbxlua_a_AR = $(AR) $(ARFLAGS)
+libzbxlua_a_LIBADD =
+am_libzbxlua_a_OBJECTS = zbxlua.$(OBJEXT) lua_uint64_lib.$(OBJEXT)
+libzbxlua_a_OBJECTS = $(am_libzbxlua_a_OBJECTS)
+DEFAULT_INCLUDES = -I. -I$(top_builddir)/include
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+SOURCES = $(libzbxlua_a_SOURCES)
+DIST_SOURCES = $(libzbxlua_a_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = ${SHELL} /home/nelsonab/svn.red-tux.net/trunk/lua/1.8.5/missing --run aclocal-1.11
+AMTAR = ${SHELL} /home/nelsonab/svn.red-tux.net/trunk/lua/1.8.5/missing --run tar
+ARCH = linux
+AUTOCONF = ${SHELL} /home/nelsonab/svn.red-tux.net/trunk/lua/1.8.5/missing --run autoconf
+AUTOHEADER = ${SHELL} /home/nelsonab/svn.red-tux.net/trunk/lua/1.8.5/missing --run autoheader
+AUTOMAKE = ${SHELL} /home/nelsonab/svn.red-tux.net/trunk/lua/1.8.5/missing --run automake-1.11
+AWK = gawk
+CC = gcc
+CCDEPMODE = depmode=gcc3
+CFLAGS = -g -O2  -I/usr/include/mysql  -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -fasynchronous-unwind-tables -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fno-strict-aliasing -fwrapv -fPIC   -DUNIV_LINUX            
+CPP = gcc -E
+CPPFLAGS = 
+CYGPATH_W = echo
+DB_CPPFLAGS =  -I/usr/include/mysql  -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -fasynchronous-unwind-tables -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fno-strict-aliasing -fwrapv -fPIC   -DUNIV_LINUX   
+DB_LDFLAGS =   -L/usr/lib/mysql   
+DB_LIBS =  -lmysqlclient    
+DEFS = -DHAVE_CONFIG_H
+DEPDIR = .deps
+ECHO_C = 
+ECHO_N = -n
+ECHO_T = 
+EGREP = /bin/grep -E
+EXEEXT = 
+GREP = /bin/grep
+ICONV_CFLAGS = 
+ICONV_LDFLAGS = 
+IKSEMEL_CFLAGS = 
+IKSEMEL_LIBS = 
+INSTALL = /usr/bin/install -c
+INSTALL_DATA = ${INSTALL} -m 644
+INSTALL_PROGRAM = ${INSTALL}
+INSTALL_SCRIPT = ${INSTALL}
+INSTALL_STRIP_PROGRAM = $(install_sh) -c -s
+IODBC_CFLAGS = 
+IODBC_LDFLAGS = 
+IODBC_LIBS = 
+JABBER_CPPFLAGS = 
+JABBER_LDFLAGS = 
+JABBER_LIBS = 
+LDAP_CPPFLAGS = 
+LDAP_LDFLAGS = 
+LDFLAGS = -rdynamic   
+LIBCURL_CFLAGS = 
+LIBCURL_LDFLAGS = 
+LIBCURL_LIBS = 
+LIBOBJS = 
+LIBS = -lm  -lresolv 
+LLUA_CFLAGS =  
+LLUA_LIBS = -llua -lm -ldl  
+LTLIBOBJS = 
+LUA_CPPFLAGS = 
+LUA_LDFLAGS = -llua -lm -ldl  
+LUA_LIBS = -llua
+MAKEINFO = ${SHELL} /home/nelsonab/svn.red-tux.net/trunk/lua/1.8.5/missing --run makeinfo
+MKDIR_P = /bin/mkdir -p
+MYSQL_CFLAGS = -I/usr/include/mysql  -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -fasynchronous-unwind-tables -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fno-strict-aliasing -fwrapv -fPIC   -DUNIV_LINUX
+MYSQL_CONFIG = /usr/bin/mysql_config
+MYSQL_LDFLAGS =  -L/usr/lib/mysql
+MYSQL_LIBS = -lmysqlclient 
+MYSQL_VERSION = 5.1.56
+OBJEXT = o
+ODBC_CFLAGS = 
+ODBC_LDFLAGS = 
+ODBC_LIBS = 
+OPENIPMI_CFLAGS = 
+OPENIPMI_LDFLAGS = 
+OPENIPMI_LIBS = 
+ORACLE_CPPFLAGS = 
+ORACLE_LDFLAGS = 
+ORACLE_LIBS = 
+ORACLE_OCI_CFLAGS = 
+ORACLE_OCI_LDFLAGS = 
+ORACLE_OCI_LIBS = 
+ORACLE_OCI_VERSION = 
+PACKAGE = zabbix
+PACKAGE_BUGREPORT = 
+PACKAGE_NAME = 
+PACKAGE_STRING = 
+PACKAGE_TARNAME = 
+PACKAGE_URL = 
+PACKAGE_VERSION = 
+PATH_SEPARATOR = :
+PG_CONFIG = no
+PKG_CONFIG = /usr/bin/pkg-config
+POSTGRESQL_CPPFLAGS = 
+POSTGRESQL_LDFLAGS = 
+POSTGRESQL_VERSION = 
+PROXY_LDFLAGS =    -L/usr/lib/mysql        
+PROXY_LIBS =   -lmysqlclient        
+RANLIB = ranlib
+RESOLV_LIBS = -lresolv
+SERVER_LDFLAGS =    -L/usr/lib/mysql    -llua -lm -ldl        
+SERVER_LIBS =   -lmysqlclient     -llua     
+SET_MAKE = 
+SHELL = /bin/sh
+SNMP_CFLAGS = 
+SNMP_CPPFLAGS = 
+SNMP_LDFLAGS = 
+SNMP_LIBS = 
+SQLITE3_CPPFLAGS = 
+SQLITE3_LDFLAGS = 
+SQLITE3_VERSION = 
+SSH2_CFLAGS = 
+SSH2_LDFLAGS = 
+SSH2_LIBS = 
+STRIP = 
+UNIXODBC_CFLAGS = 
+UNIXODBC_LDFLAGS = 
+UNIXODBC_LIBS = 
+VERSION = 1.8.5
+_libcurl_config = no
+_libnetsnmp_config = no
+_libodbc_config = 
+abs_builddir = /home/nelsonab/svn.red-tux.net/trunk/lua/1.8.5/src/libs/zbxlua
+abs_srcdir = /home/nelsonab/svn.red-tux.net/trunk/lua/1.8.5/src/libs/zbxlua
+abs_top_builddir = /home/nelsonab/svn.red-tux.net/trunk/lua/1.8.5
+abs_top_srcdir = /home/nelsonab/svn.red-tux.net/trunk/lua/1.8.5
+ac_ct_CC = gcc
+am__include = include
+am__leading_dot = .
+am__quote = 
+am__tar = ${AMTAR} chof - "$$tardir"
+am__untar = ${AMTAR} xf -
+bindir = ${exec_prefix}/bin
+build = i686-pc-linux-gnu
+build_alias = 
+build_cpu = i686
+build_os = linux-gnu
+build_vendor = pc
+builddir = .
+datadir = ${datarootdir}
+datarootdir = ${prefix}/share
+docdir = ${datarootdir}/doc/${PACKAGE}
+dvidir = ${docdir}
+exec_prefix = ${prefix}
+host = i686-pc-linux-gnu
+host_alias = 
+host_cpu = i686
+host_os = linux-gnu
+host_vendor = pc
+htmldir = ${docdir}
+includedir = ${prefix}/include
+infodir = ${datarootdir}/info
+install_sh = ${SHELL} /home/nelsonab/svn.red-tux.net/trunk/lua/1.8.5/install-sh
+libdir = ${exec_prefix}/lib
+libexecdir = ${exec_prefix}/libexec
+localedir = ${datarootdir}/locale
+localstatedir = ${prefix}/var
+mandir = ${datarootdir}/man
+mkdir_p = /bin/mkdir -p
+oldincludedir = /usr/include
+pdfdir = ${docdir}
+prefix = /usr/local
+program_transform_name = s,x,x,
+psdir = ${docdir}
+sbindir = ${exec_prefix}/sbin
+sharedstatedir = ${prefix}/com
+srcdir = .
+sysconfdir = ${prefix}/etc
+target_alias = 
+top_build_prefix = ../../../
+top_builddir = ../../..
+top_srcdir = ../../..
+noinst_LIBRARIES = libzbxlua.a
+libzbxlua_a_SOURCES = zbxlua.c  lua_uint64_lib.c
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .o .obj
+$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
+	@for dep in $?; do \
+	  case '$(am__configure_deps)' in \
+	    *$$dep*) \
+	      ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+	        && { if test -f $@; then exit 0; else break; fi; }; \
+	      exit 1;; \
+	  esac; \
+	done; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/libs/zbxlua/Makefile'; \
+	$(am__cd) $(top_srcdir) && \
+	  $(AUTOMAKE) --gnu src/libs/zbxlua/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+	@case '$?' in \
+	  *config.status*) \
+	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+	  *) \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure:  $(am__configure_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+clean-noinstLIBRARIES:
+	-test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES)
+libzbxlua.a: $(libzbxlua_a_OBJECTS) $(libzbxlua_a_DEPENDENCIES) 
+	-rm -f libzbxlua.a
+	$(libzbxlua_a_AR) libzbxlua.a $(libzbxlua_a_OBJECTS) $(libzbxlua_a_LIBADD)
+	$(RANLIB) libzbxlua.a
+
+mostlyclean-compile:
+	-rm -f *.$(OBJEXT)
+
+distclean-compile:
+	-rm -f *.tab.c
+
+include ./$(DEPDIR)/lua_uint64_lib.Po
+include ./$(DEPDIR)/zbxlua.Po
+
+.c.o:
+	$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+	$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+#	source='$<' object='$@' libtool=no \
+#	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \
+#	$(COMPILE) -c $<
+
+.c.obj:
+	$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+	$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+#	source='$<' object='$@' libtool=no \
+#	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \
+#	$(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	mkid -fID $$unique
+tags: TAGS
+
+TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	set x; \
+	here=`pwd`; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	shift; \
+	if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+	  test -n "$$unique" || unique=$$empty_fix; \
+	  if test $$# -gt 0; then \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      "$$@" $$unique; \
+	  else \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      $$unique; \
+	  fi; \
+	fi
+ctags: CTAGS
+CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	test -z "$(CTAGS_ARGS)$$unique" \
+	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+	     $$unique
+
+GTAGS:
+	here=`$(am__cd) $(top_builddir) && pwd` \
+	  && $(am__cd) $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	list='$(DISTFILES)'; \
+	  dist_files=`for file in $$list; do echo $$file; done | \
+	  sed -e "s|^$$srcdirstrip/||;t" \
+	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+	case $$dist_files in \
+	  */*) $(MKDIR_P) `echo "$$dist_files" | \
+			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+			   sort -u` ;; \
+	esac; \
+	for file in $$dist_files; do \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  if test -d $$d/$$file; then \
+	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d "$(distdir)/$$file"; then \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
+	    cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+	  else \
+	    test -f "$(distdir)/$$file" \
+	    || cp -p $$d/$$file "$(distdir)/$$file" \
+	    || exit 1; \
+	  fi; \
+	done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LIBRARIES)
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	  `test -z '$(STRIP)' || \
+	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+	-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-noinstLIBRARIES mostlyclean-am
+
+distclean: distclean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+	distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+	clean-noinstLIBRARIES ctags distclean distclean-compile \
+	distclean-generic distclean-tags distdir dvi dvi-am html \
+	html-am info info-am install install-am install-data \
+	install-data-am install-dvi install-dvi-am install-exec \
+	install-exec-am install-html install-html-am install-info \
+	install-info-am install-man install-pdf install-pdf-am \
+	install-ps install-ps-am install-strip installcheck \
+	installcheck-am installdirs maintainer-clean \
+	maintainer-clean-generic mostlyclean mostlyclean-compile \
+	mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \
+	uninstall-am
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
Index: src/libs/zbxalgo/Makefile.in
===================================================================
--- src/libs/zbxalgo/Makefile.in	(revision 302)
+++ src/libs/zbxalgo/Makefile.in	(working copy)
@@ -45,9 +45,9 @@
 	$(top_srcdir)/m4/jabber.m4 $(top_srcdir)/m4/ldap.m4 \
 	$(top_srcdir)/m4/libcurl.m4 $(top_srcdir)/m4/libiodbc.m4 \
 	$(top_srcdir)/m4/libssh2.m4 $(top_srcdir)/m4/libunixodbc.m4 \
-	$(top_srcdir)/m4/netsnmp.m4 $(top_srcdir)/m4/openipmi.m4 \
-	$(top_srcdir)/m4/resolv.m4 $(top_srcdir)/m4/ucdsnmp.m4 \
-	$(top_srcdir)/configure.in
+	$(top_srcdir)/m4/lua.m4 $(top_srcdir)/m4/netsnmp.m4 \
+	$(top_srcdir)/m4/openipmi.m4 $(top_srcdir)/m4/resolv.m4 \
+	$(top_srcdir)/m4/ucdsnmp.m4 $(top_srcdir)/configure.in
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 mkinstalldirs = $(install_sh) -d
@@ -122,7 +122,12 @@
 LIBCURL_LIBS = @LIBCURL_LIBS@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
+LLUA_CFLAGS = @LLUA_CFLAGS@
+LLUA_LIBS = @LLUA_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LUA_CPPFLAGS = @LUA_CPPFLAGS@
+LUA_LDFLAGS = @LUA_LDFLAGS@
+LUA_LIBS = @LUA_LIBS@
 MAKEINFO = @MAKEINFO@
 MKDIR_P = @MKDIR_P@
 MYSQL_CFLAGS = @MYSQL_CFLAGS@
Index: src/libs/zbxexec/Makefile.in
===================================================================
--- src/libs/zbxexec/Makefile.in	(revision 302)
+++ src/libs/zbxexec/Makefile.in	(working copy)
@@ -45,9 +45,9 @@
 	$(top_srcdir)/m4/jabber.m4 $(top_srcdir)/m4/ldap.m4 \
 	$(top_srcdir)/m4/libcurl.m4 $(top_srcdir)/m4/libiodbc.m4 \
 	$(top_srcdir)/m4/libssh2.m4 $(top_srcdir)/m4/libunixodbc.m4 \
-	$(top_srcdir)/m4/netsnmp.m4 $(top_srcdir)/m4/openipmi.m4 \
-	$(top_srcdir)/m4/resolv.m4 $(top_srcdir)/m4/ucdsnmp.m4 \
-	$(top_srcdir)/configure.in
+	$(top_srcdir)/m4/lua.m4 $(top_srcdir)/m4/netsnmp.m4 \
+	$(top_srcdir)/m4/openipmi.m4 $(top_srcdir)/m4/resolv.m4 \
+	$(top_srcdir)/m4/ucdsnmp.m4 $(top_srcdir)/configure.in
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 mkinstalldirs = $(install_sh) -d
@@ -121,7 +121,12 @@
 LIBCURL_LIBS = @LIBCURL_LIBS@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
+LLUA_CFLAGS = @LLUA_CFLAGS@
+LLUA_LIBS = @LLUA_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LUA_CPPFLAGS = @LUA_CPPFLAGS@
+LUA_LDFLAGS = @LUA_LDFLAGS@
+LUA_LIBS = @LUA_LIBS@
 MAKEINFO = @MAKEINFO@
 MKDIR_P = @MKDIR_P@
 MYSQL_CFLAGS = @MYSQL_CFLAGS@
Index: src/libs/zbxdbhigh/Makefile.in
===================================================================
--- src/libs/zbxdbhigh/Makefile.in	(revision 302)
+++ src/libs/zbxdbhigh/Makefile.in	(working copy)
@@ -45,9 +45,9 @@
 	$(top_srcdir)/m4/jabber.m4 $(top_srcdir)/m4/ldap.m4 \
 	$(top_srcdir)/m4/libcurl.m4 $(top_srcdir)/m4/libiodbc.m4 \
 	$(top_srcdir)/m4/libssh2.m4 $(top_srcdir)/m4/libunixodbc.m4 \
-	$(top_srcdir)/m4/netsnmp.m4 $(top_srcdir)/m4/openipmi.m4 \
-	$(top_srcdir)/m4/resolv.m4 $(top_srcdir)/m4/ucdsnmp.m4 \
-	$(top_srcdir)/configure.in
+	$(top_srcdir)/m4/lua.m4 $(top_srcdir)/m4/netsnmp.m4 \
+	$(top_srcdir)/m4/openipmi.m4 $(top_srcdir)/m4/resolv.m4 \
+	$(top_srcdir)/m4/ucdsnmp.m4 $(top_srcdir)/configure.in
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 mkinstalldirs = $(install_sh) -d
@@ -128,7 +128,12 @@
 LIBCURL_LIBS = @LIBCURL_LIBS@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
+LLUA_CFLAGS = @LLUA_CFLAGS@
+LLUA_LIBS = @LLUA_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LUA_CPPFLAGS = @LUA_CPPFLAGS@
+LUA_LDFLAGS = @LUA_LDFLAGS@
+LUA_LIBS = @LUA_LIBS@
 MAKEINFO = @MAKEINFO@
 MKDIR_P = @MKDIR_P@
 MYSQL_CFLAGS = @MYSQL_CFLAGS@
Index: src/libs/zbxdb/Makefile.in
===================================================================
--- src/libs/zbxdb/Makefile.in	(revision 302)
+++ src/libs/zbxdb/Makefile.in	(working copy)
@@ -45,9 +45,9 @@
 	$(top_srcdir)/m4/jabber.m4 $(top_srcdir)/m4/ldap.m4 \
 	$(top_srcdir)/m4/libcurl.m4 $(top_srcdir)/m4/libiodbc.m4 \
 	$(top_srcdir)/m4/libssh2.m4 $(top_srcdir)/m4/libunixodbc.m4 \
-	$(top_srcdir)/m4/netsnmp.m4 $(top_srcdir)/m4/openipmi.m4 \
-	$(top_srcdir)/m4/resolv.m4 $(top_srcdir)/m4/ucdsnmp.m4 \
-	$(top_srcdir)/configure.in
+	$(top_srcdir)/m4/lua.m4 $(top_srcdir)/m4/netsnmp.m4 \
+	$(top_srcdir)/m4/openipmi.m4 $(top_srcdir)/m4/resolv.m4 \
+	$(top_srcdir)/m4/ucdsnmp.m4 $(top_srcdir)/configure.in
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 mkinstalldirs = $(install_sh) -d
@@ -121,7 +121,12 @@
 LIBCURL_LIBS = @LIBCURL_LIBS@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
+LLUA_CFLAGS = @LLUA_CFLAGS@
+LLUA_LIBS = @LLUA_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LUA_CPPFLAGS = @LUA_CPPFLAGS@
+LUA_LDFLAGS = @LUA_LDFLAGS@
+LUA_LIBS = @LUA_LIBS@
 MAKEINFO = @MAKEINFO@
 MKDIR_P = @MKDIR_P@
 MYSQL_CFLAGS = @MYSQL_CFLAGS@
Index: src/libs/zbxconf/Makefile.in
===================================================================
--- src/libs/zbxconf/Makefile.in	(revision 302)
+++ src/libs/zbxconf/Makefile.in	(working copy)
@@ -45,9 +45,9 @@
 	$(top_srcdir)/m4/jabber.m4 $(top_srcdir)/m4/ldap.m4 \
 	$(top_srcdir)/m4/libcurl.m4 $(top_srcdir)/m4/libiodbc.m4 \
 	$(top_srcdir)/m4/libssh2.m4 $(top_srcdir)/m4/libunixodbc.m4 \
-	$(top_srcdir)/m4/netsnmp.m4 $(top_srcdir)/m4/openipmi.m4 \
-	$(top_srcdir)/m4/resolv.m4 $(top_srcdir)/m4/ucdsnmp.m4 \
-	$(top_srcdir)/configure.in
+	$(top_srcdir)/m4/lua.m4 $(top_srcdir)/m4/netsnmp.m4 \
+	$(top_srcdir)/m4/openipmi.m4 $(top_srcdir)/m4/resolv.m4 \
+	$(top_srcdir)/m4/ucdsnmp.m4 $(top_srcdir)/configure.in
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 mkinstalldirs = $(install_sh) -d
@@ -121,7 +121,12 @@
 LIBCURL_LIBS = @LIBCURL_LIBS@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
+LLUA_CFLAGS = @LLUA_CFLAGS@
+LLUA_LIBS = @LLUA_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LUA_CPPFLAGS = @LUA_CPPFLAGS@
+LUA_LDFLAGS = @LUA_LDFLAGS@
+LUA_LIBS = @LUA_LIBS@
 MAKEINFO = @MAKEINFO@
 MKDIR_P = @MKDIR_P@
 MYSQL_CFLAGS = @MYSQL_CFLAGS@
Index: src/libs/Makefile.am
===================================================================
--- src/libs/Makefile.am	(revision 302)
+++ src/libs/Makefile.am	(working copy)
@@ -12,6 +12,7 @@
 	zbxcomms \
 	zbxcommshigh \
 	zbxlog \
+	zbxlua \
 	zbxnix \
 	zbxconf \
 	zbxsysinfo \
@@ -43,6 +44,7 @@
 	zbxmemory \
 	zbxserver \
 	zbxicmpping \
+	zbxlua \
 	zbxmedia \
 	zbxself
 endif
Index: src/libs/zbxcommon/Makefile.in
===================================================================
--- src/libs/zbxcommon/Makefile.in	(revision 302)
+++ src/libs/zbxcommon/Makefile.in	(working copy)
@@ -45,9 +45,9 @@
 	$(top_srcdir)/m4/jabber.m4 $(top_srcdir)/m4/ldap.m4 \
 	$(top_srcdir)/m4/libcurl.m4 $(top_srcdir)/m4/libiodbc.m4 \
 	$(top_srcdir)/m4/libssh2.m4 $(top_srcdir)/m4/libunixodbc.m4 \
-	$(top_srcdir)/m4/netsnmp.m4 $(top_srcdir)/m4/openipmi.m4 \
-	$(top_srcdir)/m4/resolv.m4 $(top_srcdir)/m4/ucdsnmp.m4 \
-	$(top_srcdir)/configure.in
+	$(top_srcdir)/m4/lua.m4 $(top_srcdir)/m4/netsnmp.m4 \
+	$(top_srcdir)/m4/openipmi.m4 $(top_srcdir)/m4/resolv.m4 \
+	$(top_srcdir)/m4/ucdsnmp.m4 $(top_srcdir)/configure.in
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 mkinstalldirs = $(install_sh) -d
@@ -123,7 +123,12 @@
 LIBCURL_LIBS = @LIBCURL_LIBS@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
+LLUA_CFLAGS = @LLUA_CFLAGS@
+LLUA_LIBS = @LLUA_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LUA_CPPFLAGS = @LUA_CPPFLAGS@
+LUA_LDFLAGS = @LUA_LDFLAGS@
+LUA_LIBS = @LUA_LIBS@
 MAKEINFO = @MAKEINFO@
 MKDIR_P = @MKDIR_P@
 MYSQL_CFLAGS = @MYSQL_CFLAGS@
Index: src/libs/zbxself/Makefile.in
===================================================================
--- src/libs/zbxself/Makefile.in	(revision 302)
+++ src/libs/zbxself/Makefile.in	(working copy)
@@ -45,9 +45,9 @@
 	$(top_srcdir)/m4/jabber.m4 $(top_srcdir)/m4/ldap.m4 \
 	$(top_srcdir)/m4/libcurl.m4 $(top_srcdir)/m4/libiodbc.m4 \
 	$(top_srcdir)/m4/libssh2.m4 $(top_srcdir)/m4/libunixodbc.m4 \
-	$(top_srcdir)/m4/netsnmp.m4 $(top_srcdir)/m4/openipmi.m4 \
-	$(top_srcdir)/m4/resolv.m4 $(top_srcdir)/m4/ucdsnmp.m4 \
-	$(top_srcdir)/configure.in
+	$(top_srcdir)/m4/lua.m4 $(top_srcdir)/m4/netsnmp.m4 \
+	$(top_srcdir)/m4/openipmi.m4 $(top_srcdir)/m4/resolv.m4 \
+	$(top_srcdir)/m4/ucdsnmp.m4 $(top_srcdir)/configure.in
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 mkinstalldirs = $(install_sh) -d
@@ -121,7 +121,12 @@
 LIBCURL_LIBS = @LIBCURL_LIBS@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
+LLUA_CFLAGS = @LLUA_CFLAGS@
+LLUA_LIBS = @LLUA_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LUA_CPPFLAGS = @LUA_CPPFLAGS@
+LUA_LDFLAGS = @LUA_LDFLAGS@
+LUA_LIBS = @LUA_LIBS@
 MAKEINFO = @MAKEINFO@
 MKDIR_P = @MKDIR_P@
 MYSQL_CFLAGS = @MYSQL_CFLAGS@
Index: src/libs/zbxself/selfmon.c
===================================================================
--- src/libs/zbxself/selfmon.c	(revision 302)
+++ src/libs/zbxself/selfmon.c	(working copy)
@@ -70,6 +70,7 @@
 extern int	CONFIG_CONFSYNCER_FORKS;
 extern int	CONFIG_HEARTBEAT_FORKS;
 extern int	CONFIG_SELFMON_FORKS;
+extern int	CONFIG_LUA_POLLER_FORKS;
 
 /******************************************************************************
  *                                                                            *
@@ -128,6 +129,8 @@
 			return CONFIG_HEARTBEAT_FORKS;
 		case ZBX_PROCESS_TYPE_SELFMON:
 			return CONFIG_SELFMON_FORKS;
+		case ZBX_PROCESS_TYPE_LUA:
+			return CONFIG_LUA_POLLER_FORKS;
 	}
 
 	assert(0);
@@ -191,6 +194,8 @@
 			return "heartbeat sender";
 		case ZBX_PROCESS_TYPE_SELFMON:
 			return "self-monitoring";
+		case ZBX_PROCESS_TYPE_LUA:
+			return "Lua Items";
 	}
 
 	assert(0);
Index: src/libs/zbxsysinfo/netbsd/Makefile.in
===================================================================
--- src/libs/zbxsysinfo/netbsd/Makefile.in	(revision 302)
+++ src/libs/zbxsysinfo/netbsd/Makefile.in	(working copy)
@@ -45,9 +45,9 @@
 	$(top_srcdir)/m4/jabber.m4 $(top_srcdir)/m4/ldap.m4 \
 	$(top_srcdir)/m4/libcurl.m4 $(top_srcdir)/m4/libiodbc.m4 \
 	$(top_srcdir)/m4/libssh2.m4 $(top_srcdir)/m4/libunixodbc.m4 \
-	$(top_srcdir)/m4/netsnmp.m4 $(top_srcdir)/m4/openipmi.m4 \
-	$(top_srcdir)/m4/resolv.m4 $(top_srcdir)/m4/ucdsnmp.m4 \
-	$(top_srcdir)/configure.in
+	$(top_srcdir)/m4/lua.m4 $(top_srcdir)/m4/netsnmp.m4 \
+	$(top_srcdir)/m4/openipmi.m4 $(top_srcdir)/m4/resolv.m4 \
+	$(top_srcdir)/m4/ucdsnmp.m4 $(top_srcdir)/configure.in
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 mkinstalldirs = $(install_sh) -d
@@ -129,7 +129,12 @@
 LIBCURL_LIBS = @LIBCURL_LIBS@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
+LLUA_CFLAGS = @LLUA_CFLAGS@
+LLUA_LIBS = @LLUA_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LUA_CPPFLAGS = @LUA_CPPFLAGS@
+LUA_LDFLAGS = @LUA_LDFLAGS@
+LUA_LIBS = @LUA_LIBS@
 MAKEINFO = @MAKEINFO@
 MKDIR_P = @MKDIR_P@
 MYSQL_CFLAGS = @MYSQL_CFLAGS@
Index: src/libs/zbxsysinfo/aix/Makefile.in
===================================================================
--- src/libs/zbxsysinfo/aix/Makefile.in	(revision 302)
+++ src/libs/zbxsysinfo/aix/Makefile.in	(working copy)
@@ -45,9 +45,9 @@
 	$(top_srcdir)/m4/jabber.m4 $(top_srcdir)/m4/ldap.m4 \
 	$(top_srcdir)/m4/libcurl.m4 $(top_srcdir)/m4/libiodbc.m4 \
 	$(top_srcdir)/m4/libssh2.m4 $(top_srcdir)/m4/libunixodbc.m4 \
-	$(top_srcdir)/m4/netsnmp.m4 $(top_srcdir)/m4/openipmi.m4 \
-	$(top_srcdir)/m4/resolv.m4 $(top_srcdir)/m4/ucdsnmp.m4 \
-	$(top_srcdir)/configure.in
+	$(top_srcdir)/m4/lua.m4 $(top_srcdir)/m4/netsnmp.m4 \
+	$(top_srcdir)/m4/openipmi.m4 $(top_srcdir)/m4/resolv.m4 \
+	$(top_srcdir)/m4/ucdsnmp.m4 $(top_srcdir)/configure.in
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 mkinstalldirs = $(install_sh) -d
@@ -128,7 +128,12 @@
 LIBCURL_LIBS = @LIBCURL_LIBS@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
+LLUA_CFLAGS = @LLUA_CFLAGS@
+LLUA_LIBS = @LLUA_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LUA_CPPFLAGS = @LUA_CPPFLAGS@
+LUA_LDFLAGS = @LUA_LDFLAGS@
+LUA_LIBS = @LUA_LIBS@
 MAKEINFO = @MAKEINFO@
 MKDIR_P = @MKDIR_P@
 MYSQL_CFLAGS = @MYSQL_CFLAGS@
Index: src/libs/zbxsysinfo/Makefile.in
===================================================================
--- src/libs/zbxsysinfo/Makefile.in	(revision 302)
+++ src/libs/zbxsysinfo/Makefile.in	(working copy)
@@ -45,9 +45,9 @@
 	$(top_srcdir)/m4/jabber.m4 $(top_srcdir)/m4/ldap.m4 \
 	$(top_srcdir)/m4/libcurl.m4 $(top_srcdir)/m4/libiodbc.m4 \
 	$(top_srcdir)/m4/libssh2.m4 $(top_srcdir)/m4/libunixodbc.m4 \
-	$(top_srcdir)/m4/netsnmp.m4 $(top_srcdir)/m4/openipmi.m4 \
-	$(top_srcdir)/m4/resolv.m4 $(top_srcdir)/m4/ucdsnmp.m4 \
-	$(top_srcdir)/configure.in
+	$(top_srcdir)/m4/lua.m4 $(top_srcdir)/m4/netsnmp.m4 \
+	$(top_srcdir)/m4/openipmi.m4 $(top_srcdir)/m4/resolv.m4 \
+	$(top_srcdir)/m4/ucdsnmp.m4 $(top_srcdir)/configure.in
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 mkinstalldirs = $(install_sh) -d
@@ -167,7 +167,12 @@
 LIBCURL_LIBS = @LIBCURL_LIBS@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
+LLUA_CFLAGS = @LLUA_CFLAGS@
+LLUA_LIBS = @LLUA_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LUA_CPPFLAGS = @LUA_CPPFLAGS@
+LUA_LDFLAGS = @LUA_LDFLAGS@
+LUA_LIBS = @LUA_LIBS@
 MAKEINFO = @MAKEINFO@
 MKDIR_P = @MKDIR_P@
 MYSQL_CFLAGS = @MYSQL_CFLAGS@
Index: src/libs/zbxsysinfo/hpux/Makefile.in
===================================================================
--- src/libs/zbxsysinfo/hpux/Makefile.in	(revision 302)
+++ src/libs/zbxsysinfo/hpux/Makefile.in	(working copy)
@@ -45,9 +45,9 @@
 	$(top_srcdir)/m4/jabber.m4 $(top_srcdir)/m4/ldap.m4 \
 	$(top_srcdir)/m4/libcurl.m4 $(top_srcdir)/m4/libiodbc.m4 \
 	$(top_srcdir)/m4/libssh2.m4 $(top_srcdir)/m4/libunixodbc.m4 \
-	$(top_srcdir)/m4/netsnmp.m4 $(top_srcdir)/m4/openipmi.m4 \
-	$(top_srcdir)/m4/resolv.m4 $(top_srcdir)/m4/ucdsnmp.m4 \
-	$(top_srcdir)/configure.in
+	$(top_srcdir)/m4/lua.m4 $(top_srcdir)/m4/netsnmp.m4 \
+	$(top_srcdir)/m4/openipmi.m4 $(top_srcdir)/m4/resolv.m4 \
+	$(top_srcdir)/m4/ucdsnmp.m4 $(top_srcdir)/configure.in
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 mkinstalldirs = $(install_sh) -d
@@ -125,7 +125,12 @@
 LIBCURL_LIBS = @LIBCURL_LIBS@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
+LLUA_CFLAGS = @LLUA_CFLAGS@
+LLUA_LIBS = @LLUA_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LUA_CPPFLAGS = @LUA_CPPFLAGS@
+LUA_LDFLAGS = @LUA_LDFLAGS@
+LUA_LIBS = @LUA_LIBS@
 MAKEINFO = @MAKEINFO@
 MKDIR_P = @MKDIR_P@
 MYSQL_CFLAGS = @MYSQL_CFLAGS@
Index: src/libs/zbxsysinfo/osf/Makefile.in
===================================================================
--- src/libs/zbxsysinfo/osf/Makefile.in	(revision 302)
+++ src/libs/zbxsysinfo/osf/Makefile.in	(working copy)
@@ -45,9 +45,9 @@
 	$(top_srcdir)/m4/jabber.m4 $(top_srcdir)/m4/ldap.m4 \
 	$(top_srcdir)/m4/libcurl.m4 $(top_srcdir)/m4/libiodbc.m4 \
 	$(top_srcdir)/m4/libssh2.m4 $(top_srcdir)/m4/libunixodbc.m4 \
-	$(top_srcdir)/m4/netsnmp.m4 $(top_srcdir)/m4/openipmi.m4 \
-	$(top_srcdir)/m4/resolv.m4 $(top_srcdir)/m4/ucdsnmp.m4 \
-	$(top_srcdir)/configure.in
+	$(top_srcdir)/m4/lua.m4 $(top_srcdir)/m4/netsnmp.m4 \
+	$(top_srcdir)/m4/openipmi.m4 $(top_srcdir)/m4/resolv.m4 \
+	$(top_srcdir)/m4/ucdsnmp.m4 $(top_srcdir)/configure.in
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 mkinstalldirs = $(install_sh) -d
@@ -129,7 +129,12 @@
 LIBCURL_LIBS = @LIBCURL_LIBS@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
+LLUA_CFLAGS = @LLUA_CFLAGS@
+LLUA_LIBS = @LLUA_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LUA_CPPFLAGS = @LUA_CPPFLAGS@
+LUA_LDFLAGS = @LUA_LDFLAGS@
+LUA_LIBS = @LUA_LIBS@
 MAKEINFO = @MAKEINFO@
 MKDIR_P = @MKDIR_P@
 MYSQL_CFLAGS = @MYSQL_CFLAGS@
Index: src/libs/zbxsysinfo/common/Makefile.in
===================================================================
--- src/libs/zbxsysinfo/common/Makefile.in	(revision 302)
+++ src/libs/zbxsysinfo/common/Makefile.in	(working copy)
@@ -45,9 +45,9 @@
 	$(top_srcdir)/m4/jabber.m4 $(top_srcdir)/m4/ldap.m4 \
 	$(top_srcdir)/m4/libcurl.m4 $(top_srcdir)/m4/libiodbc.m4 \
 	$(top_srcdir)/m4/libssh2.m4 $(top_srcdir)/m4/libunixodbc.m4 \
-	$(top_srcdir)/m4/netsnmp.m4 $(top_srcdir)/m4/openipmi.m4 \
-	$(top_srcdir)/m4/resolv.m4 $(top_srcdir)/m4/ucdsnmp.m4 \
-	$(top_srcdir)/configure.in
+	$(top_srcdir)/m4/lua.m4 $(top_srcdir)/m4/netsnmp.m4 \
+	$(top_srcdir)/m4/openipmi.m4 $(top_srcdir)/m4/resolv.m4 \
+	$(top_srcdir)/m4/ucdsnmp.m4 $(top_srcdir)/configure.in
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 mkinstalldirs = $(install_sh) -d
@@ -122,7 +122,12 @@
 LIBCURL_LIBS = @LIBCURL_LIBS@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
+LLUA_CFLAGS = @LLUA_CFLAGS@
+LLUA_LIBS = @LLUA_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LUA_CPPFLAGS = @LUA_CPPFLAGS@
+LUA_LDFLAGS = @LUA_LDFLAGS@
+LUA_LIBS = @LUA_LIBS@
 MAKEINFO = @MAKEINFO@
 MKDIR_P = @MKDIR_P@
 MYSQL_CFLAGS = @MYSQL_CFLAGS@
Index: src/libs/zbxsysinfo/simple/Makefile.in
===================================================================
--- src/libs/zbxsysinfo/simple/Makefile.in	(revision 302)
+++ src/libs/zbxsysinfo/simple/Makefile.in	(working copy)
@@ -45,9 +45,9 @@
 	$(top_srcdir)/m4/jabber.m4 $(top_srcdir)/m4/ldap.m4 \
 	$(top_srcdir)/m4/libcurl.m4 $(top_srcdir)/m4/libiodbc.m4 \
 	$(top_srcdir)/m4/libssh2.m4 $(top_srcdir)/m4/libunixodbc.m4 \
-	$(top_srcdir)/m4/netsnmp.m4 $(top_srcdir)/m4/openipmi.m4 \
-	$(top_srcdir)/m4/resolv.m4 $(top_srcdir)/m4/ucdsnmp.m4 \
-	$(top_srcdir)/configure.in
+	$(top_srcdir)/m4/lua.m4 $(top_srcdir)/m4/netsnmp.m4 \
+	$(top_srcdir)/m4/openipmi.m4 $(top_srcdir)/m4/resolv.m4 \
+	$(top_srcdir)/m4/ucdsnmp.m4 $(top_srcdir)/configure.in
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 mkinstalldirs = $(install_sh) -d
@@ -121,7 +121,12 @@
 LIBCURL_LIBS = @LIBCURL_LIBS@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
+LLUA_CFLAGS = @LLUA_CFLAGS@
+LLUA_LIBS = @LLUA_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LUA_CPPFLAGS = @LUA_CPPFLAGS@
+LUA_LDFLAGS = @LUA_LDFLAGS@
+LUA_LIBS = @LUA_LIBS@
 MAKEINFO = @MAKEINFO@
 MKDIR_P = @MKDIR_P@
 MYSQL_CFLAGS = @MYSQL_CFLAGS@
Index: src/libs/zbxsysinfo/openbsd/Makefile.in
===================================================================
--- src/libs/zbxsysinfo/openbsd/Makefile.in	(revision 302)
+++ src/libs/zbxsysinfo/openbsd/Makefile.in	(working copy)
@@ -45,9 +45,9 @@
 	$(top_srcdir)/m4/jabber.m4 $(top_srcdir)/m4/ldap.m4 \
 	$(top_srcdir)/m4/libcurl.m4 $(top_srcdir)/m4/libiodbc.m4 \
 	$(top_srcdir)/m4/libssh2.m4 $(top_srcdir)/m4/libunixodbc.m4 \
-	$(top_srcdir)/m4/netsnmp.m4 $(top_srcdir)/m4/openipmi.m4 \
-	$(top_srcdir)/m4/resolv.m4 $(top_srcdir)/m4/ucdsnmp.m4 \
-	$(top_srcdir)/configure.in
+	$(top_srcdir)/m4/lua.m4 $(top_srcdir)/m4/netsnmp.m4 \
+	$(top_srcdir)/m4/openipmi.m4 $(top_srcdir)/m4/resolv.m4 \
+	$(top_srcdir)/m4/ucdsnmp.m4 $(top_srcdir)/configure.in
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 mkinstalldirs = $(install_sh) -d
@@ -131,7 +131,12 @@
 LIBCURL_LIBS = @LIBCURL_LIBS@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
+LLUA_CFLAGS = @LLUA_CFLAGS@
+LLUA_LIBS = @LLUA_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LUA_CPPFLAGS = @LUA_CPPFLAGS@
+LUA_LDFLAGS = @LUA_LDFLAGS@
+LUA_LIBS = @LUA_LIBS@
 MAKEINFO = @MAKEINFO@
 MKDIR_P = @MKDIR_P@
 MYSQL_CFLAGS = @MYSQL_CFLAGS@
Index: src/libs/zbxsysinfo/linux/Makefile.in
===================================================================
--- src/libs/zbxsysinfo/linux/Makefile.in	(revision 302)
+++ src/libs/zbxsysinfo/linux/Makefile.in	(working copy)
@@ -45,9 +45,9 @@
 	$(top_srcdir)/m4/jabber.m4 $(top_srcdir)/m4/ldap.m4 \
 	$(top_srcdir)/m4/libcurl.m4 $(top_srcdir)/m4/libiodbc.m4 \
 	$(top_srcdir)/m4/libssh2.m4 $(top_srcdir)/m4/libunixodbc.m4 \
-	$(top_srcdir)/m4/netsnmp.m4 $(top_srcdir)/m4/openipmi.m4 \
-	$(top_srcdir)/m4/resolv.m4 $(top_srcdir)/m4/ucdsnmp.m4 \
-	$(top_srcdir)/configure.in
+	$(top_srcdir)/m4/lua.m4 $(top_srcdir)/m4/netsnmp.m4 \
+	$(top_srcdir)/m4/openipmi.m4 $(top_srcdir)/m4/resolv.m4 \
+	$(top_srcdir)/m4/ucdsnmp.m4 $(top_srcdir)/configure.in
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 mkinstalldirs = $(install_sh) -d
@@ -131,7 +131,12 @@
 LIBCURL_LIBS = @LIBCURL_LIBS@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
+LLUA_CFLAGS = @LLUA_CFLAGS@
+LLUA_LIBS = @LLUA_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LUA_CPPFLAGS = @LUA_CPPFLAGS@
+LUA_LDFLAGS = @LUA_LDFLAGS@
+LUA_LIBS = @LUA_LIBS@
 MAKEINFO = @MAKEINFO@
 MKDIR_P = @MKDIR_P@
 MYSQL_CFLAGS = @MYSQL_CFLAGS@
Index: src/libs/zbxsysinfo/unknown/Makefile.in
===================================================================
--- src/libs/zbxsysinfo/unknown/Makefile.in	(revision 302)
+++ src/libs/zbxsysinfo/unknown/Makefile.in	(working copy)
@@ -45,9 +45,9 @@
 	$(top_srcdir)/m4/jabber.m4 $(top_srcdir)/m4/ldap.m4 \
 	$(top_srcdir)/m4/libcurl.m4 $(top_srcdir)/m4/libiodbc.m4 \
 	$(top_srcdir)/m4/libssh2.m4 $(top_srcdir)/m4/libunixodbc.m4 \
-	$(top_srcdir)/m4/netsnmp.m4 $(top_srcdir)/m4/openipmi.m4 \
-	$(top_srcdir)/m4/resolv.m4 $(top_srcdir)/m4/ucdsnmp.m4 \
-	$(top_srcdir)/configure.in
+	$(top_srcdir)/m4/lua.m4 $(top_srcdir)/m4/netsnmp.m4 \
+	$(top_srcdir)/m4/openipmi.m4 $(top_srcdir)/m4/resolv.m4 \
+	$(top_srcdir)/m4/ucdsnmp.m4 $(top_srcdir)/configure.in
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 mkinstalldirs = $(install_sh) -d
@@ -121,7 +121,12 @@
 LIBCURL_LIBS = @LIBCURL_LIBS@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
+LLUA_CFLAGS = @LLUA_CFLAGS@
+LLUA_LIBS = @LLUA_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LUA_CPPFLAGS = @LUA_CPPFLAGS@
+LUA_LDFLAGS = @LUA_LDFLAGS@
+LUA_LIBS = @LUA_LIBS@
 MAKEINFO = @MAKEINFO@
 MKDIR_P = @MKDIR_P@
 MYSQL_CFLAGS = @MYSQL_CFLAGS@
Index: src/libs/zbxsysinfo/osx/Makefile.in
===================================================================
--- src/libs/zbxsysinfo/osx/Makefile.in	(revision 302)
+++ src/libs/zbxsysinfo/osx/Makefile.in	(working copy)
@@ -45,9 +45,9 @@
 	$(top_srcdir)/m4/jabber.m4 $(top_srcdir)/m4/ldap.m4 \
 	$(top_srcdir)/m4/libcurl.m4 $(top_srcdir)/m4/libiodbc.m4 \
 	$(top_srcdir)/m4/libssh2.m4 $(top_srcdir)/m4/libunixodbc.m4 \
-	$(top_srcdir)/m4/netsnmp.m4 $(top_srcdir)/m4/openipmi.m4 \
-	$(top_srcdir)/m4/resolv.m4 $(top_srcdir)/m4/ucdsnmp.m4 \
-	$(top_srcdir)/configure.in
+	$(top_srcdir)/m4/lua.m4 $(top_srcdir)/m4/netsnmp.m4 \
+	$(top_srcdir)/m4/openipmi.m4 $(top_srcdir)/m4/resolv.m4 \
+	$(top_srcdir)/m4/ucdsnmp.m4 $(top_srcdir)/configure.in
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 mkinstalldirs = $(install_sh) -d
@@ -129,7 +129,12 @@
 LIBCURL_LIBS = @LIBCURL_LIBS@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
+LLUA_CFLAGS = @LLUA_CFLAGS@
+LLUA_LIBS = @LLUA_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LUA_CPPFLAGS = @LUA_CPPFLAGS@
+LUA_LDFLAGS = @LUA_LDFLAGS@
+LUA_LIBS = @LUA_LIBS@
 MAKEINFO = @MAKEINFO@
 MKDIR_P = @MKDIR_P@
 MYSQL_CFLAGS = @MYSQL_CFLAGS@
Index: src/libs/zbxsysinfo/freebsd/Makefile.in
===================================================================
--- src/libs/zbxsysinfo/freebsd/Makefile.in	(revision 302)
+++ src/libs/zbxsysinfo/freebsd/Makefile.in	(working copy)
@@ -45,9 +45,9 @@
 	$(top_srcdir)/m4/jabber.m4 $(top_srcdir)/m4/ldap.m4 \
 	$(top_srcdir)/m4/libcurl.m4 $(top_srcdir)/m4/libiodbc.m4 \
 	$(top_srcdir)/m4/libssh2.m4 $(top_srcdir)/m4/libunixodbc.m4 \
-	$(top_srcdir)/m4/netsnmp.m4 $(top_srcdir)/m4/openipmi.m4 \
-	$(top_srcdir)/m4/resolv.m4 $(top_srcdir)/m4/ucdsnmp.m4 \
-	$(top_srcdir)/configure.in
+	$(top_srcdir)/m4/lua.m4 $(top_srcdir)/m4/netsnmp.m4 \
+	$(top_srcdir)/m4/openipmi.m4 $(top_srcdir)/m4/resolv.m4 \
+	$(top_srcdir)/m4/ucdsnmp.m4 $(top_srcdir)/configure.in
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 mkinstalldirs = $(install_sh) -d
@@ -130,7 +130,12 @@
 LIBCURL_LIBS = @LIBCURL_LIBS@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
+LLUA_CFLAGS = @LLUA_CFLAGS@
+LLUA_LIBS = @LLUA_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LUA_CPPFLAGS = @LUA_CPPFLAGS@
+LUA_LDFLAGS = @LUA_LDFLAGS@
+LUA_LIBS = @LUA_LIBS@
 MAKEINFO = @MAKEINFO@
 MKDIR_P = @MKDIR_P@
 MYSQL_CFLAGS = @MYSQL_CFLAGS@
Index: src/libs/zbxsysinfo/solaris/Makefile.in
===================================================================
--- src/libs/zbxsysinfo/solaris/Makefile.in	(revision 302)
+++ src/libs/zbxsysinfo/solaris/Makefile.in	(working copy)
@@ -45,9 +45,9 @@
 	$(top_srcdir)/m4/jabber.m4 $(top_srcdir)/m4/ldap.m4 \
 	$(top_srcdir)/m4/libcurl.m4 $(top_srcdir)/m4/libiodbc.m4 \
 	$(top_srcdir)/m4/libssh2.m4 $(top_srcdir)/m4/libunixodbc.m4 \
-	$(top_srcdir)/m4/netsnmp.m4 $(top_srcdir)/m4/openipmi.m4 \
-	$(top_srcdir)/m4/resolv.m4 $(top_srcdir)/m4/ucdsnmp.m4 \
-	$(top_srcdir)/configure.in
+	$(top_srcdir)/m4/lua.m4 $(top_srcdir)/m4/netsnmp.m4 \
+	$(top_srcdir)/m4/openipmi.m4 $(top_srcdir)/m4/resolv.m4 \
+	$(top_srcdir)/m4/ucdsnmp.m4 $(top_srcdir)/configure.in
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 mkinstalldirs = $(install_sh) -d
@@ -130,7 +130,12 @@
 LIBCURL_LIBS = @LIBCURL_LIBS@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
+LLUA_CFLAGS = @LLUA_CFLAGS@
+LLUA_LIBS = @LLUA_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LUA_CPPFLAGS = @LUA_CPPFLAGS@
+LUA_LDFLAGS = @LUA_LDFLAGS@
+LUA_LIBS = @LUA_LIBS@
 MAKEINFO = @MAKEINFO@
 MKDIR_P = @MKDIR_P@
 MYSQL_CFLAGS = @MYSQL_CFLAGS@
Index: src/zabbix_agent/Makefile.in
===================================================================
--- src/zabbix_agent/Makefile.in	(revision 302)
+++ src/zabbix_agent/Makefile.in	(working copy)
@@ -46,9 +46,9 @@
 	$(top_srcdir)/m4/jabber.m4 $(top_srcdir)/m4/ldap.m4 \
 	$(top_srcdir)/m4/libcurl.m4 $(top_srcdir)/m4/libiodbc.m4 \
 	$(top_srcdir)/m4/libssh2.m4 $(top_srcdir)/m4/libunixodbc.m4 \
-	$(top_srcdir)/m4/netsnmp.m4 $(top_srcdir)/m4/openipmi.m4 \
-	$(top_srcdir)/m4/resolv.m4 $(top_srcdir)/m4/ucdsnmp.m4 \
-	$(top_srcdir)/configure.in
+	$(top_srcdir)/m4/lua.m4 $(top_srcdir)/m4/netsnmp.m4 \
+	$(top_srcdir)/m4/openipmi.m4 $(top_srcdir)/m4/resolv.m4 \
+	$(top_srcdir)/m4/ucdsnmp.m4 $(top_srcdir)/configure.in
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 mkinstalldirs = $(install_sh) -d
@@ -136,7 +136,12 @@
 LIBCURL_LIBS = @LIBCURL_LIBS@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
+LLUA_CFLAGS = @LLUA_CFLAGS@
+LLUA_LIBS = @LLUA_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LUA_CPPFLAGS = @LUA_CPPFLAGS@
+LUA_LDFLAGS = @LUA_LDFLAGS@
+LUA_LIBS = @LUA_LIBS@
 MAKEINFO = @MAKEINFO@
 MKDIR_P = @MKDIR_P@
 MYSQL_CFLAGS = @MYSQL_CFLAGS@
Index: src/zabbix_get/Makefile.in
===================================================================
--- src/zabbix_get/Makefile.in	(revision 302)
+++ src/zabbix_get/Makefile.in	(working copy)
@@ -46,9 +46,9 @@
 	$(top_srcdir)/m4/jabber.m4 $(top_srcdir)/m4/ldap.m4 \
 	$(top_srcdir)/m4/libcurl.m4 $(top_srcdir)/m4/libiodbc.m4 \
 	$(top_srcdir)/m4/libssh2.m4 $(top_srcdir)/m4/libunixodbc.m4 \
-	$(top_srcdir)/m4/netsnmp.m4 $(top_srcdir)/m4/openipmi.m4 \
-	$(top_srcdir)/m4/resolv.m4 $(top_srcdir)/m4/ucdsnmp.m4 \
-	$(top_srcdir)/configure.in
+	$(top_srcdir)/m4/lua.m4 $(top_srcdir)/m4/netsnmp.m4 \
+	$(top_srcdir)/m4/openipmi.m4 $(top_srcdir)/m4/resolv.m4 \
+	$(top_srcdir)/m4/ucdsnmp.m4 $(top_srcdir)/configure.in
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 mkinstalldirs = $(install_sh) -d
@@ -126,7 +126,12 @@
 LIBCURL_LIBS = @LIBCURL_LIBS@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
+LLUA_CFLAGS = @LLUA_CFLAGS@
+LLUA_LIBS = @LLUA_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LUA_CPPFLAGS = @LUA_CPPFLAGS@
+LUA_LDFLAGS = @LUA_LDFLAGS@
+LUA_LIBS = @LUA_LIBS@
 MAKEINFO = @MAKEINFO@
 MKDIR_P = @MKDIR_P@
 MYSQL_CFLAGS = @MYSQL_CFLAGS@
Index: misc/Makefile.in
===================================================================
--- misc/Makefile.in	(revision 302)
+++ misc/Makefile.in	(working copy)
@@ -44,9 +44,9 @@
 	$(top_srcdir)/m4/jabber.m4 $(top_srcdir)/m4/ldap.m4 \
 	$(top_srcdir)/m4/libcurl.m4 $(top_srcdir)/m4/libiodbc.m4 \
 	$(top_srcdir)/m4/libssh2.m4 $(top_srcdir)/m4/libunixodbc.m4 \
-	$(top_srcdir)/m4/netsnmp.m4 $(top_srcdir)/m4/openipmi.m4 \
-	$(top_srcdir)/m4/resolv.m4 $(top_srcdir)/m4/ucdsnmp.m4 \
-	$(top_srcdir)/configure.in
+	$(top_srcdir)/m4/lua.m4 $(top_srcdir)/m4/netsnmp.m4 \
+	$(top_srcdir)/m4/openipmi.m4 $(top_srcdir)/m4/resolv.m4 \
+	$(top_srcdir)/m4/ucdsnmp.m4 $(top_srcdir)/configure.in
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 mkinstalldirs = $(install_sh) -d
@@ -103,7 +103,12 @@
 LIBCURL_LIBS = @LIBCURL_LIBS@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
+LLUA_CFLAGS = @LLUA_CFLAGS@
+LLUA_LIBS = @LLUA_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LUA_CPPFLAGS = @LUA_CPPFLAGS@
+LUA_LDFLAGS = @LUA_LDFLAGS@
+LUA_LIBS = @LUA_LIBS@
 MAKEINFO = @MAKEINFO@
 MKDIR_P = @MKDIR_P@
 MYSQL_CFLAGS = @MYSQL_CFLAGS@
Index: frontends/php/include/locales/en_gb.inc.php
===================================================================
--- frontends/php/include/locales/en_gb.inc.php	(revision 302)
+++ frontends/php/include/locales/en_gb.inc.php	(working copy)
@@ -700,6 +700,7 @@
 	'S_YAXIS_MIN_VALUE'=>			'Y axis MIN value',
 	'S_YAXIS_MAX_VALUE'=>			'Y axis MAX value',
 	'S_CALCULATED'=>			'Calculated',
+
 	'S_FIXED'=>				'Fixed',
 	'S_CREATE_GRAPH'=>			'Create Graph',
 	'S_SHOW_WORKING_TIME'=>			'Show working time',
@@ -1175,7 +1176,10 @@
 	'S_DELETE_HISTORY_SELECTED_ITEMS_Q'=>			'Delete history of selected items?',
 	'S_DELETE_SELECTED_ITEMS_Q'=>				'Delete selected items?',
 	'S_FORMULA'=>						'Formula',
+    'S_LUA_SCRIPT_TYPE'=>                      'Lua script',
+    'S_LUA_SCRIPT'=>                     'Script',
 
+
 //	events.php
 	'S_EVENT'=>				'Event',
 	'S_EVENT_DETAILS'=>			'Event details',
Index: frontends/php/include/forms.inc.php
===================================================================
--- frontends/php/include/forms.inc.php	(revision 302)
+++ frontends/php/include/forms.inc.php	(working copy)
@@ -1788,6 +1788,9 @@
 				case ITEM_TYPE_TELNET:
 					zbx_subarray_push($typeVisibility, $it, array('id'=>'key', 'defaultValue'=> 'telnet.run[<unique short description>,<ip>,<port>,<encoding>]'));
 				break;
+                case ITEM_TYPE_LUA:
+                    zbx_subarray_push($typeVisibility, $it, array('id'=>'key', 'defaultValue'=>'lua[<unique short description>]'));
+                break;
 				default:
 					zbx_subarray_push($typeVisibility, $it, array('id'=>'key', 'defaultValue'=> ''));
 			}
@@ -1851,17 +1854,23 @@
 		$spanF->setAttribute('id', 'label_formula');
 		zbx_subarray_push($typeVisibility, ITEM_TYPE_CALCULATED, 'label_formula');
 
+        $spanL = new CSpan(S_LUA_SCRIPT);
+        $spanL->setAttribute('id', 'label_lua');
+        zbx_subarray_push($typeVisibility, ITEM_TYPE_LUA, 'label_lua');
 
+
 		$params_script = new CTextArea('params', $params, 60, 4);
 		$params_script->setAttribute('id', 'params_script');
 		$params_dbmonitor = new CTextArea('params', $params, 60, 4);
 		$params_dbmonitor->setAttribute('id', 'params_dbmonitor');
 		$params_calculted = new CTextArea('params', $params, 60, 4);
 		$params_calculted->setAttribute('id', 'params_calculted');
+        $params_lua = new CTextArea('params',$params, 60, 4);
+        $params_lua->setAttribute('id','params_lua');
 
 		$row = new CRow(array(
-			new CCol(array($spanEC, $spanP, $spanF),'form_row_l'),
-			new CCol(array($params_script, $params_dbmonitor, $params_calculted),'form_row_r')
+			new CCol(array($spanEC, $spanP, $spanF,$spanL),'form_row_l'),
+			new CCol(array($params_script, $params_dbmonitor, $params_calculted,$params_lua),'form_row_r')
 		));
 		$row->setAttribute('id', 'row_params');
 		$frmItem->addRow($row);
@@ -1873,7 +1882,10 @@
 		zbx_subarray_push($typeVisibility, ITEM_TYPE_DB_MONITOR, 'row_params');
 		zbx_subarray_push($typeVisibility, ITEM_TYPE_CALCULATED, 'params_calculted');
 		zbx_subarray_push($typeVisibility, ITEM_TYPE_CALCULATED, 'row_params');
+        zbx_subarray_push($typeVisibility, ITEM_TYPE_LUA, 'params_lua');
+        zbx_subarray_push($typeVisibility, ITEM_TYPE_LUA, 'row_params');
 
+
 /*
 ITEM_TYPE_DB_MONITOR $key = 'db.odbc.select[<unique short description>]'; $params = "DSN=<database source name>\nuser=<user name>\npassword=<password>\nsql=<query>";
 ITEM_TYPE_SSH $key = 'ssh.run[<unique short description>,<ip>,<port>,<encoding>]'; $params = '';
Index: frontends/php/include/defines.inc.php
===================================================================
--- frontends/php/include/defines.inc.php	(revision 302)
+++ frontends/php/include/defines.inc.php	(working copy)
@@ -284,6 +284,7 @@
 	define('ITEM_TYPE_SSH',				13);
 	define('ITEM_TYPE_TELNET',			14);
 	define('ITEM_TYPE_CALCULATED',		15);
+    define('ITEM_TYPE_LUA',             16);
 
 	define('ITEM_VALUE_TYPE_FLOAT',		0);
 	define('ITEM_VALUE_TYPE_STR',		1);
Index: frontends/php/include/items.inc.php
===================================================================
--- frontends/php/include/items.inc.php	(revision 302)
+++ frontends/php/include/items.inc.php	(working copy)
@@ -84,6 +84,7 @@
 			ITEM_TYPE_TELNET => S_TELNET_AGENT,
 			ITEM_TYPE_CALCULATED => S_CALCULATED,
 			ITEM_TYPE_HTTPTEST => S_WEB_MONITORING,
+            ITEM_TYPE_LUA => S_LUA_SCRIPT_TYPE
 		);
 
 		if(is_null($type)){
@@ -248,6 +249,7 @@
 	 *                                                                            *
 	 ******************************************************************************/
 	function add_item($item){
+    global $USER_DETAILS;
 		$item_db_fields = array(
 				'description'		=> null,
 				'key_'			=> null,
@@ -297,14 +299,16 @@
 		if(($i = array_search(0,$item['applications'])) !== FALSE)
 			unset($item['applications'][$i]);
 
-		if(!preg_match('/^'.ZBX_PREG_ITEM_KEY_FORMAT.'$/u', $item['key_']) ){
-			error(S_INCORRECT_KEY_FORMAT.SPACE."'key_name[param1,param2,...]'");
-			return false;
-		}
+ 	    if(!preg_match('/^'.ZBX_PREG_ITEM_KEY_FORMAT.'$/u', $item['key_']) ){
+		    error(S_INCORRECT_KEY_FORMAT.SPACE."'key_name[param1,param2,...]'");
+		    return false;
+	    }
 
 		if(($item['type'] == ITEM_TYPE_DB_MONITOR && $item['key_'] == 'db.odbc.select[<unique short description>]') ||
 		   ($item['type'] == ITEM_TYPE_SSH && $item['key_'] == 'ssh.run[<unique short description>,<ip>,<port>,<encoding>]') ||
-		   ($item['type'] == ITEM_TYPE_TELNET && $item['key_'] == 'telnet.run[<unique short description>,<ip>,<port>,<encoding>]')) {
+		   ($item['type'] == ITEM_TYPE_TELNET && $item['key_'] == 'telnet.run[<unique short description>,<ip>,<port>,<encoding>]') ||
+           ($item['type'] == ITEM_TYPE_LUA && $item['key_'] == 'lua[<unique short description>]'))
+        {
 		   	error(S_ITEMS_CHECK_KEY_DEFAULT_EXAMPLE_PASSED);
 		   	return false;
 		}
@@ -390,6 +394,10 @@
 			return false;
 		}
 
+        if ($item['type']==ITEM_TYPE_LUA){
+            $item['username']=$USER_DETAILS['alias'];    //always set the username to the current alias for Lua items.
+        }
+
 		// first add mother item
 		$itemid=get_dbid('items','itemid');
 		$result=DBexecute('INSERT INTO items '.
@@ -502,6 +510,9 @@
 		'snmpv3_securityname','snmpv3_securitylevel','snmpv3_authpassphrase','snmpv3_privpassphrase',
 		'formula','trends','logtimefmt','valuemapid','delay_flex','params','ipmi_sensor','applications','templateid');
 */
+
+        global $USER_DETAILS;
+
 		$upd_app = ((isset($item['applications'])) && !is_null($item['applications']));
 		$item_in_params = $item;
 
@@ -518,13 +529,15 @@
 		if(($i = array_search(0,$item['applications'])) !== FALSE) unset($item['applications'][$i]);
 
 		if( !preg_match('/^'.ZBX_PREG_ITEM_KEY_FORMAT.'$/u', $item['key_']) ){
-			error(S_INCORRECT_KEY_FORMAT.SPACE."'key_name[param1,param2,...]'");
-			return false;
-		}
+	    	error(S_INCORRECT_KEY_FORMAT.SPACE."'key_name[param1,param2,...]'");
+		    return false;
+	    }
 
 		if(($item['type'] == ITEM_TYPE_DB_MONITOR && $item['key_'] == 'db.odbc.select[<unique short description>]') ||
 		   ($item['type'] == ITEM_TYPE_SSH && $item['key_'] == 'ssh.run[<unique short description>,<ip>,<port>,<encoding>]') ||
-		   ($item['type'] == ITEM_TYPE_TELNET && $item['key_'] == 'telnet.run[<unique short description>,<ip>,<port>,<encoding>]')) {
+		   ($item['type'] == ITEM_TYPE_TELNET && $item['key_'] == 'telnet.run[<unique short description>,<ip>,<port>,<encoding>]') ||
+           ($item['type'] == ITEM_TYPE_LUA && $item['key_'] == 'lua[<unique short description>]'))
+        {
 		   	error(S_ITEMS_CHECK_KEY_DEFAULT_EXAMPLE_PASSED);
 			return false;
 		}
@@ -618,6 +631,10 @@
 		if($item['status'] == ITEM_STATUS_ACTIVE)
 			DBexecute("UPDATE items SET error='' WHERE itemid=".$itemid.' and status<>'.$item['status']);
 
+        if ($item['type']==ITEM_TYPE_LUA){
+            $item['username']=$USER_DETAILS['alias'];  //always set the username to the current alias for Lua items.
+        }
+
 		$result=DBexecute(
 			'UPDATE items '.
 			' SET description='.zbx_dbstr($item['description']).','.
Index: frontends/php/items.php
===================================================================
--- frontends/php/items.php	(revision 302)
+++ frontends/php/items.php	(working copy)
@@ -91,7 +91,7 @@
 				IN(array(-1,ITEM_TYPE_ZABBIX,ITEM_TYPE_SNMPV1,ITEM_TYPE_TRAPPER,ITEM_TYPE_SIMPLE,
 					ITEM_TYPE_SNMPV2C,ITEM_TYPE_INTERNAL,ITEM_TYPE_SNMPV3,ITEM_TYPE_ZABBIX_ACTIVE,
 					ITEM_TYPE_AGGREGATE,ITEM_TYPE_EXTERNAL,ITEM_TYPE_DB_MONITOR,
-					ITEM_TYPE_IPMI,ITEM_TYPE_SSH,ITEM_TYPE_TELNET,ITEM_TYPE_CALCULATED)),'isset({save})'),
+					ITEM_TYPE_IPMI,ITEM_TYPE_SSH,ITEM_TYPE_TELNET,ITEM_TYPE_CALCULATED,ITEM_TYPE_LUA)),'isset({save})'),
 		'trends'=>		array(T_ZBX_INT, O_OPT,  null,  BETWEEN(0,65535),	'isset({save})&&isset({value_type})&&'.IN(
 												ITEM_VALUE_TYPE_FLOAT.','.
 												ITEM_VALUE_TYPE_UINT64, 'value_type')),
@@ -183,7 +183,7 @@
 				IN(array(-1,ITEM_TYPE_ZABBIX,ITEM_TYPE_SNMPV1,ITEM_TYPE_TRAPPER,ITEM_TYPE_SIMPLE,
 				ITEM_TYPE_SNMPV2C,ITEM_TYPE_INTERNAL,ITEM_TYPE_SNMPV3,ITEM_TYPE_ZABBIX_ACTIVE,
 				ITEM_TYPE_AGGREGATE,ITEM_TYPE_EXTERNAL,ITEM_TYPE_DB_MONITOR,
-				ITEM_TYPE_IPMI,ITEM_TYPE_SSH,ITEM_TYPE_TELNET,ITEM_TYPE_CALCULATED)),null),
+				ITEM_TYPE_IPMI,ITEM_TYPE_SSH,ITEM_TYPE_TELNET,ITEM_TYPE_CALCULATED,ITEM_TYPE_LUA)),null),
 		'filter_key'=>				array(T_ZBX_STR, O_OPT,  null,  null,		null),
 		'filter_snmp_community'=>array(T_ZBX_STR, O_OPT,  null,  null,	null),
 		'filter_snmpv3_securityname'=>array(T_ZBX_STR, O_OPT,  null,  null,  null),
Index: create/Makefile.in
===================================================================
--- create/Makefile.in	(revision 302)
+++ create/Makefile.in	(working copy)
@@ -44,9 +44,9 @@
 	$(top_srcdir)/m4/jabber.m4 $(top_srcdir)/m4/ldap.m4 \
 	$(top_srcdir)/m4/libcurl.m4 $(top_srcdir)/m4/libiodbc.m4 \
 	$(top_srcdir)/m4/libssh2.m4 $(top_srcdir)/m4/libunixodbc.m4 \
-	$(top_srcdir)/m4/netsnmp.m4 $(top_srcdir)/m4/openipmi.m4 \
-	$(top_srcdir)/m4/resolv.m4 $(top_srcdir)/m4/ucdsnmp.m4 \
-	$(top_srcdir)/configure.in
+	$(top_srcdir)/m4/lua.m4 $(top_srcdir)/m4/netsnmp.m4 \
+	$(top_srcdir)/m4/openipmi.m4 $(top_srcdir)/m4/resolv.m4 \
+	$(top_srcdir)/m4/ucdsnmp.m4 $(top_srcdir)/configure.in
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 mkinstalldirs = $(install_sh) -d
@@ -103,7 +103,12 @@
 LIBCURL_LIBS = @LIBCURL_LIBS@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
+LLUA_CFLAGS = @LLUA_CFLAGS@
+LLUA_LIBS = @LLUA_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LUA_CPPFLAGS = @LUA_CPPFLAGS@
+LUA_LDFLAGS = @LUA_LDFLAGS@
+LUA_LIBS = @LUA_LIBS@
 MAKEINFO = @MAKEINFO@
 MKDIR_P = @MKDIR_P@
 MYSQL_CFLAGS = @MYSQL_CFLAGS@
Index: INSTALL
===================================================================
--- INSTALL	(revision 302)
+++ INSTALL	(working copy)
@@ -1 +1,8 @@
+Before following the standard Zabbix installation instructions you must first
+set up autoconfig.  To do so execute the following command:
+bash bootstrap.sh
+
+It may be necisary to run this command between svn updates as well.
+
+
 Please see http://www.zabbix.com/documentation/1.8/manual/installation for installation instructions.
Index: upgrades/Makefile.in
===================================================================
--- upgrades/Makefile.in	(revision 302)
+++ upgrades/Makefile.in	(working copy)
@@ -44,9 +44,9 @@
 	$(top_srcdir)/m4/jabber.m4 $(top_srcdir)/m4/ldap.m4 \
 	$(top_srcdir)/m4/libcurl.m4 $(top_srcdir)/m4/libiodbc.m4 \
 	$(top_srcdir)/m4/libssh2.m4 $(top_srcdir)/m4/libunixodbc.m4 \
-	$(top_srcdir)/m4/netsnmp.m4 $(top_srcdir)/m4/openipmi.m4 \
-	$(top_srcdir)/m4/resolv.m4 $(top_srcdir)/m4/ucdsnmp.m4 \
-	$(top_srcdir)/configure.in
+	$(top_srcdir)/m4/lua.m4 $(top_srcdir)/m4/netsnmp.m4 \
+	$(top_srcdir)/m4/openipmi.m4 $(top_srcdir)/m4/resolv.m4 \
+	$(top_srcdir)/m4/ucdsnmp.m4 $(top_srcdir)/configure.in
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 mkinstalldirs = $(install_sh) -d
@@ -103,7 +103,12 @@
 LIBCURL_LIBS = @LIBCURL_LIBS@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
+LLUA_CFLAGS = @LLUA_CFLAGS@
+LLUA_LIBS = @LLUA_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LUA_CPPFLAGS = @LUA_CPPFLAGS@
+LUA_LDFLAGS = @LUA_LDFLAGS@
+LUA_LIBS = @LUA_LIBS@
 MAKEINFO = @MAKEINFO@
 MKDIR_P = @MKDIR_P@
 MYSQL_CFLAGS = @MYSQL_CFLAGS@
Index: man/Makefile.in
===================================================================
--- man/Makefile.in	(revision 302)
+++ man/Makefile.in	(working copy)
@@ -44,9 +44,9 @@
 	$(top_srcdir)/m4/jabber.m4 $(top_srcdir)/m4/ldap.m4 \
 	$(top_srcdir)/m4/libcurl.m4 $(top_srcdir)/m4/libiodbc.m4 \
 	$(top_srcdir)/m4/libssh2.m4 $(top_srcdir)/m4/libunixodbc.m4 \
-	$(top_srcdir)/m4/netsnmp.m4 $(top_srcdir)/m4/openipmi.m4 \
-	$(top_srcdir)/m4/resolv.m4 $(top_srcdir)/m4/ucdsnmp.m4 \
-	$(top_srcdir)/configure.in
+	$(top_srcdir)/m4/lua.m4 $(top_srcdir)/m4/netsnmp.m4 \
+	$(top_srcdir)/m4/openipmi.m4 $(top_srcdir)/m4/resolv.m4 \
+	$(top_srcdir)/m4/ucdsnmp.m4 $(top_srcdir)/configure.in
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 mkinstalldirs = $(install_sh) -d
@@ -129,7 +129,12 @@
 LIBCURL_LIBS = @LIBCURL_LIBS@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
+LLUA_CFLAGS = @LLUA_CFLAGS@
+LLUA_LIBS = @LLUA_LIBS@
 LTLIBOBJS = @LTLIBOBJS@
+LUA_CPPFLAGS = @LUA_CPPFLAGS@
+LUA_LDFLAGS = @LUA_LDFLAGS@
+LUA_LIBS = @LUA_LIBS@
 MAKEINFO = @MAKEINFO@
 MKDIR_P = @MKDIR_P@
 MYSQL_CFLAGS = @MYSQL_CFLAGS@
Index: aclocal.m4
===================================================================
--- aclocal.m4	(revision 302)
+++ aclocal.m4	(working copy)
@@ -87,16 +87,14 @@
 # _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
 # ---------------------------------------------
 m4_define([_PKG_CONFIG],
-[if test -n "$PKG_CONFIG"; then
-    if test -n "$$1"; then
-        pkg_cv_[]$1="$$1"
-    else
-        PKG_CHECK_EXISTS([$3],
-                         [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`],
-			 [pkg_failed=yes])
-    fi
-else
-	pkg_failed=untried
+[if test -n "$$1"; then
+    pkg_cv_[]$1="$$1"
+ elif test -n "$PKG_CONFIG"; then
+    PKG_CHECK_EXISTS([$3],
+                     [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`],
+		     [pkg_failed=yes])
+ else
+    pkg_failed=untried
 fi[]dnl
 ])# _PKG_CONFIG
 
@@ -140,9 +138,9 @@
 if test $pkg_failed = yes; then
         _PKG_SHORT_ERRORS_SUPPORTED
         if test $_pkg_short_errors_supported = yes; then
-	        $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --errors-to-stdout --print-errors "$2"`
+	        $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "$2" 2>&1`
         else 
-	        $1[]_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "$2"`
+	        $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors "$2" 2>&1`
         fi
 	# Put the nasty error message in config.log where it belongs
 	echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD
@@ -1166,6 +1164,7 @@
 m4_include([m4/libiodbc.m4])
 m4_include([m4/libssh2.m4])
 m4_include([m4/libunixodbc.m4])
+m4_include([m4/lua.m4])
 m4_include([m4/netsnmp.m4])
 m4_include([m4/openipmi.m4])
 m4_include([m4/resolv.m4])

