Skip to content

Commit

Permalink
replace log.Fatal with proper logging message and return the error
Browse files Browse the repository at this point in the history
  • Loading branch information
vkuznet committed Mar 23, 2021
1 parent a0625fa commit 83212a8
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/go/MONIT/hdfs_exporter.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"errors"
"flag"
"fmt"
"log"
Expand All @@ -23,6 +24,7 @@ type Record struct {
}

func run(path, pattern string, timeoffset, verbose int) ([]Record, error) {
var records []Record
args := []string{"fs", "-ls"}
command := "hadoop"
now := time.Now().Unix() - int64(timeoffset)
Expand All @@ -37,12 +39,12 @@ func run(path, pattern string, timeoffset, verbose int) ([]Record, error) {
stdout, err := cmd.Output()
if err != nil {
msg := fmt.Sprintf("%v %v %v", command, args, err)
log.Fatal(msg)
log.Println(msg)
return records, errors.New(msg)
}
if verbose > 0 {
log.Println(string(stdout))
}
var records []Record
for _, line := range strings.Split(string(stdout), "\n") {
var arr []string
for _, a := range strings.Split(line, " ") {
Expand Down

0 comments on commit 83212a8

Please sign in to comment.