-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package nodelogs | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"strings" | ||
|
||
"github.com/gmeghnag/omc/vars" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
// alertCmd represents the alert command | ||
var NodeLogs = &cobra.Command{ | ||
Use: "node-logs", | ||
Run: func(cmd *cobra.Command, args []string) { | ||
if len(args) == 0 { | ||
fmt.Println("The following node services logs are available to be read:") | ||
fmt.Println("") | ||
files, _ := os.ReadDir(vars.MustGatherRootPath + "/host_service_logs/masters/") | ||
for _, f := range files { | ||
fmt.Println("-", strings.TrimSuffix(f.Name(), "_service.log")) | ||
} | ||
fmt.Println("\nis it possible to read the content by executing 'omc node-logs <SERVICE>'.") | ||
} | ||
if len(args) > 1 { | ||
fmt.Fprintln(os.Stderr, "Expect zero arguemnt, found: ", len(args)) | ||
os.Exit(1) | ||
} | ||
if len(args) == 1 { | ||
text, err := os.ReadFile(vars.MustGatherRootPath + "/host_service_logs/masters/" + args[0] + "_service.log") | ||
if err != nil { | ||
fmt.Fprintln(os.Stderr, "logs for service \""+args[0]+"\" not found or readable.") | ||
os.Exit(1) | ||
} | ||
fmt.Print(string(text)) | ||
} | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters