diff --git a/cmd/netintcheck.go b/cmd/netintcheck.go index 5fdf9ca..2f548f6 100644 --- a/cmd/netintcheck.go +++ b/cmd/netintcheck.go @@ -105,7 +105,10 @@ func networkInterfaceCheck(snmpVersion string, cmd *cobra.Command, args []string asExp := false err = file.CheckFileExist(file.DevicePath, "index.json") if err == nil { - asExp = file.AsExp(file.DevicePath, "index.json", time.Duration(indexFileExp)*time.Minute) + asExp, err = file.AsExp(file.DevicePath, "index.json", time.Duration(indexFileExp)*time.Minute) + if err != nil { + sknchk.Unknown(fmt.Sprintf("Error while accessing Index file : %v", err), "") + } if asExp { log.Debugln("Regeneration of the file...") } diff --git a/file/file.go b/file/file.go index 37770e5..256b4a7 100644 --- a/file/file.go +++ b/file/file.go @@ -57,12 +57,12 @@ func CreatePath(fPath string) error { } //AsExp check if the file is older than the given expiration duration -func AsExp(devicePath string, filename string, exptime time.Duration) bool { +func AsExp(devicePath string, filename string, exptime time.Duration) (bool, error) { log.Debugln("===== File expiration check =====") file, err := os.Stat(path.Join(devicePath, filename)) log.Debugf("Tested file : %v", path.Join(devicePath, filename)) if err != nil { - return false + return false, err } log.Debugf("Expiration delay : %v", exptime) modifiedtime := file.ModTime() @@ -71,10 +71,10 @@ func AsExp(devicePath string, filename string, exptime time.Duration) bool { log.Debugf("Last modification time : %s ago", elapsed) if elapsed > exptime { log.Debugln("The file have expired") - return true + return true, nil } log.Debugln("The file haven't expired") - return false + return false, nil } //CreateJSONFile will create a json file bases on the interface{} datas.