Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Agent = &cobra.Command{ Use: "agent", Short: "Skydive agent", Long: "Skydive agent", SilenceUsage: true, Run: func(cmd *cobra.Command, args []string) { config.GetConfig().Set("logging.id", "agent") logging.GetLogger().Noticef("Skydive Agent %s starting...", version.Version) agent, err := agent.NewAgent() if err != nil { logging.GetLogger().Errorf("Can't start Skydive agent: %v", err) os.Exit(1) } agent.Start() logging.GetLogger().Notice("Skydive Agent started") ch := make(chan os.Signal) signal.Notify(ch, syscall.SIGINT, syscall.SIGTERM) <-ch agent.Stop() logging.GetLogger().Notice("Skydive Agent stopped.") }, }
Agent skydive agent root command
View Source
var AllInOne = &cobra.Command{ Use: "allinone", Short: "Skydive All-In-One", Long: "Skydive All-In-One (Analyzer + Agent)", SilenceUsage: true, Run: func(cmd *cobra.Command, args []string) { if uid := os.Geteuid(); uid != 0 { fmt.Fprintln(os.Stderr, "All-In-One mode has to be run as root") os.Exit(1) } skydivePath, _ := osext.Executable() logFile := config.GetConfig().GetString("logging.file.path") extension := filepath.Ext(logFile) logFile = strings.TrimSuffix(logFile, extension) os.Setenv("SKYDIVE_LOGGING_FILE_PATH", logFile+"-analyzer"+extension) analyzerAttr := &os.ProcAttr{ Files: []*os.File{os.Stdin, os.Stdout, os.Stderr}, Env: os.Environ(), } if analyzerUID != 0 { analyzerAttr.Sys = &syscall.SysProcAttr{ Credential: &syscall.Credential{ Uid: analyzerUID, }, } } args = []string{"skydive"} for _, cfgFile := range CfgFiles { args = append(args, "-c") args = append(args, cfgFile) } if cfgBackend != "" { args = append(args, "-b") args = append(args, cfgBackend) } analyzerArgs := make([]string, len(args)) copy(analyzerArgs, args) if len(CfgFiles) != 0 { if err := config.InitConfig(cfgBackend, CfgFiles); err != nil { fmt.Fprintf(os.Stderr, "Failed to initialize config: %s", err.Error()) os.Exit(1) } } analyzerProcess, err := os.StartProcess(skydivePath, append(analyzerArgs, "analyzer"), analyzerAttr) if err != nil { logging.GetLogger().Errorf("Can't start Skydive analyzer: %v", err) os.Exit(1) } authOptions := analyzer.NewAnalyzerAuthenticationOpts() svcAddr, _ := common.ServiceAddressFromString(config.GetConfig().GetString("analyzer.listen")) restClient := http.NewRestClient(config.GetURL("http", svcAddr.Addr, svcAddr.Port, ""), authOptions) err = common.Retry(func() error { _, err := restClient.Request("GET", "/api", nil, nil) return err }, 10, time.Second) if err != nil { logging.GetLogger().Errorf("Failed to start Skydive analyzer: %v", err) os.Exit(1) } os.Setenv("SKYDIVE_ANALYZERS", config.GetConfig().GetString("analyzer.listen")) os.Setenv("SKYDIVE_LOGGING_FILE_PATH", logFile+"-agent"+extension) agentAttr := &os.ProcAttr{ Files: []*os.File{os.Stdin, os.Stdout, os.Stderr}, Env: os.Environ(), } agentArgs := make([]string, len(args)) copy(agentArgs, args) agentProcess, err := os.StartProcess(skydivePath, append(agentArgs, "agent"), agentAttr) if err != nil { logging.GetLogger().Errorf("Can't start Skydive agent: %s. Please check you are root", err.Error()) os.Exit(1) } logging.GetLogger().Notice("Skydive All-in-One starting !") ch := make(chan os.Signal) signal.Notify(ch, syscall.SIGINT, syscall.SIGTERM) <-ch analyzerProcess.Kill() agentProcess.Kill() analyzerProcess.Wait() agentProcess.Wait() logging.GetLogger().Notice("Skydive All-in-One stopped.") }, }
AllInOne skydive allinone root command
View Source
var Analyzer = &cobra.Command{ Use: "analyzer", Short: "Skydive analyzer", Long: "Skydive analyzer", SilenceUsage: true, Run: func(cmd *cobra.Command, args []string) { config.GetConfig().Set("logging.id", "agent") logging.GetLogger().Noticef("Skydive Analyzer %s starting...", version.Version) server, err := analyzer.NewServerFromConfig() if err != nil { fmt.Fprintf(os.Stderr, "Failed to create analyzer: %s", err.Error()) os.Exit(1) } if err := server.Start(); err != nil { fmt.Fprintf(os.Stderr, "Failed to start analyzer: %s", err.Error()) os.Exit(1) } logging.GetLogger().Notice("Skydive Analyzer started !") ch := make(chan os.Signal) signal.Notify(ch, syscall.SIGINT, syscall.SIGTERM) <-ch server.Stop() logging.GetLogger().Notice("Skydive Analyzer stopped.") }, }
Analyzer skydive analyzer root command
View Source
var BashCompletion = &cobra.Command{ Use: "bash-completion", Short: "generate bash completion helper", Long: "generate bash completion helper (skydive-bash-completion.sh)", SilenceUsage: true, Run: func(cmd *cobra.Command, args []string) { RootCmd.GenBashCompletionFile("skydive-bash-completion.sh") fmt.Println("skydive-bash-completion.sh has been generated") }, }
BashCompletion skydive root command
View Source
var ( // CfgFiles skydive configuration files CfgFiles []string )
View Source
var Client = &cobra.Command{ Use: "client", Short: "Skydive client", Long: "Skydive client", SilenceUsage: true, PersistentPreRun: func(cmd *cobra.Command, args []string) { cmd.Root().PersistentPreRun(cmd.Root(), args) if analyzerAddr != "" { config.GetConfig().Set("analyzers", analyzerAddr) } else { config.GetConfig().SetDefault("analyzers", "localhost:8082") } }, }
Client skydive client root command
View Source
var RootCmd = &cobra.Command{ Use: "skydive [sub]", Short: "Skydive", SilenceUsage: true, PersistentPreRun: func(cmd *cobra.Command, args []string) { LoadConfiguration() }, }
RootCmd skydive root command
View Source
var VersionCmd = &cobra.Command{ Use: "version", Short: "Print the version number of Skydive", Run: func(cmd *cobra.Command, args []string) { version.PrintVersion() }, }
VersionCmd skydive version root command
Functions ¶
Types ¶
This section is empty.
Source Files ¶
Click to show internal directories.
Click to hide internal directories.