Skip to content

Commit

Permalink
debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
an1l4 committed Feb 15, 2024
1 parent 562c7ec commit 92dbdbc
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 71 deletions.
21 changes: 11 additions & 10 deletions agent/kubviz/k8smetrics_agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@ import (
"github.com/intelops/kubviz/agent/kubviz/plugins/kubepreupgrade"

"github.com/intelops/kubviz/agent/kubviz/plugins/kuberhealthy"
"github.com/intelops/kubviz/agent/kubviz/plugins/kubescore"
//"github.com/intelops/kubviz/agent/kubviz/plugins/kubescore"
"github.com/intelops/kubviz/agent/kubviz/plugins/outdated"
"github.com/intelops/kubviz/agent/kubviz/plugins/rakkess"
"github.com/intelops/kubviz/agent/kubviz/plugins/trivy"

//"github.com/intelops/kubviz/agent/kubviz/plugins/trivy"
"github.com/intelops/kubviz/agent/kubviz/scheduler"

_ "k8s.io/client-go/plugin/pkg/client/auth/azure"
Expand Down Expand Up @@ -141,14 +142,14 @@ func main() {
events.LogErr(err)
err = rakkess.RakeesOutput(config, js)
events.LogErr(err)
err = trivy.RunTrivySbomScan(config, js)
events.LogErr(err)
err = trivy.RunTrivyImageScans(config, js)
events.LogErr(err)
err = trivy.RunTrivyK8sClusterScan(js)
events.LogErr(err)
err = kubescore.RunKubeScore(clientset, js)
events.LogErr(err)
// err = trivy.RunTrivySbomScan(config, js)
// events.LogErr(err)
// err = trivy.RunTrivyImageScans(config, js)
// events.LogErr(err)
// err = trivy.RunTrivyK8sClusterScan(js)
// events.LogErr(err)
// err = kubescore.RunKubeScore(clientset, js)
// events.LogErr(err)
}

collectAndPublishMetrics()
Expand Down
122 changes: 61 additions & 61 deletions client/pkg/clients/kubviz_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,37 +131,37 @@ func (n *NATSContext) SubscribeAllKubvizNats(conn clickhouse.DBInterface) {
log.Println()
},
},
{
Subject: constants.TRIVY_IMAGE_SUBJECT,
Consumer: cfg.TrivyImageConsumer,
Handler: func(msg *nats.Msg) {
msg.Ack()
var metrics model.TrivyImage
err := json.Unmarshal(msg.Data, &metrics)
if err != nil {
log.Fatal(err)
}
log.Printf("Trivy Metrics Received: %#v,", metrics)
conn.InsertTrivyImageMetrics(metrics)
log.Println()
},
},
{
Subject: constants.TRIVY_SBOM_SUBJECT,
Consumer: cfg.TrivySbomConsumer,
Handler: func(msg *nats.Msg) {
msg.Ack()
var metrics model.SbomData
err := json.Unmarshal(msg.Data, &metrics)
if err != nil {
log.Println("failed to unmarshal from nats", err)
return
}
log.Printf("Trivy sbom Metrics Received: %#v,", metrics)
conn.InsertTrivySbomMetrics(metrics)
log.Println()
},
},
// {
// Subject: constants.TRIVY_IMAGE_SUBJECT,
// Consumer: cfg.TrivyImageConsumer,
// Handler: func(msg *nats.Msg) {
// msg.Ack()
// var metrics model.TrivyImage
// err := json.Unmarshal(msg.Data, &metrics)
// if err != nil {
// log.Fatal(err)
// }
// log.Printf("Trivy Metrics Received: %#v,", metrics)
// conn.InsertTrivyImageMetrics(metrics)
// log.Println()
// },
// },
// {
// Subject: constants.TRIVY_SBOM_SUBJECT,
// Consumer: cfg.TrivySbomConsumer,
// Handler: func(msg *nats.Msg) {
// msg.Ack()
// var metrics model.SbomData
// err := json.Unmarshal(msg.Data, &metrics)
// if err != nil {
// log.Println("failed to unmarshal from nats", err)
// return
// }
// log.Printf("Trivy sbom Metrics Received: %#v,", metrics)
// conn.InsertTrivySbomMetrics(metrics)
// log.Println()
// },
// },
{
Subject: constants.KubvizSubject,
Consumer: cfg.KubvizConsumer,
Expand All @@ -177,36 +177,36 @@ func (n *NATSContext) SubscribeAllKubvizNats(conn clickhouse.DBInterface) {
log.Println()
},
},
{
Subject: constants.KUBESCORE_SUBJECT,
Consumer: cfg.KubscoreConsumer,
Handler: func(msg *nats.Msg) {
msg.Ack()
var metrics model.KubeScoreRecommendations
err := json.Unmarshal(msg.Data, &metrics)
if err != nil {
log.Fatal(err)
}
log.Printf("Kubscore Metrics Received: %#v,", metrics)
conn.InsertKubeScoreMetrics(metrics)
log.Println()
},
},
{
Subject: constants.TRIVY_K8S_SUBJECT,
Consumer: cfg.TrivyConsumer,
Handler: func(msg *nats.Msg) {
msg.Ack()
var metrics model.Trivy
err := json.Unmarshal(msg.Data, &metrics)
if err != nil {
log.Fatal(err)
}
log.Printf("Trivy Metrics Received: %#v,", metrics)
conn.InsertTrivyMetrics(metrics)
log.Println()
},
},
// {
// Subject: constants.KUBESCORE_SUBJECT,
// Consumer: cfg.KubscoreConsumer,
// Handler: func(msg *nats.Msg) {
// msg.Ack()
// var metrics model.KubeScoreRecommendations
// err := json.Unmarshal(msg.Data, &metrics)
// if err != nil {
// log.Fatal(err)
// }
// log.Printf("Kubscore Metrics Received: %#v,", metrics)
// conn.InsertKubeScoreMetrics(metrics)
// log.Println()
// },
// },
// {
// Subject: constants.TRIVY_K8S_SUBJECT,
// Consumer: cfg.TrivyConsumer,
// Handler: func(msg *nats.Msg) {
// msg.Ack()
// var metrics model.Trivy
// err := json.Unmarshal(msg.Data, &metrics)
// if err != nil {
// log.Fatal(err)
// }
// log.Printf("Trivy Metrics Received: %#v,", metrics)
// conn.InsertTrivyMetrics(metrics)
// log.Println()
// },
// },
}

for _, sub := range subscriptions {
Expand Down

0 comments on commit 92dbdbc

Please sign in to comment.