@@ -180,43 +180,50 @@ def analyze(self, controllerData, thresholds):
180180 application ["appAgentVersions" ] = []
181181
182182 for node in application ["nodes" ]:
183- app_agent_present = node .get ("appAgentPresent" ) is True
184- if app_agent_present and node ["appAgentVersion" ] in nodeVersionMap :
185- nodeVersionMap [node ["appAgentVersion" ]] += 1
186- elif app_agent_present :
187- nodeVersionMap [node ["appAgentVersion" ]] = 1
188-
189- # Calculate version age
190- numberNodesWithAppAgentInstalled += 1
191- if not app_agent_present :
192- continue
193-
194- version = semanticVersionRegex .search (node ["appAgentVersion" ])[0 ].split ("." ) # e.g. 'Server Agent v21.6.1.2 GA ...'
195- majorVersion = int (version [0 ])
196- minorVersion = int (version [1 ])
197-
198- hostInfo ["appAgentVersions" ].add ((majorVersion , minorVersion , node ["agentType" ]))
199- application ["appAgentVersions" ].append (f"{ node ['agentType' ]} :{ version [0 ]} .{ version [1 ]} " )
200-
201- if majorVersion == 4 : # Agents with version 4 and below will always fail.
202- node ["appAgentAge" ] = 3
203- else :
204- years = currYear - majorVersion
205- if minorVersion < currMonth :
206- years += 1
207- node ["appAgentAge" ] = years
208-
209- if years <= 2 :
210- numberAppAgentsLessThan2YearsOld += 1
211- if years == 1 :
212- numberAppAgentsLessThan1YearOld += 1
213-
214- # Determine application load
215- if node ["appAgentAvailability" ] != 0 :
216- numberAppAgentsReportingData += 1
217-
218- if node ["nodeMetricsUploadRequestsExceedingLimit" ] != 0 :
219- analysisDataEvaluatedMetrics ["metricLimitNotHit" ] = False
183+ # Support both APIs: new (explicit flag) and old (implicit via non-empty version string)
184+ app_agent_present_flag = node .get ("appAgentPresent" , None )
185+ app_agent_present = (
186+ app_agent_present_flag is True
187+ or (app_agent_present_flag is None and node .get ("appAgentVersion" , "" ) != "" )
188+ )
189+
190+ if app_agent_present :
191+ version_str = node .get ("appAgentVersion" , "" )
192+ if version_str in nodeVersionMap :
193+ nodeVersionMap [version_str ] += 1
194+ else :
195+ nodeVersionMap [version_str ] = 1
196+
197+ numberNodesWithAppAgentInstalled += 1
198+
199+ match = semanticVersionRegex .search (version_str )
200+ if not match :
201+ continue # Cannot parse semantic version, skip aging logic
202+
203+ version = match [0 ].split ("." )
204+ majorVersion = int (version [0 ])
205+ minorVersion = int (version [1 ])
206+
207+ hostInfo ["appAgentVersions" ].add ((majorVersion , minorVersion , node .get ("agentType" )))
208+ application ["appAgentVersions" ].append (f"{ node .get ('agentType' )} :{ version [0 ]} .{ version [1 ]} " )
209+
210+ if majorVersion == 4 :
211+ node ["appAgentAge" ] = 3
212+ else :
213+ years = currYear - majorVersion
214+ if minorVersion < currMonth :
215+ years += 1
216+ node ["appAgentAge" ] = years
217+ if years <= 2 :
218+ numberAppAgentsLessThan2YearsOld += 1
219+ if years == 1 :
220+ numberAppAgentsLessThan1YearOld += 1
221+
222+ if node .get ("appAgentAvailability" , 0 ) != 0 :
223+ numberAppAgentsReportingData += 1
224+
225+ if node .get ("nodeMetricsUploadRequestsExceedingLimit" , 0 ) != 0 :
226+ analysisDataEvaluatedMetrics ["metricLimitNotHit" ] = False
220227
221228 # In the case of multiple versions, will return the largest common agent count regardless of version.
222229 try :
0 commit comments