fixed agent failures bit mask; refactoring of agent local database/log file status...
authorVictor Kirhenshtein <victor@netxms.org>
Wed, 15 Jun 2016 16:39:19 +0000 (19:39 +0300)
committerVictor Kirhenshtein <victor@netxms.org>
Wed, 15 Jun 2016 16:39:19 +0000 (19:39 +0300)
include/nms_agent.h
include/nxevent.h
sql/events.in
sql/policy.in
src/agent/core/getparam.cpp
src/agent/core/nxagentd.cpp
src/agent/core/nxagentd.h
src/server/core/node.cpp
src/server/tools/nxdbmgr/upgrade.cpp

index a433241..13ab436 100644 (file)
 #define DCIDESC_AGENT_GENERATED_TRAPS             _T("Number of traps generated by agent")
 #define DCIDESC_AGENT_IS_SUBAGENT_LOADED          _T("Check if given subagent is loaded")
 #define DCIDESC_AGENT_LAST_TRAP_TIME              _T("Timestamp of last generated trap")
+#define DCIDESC_AGENT_LOCALDB_FAILED_QUERIES      _T("Agent local database: failed queries")
+#define DCIDESC_AGENT_LOCALDB_SLOW_QUERIES        _T("Agent local database: long running queries")
+#define DCIDESC_AGENT_LOCALDB_STATUS              _T("Agent local database: status")
+#define DCIDESC_AGENT_LOCALDB_TOTAL_QUERIES       _T("Agent local database: total queries executed")
+#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_REJECTEDCONNECTIONS         _T("Number of connections rejected by agent")
index 7b138a0..fc83051 100644 (file)
 // System-defined events
 //
 
