Commits

Anonymous committed d05802a

Added optional parameter to override the IP address to be able to bind the CIFS monitor on different nodes, than the share

Comments (0)

Files changed (1)

features/poller/cifs-monitor/src/main/java/org/opennms/netmgt/poller/monitors/JCifsMonitor.java

     /**
      * logging for JCifs monitor
      */
-    private final Logger logger = LoggerFactory.getLogger("OpenNMS.JCifs." + JCifsMonitor.class.getName());
+    "OpenNMS.Report." + DefaultGlobalReportRepository.        class.getName()
+    private final Logger logger = LoggerFactory.getLogger("OpenNMS.Poller." + JCifsMonitor.class.getName());
 
     /**
      * This method queries the CIFS share.
      */
     public PollStatus poll(MonitoredService svc, Map<String, Object> parameters) {
 
-        String domain = parameters.containsKey("domain") ? (String) parameters.get("domain") : "";
-        String username = parameters.containsKey("username") ? (String) parameters.get("username") : "";
-        String password = parameters.containsKey("password") ? (String) parameters.get("password") : "";
+        final String domain = parameters.containsKey("domain") ? (String) parameters.get("domain") : "";
+        final String username = parameters.containsKey("username") ? (String) parameters.get("username") : "";
+        final String password = parameters.containsKey("password") ? (String) parameters.get("password") : "";
         String mode = parameters.containsKey("mode") ? ((String) parameters.get("mode")).toUpperCase() : "PATH_EXIST";
         String path = parameters.containsKey("path") ? (String) parameters.get("path") : "";
+        final String smbHost = parameters.containsKey("smb-host") ? (String) parameters.get("smb-host") : svc.getIpAddr();
         final String folderIgnoreFiles = parameters.containsKey("folderIgnoreFiles") ? (String) parameters.get("folderIgnoreFiles") : "";
 
-
+        // Filename filter to give user the possibility to ignore specific files in folder for the folder check.
         SmbFilenameFilter smbFilenameFilter = new SmbFilenameFilter() {
             @Override
             public boolean accept(SmbFile smbFile, String s) throws SmbException {
             }
         };
 
+        // Initialize mode with default as PATH_EXIST
         Mode enumMode = Mode.PATH_EXIST;
 
         try {
         authString += username + ":" + password;
 
         // ... and path
-        String fullUrl = "smb://" + svc.getIpAddr() + path;
+        String fullUrl = "smb://" + smbHost + path;
 
         logger.debug("Domain: [{}], Username: [{}], Password: [{}], Mode: [{}], Path: [{}], Authentication: [{}], Full Url: [{}]", new Object[]{domain, username, password, mode, path, authString, fullUrl});
 
                 }
 
             } catch (MalformedURLException exception) {
-                logger.error("URL exception '{}'", exception.getMessage());
+                logger.error("Malformed URL on '{}' with error: '{}'", smbHost, exception.getMessage());
                 serviceStatus = PollStatus.down(exception.getMessage());
             } catch (SmbException exception) {
-                logger.error("SMB exception '{}'", exception.getMessage());
+                logger.error("SMB error on '{}' with error: '{}'", smbHost, exception.getMessage());
                 serviceStatus = PollStatus.down(exception.getMessage());
             }
         }
         return serviceStatus;
     }
 
+    /**
+     * Supported modes for CIFS monitor
+     */
     private enum Mode {
         PATH_EXIST,
         PATH_NOT_EXIST,