MCPcopy
hub / github.com/crowdsecurity/crowdsec / dump

Method dump

cmd/crowdsec-cli/clisupport/support.go:515–665  ·  view source on GitHub ↗
(ctx context.Context, outFile string, fast bool)

Source from the content-addressed store, hash-verified

513}
514
515func (cli *cliSupport) dump(ctx context.Context, outFile string, fast bool) error {
516 var skipCAPI, skipLAPI, skipAgent bool
517
518 collector := &StringHook{
519 LogLevels: log.AllLevels,
520 }
521 log.AddHook(collector)
522
523 cfg := cli.cfg()
524
525 if outFile == "" {
526 outFile = filepath.Join(os.TempDir(), "crowdsec-support.zip")
527 }
528
529 w := bytes.NewBuffer(nil)
530 zipWriter := zip.NewWriter(w)
531
532 db, err := require.DBClient(ctx, cfg.DbConfig)
533 if err != nil {
534 log.Warn(err)
535 }
536
537 if err = cfg.LoadAPIServer(true, false); err != nil {
538 log.Warnf("could not load LAPI, skipping CAPI check")
539
540 skipCAPI = true
541 }
542
543 if err = cfg.LoadCrowdsec(); err != nil {
544 log.Warnf("could not load agent config, skipping crowdsec config check")
545
546 skipAgent = true
547 }
548
549 hub, err := require.Hub(cfg, nil)
550 if err != nil {
551 log.Warn("Could not init hub, running on LAPI? Hub related information will not be collected")
552 // XXX: lapi status check requires scenarios, will return an error
553 }
554
555 if cfg.API.Client == nil || cfg.API.Client.Credentials == nil {
556 log.Warn("no agent credentials found, skipping LAPI connectivity check")
557
558 skipLAPI = true
559 }
560
561 if cfg.API.Server == nil || cfg.API.Server.OnlineClient == nil || cfg.API.Server.OnlineClient.Credentials == nil {
562 log.Warn("no CAPI credentials found, skipping CAPI connectivity check")
563
564 skipCAPI = true
565 }
566
567 if err = cli.dumpMetrics(ctx, db, zipWriter); err != nil {
568 log.Warn(err)
569 }
570
571 if err = cli.dumpSystemInfo(zipWriter); err != nil {
572 log.Warnf("could not collect system information: %s", err)

Callers 1

NewDumpCmdMethod · 0.95

Calls 15

dumpMetricsMethod · 0.95
dumpSystemInfoMethod · 0.95
dumpConfigYAMLMethod · 0.95
dumpHubItemsMethod · 0.95
dumpBouncersMethod · 0.95
dumpAgentsMethod · 0.95
dumpCAPIStatusMethod · 0.95
dumpPAPIStatusMethod · 0.95
dumpLAPIStatusMethod · 0.95
dumpPprofMethod · 0.95
dumpProfilesMethod · 0.95
dumpAcquisitionConfigMethod · 0.95

Tested by

no test coverage detected