Tuxedo subagent compiles under Linux
authorVictor Kirhenshtein <victor@netxms.org>
Tue, 18 Nov 2014 16:23:21 +0000 (18:23 +0200)
committerVictor Kirhenshtein <victor@netxms.org>
Tue, 18 Nov 2014 16:25:20 +0000 (18:25 +0200)
configure.ac
src/agent/core/comm.cpp
src/agent/subagents/tuxedo/Makefile.am [new file with mode: 0644]
src/agent/subagents/tuxedo/clients.cpp
src/agent/subagents/tuxedo/machines.cpp
src/agent/subagents/tuxedo/queues.cpp
src/agent/subagents/tuxedo/servers.cpp
src/agent/subagents/tuxedo/services.cpp

index 09c7984..275d08b 100644 (file)
@@ -241,6 +241,15 @@ AC_ARG_WITH(jdk,
        COMPONENTS="$COMPONENTS java"
 fi ])
 
+AC_ARG_WITH(tuxedo,
+[AS_HELP_STRING(--with-tuxedo,build Tuxedo-dependent components)],
+[ if test "x$withval" != "xno" ; then
+       if test "x$withval" != "x" && test "x$withval" != "xyes" ; then
+               TUXEDO_BASE="$withval"
+       fi
+       COMPONENTS="$COMPONENTS tuxedo"
+fi ])
+
 AC_ARG_WITH(sqlite,
 [AS_HELP_STRING(--with-sqlite,build SQLite database driver)],
 [ if test "x$withval" != "xno" ; then
@@ -474,7 +483,7 @@ AC_ARG_WITH(dist,
 [AS_HELP_STRING(--with-dist,for maintainers only)],
        DB_DRIVERS=" mysql pgsql odbc mssql sqlite oracle db2 informix"
        MODULES="jansson libexpat libstrophe libtre zlib libnetxms install sqlite snmp libnxsl libnxlp db server agent libnxmap libnxcl client nxscript nxcproxy nxlptest tools"
-       SUBAGENT_DIRS="linux freebsd openbsd netbsd sunos aix ipso hpux odbcquery informix oracle lmsensors darwin rpi java netsvc db2"
+       SUBAGENT_DIRS="linux freebsd openbsd netbsd sunos aix ipso hpux odbcquery informix oracle lmsensors darwin rpi java netsvc db2 tuxedo"
        SMSDRV_DIRS="kannel websms"
    HDLINK_DIRS="jira"
    PDSDRV_DIRS="rrdtool"
@@ -744,6 +753,11 @@ if test $? = 0; then
        SUBAGENT_DIRS="$SUBAGENT_DIRS java"
 fi
 
+check_substr "$COMPONENTS" "tuxedo"
+if test $? = 0; then
+       SUBAGENT_DIRS="$SUBAGENT_DIRS tuxedo"
+fi
+
 check_substr "$COMPONENTS" "sdk"
 if test $? = 0; then
        MODULES="$MODULES libnxmap libnxcl libnxsl libnxlp db nxscript"
@@ -2429,6 +2443,38 @@ fi
 
 
 #--------------------------------------------------------------------
+# Tuxedo
+#--------------------------------------------------------------------
+
+check_substr "$COMPONENTS" "tuxedo"
+if test $? = 0; then
+       OLD_CPPFLAGS="$CPPFLAGS"
+       OLD_LDFLAGS="$LDFLAGS"
+       OLD_LIBS="$LIBS"
+
+       if test "x$TUXEDO_BASE" != "x"; then
+               TUXEDO_CPPFLAGS="-I$TUXEDO_BASE/include"
+               TUXEDO_LDFLAGS="-L$TUXEDO_BASE/lib"
+               CPPFLAGS="$CPPFLAGS $TUXEDO_CPPFLAGS"
+               LDFLAGS="$LDFLAGS $TUXEDO_LDFLAGS"
+       fi
+       
+       AC_CHECK_HEADER(atmi.h,,AC_MSG_ERROR([*** Cannot find atmi.h - check your Tuxedo installation ***]))
+
+       # https://community.oracle.com/thread/2346582
+       if test "x$PLATFORM" = "xLinux"; then
+               TUXEDO_LDFLAGS="$TUXEDO_LDFLAGS -Xlinker --no-as-needed"
+               LDFLAGS="$LDFLAGS -Xlinker --no-as-needed"
+       fi
+       AC_CHECK_LIB(tux, tpinit, [], [AC_MSG_ERROR(libtux is required for Tuxedo support)])
+
+       CPPFLAGS="$OLD_CPPFLAGS"
+       LDFLAGS="$OLD_LDFLAGS"
+       LIBS="$OLD_LIBS"
+fi
+
+
+#--------------------------------------------------------------------
 # Other settings
 #--------------------------------------------------------------------
 
@@ -2518,6 +2564,8 @@ AC_SUBST(INFORMIX_LIBS)
 AC_SUBST(OBJECT_MODE)
 AC_SUBST(SQLFLAGS)
 AC_SUBST(SHLIB_SUFFIX)
+AC_SUBST(TUXEDO_CPPFLAGS)
+AC_SUBST(TUXEDO_LDFLAGS)
 
 #--------------------------------------------------------------------
 # Shared libs versions
@@ -2617,6 +2665,7 @@ AC_CONFIG_FILES([
        src/agent/subagents/rpi/Makefile
        src/agent/subagents/sms/Makefile
        src/agent/subagents/sunos/Makefile
+       src/agent/subagents/tuxedo/Makefile
        src/agent/subagents/ups/Makefile
        src/agent/subagents/winnt/Makefile
        src/agent/subagents/winperf/Makefile
@@ -2901,6 +2950,13 @@ if test "x${INFORMIX_LIBS}" != "x"; then
        echo "Informix LIBS           : ${INFORMIX_LIBS}"
 fi
 
+if test "x${TUXEDO_CPPFLAGS}" != "x"; then
+       echo "Tuxedo CPPFLAGS         : ${TUXEDO_CPPFLAGS}"
+fi
+if test "x${TUXEDO_LDFLAGS}" != "x"; then
+       echo "Tuxedo LDFLAGS          : ${TUXEDO_LDFLAGS}"
+fi
+
 FLAGS_CPP="src/tools/nxdevcfg/flags.cpp"
 echo "/* Automatically generated by configure */" > $FLAGS_CPP
 echo "#include <nms_common.h>" >> $FLAGS_CPP
index 081d139..42341f2 100644 (file)
@@ -377,7 +377,7 @@ THREAD_RESULT THREAD_CALL SessionWatchdog(void *)
          {
             if (g_pSessionList[i]->getTimeStamp() < (now - (time_t)g_dwIdleTimeout))
                                {
-                                       DebugPrintf(i, 5, _T("Session disconnected by watchdog (last activity timestamp is ") TIME_T_FMT _T(")"), g_pSessionList[i]->getTimeStamp());
+                                       DebugPrintf(i, 5, _T("Session disconnected by watchdog (last activity timestamp is ") UINT64_FMT _T(")"), (UINT64)g_pSessionList[i]->getTimeStamp());
                g_pSessionList[i]->disconnect();
                                }
          }
diff --git a/src/agent/subagents/tuxedo/Makefile.am b/src/agent/subagents/tuxedo/Makefile.am
new file mode 100644 (file)
index 0000000..dda8a22
--- /dev/null
@@ -0,0 +1,18 @@
+SUBAGENT = tuxedo
+
+pkglib_LTLIBRARIES = tuxedo.la
+tuxedo_la_SOURCES = clients.cpp domain.cpp machines.cpp main.cpp queues.cpp servers.cpp services.cpp
+tuxedo_la_CPPFLAGS=-I@top_srcdir@/include @TUXEDO_CPPFLAGS@
+tuxedo_la_LDFLAGS = -module -avoid-version @TUXEDO_LDFLAGS@
+tuxedo_la_LIBADD = ../../../libnetxms/libnetxms.la -ltux -lfml32
+
+EXTRA_DIST = tuxedo.vcproj tuxedo_subagent.h
+
+if !STATIC_BUILD
+install-exec-hook:
+       if test "x`uname -s`" = "xAIX" ; then OBJECT_MODE=@OBJECT_MODE@ $(AR) x $(DESTDIR)$(pkglibdir)/$(SUBAGENT).a $(DESTDIR)$(pkglibdir)/$(SUBAGENT)@SHLIB_SUFFIX@ ; rm -f $(DESTDIR)$(pkglibdir)/$(SUBAGENT).a ; fi
+       mv -f $(DESTDIR)$(pkglibdir)/$(SUBAGENT)@SHLIB_SUFFIX@ $(DESTDIR)$(pkglibdir)/$(SUBAGENT).nsm
+       rm -f $(DESTDIR)$(pkglibdir)/$(SUBAGENT).la
+       rm -f $(DESTDIR)$(libdir)/libnsm_$(SUBAGENT)@SHLIB_SUFFIX@
+       ln -s netxms/$(SUBAGENT).nsm $(DESTDIR)$(libdir)/libnsm_$(SUBAGENT)@SHLIB_SUFFIX@
+endif
index 35e989c..9d43f21 100644 (file)
@@ -126,17 +126,17 @@ static void QueryClients()
    if (!TuxedoConnect())
       AgentWriteDebugLog(3, _T("Tuxedo: tpinit() call failed (%d)"), errno);
 
-       FBFR32 *fb = (FBFR32 *)tpalloc("FML32", NULL, 4096);
-       CFchg32(fb, TA_OPERATION, 0, (char *)"GET", 0, FLD_STRING);
-       CFchg32(fb, TA_CLASS, 0, (char *)"T_CLIENT", 0, FLD_STRING);
+   FBFR32 *fb = (FBFR32 *)tpalloc((char *)"FML32", NULL, 4096);
+   CFchg32(fb, TA_OPERATION, 0, (char *)"GET", 0, FLD_STRING);
+   CFchg32(fb, TA_CLASS, 0, (char *)"T_CLIENT", 0, FLD_STRING);
 
    bool readMore = true;
    long rsplen = 262144;
-   FBFR32 *rsp = (FBFR32 *)tpalloc("FML32", NULL, rsplen);
+   FBFR32 *rsp = (FBFR32 *)tpalloc((char *)"FML32", NULL, rsplen);
    while(readMore)
    {
       readMore = false;
-      if (tpcall(".TMIB", (char *)fb, 0, (char **)&rsp, &rsplen, 0) != -1)
+      if (tpcall((char *)".TMIB", (char *)fb, 0, (char **)&rsp, &rsplen, 0) != -1)
       {
          if (s_clients == NULL)
             s_clients = new StringObjectMap<TuxedoClient>(true);
@@ -251,17 +251,17 @@ LONG H_ClientsTable(const TCHAR *param, const TCHAR *arg, Table *value)
          value->set(3, c->m_state);
          value->set(4, c->m_serverGroup);
          value->set(5, c->m_userName);
-         value->set(6, c->m_idleTime);
-         value->set(7, c->m_pid);
-         value->set(8, c->m_activeRequests);
-         value->set(9, c->m_activeConv);
-         value->set(10, c->m_convCount);
-         value->set(11, c->m_dequeueCount);
-         value->set(12, c->m_enqueueCount);
-         value->set(13, c->m_postCount);
-         value->set(14, c->m_requestCount);
-         value->set(15, c->m_subscribeCount);
-         value->set(16, c->m_tranCount);
+         value->set(6, (INT32)c->m_idleTime);
+         value->set(7, (INT32)c->m_pid);
+         value->set(8, (INT32)c->m_activeRequests);
+         value->set(9, (INT32)c->m_activeConv);
+         value->set(10, (INT32)c->m_convCount);
+         value->set(11, (INT32)c->m_dequeueCount);
+         value->set(12, (INT32)c->m_enqueueCount);
+         value->set(13, (INT32)c->m_postCount);
+         value->set(14, (INT32)c->m_requestCount);
+         value->set(15, (INT32)c->m_subscribeCount);
+         value->set(16, (INT32)c->m_tranCount);
          value->set(17, c->m_wsc);
          value->set(18, c->m_wsClientId);
          value->set(19, c->m_netAddr);
index 041571e..a4c4193 100644 (file)
@@ -123,20 +123,20 @@ static void QueryMachines()
    if (!TuxedoConnect())
       AgentWriteDebugLog(3, _T("Tuxedo: tpinit() call failed (%d)"), errno);
 
-       FBFR32 *fb = (FBFR32 *)tpalloc("FML32", NULL, 4096);
-       CFchg32(fb, TA_OPERATION, 0, (char *)"GET", 0, FLD_STRING);
-       CFchg32(fb, TA_CLASS, 0, (char *)"T_MACHINE", 0, FLD_STRING);
+   FBFR32 *fb = (FBFR32 *)tpalloc((char *)"FML32", NULL, 4096);
+   CFchg32(fb, TA_OPERATION, 0, (char *)"GET", 0, FLD_STRING);
+   CFchg32(fb, TA_CLASS, 0, (char *)"T_MACHINE", 0, FLD_STRING);
 
    long flags = MIB_LOCAL;
-       CFchg32(fb, TA_FLAGS, 0, (char *)&flags, 0, FLD_LONG);
+   CFchg32(fb, TA_FLAGS, 0, (char *)&flags, 0, FLD_LONG);
 
    bool readMore = true;
    long rsplen = 262144;
-   FBFR32 *rsp = (FBFR32 *)tpalloc("FML32", NULL, rsplen);
+   FBFR32 *rsp = (FBFR32 *)tpalloc((char *)"FML32", NULL, rsplen);
    while(readMore)
    {
       readMore = false;
-      if (tpcall(".TMIB", (char *)fb, 0, (char **)&rsp, &rsplen, 0) != -1)
+      if (tpcall((char *)".TMIB", (char *)fb, 0, (char **)&rsp, &rsplen, 0) != -1)
       {
          if (s_machines == NULL)
             s_machines = new StringObjectMap<TuxedoMachine>(true);
@@ -251,13 +251,13 @@ LONG H_MachinesTable(const TCHAR *param, const TCHAR *arg, Table *value)
          value->set(4, m->m_role);
          value->set(5, m->m_bridge);
          value->set(6, m->m_swrelease);
-         value->set(7, m->m_accessers);
-         value->set(8, m->m_clients);
-         value->set(9, m->m_wsClients);
-         value->set(10, m->m_conversations);
-         value->set(11, m->m_load);
-         value->set(12, m->m_workloadsProcessed);
-         value->set(13, m->m_workloadsInitiated);
+         value->set(7, (INT32)m->m_accessers);
+         value->set(8, (INT32)m->m_clients);
+         value->set(9, (INT32)m->m_wsClients);
+         value->set(10, (INT32)m->m_conversations);
+         value->set(11, (INT32)m->m_load);
+         value->set(12, (INT32)m->m_workloadsProcessed);
+         value->set(13, (INT32)m->m_workloadsInitiated);
          value->set(14, m->m_tuxConfig);
          value->set(15, m->m_tuxDir);
          value->set(16, m->m_appDir);
index 09bf4eb..99e2390 100644 (file)
@@ -103,20 +103,20 @@ static void QueryQueues()
    if (!TuxedoConnect())
       AgentWriteDebugLog(3, _T("Tuxedo: tpinit() call failed (%d)"), errno);
 
-       FBFR32 *fb = (FBFR32 *)tpalloc("FML32", NULL, 4096);
-       CFchg32(fb, TA_OPERATION, 0, (char *)"GET", 0, FLD_STRING);
-       CFchg32(fb, TA_CLASS, 0, (char *)"T_QUEUE", 0, FLD_STRING);
+   FBFR32 *fb = (FBFR32 *)tpalloc((char *)"FML32", NULL, 4096);
+   CFchg32(fb, TA_OPERATION, 0, (char *)"GET", 0, FLD_STRING);
+   CFchg32(fb, TA_CLASS, 0, (char *)"T_QUEUE", 0, FLD_STRING);
 
    long flags = MIB_LOCAL;
-       CFchg32(fb, TA_FLAGS, 0, (char *)&flags, 0, FLD_LONG);
+   CFchg32(fb, TA_FLAGS, 0, (char *)&flags, 0, FLD_LONG);
 
    bool readMore = true;
    long rsplen = 262144;
-   FBFR32 *rsp = (FBFR32 *)tpalloc("FML32", NULL, rsplen);
+   FBFR32 *rsp = (FBFR32 *)tpalloc((char *)"FML32", NULL, rsplen);
    while(readMore)
    {
       readMore = false;
-      if (tpcall(".TMIB", (char *)fb, 0, (char **)&rsp, &rsplen, 0) != -1)
+      if (tpcall((char *)".TMIB", (char *)fb, 0, (char **)&rsp, &rsplen, 0) != -1)
       {
          if (s_queues == NULL)
             s_queues = new StringObjectMap<TuxedoQueue>(true);
@@ -228,11 +228,11 @@ LONG H_QueuesTable(const TCHAR *param, const TCHAR *arg, Table *value)
          value->set(1, q->m_lmid);
          value->set(2, q->m_serverName);
          value->set(3, q->m_state);
-         value->set(4, q->m_serverCount);
-         value->set(5, q->m_requestsTotal);
-         value->set(6, q->m_requestsCurrent);
-         value->set(7, q->m_workloadsTotal);
-         value->set(8, q->m_workloadsCurrent);
+         value->set(4, (INT32)q->m_serverCount);
+         value->set(5, (INT32)q->m_requestsTotal);
+         value->set(6, (INT32)q->m_requestsCurrent);
+         value->set(7, (INT32)q->m_workloadsTotal);
+         value->set(8, (INT32)q->m_workloadsCurrent);
       }
       delete queues;
    }
index 6c2dfd8..5940fa6 100644 (file)
@@ -147,20 +147,20 @@ static void QueryServers()
    if (!TuxedoConnect())
       AgentWriteDebugLog(3, _T("Tuxedo: tpinit() call failed (%d)"), errno);
 
-       FBFR32 *fb = (FBFR32 *)tpalloc("FML32", NULL, 4096);
-       CFchg32(fb, TA_OPERATION, 0, (char *)"GET", 0, FLD_STRING);
-       CFchg32(fb, TA_CLASS, 0, (char *)"T_SERVER", 0, FLD_STRING);
+   FBFR32 *fb = (FBFR32 *)tpalloc((char *)"FML32", NULL, 4096);
+   CFchg32(fb, TA_OPERATION, 0, (char *)"GET", 0, FLD_STRING);
+   CFchg32(fb, TA_CLASS, 0, (char *)"T_SERVER", 0, FLD_STRING);
 
    long flags = MIB_LOCAL;
-       CFchg32(fb, TA_FLAGS, 0, (char *)&flags, 0, FLD_LONG);
+   CFchg32(fb, TA_FLAGS, 0, (char *)&flags, 0, FLD_LONG);
 
    bool readMore = true;
    long rsplen = 262144;
-   FBFR32 *rsp = (FBFR32 *)tpalloc("FML32", NULL, rsplen);
+   FBFR32 *rsp = (FBFR32 *)tpalloc((char *)"FML32", NULL, rsplen);
    while(readMore)
    {
       readMore = false;
-      if (tpcall(".TMIB", (char *)fb, 0, (char **)&rsp, &rsplen, 0) != -1)
+      if (tpcall((char *)".TMIB", (char *)fb, 0, (char **)&rsp, &rsplen, 0) != -1)
       {
          if (s_servers == NULL)
             s_servers = new ObjectArray<TuxedoServer>(256, 256, true);
@@ -216,7 +216,7 @@ LONG H_ServersList(const TCHAR *param, const TCHAR *arg, StringList *value)
          TuxedoServer *s = s_servers->get(i);
          if (s != NULL)
          {
-            value->add(s->m_id);
+            value->add((INT32)s->m_id);
          }
       }
    }
@@ -280,32 +280,32 @@ LONG H_ServersTable(const TCHAR *param, const TCHAR *arg, Table *value)
             continue;
 
          value->addRow();
-         value->set(0, s->m_id);
-         value->set(1, s->m_baseId);
+         value->set(0, (INT32)s->m_id);
+         value->set(1, (INT32)s->m_baseId);
          value->set(2, s->m_group);
          value->set(3, s->m_name);
          value->set(4, s->m_state);
          value->set(5, s->m_rqAddr);
          value->set(6, s->m_lmid);
-         value->set(7, s->m_pid);
-         value->set(8, s->m_generation);
-         value->set(9, s->m_curThreads);
-         value->set(10, s->m_minThreads);
-         value->set(11, s->m_maxThreads);
-         value->set(12, s->m_activeRequests);
+         value->set(7, (INT32)s->m_pid);
+         value->set(8, (INT32)s->m_generation);
+         value->set(9, (INT32)s->m_curThreads);
+         value->set(10, (INT32)s->m_minThreads);
+         value->set(11, (INT32)s->m_maxThreads);
+         value->set(12, (INT32)s->m_activeRequests);
          value->set(13, s->m_currService);
-         value->set(14, s->m_tranLevel);
-         value->set(15, s->m_totalRequests);
-         value->set(16, s->m_totalWorkloads);
-         value->set(17, s->m_convCount);
-         value->set(18, s->m_dequeueCount);
-         value->set(19, s->m_enqueueCount);
-         value->set(20, s->m_postCount);
-         value->set(21, s->m_reqCount);
-         value->set(22, s->m_subscribeCount);
-         value->set(23, s->m_txnCount);
-         value->set(24, s->m_timeStart);
-         value->set(25, s->m_timeRestart);
+         value->set(14, (INT32)s->m_tranLevel);
+         value->set(15, (INT32)s->m_totalRequests);
+         value->set(16, (INT32)s->m_totalWorkloads);
+         value->set(17, (INT32)s->m_convCount);
+         value->set(18, (INT32)s->m_dequeueCount);
+         value->set(19, (INT32)s->m_enqueueCount);
+         value->set(20, (INT32)s->m_postCount);
+         value->set(21, (INT32)s->m_reqCount);
+         value->set(22, (INT32)s->m_subscribeCount);
+         value->set(23, (INT32)s->m_txnCount);
+         value->set(24, (INT32)s->m_timeStart);
+         value->set(25, (INT32)s->m_timeRestart);
          value->set(26, s->m_envFile);
          value->set(27, s->m_cmdLine);
       }
index 97e1bc4..4f44b9b 100644 (file)
@@ -78,17 +78,17 @@ static void QueryServices()
    if (!TuxedoConnect())
       AgentWriteDebugLog(3, _T("Tuxedo: tpinit() call failed (%d)"), errno);
 
-       FBFR32 *fb = (FBFR32 *)tpalloc("FML32", NULL, 4096);
-       CFchg32(fb, TA_OPERATION, 0, (char *)"GET", 0, FLD_STRING);
-       CFchg32(fb, TA_CLASS, 0, (char *)"T_SERVICE", 0, FLD_STRING);
+   FBFR32 *fb = (FBFR32 *)tpalloc((char *)"FML32", NULL, 4096);
+   CFchg32(fb, TA_OPERATION, 0, (char *)"GET", 0, FLD_STRING);
+   CFchg32(fb, TA_CLASS, 0, (char *)"T_SERVICE", 0, FLD_STRING);
 
    bool readMore = true;
    long rsplen = 262144;
-   FBFR32 *rsp = (FBFR32 *)tpalloc("FML32", NULL, rsplen);
+   FBFR32 *rsp = (FBFR32 *)tpalloc((char *)"FML32", NULL, rsplen);
    while(readMore)
    {
       readMore = false;
-      if (tpcall(".TMIB", (char *)fb, 0, (char **)&rsp, &rsplen, 0) != -1)
+      if (tpcall((char *)".TMIB", (char *)fb, 0, (char **)&rsp, &rsplen, 0) != -1)
       {
          if (s_services == NULL)
             s_services = new StringObjectMap<TuxedoService>(true);
@@ -184,8 +184,8 @@ LONG H_ServicesTable(const TCHAR *param, const TCHAR *arg, Table *value)
          value->set(0, s->m_name);
          value->set(1, s->m_state);
          value->set(2, s->m_routingName);
-         value->set(3, s->m_load);
-         value->set(4, s->m_priority);
+         value->set(3, (INT32)s->m_load);
+         value->set(4, (INT32)s->m_priority);
       }
       delete services;
    }