-
Notifications
You must be signed in to change notification settings - Fork 1
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
0 parents
commit 4960d7a
Showing
14 changed files
with
22,664 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,3 @@ | ||
# eck-diagnostics-parser | ||
|
||
_(WIP)_ |
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,28 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
|
||
resources "github.com/framsouza/eck-diagnostics-parser/pkg/resources" | ||
) | ||
|
||
// DON'T FORGET!!! REMEMBER TO FIND ANOTHER WAY TO PASS THE FILE NAMES TO THE FUNCITONS!!!!! | ||
// CREATE A SUMMARY summary.go CHECKING IF THE SVC LABELS EXISTS, AND WITH SOME RECOMMENDATIONS | ||
// CHECK IF STORAGECLASS FILE EXISTS AND PRINT IT | ||
// TREAT ERRORS AND LOGS | ||
|
||
func main() { | ||
fmt.Print("\nWelcome to the ECK diagnostic parser tool\n") | ||
// Print ECK version | ||
resources.DiagV() | ||
resources.ECKV() // Remove time/date from the line | ||
resources.Nodes() | ||
resources.Pods() | ||
resources.Es() | ||
resources.Kibana() | ||
resources.StatefulSet() | ||
resources.Deployment() | ||
resources.PVC() | ||
//resources.Events() | ||
|
||
} |
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,3 @@ | ||
module github.com/framsouza/eck-diagnostics-parser | ||
|
||
go 1.17 |
Large diffs are not rendered by default.
Oops, something went wrong.
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,28 @@ | ||
package resources | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"text/tabwriter" | ||
|
||
load "github.com/framsouza/eck-diagnostics-parser/pkg/load" | ||
) | ||
|
||
func Deployment() { | ||
w := new(tabwriter.Writer) | ||
w.Init(os.Stdout, 8, 8, 0, '\t', 0) | ||
defer w.Flush() | ||
|
||
config, _ := load.LoadDeploy("/Users/francismarasouza/finding-file/tmp/default/deployments.json") | ||
fmt.Fprintf(w, "\n\n%s\t\t\t%s\t\t", "DEPLOYMENT NAME", "REPLICAS") | ||
|
||
for i := range config.Items { | ||
fmt.Fprintf(w, "\n%s\t\t\t", config.Items[i].Metadata.Name) | ||
fmt.Fprintf(w, "%v\t", config.Items[i].Spec.Replicas) | ||
|
||
} | ||
} | ||
|
||
// Check if JVM was set | ||
|
||
//CHECK VOLUMES ATTACHED |
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,32 @@ | ||
package resources | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"text/tabwriter" | ||
|
||
load "github.com/framsouza/eck-diagnostics-parser/pkg/load" | ||
) | ||
|
||
func Es() { | ||
w := new(tabwriter.Writer) | ||
w.Init(os.Stdout, 8, 8, 0, '\t', 0) | ||
defer w.Flush() | ||
|
||
config, _ := load.LoadES("/Users/francismarasouza/finding-file/tmp/default/elasticsearch.json") | ||
fmt.Fprintf(w, "\n\n%s\t\t%s\t\t%s\t\t%s\t\t%s\t", "ES NAME", "STATUS", "VERSION", "PHASE", "NODES") | ||
|
||
for i := range config.Items { | ||
// Add condition to print "NOT SPECIFIED" in case there's not limit/request specified | ||
|
||
fmt.Fprintf(w, "\n%s\t\t", config.Items[i].Metadata.Name) | ||
fmt.Fprintf(w, "%s\t\t", config.Items[i].Status.Health) | ||
fmt.Fprintf(w, "%s\t\t", config.Items[i].Spec.Version) | ||
fmt.Fprintf(w, "%s\t\t", config.Items[i].Status.Phase) | ||
fmt.Fprintf(w, "%v\t", config.Items[i].Status.AvailableNodes) | ||
|
||
// Print labels to compare with the service labels | ||
} | ||
|
||
//ADD NODES CONDITIONS | ||
} |
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,28 @@ | ||
package resources | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"text/tabwriter" | ||
|
||
load "github.com/framsouza/eck-diagnostics-parser/pkg/load" | ||
) | ||
|
||
func Events() { | ||
w := new(tabwriter.Writer) | ||
w.Init(os.Stdout, 8, 8, 0, '\t', 0) | ||
defer w.Flush() | ||
|
||
config, _ := load.LoadEvents("/Users/francismarasouza/finding-file/tmp/default/events.json") | ||
fmt.Fprintf(w, "\n\n%s\t\t%s\t\t%s\t\t%s\t\t", "TIMESTAMP", "TYPE", "KIND", "MESSAGE") | ||
|
||
for i := range config.Items { | ||
fmt.Fprintf(w, "\n%s\t\t", config.Items[i].LastTimestamp) | ||
fmt.Fprintf(w, "%s\t\t", config.Items[i].Type) | ||
fmt.Fprintf(w, "%s\t\t", config.Items[i].InvolvedObject.Kind) | ||
fmt.Fprintf(w, "%s\t\t", config.Items[i].Message) | ||
|
||
} | ||
|
||
//ADD NODES CONDITIONS | ||
} |
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,31 @@ | ||
package resources | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"text/tabwriter" | ||
|
||
load "github.com/framsouza/eck-diagnostics-parser/pkg/load" | ||
) | ||
|
||
func Kibana() { | ||
w := new(tabwriter.Writer) | ||
w.Init(os.Stdout, 8, 8, 0, '\t', 0) | ||
defer w.Flush() | ||
|
||
config, _ := load.LoadKibana("/Users/francismarasouza/finding-file/tmp/default/kibana.json") | ||
fmt.Fprintf(w, "\n\n%s\t\t%s\t\t%s\t\t%s\t%s\t", "KB NAME", "STATUS", "VERSION", "PHASE", "NODES") | ||
|
||
for i := range config.Items { | ||
|
||
fmt.Fprintf(w, "\n%s\t\t", config.Items[i].Metadata.Name) | ||
fmt.Fprintf(w, "%s\t\t", config.Items[i].Status.Health) | ||
fmt.Fprintf(w, "%s\t\t", config.Items[i].Spec.Version) | ||
fmt.Fprintf(w, "%s\t", config.Items[i].Status.AssociationStatus) | ||
fmt.Fprintf(w, "%v\t", config.Items[i].Status.AvailableNodes) | ||
|
||
// Print labels to compare with the service labels | ||
} | ||
|
||
//ADD NODES CONDITIONS | ||
} |
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,32 @@ | ||
package resources | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"text/tabwriter" | ||
|
||
load "github.com/framsouza/eck-diagnostics-parser/pkg/load" | ||
) | ||
|
||
func Nodes() { | ||
w := new(tabwriter.Writer) | ||
w.Init(os.Stdout, 8, 8, 0, '\t', 0) | ||
defer w.Flush() | ||
|
||
config, _ := load.LoadNodes("/Users/francismarasouza/finding-file/tmp/nodes.json") | ||
fmt.Fprintf(w, "\n%s\t%s\t%s\t%s\t\t%s\t\t%s\t%s\t", "NODE NAME", "CPU CAPACITY", "CPU ALLOCATED", "MEMORY CAPACITY", "MEMORY ALLOCATED", "VERSION", "NODE CONDITIONS") | ||
|
||
for i := range config.Items { | ||
fmt.Fprintf(w, "\n%s\t", config.Items[i].Metadata.Name) | ||
fmt.Fprintf(w, "%s\t", config.Items[i].Status.Capacity.Cpu) | ||
fmt.Fprintf(w, "%s\t", config.Items[i].Status.Allocatable.Cpu) | ||
fmt.Fprintf(w, "%s\t\t", config.Items[i].Status.Capacity.Memory) | ||
fmt.Fprintf(w, "%s\t\t", config.Items[i].Status.Allocatable.Memory) | ||
fmt.Fprintf(w, "%s\t", config.Items[i].Status.NodeInfo.KubeletVersion) | ||
fmt.Fprintf(w, "%s %s, ", config.Items[i].Status.Conditions[0].Type, config.Items[i].Status.Conditions[0].Status) | ||
fmt.Fprintf(w, "%s %s, ", config.Items[i].Status.Conditions[1].Type, config.Items[i].Status.Conditions[0].Status) | ||
fmt.Fprintf(w, "%s %s, ", config.Items[i].Status.Conditions[2].Type, config.Items[i].Status.Conditions[0].Status) | ||
fmt.Fprintf(w, "%s %s", config.Items[i].Status.Conditions[3].Type, config.Items[i].Status.Conditions[0].Status) | ||
|
||
} | ||
} |
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,57 @@ | ||
package resources | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"text/tabwriter" | ||
|
||
load "github.com/framsouza/eck-diagnostics-parser/pkg/load" | ||
) | ||
|
||
func Pods() { | ||
w := new(tabwriter.Writer) | ||
w.Init(os.Stdout, 8, 8, 0, '\t', 0) | ||
defer w.Flush() | ||
|
||
config, _ := load.LoadPods("/Users/francismarasouza/eck-diagnostics-parser/pods.json") | ||
fmt.Fprintf(w, "\n\n%s\t%s\t\t%s\t%s\t%s\t%s\t%s\t", "PODS NAME", "STATUS", "MEM REQUEST", "MEM LIMIT", "CPU REQUEST", "CPU LIMIT", "INIT CONTAINER STATUS") | ||
|
||
for i := range config.Items { | ||
fmt.Fprintf(w, "\n%s\t", config.Items[i].Metadata.Name) | ||
fmt.Fprintf(w, "%s\t\t", config.Items[i].Status.Phase) | ||
for r := range config.Items[i].Spec.Containers { | ||
if config.Items[i].Spec.Containers[r].Resources.Requests.Memory == "" { | ||
fmt.Fprintf(w, "%s\t", "No Request set") | ||
} else { | ||
fmt.Fprintf(w, "%s\t", config.Items[i].Spec.Containers[r].Resources.Requests.Memory) | ||
} | ||
|
||
if config.Items[i].Spec.Containers[r].Resources.Limits.Memory == "" { | ||
fmt.Fprintf(w, "%s\t", "No limit set") | ||
} else { | ||
fmt.Fprintf(w, "%s\t", config.Items[i].Spec.Containers[r].Resources.Limits.Memory) | ||
} | ||
|
||
if config.Items[i].Spec.Containers[r].Resources.Requests.Cpu == "" { | ||
fmt.Fprintf(w, "%s\t", "No Request set") | ||
} else { | ||
fmt.Fprintf(w, "%s\t", config.Items[i].Spec.Containers[r].Resources.Requests.Cpu) | ||
} | ||
|
||
if config.Items[i].Spec.Containers[r].Resources.Limits.Cpu == "" { | ||
fmt.Fprintf(w, "%s\t", "No limit set") | ||
} else { | ||
fmt.Fprintf(w, "%s\t", config.Items[i].Spec.Containers[r].Resources.Limits.Cpu) | ||
|
||
} | ||
} | ||
//Check initcontainers | ||
for c := range config.Items[i].Status.InitContainerStatuses { | ||
fmt.Fprintf(w, "%s %s, ", config.Items[i].Status.InitContainerStatuses[c].Name, config.Items[i].Status.InitContainerStatuses[c].State.Terminated.Reason) | ||
|
||
} | ||
|
||
} | ||
|
||
// Print labels to compare with the service labels | ||
} |
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,30 @@ | ||
package resources | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"text/tabwriter" | ||
|
||
load "github.com/framsouza/eck-diagnostics-parser/pkg/load" | ||
) | ||
|
||
func PVC() { | ||
w := new(tabwriter.Writer) | ||
w.Init(os.Stdout, 8, 8, 0, '\t', 0) | ||
defer w.Flush() | ||
|
||
config, _ := load.LoadPVC("/Users/francismarasouza/finding-file/tmp/default/persistentvolumeclaims.json") | ||
fmt.Fprintf(w, "\n\n%s\t%s\t\t%s\t\t%s\t\t", "VOLUME NAME", "STATUS", "CAPACITY", "STORAGE CLASS NAME") | ||
|
||
for i := range config.Items { | ||
fmt.Fprintf(w, "\n%s\t", config.Items[i].Metadata.Name) | ||
fmt.Fprintf(w, "%v\t\t", config.Items[i].Status.Phase) | ||
fmt.Fprintf(w, "%v\t\t", config.Items[i].Status.Capacity.Storage) | ||
fmt.Fprintf(w, "%v\t", config.Items[i].Spec.StorageClassName) | ||
|
||
} | ||
} | ||
|
||
// Check if JVM was set | ||
|
||
//CHECK VOLUMES ATTACHED |
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 resources | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"text/tabwriter" | ||
|
||
load "github.com/framsouza/eck-diagnostics-parser/pkg/load" | ||
) | ||
|
||
func StatefulSet() { | ||
w := new(tabwriter.Writer) | ||
w.Init(os.Stdout, 8, 8, 0, '\t', 0) | ||
defer w.Flush() | ||
|
||
config, _ := load.LoadStatefulSet("/Users/francismarasouza/finding-file/tmp/default/statefulsets.json") | ||
fmt.Fprintf(w, "\n\n%s\t\t%s\t\t%s\t\t", "STATEFULSET NAME", "REPLICAS", "HEAP SIZE") | ||
|
||
for i := range config.Items { | ||
fmt.Fprintf(w, "\n%s\t\t", config.Items[i].Metadata.Name) | ||
fmt.Fprintf(w, "%v\t\t", config.Items[i].Spec.Replicas) | ||
//fmt.Fprintf(w, "%v\t", config.Items[i].Spec.Template.Spec.Containers) | ||
for c := range config.Items[i].Spec.Template.Spec.Containers { | ||
for e := range config.Items[i].Spec.Template.Spec.Containers[c].Env { | ||
list := config.Items[i].Spec.Template.Spec.Containers[c].Env[e] | ||
if list.Name == "ES_JAVA_OPTS" { | ||
fmt.Fprintf(w, "%v\t\t\t", config.Items[i].Spec.Template.Spec.Containers[c].Env[e].Value) | ||
} | ||
// PRINT SOMETHING IF HEAP IS NOT SET OR SEND IT TO THE SUMMARY.GO | ||
} | ||
} | ||
|
||
} | ||
} | ||
|
||
// Check if JVM was set | ||
|
||
//CHECK VOLUMES ATTACHED |
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,34 @@ | ||
package resources | ||
|
||
import ( | ||
"bytes" | ||
"fmt" | ||
"io/ioutil" | ||
"os" | ||
"text/tabwriter" | ||
|
||
load "github.com/framsouza/eck-diagnostics-parser/pkg/load" | ||
) | ||
|
||
func DiagV() { | ||
w := new(tabwriter.Writer) | ||
w.Init(os.Stdout, 8, 8, 0, '\t', 0) | ||
defer w.Flush() | ||
|
||
config, _ := load.LoadDiagV("/Users/francismarasouza/finding-file/tmp/version.json") | ||
fmt.Println("\nDiagnostic version is", config.DiagnosticsVersion.Version) | ||
|
||
} | ||
|
||
func ECKV() { | ||
var version string | ||
b, e := ioutil.ReadFile("/Users/francismarasouza/finding-file/tmp/eck-diagnostics.log") | ||
if e != nil { | ||
panic(e) | ||
} | ||
array := bytes.Split(b, []byte("\n")) | ||
version = string(array[2]) | ||
|
||
fmt.Printf("%s\n", version) | ||
|
||
} |
Oops, something went wrong.