-#define EVENT_NODE_ADDED                  1
-#define EVENT_SUBNET_ADDED                2
-#define EVENT_INTERFACE_ADDED             3
-#define EVENT_INTERFACE_UP                4
-#define EVENT_INTERFACE_DOWN              5
-#define EVENT_NODE_NORMAL                 6
-#define EVENT_NODE_WARNING                7
-#define EVENT_NODE_MINOR                  8
-#define EVENT_NODE_MAJOR                  9
-#define EVENT_NODE_CRITICAL               10
-#define EVENT_NODE_UNKNOWN                11
-#define EVENT_NODE_UNMANAGED              12
-#define EVENT_NODE_FLAGS_CHANGED          13
-#define EVENT_SNMP_FAIL                   14
-#define EVENT_AGENT_FAIL                  15
-#define EVENT_INTERFACE_DELETED           16
-#define EVENT_THRESHOLD_REACHED           17
-#define EVENT_THRESHOLD_REARMED           18
-#define EVENT_SUBNET_DELETED              19
-#define EVENT_THREAD_HANGS                20
-#define EVENT_THREAD_RUNNING              21
-#define EVENT_SMTP_FAILURE                22
-#define EVENT_MAC_ADDR_CHANGED            23
-#define EVENT_INCORRECT_NETMASK           24
-#define EVENT_SERVICE_DOWN                25
-#define EVENT_SERVICE_UP                  26
-#define EVENT_SERVICE_UNKNOWN             27
-#define EVENT_NODE_DOWN                   28
-#define EVENT_NODE_UP                     29
-#define EVENT_SMS_FAILURE                 30
-#define EVENT_SNMP_OK                     31
-#define EVENT_AGENT_OK                    32
-#define EVENT_SCRIPT_ERROR                33
-#define EVENT_CONDITION_ACTIVATED         34
-#define EVENT_CONDITION_DEACTIVATED       35
-#define EVENT_DB_CONNECTION_LOST          36
-#define EVENT_DB_CONNECTION_RESTORED      37
-#define EVENT_CLUSTER_RESOURCE_MOVED      38
-#define EVENT_CLUSTER_RESOURCE_DOWN       39
-#define EVENT_CLUSTER_RESOURCE_UP         40
-#define EVENT_CLUSTER_DOWN                41
-#define EVENT_CLUSTER_UP                  42
-#define EVENT_ALARM_TIMEOUT               43
-#define EVENT_LOG_RECORD_MATCHED          44
-#define EVENT_INTERFACE_UNKNOWN           45
-#define EVENT_INTERFACE_DISABLED          46
-#define EVENT_INTERFACE_TESTING           47
-#define EVENT_EVENT_STORM_DETECTED        48
-#define EVENT_EVENT_STORM_ENDED           49
-#define EVENT_NETWORK_CONNECTION_LOST     50
-#define EVENT_NETWORK_CONNECTION_RESTORED 51
-#define EVENT_DB_QUERY_FAILED             52
-#define EVENT_DCI_UNSUPPORTED             53
-#define EVENT_DCI_DISABLED                54
-#define EVENT_DCI_ACTIVE                  55
-#define EVENT_IP_ADDRESS_CHANGED          56
-#define EVENT_8021X_PAE_STATE_CHANGED     57
-#define EVENT_8021X_BACKEND_STATE_CHANGED 58
-#define EVENT_8021X_PAE_FORCE_UNAUTH      59
-#define EVENT_8021X_AUTH_FAILED           60
-#define EVENT_8021X_AUTH_TIMEOUT          61
-#define EVENT_INTERFACE_UNEXPECTED_UP     62
-#define EVENT_INTERFACE_EXPECTED_DOWN     63
-#define EVENT_CONTAINER_AUTOBIND          64
-#define EVENT_CONTAINER_AUTOUNBIND        65
-#define EVENT_TEMPLATE_AUTOAPPLY          66
-#define EVENT_TEMPLATE_AUTOREMOVE         67
-#define EVENT_NODE_UNREACHABLE            68
-#define EVENT_TABLE_THRESHOLD_ACTIVATED   69
-#define EVENT_TABLE_THRESHOLD_DEACTIVATED 70
-#define EVENT_IF_PEER_CHANGED             71
-#define EVENT_AP_ADOPTED                  72
-#define EVENT_AP_UNADOPTED                73
-#define EVENT_AP_DOWN                     74
-#define EVENT_IF_MASK_CHANGED             75
-#define EVENT_IF_IPADDR_ADDED             76
-#define EVENT_IF_IPADDR_DELETED           77
-#define EVENT_MAINTENANCE_MODE_ENTERED    78
-#define EVENT_MAINTENANCE_MODE_LEFT       79
-#define EVENT_LDAP_SYNC_ERROR             80
-#define EVENT_AGENT_LOG_FAIL              81
-#define EVENT_AGENT_LOCAL_DATABASE_FAIL   82
-
-#define EVENT_SNMP_UNMATCHED_TRAP         500
-#define EVENT_SNMP_COLD_START             501
-#define EVENT_SNMP_WARM_START             502
-#define EVENT_SNMP_LINK_DOWN              503
-#define EVENT_SNMP_LINK_UP                504
-#define EVENT_SNMP_AUTH_FAILURE           505
-#define EVENT_SNMP_EGP_NL                 506
-
-#define FIRST_USER_EVENT_ID               100000
+#define EVENT_NODE_ADDED                   1
+#define EVENT_SUBNET_ADDED                 2
+#define EVENT_INTERFACE_ADDED              3
+#define EVENT_INTERFACE_UP                 4
+#define EVENT_INTERFACE_DOWN               5
+#define EVENT_NODE_NORMAL                  6
+#define EVENT_NODE_WARNING                 7
+#define EVENT_NODE_MINOR                   8
+#define EVENT_NODE_MAJOR                   9
+#define EVENT_NODE_CRITICAL                10
+#define EVENT_NODE_UNKNOWN                 11
+#define EVENT_NODE_UNMANAGED               12
+#define EVENT_NODE_FLAGS_CHANGED           13
+#define EVENT_SNMP_FAIL                    14
+#define EVENT_AGENT_FAIL                   15
+#define EVENT_INTERFACE_DELETED            16
+#define EVENT_THRESHOLD_REACHED            17
+#define EVENT_THRESHOLD_REARMED            18
+#define EVENT_SUBNET_DELETED               19
+#define EVENT_THREAD_HANGS                 20
+#define EVENT_THREAD_RUNNING               21
+#define EVENT_SMTP_FAILURE                 22
+#define EVENT_MAC_ADDR_CHANGED             23
+#define EVENT_INCORRECT_NETMASK            24
+#define EVENT_SERVICE_DOWN                 25
+#define EVENT_SERVICE_UP                   26
+#define EVENT_SERVICE_UNKNOWN              27
+#define EVENT_NODE_DOWN                    28
+#define EVENT_NODE_UP                      29
+#define EVENT_SMS_FAILURE                  30
+#define EVENT_SNMP_OK                      31
+#define EVENT_AGENT_OK                     32
+#define EVENT_SCRIPT_ERROR                 33
+#define EVENT_CONDITION_ACTIVATED          34
+#define EVENT_CONDITION_DEACTIVATED        35
+#define EVENT_DB_CONNECTION_LOST           36
+#define EVENT_DB_CONNECTION_RESTORED       37
+#define EVENT_CLUSTER_RESOURCE_MOVED       38
+#define EVENT_CLUSTER_RESOURCE_DOWN        39
+#define EVENT_CLUSTER_RESOURCE_UP          40
+#define EVENT_CLUSTER_DOWN                 41
+#define EVENT_CLUSTER_UP                   42
+#define EVENT_ALARM_TIMEOUT                43
+#define EVENT_LOG_RECORD_MATCHED           44
+#define EVENT_INTERFACE_UNKNOWN            45
+#define EVENT_INTERFACE_DISABLED           46
+#define EVENT_INTERFACE_TESTING            47
+#define EVENT_EVENT_STORM_DETECTED         48
+#define EVENT_EVENT_STORM_ENDED            49
+#define EVENT_NETWORK_CONNECTION_LOST      50
+#define EVENT_NETWORK_CONNECTION_RESTORED  51
+#define EVENT_DB_QUERY_FAILED              52
+#define EVENT_DCI_UNSUPPORTED              53
+#define EVENT_DCI_DISABLED                 54
+#define EVENT_DCI_ACTIVE                   55
+#define EVENT_IP_ADDRESS_CHANGED           56
+#define EVENT_8021X_PAE_STATE_CHANGED      57
+#define EVENT_8021X_BACKEND_STATE_CHANGED  58
+#define EVENT_8021X_PAE_FORCE_UNAUTH       59
+#define EVENT_8021X_AUTH_FAILED            60
+#define EVENT_8021X_AUTH_TIMEOUT           61
+#define EVENT_INTERFACE_UNEXPECTED_UP      62
+#define EVENT_INTERFACE_EXPECTED_DOWN      63
+#define EVENT_CONTAINER_AUTOBIND           64
+#define EVENT_CONTAINER_AUTOUNBIND         65
+#define EVENT_TEMPLATE_AUTOAPPLY           66
+#define EVENT_TEMPLATE_AUTOREMOVE          67
+#define EVENT_NODE_UNREACHABLE             68
+#define EVENT_TABLE_THRESHOLD_ACTIVATED    69
+#define EVENT_TABLE_THRESHOLD_DEACTIVATED  70
+#define EVENT_IF_PEER_CHANGED              71
+#define EVENT_AP_ADOPTED                   72
+#define EVENT_AP_UNADOPTED                 73
+#define EVENT_AP_DOWN                      74
+#define EVENT_IF_MASK_CHANGED              75
+#define EVENT_IF_IPADDR_ADDED              76
+#define EVENT_IF_IPADDR_DELETED            77
+#define EVENT_MAINTENANCE_MODE_ENTERED     78
+#define EVENT_MAINTENANCE_MODE_LEFT        79
+#define EVENT_LDAP_SYNC_ERROR              80
+#define EVENT_AGENT_LOG_PROBLEM            81
+#define EVENT_AGENT_LOCAL_DATABASE_PROBLEM 82
+
+#define EVENT_SNMP_UNMATCHED_TRAP          500
+#define EVENT_SNMP_COLD_START              501
+#define EVENT_SNMP_WARM_START              502
+#define EVENT_SNMP_LINK_DOWN               503
+#define EVENT_SNMP_LINK_UP                 504
+#define EVENT_SNMP_AUTH_FAILURE            505
+#define EVENT_SNMP_EGP_NL                  506
+
+#define FIRST_USER_EVENT_ID                100000
 
 #endif
