added parameters for monitoring agent syslog proxy status (issue #568)
authorVictor Kirhenshtein <victor@netxms.org>
Sun, 28 Aug 2016 14:37:41 +0000 (17:37 +0300)
committerVictor Kirhenshtein <victor@netxms.org>
Sun, 28 Aug 2016 14:38:13 +0000 (17:38 +0300)
include/nms_agent.h
src/agent/core/getparam.cpp
src/agent/core/syslog.cpp

index 44b76b6..0fca91a 100644 (file)
 #define DCIDESC_AGENT_LOG_STATUS                  _T("Agent log status")
 #define DCIDESC_AGENT_PROCESSEDREQUESTS           _T("Number of requests processed by agent")
 #define DCIDESC_AGENT_REGISTRAR                   _T("Registrar server address set on agent startup")
+#define DCIDESC_AGENT_RECEIVEDSYSLOGMESSAGES      _T("Number of syslog messages received by agent")
 #define DCIDESC_AGENT_REJECTEDCONNECTIONS         _T("Number of connections rejected by agent")
 #define DCIDESC_AGENT_SENT_TRAPS                  _T("Number of traps successfully sent to server")
 #define DCIDESC_AGENT_SOURCEPACKAGESUPPORT        _T("Check if source packages are supported")
 #define DCIDESC_AGENT_SUPPORTEDCIPHERS            _T("List of ciphers supported by agent")
+#define DCIDESC_AGENT_SYSLOGPROXYQUEUESIZE        _T("Agent syslog proxy queue size")
 #define DCIDESC_AGENT_THREADPOOL_ACTIVEREQUESTS   _T("Agent thread pool {instance}: active requests")
 #define DCIDESC_AGENT_THREADPOOL_CURRSIZE         _T("Agent thread pool {instance}: current size")
 #define DCIDESC_AGENT_THREADPOOL_LOAD             _T("Agent thread pool {instance}: current load")
index bfe2ca3..d2c002f 100644 (file)
@@ -37,6 +37,7 @@ LONG H_MD5Hash(const TCHAR *cmd, const TCHAR *arg, TCHAR *value, AbstractCommSes
 LONG H_SHA1Hash(const TCHAR *cmd, const TCHAR *arg, TCHAR *value, AbstractCommSession *session);
 LONG H_SubAgentList(const TCHAR *cmd, const TCHAR *arg, StringList *value, AbstractCommSession *session);
 LONG H_SubAgentTable(const TCHAR *cmd, const TCHAR *arg, Table *value, AbstractCommSession *session);
+LONG H_SyslogStats(const TCHAR *cmd, const TCHAR *arg, TCHAR *value, AbstractCommSession *session);
 LONG H_ActionList(const TCHAR *cmd, const TCHAR *arg, StringList *value, AbstractCommSession *session);
 LONG H_ExternalParameter(const TCHAR *cmd, const TCHAR *arg, TCHAR *value, AbstractCommSession *session);
 LONG H_ExternalList(const TCHAR *cmd, const TCHAR *arg, StringList *value, AbstractCommSession *session);
@@ -285,10 +286,12 @@ static NETXMS_SUBAGENT_PARAM m_stdParams[] =
    { _T("Agent.LogFile.Status"), H_ComponentStatus, _T("L"), DCI_DT_UINT, DCIDESC_AGENT_LOG_STATUS },
    { _T("Agent.ProcessedRequests"), H_UIntPtr, (TCHAR *)&m_dwProcessedRequests, DCI_DT_UINT, DCIDESC_AGENT_PROCESSEDREQUESTS },
    { _T("Agent.Registrar"), H_StringConstant, g_szRegistrar, DCI_DT_STRING, DCIDESC_AGENT_REGISTRAR },
+   { _T("Agent.ReceivedSyslogMessages"), H_SyslogStats, _T("R"), DCI_DT_UINT64, DCIDESC_AGENT_RECEIVEDSYSLOGMESSAGES },
    { _T("Agent.RejectedConnections"), H_UIntPtr, (TCHAR *)&g_dwRejectedConnections, DCI_DT_UINT, DCIDESC_AGENT_REJECTEDCONNECTIONS },
    { _T("Agent.SentTraps"), H_AgentTraps, _T("S"), DCI_DT_UINT64, DCIDESC_AGENT_SENT_TRAPS },
    { _T("Agent.SourcePackageSupport"), H_StringConstant, _T("0"), DCI_DT_INT, DCIDESC_AGENT_SOURCEPACKAGESUPPORT },
    { _T("Agent.SupportedCiphers"), H_SupportedCiphers, NULL, DCI_DT_STRING, DCIDESC_AGENT_SUPPORTEDCIPHERS },
+   { _T("Agent.SyslogProxyQueueSize"), H_SyslogStats, _T("Q"), DCI_DT_UINT, DCIDESC_AGENT_SYSLOGPROXYQUEUESIZE },
    { _T("Agent.ThreadPool.ActiveRequests(*)"), H_ThreadPoolInfo, (TCHAR *)THREAD_POOL_REQUESTS, DCI_DT_UINT, DCIDESC_AGENT_THREADPOOL_ACTIVEREQUESTS },
    { _T("Agent.ThreadPool.CurrSize(*)"), H_ThreadPoolInfo, (TCHAR *)THREAD_POOL_CURR_SIZE, DCI_DT_UINT, DCIDESC_AGENT_THREADPOOL_CURRSIZE },
    { _T("Agent.ThreadPool.Load(*)"), H_ThreadPoolInfo, (TCHAR *)THREAD_POOL_LOAD, DCI_DT_UINT, DCIDESC_AGENT_THREADPOOL_LOAD },
index 1700b81..633f09f 100644 (file)
@@ -53,6 +53,30 @@ public:
  */
 static Queue s_syslogSenderQueue;
 
+/**
+ * Counter for received messages
+ */
+static UINT64 s_receivedMessages = 0;
+
+/**
+ * Handler for syslog proxy information parameters
+ */
+LONG H_SyslogStats(const TCHAR *cmd, const TCHAR *arg, TCHAR *value, AbstractCommSession *session)
+{
+   switch(*arg)
+   {
+      case 'R':   // received messages
+         ret_uint64(value, s_receivedMessages);
+         break;
+      case 'Q':   // queue size
+         ret_int(value, s_syslogSenderQueue.size());
+         break;
+      default:
+         return SYSINFO_RC_UNSUPPORTED;
+   }
+   return SYSINFO_RC_SUCCESS;
+}
+
 /**
  * Shutdown trap sender
  */
@@ -291,6 +315,7 @@ THREAD_RESULT THREAD_CALL SyslogReceiver(void *)
          {
             syslogMessage[bytes] = 0;
             s_syslogSenderQueue.put(new SyslogRecord(InetAddress::createFromSockaddr((struct sockaddr *)&addr), syslogMessage, bytes));
+            s_receivedMessages++;
          }
          else
          {