Commits

Ruwan Linton committed 9021a9c

Fixing the default zabbix version to be 2.2 (merging the changes from Marek into the 2.3 branch)

Comments (0)

Files changed (4)

modules/uconsole/src/main/java/org/adroitlogic/ultraesb/admin/ZabbixAdmin.java

                 }
             }
             if (hosts.size() > 0) {
-                Map sesseionHostMap = (Map) session.getAttribute(ZabbixConstants.SESSION_HOST_MAP);
+                Map sessionHostMap = (Map) session.getAttribute(ZabbixConstants.SESSION_HOST_MAP);
                 Map<ZabbixHost, String> createdHostIds = registrar.createHosts(hosts);
                 for (ZabbixHost zh : createdHostIds.keySet()) {
                     String hostId = createdHostIds.get(zh);
-                    sesseionHostMap.put(hostId, zh.getHostName());
+                    sessionHostMap.put(hostId, zh.getHostName());
                     String category = hosts.get(zh);
                     if (!categoryToHostIds.containsKey(category)) {
                         categoryToHostIds.put(category, "");
                     String nodeN = hostIds2NodeNames.remove(zh.getHostName());
                     hostIds2NodeNames.put(hostId, nodeN);
                 }
-                session.setAttribute(ZabbixConstants.SESSION_HOST_MAP, sesseionHostMap);
-                if ("2.0".equals(version)) {
+                session.setAttribute(ZabbixConstants.SESSION_HOST_MAP, sessionHostMap);
+                if (version.startsWith("2")) {
                     session.setAttribute(ZabbixConstants.SESSION_HOST_INTERFACE_MAP,
                         registrar.getHostIdsToAgentInterfaceIds(hostIds2NodeNames.keySet()));
                 }

modules/uterm/src/main/java/org/adroitlogic/ultraesb/terminal/commands/MonitoringCommands.java

         @CommandOption(
             shortForm = "v",
             longForm = "version",
-            description = "to choose the version of the Zabbix installation (defaults to version 2.0)",
+            description = "to choose the version of the Zabbix installation (defaults to version 2.2)",
             argument = true) String version) throws TerminalException {
 
         logger.debug("Start :: zabbixRegister with zabbix url : " + zabbixURL + " with username : " + username);
                 configFile += (configFile.endsWith("/") || configFile.endsWith(File.separator) ? "monitoring" :
                         File.separator + "monitoring") + File.separator + "uz" + File.separator;
             }
-            String versionDir = "1.8".equals(version) ? version : "2.0";
+            String versionDir = (version != null ? version : "2.2");
 
             DefaultSecurityManager securityManager = new DefaultSecurityManager();
             SecurityUtils.setSecurityManager(securityManager);
     	@CommandOption(
     		shortForm = "v",
     		longForm = "version",
-    		description = "to choose the version of the Zabbix installation (defaults to version 2.0)", argument = true) String version) {
+    		description = "to choose the version of the Zabbix installation (defaults to version 2.2)", argument = true) String version) {
     	
         String configFile = System.getProperty(TerminalConstants.CONFIGURATION_LOCATION);
         RegistrationStat stat = null;
             }
             session.setAttribute(ZabbixConstants.SESSION_HOST_MAP, sessionHostMap);
 
-            if ("2.0".equals(registrar.getZabbixVersion())) {
+            if (registrar.getZabbixVersion().startsWith("2")) {
                 session.setAttribute(ZabbixConstants.SESSION_HOST_INTERFACE_MAP,
                     registrar.getHostIdsToAgentInterfaceIds(hostIds2NodeNames.keySet()));
             }

modules/uterm/src/main/java/org/adroitlogic/ultraesb/uz/ZabbixRegistrar.java

                         (String) hostDetailsMap.get("hostid"),
                         (String) hostDetailsMap.get("host")));
                 } else {
-                    //Zabbix API version 1.4 requires an interface for each host
-                    Map interfaces = (Map) hostDetailsMap.get("interfaces");
-                    for (Object interfaceDetails : interfaces.values()) {
+                    //Zabbix API version >=1.4 requires an interface for each host
+                    List interfaces = (ArrayList) hostDetailsMap.get("interfaces");
+                    for (Object interfaceDetails : interfaces) {
                         Map interfaceDetailMap = (Map)interfaceDetails;
 
                         if (interfaceDetailMap.get("hostid").equals(hostDetailsMap.get("hostid"))) {
                         logger.info("Zabbix API version found to be {}", apiVersion);
                     }
                 } else if (major == 2) {
-                    if (!("2.0".equals(this.zabbixVersion))) {
-                        final String mgs = "Installed Zabbix API version is: " + apiVersion +
-                            ", please choose the correct version from the console";
-                        logger.error(mgs);
-                        throw new UnsupportedOperationException(mgs);
-                    } else if (minor > 0) {
-                        logger.warn("Supported Zabbix version is 2.0, might not work with the installed version {}", this.zabbixVersion);
-                    } else {
+
                         logger.info("Zabbix version found to be {}", this.zabbixVersion);
-                    }
                 } else {
-                    logger.warn("Supported Zabbix version is 2.0, might not work with the installed version {}", this.zabbixVersion);
+                    logger.warn("Supported Zabbix versions are: 1.8, 2.0, 2.2. The ESB might not work with the installed version {}!",
+                            this.zabbixVersion);
                 }
             }
         } catch (UZException e) {

modules/uterm/src/main/java/org/adroitlogic/ultraesb/uz/util/RegistrationUtils.java

 
         logger.debug("Sending message number {} to the Zabbix Server {}", call.getNumber(), url);
         if (verbose) {
+            logger.info("Sending request: " + request);
             call.setStartTime(System.currentTimeMillis());
             call.setRequest(request);
         }