index c71e1e1..b12075f 100644 (file)
@@ -942,23 +942,23 @@ INSERT INTO event_cfg (event_code,event_name,guid,severity,flags,message,descrip
 
 INSERT INTO event_cfg (event_code,event_name,guid,severity,flags,message,description) VALUES
    (
-      EVENT_AGENT_LOG_FAIL, 'SYS_AGENT_LOG_FAIL', '262057ca-357a-4a4d-9b78-42ae96e490a1',
+      EVENT_AGENT_LOG_PROBLEM, 'SYS_AGENT_LOG_PROBLEM', '262057ca-357a-4a4d-9b78-42ae96e490a1',
       EVENT_SEVERITY_MAJOR, 1,
       'Problem with agent log: %2',
-      'Generated on status poll if agent reposts log open problem.' CONCAT CRLF CONCAT
+      'Generated on status poll if agent reports problem with log file.' CONCAT CRLF CONCAT
       'Parameters:' CONCAT CRLF CONCAT
-      '   1) Status' CONCAT CRLF CONCAT
+      '   1) Status code' CONCAT CRLF CONCAT
       '   2) Description'
    );
 
 INSERT INTO event_cfg (event_code,event_name,guid,severity,flags,message,description) VALUES
    (
-      EVENT_AGENT_LOCAL_DATABASE_FAIL, 'SYS_AGENT_LOCAL_DATABASE_FAIL', 'd02b63f1-1151-429e-adb9-1dfbb3a31b32',
+      EVENT_AGENT_LOCAL_DATABASE_PROBLEM, 'SYS_AGENT_LOCAL_DATABASE_PROBLEM', 'd02b63f1-1151-429e-adb9-1dfbb3a31b32',
       EVENT_SEVERITY_MAJOR, 1,
       'Problem with agent local database: %2',
-      'Generated on status poll if agent reposts local database problem.' CONCAT CRLF CONCAT
+      'Generated on status poll if agent reports local database problem.' CONCAT CRLF CONCAT
       'Parameters:' CONCAT CRLF CONCAT
-      '   1) Status' CONCAT CRLF CONCAT
+      '   1) Status code' CONCAT CRLF CONCAT
       '   2) Description'
    );
 
index 0c604ff..a2f01b6 100644 (file)
@@ -125,12 +125,12 @@ INSERT INTO event_policy (rule_id,rule_guid,flags,comments,alarm_message,alarm_s
         '%m',5,'SYS_LDAP_SYNC_ERROR_%2','',0,EVENT_ALARM_TIMEOUT,0,'');
 
 INSERT INTO event_policy (rule_id,rule_guid,flags,comments,alarm_message,alarm_severity,alarm_key,script,alarm_timeout,alarm_timeout_event,situation_id,situation_instance)
-    VALUES (30,'19bd89ba-8bb2-4915-8546-a1ecc650dedd',7944,'Generate an alarm when there is problem with log on agent',
-        '%m',5,'SYS_AGENT_LOG_FAIL_%1','',0,EVENT_ALARM_TIMEOUT,0,'');
+    VALUES (30,'19bd89ba-8bb2-4915-8546-a1ecc650dedd',7944,'Generate an alarm when there is problem with agent log',
+        '%m',5,'SYS_AGENT_LOG_PROBLEM_%i','',0,EVENT_ALARM_TIMEOUT,0,'');
 
 INSERT INTO event_policy (rule_id,rule_guid,flags,comments,alarm_message,alarm_severity,alarm_key,script,alarm_timeout,alarm_timeout_event,situation_id,situation_instance)
-    VALUES (31,'cff7fe6b-2ad1-4c18-8a8f-4d397d44fe04',7944,'Generate an alarm when there is problem with local database on agent',
-        '%m',5,'SYS_AGENT_LOCAL_DATABASE_FAIL_%1','',0,EVENT_ALARM_TIMEOUT,0,'');
+    VALUES (31,'cff7fe6b-2ad1-4c18-8a8f-4d397d44fe04',7944,'Generate an alarm when there is problem with agent local database',
+        '%m',5,'SYS_AGENT_LOCAL_DATABASE_PROBLEM_%i','',0,EVENT_ALARM_TIMEOUT,0,'');
 
 INSERT INTO policy_event_list (rule_id,event_code) VALUES (0,EVENT_NODE_DOWN);
 INSERT INTO policy_event_list (rule_id,event_code) VALUES (1,EVENT_NODE_UP);
@@ -164,5 +164,5 @@ INSERT INTO policy_event_list (rule_id,event_code) VALUES (26,EVENT_AGENT_OK);
 INSERT INTO policy_event_list (rule_id,event_code) VALUES (27,EVENT_SNMP_FAIL);
 INSERT INTO policy_event_list (rule_id,event_code) VALUES (28,EVENT_SNMP_OK);
 INSERT INTO policy_event_list (rule_id,event_code) VALUES (29,EVENT_LDAP_SYNC_ERROR);
-INSERT INTO policy_event_list (rule_id,event_code) VALUES (30,EVENT_AGENT_LOG_FAIL);
-INSERT INTO policy_event_list (rule_id,event_code) VALUES (31,EVENT_AGENT_LOCAL_DATABASE_FAIL);
+INSERT INTO policy_event_list (rule_id,event_code) VALUES (30,EVENT_AGENT_LOG_PROBLEM);
+INSERT INTO policy_event_list (rule_id,event_code) VALUES (31,EVENT_AGENT_LOCAL_DATABASE_PROBLEM);
index f7b7a4c..c444f98 100644 (file)
@@ -181,6 +181,54 @@ static LONG H_TableList(const TCHAR *cmd, const TCHAR *arg, StringList *value, A
 }
 
 /**
+ * Handler for component statuses based on failure flags
+ */
+static LONG H_ComponentStatus(const TCHAR *pszParam, const TCHAR *pArg, TCHAR *pValue, AbstractCommSession *session)
+{
+   UINT32 result = 0;
+   switch(*pArg)
+   {
+      case 'D':
+         if ((g_failFlags & FAIL_OPEN_DATABASE) != 0)
+            result++;
+         if ((g_failFlags & FIAL_UPGRADE_DATABASE) != 0)
+            result++;
+         break;
+      case 'L':
+         if ((g_failFlags & FAIL_OPEN_LOG) != 0)
+            result++;
+         break;
+   }
+
+   ret_uint(pValue, result);
+   return SYSINFO_RC_SUCCESS;
+}
+
+/**
+ * Handler for local database counters
+ */
+static LONG H_LocalDatabaseCounters(const TCHAR *pszParam, const TCHAR *pArg, TCHAR *pValue, AbstractCommSession *session)
+{
+   LIBNXDB_PERF_COUNTERS counters;
+   DBGetPerfCounters(&counters);
+   switch(*pArg)
+   {
+      case 'F':
+         ret_int64(pValue, counters.failedQueries);
+         break;
+      case 'L':
+         ret_int64(pValue, counters.longRunningQueries);
+         break;
+      case 'T':
+         ret_int64(pValue, counters.totalQueries);
+         break;
+      default:
+         return SYSINFO_RC_UNSUPPORTED;
+   }
+   return SYSINFO_RC_SUCCESS;
+}
+
+/**
  * Standard agent's parameters
  */
 static NETXMS_SUBAGENT_PARAM m_stdParams[] =
@@ -219,6 +267,7 @@ static NETXMS_SUBAGENT_PARAM m_stdParams[] =
    { _T("System.Memory.Virtual.UsedPerc"), H_MemoryInfo, (TCHAR *)MEMINFO_VIRTUAL_USED_PCT, DCI_DT_UINT, DCIDESC_SYSTEM_MEMORY_VIRTUAL_USED_PCT },
    { _T("System.Uname"), H_SystemUname, NULL, DCI_DT_STRING, DCIDESC_SYSTEM_UNAME },
 #endif
+
    { _T("Agent.AcceptedConnections"), H_UIntPtr, (TCHAR *)&g_dwAcceptedConnections, DCI_DT_UINT, DCIDESC_AGENT_ACCEPTEDCONNECTIONS },
    { _T("Agent.AcceptErrors"), H_UIntPtr, (TCHAR *)&g_dwAcceptErrors, DCI_DT_UINT, DCIDESC_AGENT_ACCEPTERRORS },
    { _T("Agent.ActiveConnections"), H_ActiveConnections, NULL, DCI_DT_UINT, DCIDESC_AGENT_ACTIVECONNECTIONS },
@@ -229,6 +278,11 @@ static NETXMS_SUBAGENT_PARAM m_stdParams[] =
    { _T("Agent.GeneratedTraps"), H_AgentTraps, _T("G"), DCI_DT_UINT64, DCIDESC_AGENT_GENERATED_TRAPS },
    { _T("Agent.IsSubagentLoaded(*)"), H_IsSubagentLoaded, NULL, DCI_DT_INT, DCIDESC_AGENT_IS_SUBAGENT_LOADED },
    { _T("Agent.LastTrapTime"), H_AgentTraps, _T("T"), DCI_DT_UINT64, DCIDESC_AGENT_LAST_TRAP_TIME },
+   { _T("Agent.LocalDatabase.FailedQueries"), H_LocalDatabaseCounters, _T("F"), DCI_DT_UINT64, DCIDESC_AGENT_LOCALDB_FAILED_QUERIES },
+   { _T("Agent.LocalDatabase.LongRunningQueries"), H_LocalDatabaseCounters, _T("L"), DCI_DT_UINT64, DCIDESC_AGENT_LOCALDB_SLOW_QUERIES },
+   { _T("Agent.LocalDatabase.Status"), H_ComponentStatus, _T("D"), DCI_DT_UINT, DCIDESC_AGENT_LOCALDB_STATUS },
+   { _T("Agent.LocalDatabase.TotalQueries"), H_LocalDatabaseCounters, _T("T"), DCI_DT_UINT64, DCIDESC_AGENT_LOCALDB_TOTAL_QUERIES },
+   { _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.RejectedConnections"), H_UIntPtr, (TCHAR *)&g_dwRejectedConnections, DCI_DT_UINT, DCIDESC_AGENT_REJECTEDCONNECTIONS },
index 6741fc2..2edd3b8 100644 (file)
@@ -533,43 +533,6 @@ static LONG H_RestartAgent(const TCHAR *action, StringList *args, const TCHAR *d
 #endif
 }
 
-static LONG H_FailStatusProvider(const TCHAR *pszParam, const TCHAR *pArg, TCHAR *pValue, AbstractCommSession *session)
-{
-   UINT32 result = 0;
-   switch(*pArg)
-   {
-      case 'D':
-         if((g_failFlags & FAIL_OPEN_DATABASE) > 0)
-            result++;
-         if((g_failFlags & FIAL_UPGRADE_DATABASE) > 0)
-            result++;
-         break;
-      case 'L':
-         if((g_failFlags & FAIL_OPEN_LOG) > 0)
-            result++;
-         break;
-   }
-
-   ret_int(pValue, result);
-   return SYSINFO_RC_SUCCESS;
-}
-
-static LONG H_DbCountersProvider(const TCHAR *pszParam, const TCHAR *pArg, TCHAR *pValue, AbstractCommSession *session)
-{
-   LIBNXDB_PERF_COUNTERS counters;
-   DBGetPerfCounters(&counters);
-   switch(*pArg)
-   {
-      case 'F':
-         ret_int64(pValue, counters.failedQueries);
-         break;
-      case 'L':
-         ret_int64(pValue, counters.longRunningQueries);
-         break;
-   }
-   return SYSINFO_RC_SUCCESS;
-}
-
 /**
  * This function writes message from subagent to agent's log
  */
@@ -841,12 +804,6 @@ BOOL Initialize()
                // Add built-in actions
                AddAction(_T("Agent.Restart"), AGENT_ACTION_SUBAGENT, NULL, H_RestartAgent, _T("CORE"), _T("Restart agent"));
 
-               //Add build-in DCIs
-      AddParameter(_T("Agent.LogFile"), H_FailStatusProvider, _T("L"), DCI_DT_UINT, _T("Get log status"));
-      AddParameter(_T("Agent.LocalDatabase"), H_FailStatusProvider, _T("D"), DCI_DT_UINT, _T("Get database status"));
-      AddParameter(_T("Agent.LocalDatabase.LongRunningQueries"), H_DbCountersProvider, _T("L"), DCI_DT_UINT, _T("Get database long running query count"));
-      AddParameter(_T("Agent.LocalDatabase.FailedQueries"), H_DbCountersProvider, _T("F"), DCI_DT_UINT, _T("Get database failed query count"));
-
           // Load platform subagents
 #if !defined(_WIN32)
                InitStaticSubagents();
index 0861d49..914f1cf 100644 (file)
 //Flags for errors while loading
 #define FAIL_OPEN_LOG               0x00000001
 #define FAIL_OPEN_DATABASE          0x00000002
-#define FIAL_UPGRADE_DATABASE       0x00000003
+#define FIAL_UPGRADE_DATABASE       0x00000004
 
 #ifdef _WIN32
 
index 8b4d38c..53e8fa0 100644 (file)
@@ -1645,18 +1645,18 @@ restart_agent_check:
    if (!(m_dwDynamicFlags & NDF_UNREACHABLE))
    {
       TCHAR buffer[MAX_RESULT_LENGTH];
-      if (getItemFromAgent(_T("Agent.LogFile"), MAX_RESULT_LENGTH, buffer) == DCE_SUCCESS)
+      if (getItemFromAgent(_T("Agent.LogFile.Status"), MAX_RESULT_LENGTH, buffer) == DCE_SUCCESS)
       {
          UINT32 status = _tcstol(buffer, NULL, 0);
-         if(status != 0)
-            PostEvent(EVENT_AGENT_LOG_FAIL, m_id, "ds", status, _T("could not open"));
+         if (status != 0)
+            PostEvent(EVENT_AGENT_LOG_PROBLEM, m_id, "ds", status, _T("could not open"));
       }
       else
       {
-         DbgPrintf(5, _T("StatusPoll(%s [%d]): unable to get agent log status"), m_name, m_id);
+         nxlog_debug(5, _T("StatusPoll(%s [%d]): unable to get agent log status"), m_name, m_id);
       }
 
-      if (getItemFromAgent(_T("Agent.LocalDatabase"), MAX_RESULT_LENGTH, buffer) == DCE_SUCCESS)
+      if (getItemFromAgent(_T("Agent.LocalDatabase.Status"), MAX_RESULT_LENGTH, buffer) == DCE_SUCCESS)
       {
          UINT32 status = _tcstol(buffer, NULL, 0);
          const TCHAR *statusDescription[3]= {
@@ -1664,12 +1664,12 @@ restart_agent_check:
                                        _T("could not open database"),
                                        _T("could not update database"),
                                        };
-         if(status != 0)
-            PostEvent(EVENT_AGENT_LOCAL_DATABASE_FAIL, m_id, "ds", status, statusDescription[status]);
+         if (status != 0)
+            PostEvent(EVENT_AGENT_LOCAL_DATABASE_PROBLEM, m_id, "ds", status, statusDescription[status]);
       }
       else
       {
-         DbgPrintf(5, _T("StatusPoll(%s [%d]): unable to get agent local database status"), m_name, m_id);
+         nxlog_debug(5, _T("StatusPoll(%s [%d]): unable to get agent local database status"), m_name, m_id);
       }
    }
 
index 7693731..10c1103 100644 (file)
@@ -678,35 +678,36 @@ static int NextFreeEPPruleID()
  */
 static BOOL H_UpgradeFromV404(int currVersion, int newVersion)
 {
-   CHK_EXEC(CreateEventTemplate(EVENT_AGENT_LOG_FAIL, _T("SYS_AGENT_LOG_FAIL"),
+   CHK_EXEC(CreateEventTemplate(EVENT_AGENT_LOG_PROBLEM, _T("SYS_AGENT_LOG_PROBLEM"),
             SEVERITY_MAJOR, EF_LOG, _T("262057ca-357a-4a4d-9b78-42ae96e490a1"),
       _T("Problem with agent log: %2"),
-      _T("Generated on status poll if agent reposts log open problem.\r\n")
+      _T("Generated on status poll if agent reports problem with log file.\r\n")
       _T("Parameters:\r\n")
-      _T("    1) Status\r\n")
+      _T("    1) Status code\r\n")
       _T("    2) Description")));
-   CHK_EXEC(CreateEventTemplate(EVENT_AGENT_LOCAL_DATABASE_FAIL, _T("SYS_AGENT_LOCAL_DATABASE_FAIL"),
+   CHK_EXEC(CreateEventTemplate(EVENT_AGENT_LOCAL_DATABASE_PROBLEM, _T("SYS_AGENT_LOCAL_DATABASE_PROBLEM"),
             SEVERITY_MAJOR, EF_LOG, _T("d02b63f1-1151-429e-adb9-1dfbb3a31b32"),
       _T("Problem with agent local database: %2"),
-      _T("Generated on status poll if agent reposts local database problem.\r\n")
+      _T("Generated on status poll if agent reports local database problem.\r\n")
       _T("Parameters:\r\n")
-      _T("    1) Status\r\n")
+      _T("    1) Status code\r\n")
       _T("    2) Description")));
 
        int ruleId = NextFreeEPPruleID();
    TCHAR query[1024];
        _sntprintf(query, 1024, _T("INSERT INTO event_policy (rule_id,rule_guid,flags,comments,alarm_message,alarm_severity,alarm_key,script,alarm_timeout,alarm_timeout_event,situation_id,situation_instance) ")
-                           _T("VALUES (%d,'19bd89ba-8bb2-4915-8546-a1ecc650dedd',7944,'Generate an alarm when there is problem with log on agent','%%m',5,'SYS_AGENT_LOG_FAIL_%%1','',0,%d,0,'')"),
+                           _T("VALUES (%d,'19bd89ba-8bb2-4915-8546-a1ecc650dedd',7944,'Generate an alarm when there is problem with agent log','%%m',5,'SYS_AGENT_LOG_PROBLEM_%%i','',0,%d,0,'')"),
                            ruleId, EVENT_ALARM_TIMEOUT);
    CHK_EXEC(SQLQuery(query));
-   _sntprintf(query, 1024, _T("INSERT INTO policy_event_list (rule_id,event_code) VALUES (%d,%d)"), ruleId, EVENT_AGENT_LOG_FAIL);
+   _sntprintf(query, 1024, _T("INSERT INTO policy_event_list (rule_id,event_code) VALUES (%d,%d)"), ruleId, EVENT_AGENT_LOG_PROBLEM);
    CHK_EXEC(SQLQuery(query));
-       ruleId = NextFreeEPPruleID();
+
+   ruleId = NextFreeEPPruleID();
        _sntprintf(query, 1024, _T("INSERT INTO event_policy (rule_id,rule_guid,flags,comments,alarm_message,alarm_severity,alarm_key,script,alarm_timeout,alarm_timeout_event,situation_id,situation_instance) ")
-                           _T("VALUES (%d,'cff7fe6b-2ad1-4c18-8a8f-4d397d44fe04',7944,'Generate an alarm when there is problem with local database on agent','%%m',5,'SYS_AGENT_LOCAL_DATABASE_FAIL_%%1','',0,%d,0,'')"),
+                           _T("VALUES (%d,'cff7fe6b-2ad1-4c18-8a8f-4d397d44fe04',7944,'Generate an alarm when there is problem with agent local database','%%m',5,'SYS_AGENT_LOCAL_DATABASE_PROBLEM_%%i','',0,%d,0,'')"),
                            ruleId, EVENT_ALARM_TIMEOUT);
    CHK_EXEC(SQLQuery(query));
-   _sntprintf(query, 1024, _T("INSERT INTO policy_event_list (rule_id,event_code) VALUES (%d,%d)"), ruleId, EVENT_AGENT_LOCAL_DATABASE_FAIL);
+   _sntprintf(query, 1024, _T("INSERT INTO policy_event_list (rule_id,event_code) VALUES (%d,%d)"), ruleId, EVENT_AGENT_LOCAL_DATABASE_PROBLEM);
    CHK_EXEC(SQLQuery(query));
 
    CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='405' WHERE var_name='SchemaVersion'")));