Documentation ¶
Index ¶
- Variables
- type GremlinQueryHelper
- func (g *GremlinQueryHelper) GetFlowMetric(query string) (m *flow.FlowMetric, _ error)
- func (g *GremlinQueryHelper) GetFlows(query string) (flows []*flow.Flow, err error)
- func (g *GremlinQueryHelper) GetMetric(query string) (*common.TimedMetric, error)
- func (g *GremlinQueryHelper) GetMetrics(query string) (map[string][]*common.TimedMetric, error)
- func (g *GremlinQueryHelper) GetNode(query string) (node *graph.Node, _ error)
- func (g *GremlinQueryHelper) GetNodes(query string) ([]*graph.Node, error)
- func (g *GremlinQueryHelper) Query(query string, values interface{}) error
- func (g *GremlinQueryHelper) Request(query string, header http.Header) (*http.Response, error)
- type Session
Constants ¶
This section is empty.
Variables ¶
var ( // ErrContinue parser error continue input ErrContinue = errors.New("<continue input>") // ErrQuit parser error quit session ErrQuit = errors.New("<quit session>") )
var AlertCmd = &cobra.Command{ Use: "alert", Short: "Manage alerts", Long: "Manage alerts", SilenceUsage: false, }
AlertCmd skydive alert root command
var AlertCreate = &cobra.Command{ Use: "create", Short: "Create alert", Long: "Create alert", Run: func(cmd *cobra.Command, args []string) { client, err := api.NewCrudClientFromConfig(&AuthenticationOpts) if err != nil { logging.GetLogger().Criticalf(err.Error()) } alert := api.NewAlert() alert.Name = alertName alert.Description = alertDescription alert.Expression = alertExpression alert.Trigger = alertTrigger alert.Action = alertAction if errs := validator.Validate(alert); errs != nil { fmt.Println("Error: ", errs) cmd.Usage() os.Exit(1) } if err := client.Create("alert", &alert); err != nil { logging.GetLogger().Errorf(err.Error()) os.Exit(1) } printJSON(&alert) }, }
AlertCreate skydive alert creates command
var AlertDelete = &cobra.Command{ Use: "delete [alert]", Short: "Delete alert", Long: "Delete alert", PreRun: func(cmd *cobra.Command, args []string) { if len(args) == 0 { cmd.Usage() os.Exit(1) } }, Run: func(cmd *cobra.Command, args []string) { client, err := api.NewCrudClientFromConfig(&AuthenticationOpts) if err != nil { logging.GetLogger().Criticalf(err.Error()) } if err := client.Delete("alert", args[0]); err != nil { logging.GetLogger().Errorf(err.Error()) os.Exit(1) } }, }
AlertDelete skydive alert delete command
var AlertGet = &cobra.Command{ Use: "get [alert]", Short: "Display alert", Long: "Display alert", PreRun: func(cmd *cobra.Command, args []string) { if len(args) == 0 { cmd.Usage() os.Exit(1) } }, Run: func(cmd *cobra.Command, args []string) { var alert api.Alert client, err := api.NewCrudClientFromConfig(&AuthenticationOpts) if err != nil { logging.GetLogger().Criticalf(err.Error()) } if err := client.Get("alert", args[0], &alert); err != nil { logging.GetLogger().Errorf(err.Error()) os.Exit(1) } printJSON(&alert) }, }
AlertGet skydive alert get command
var AlertList = &cobra.Command{ Use: "list", Short: "List alerts", Long: "List alerts", Run: func(cmd *cobra.Command, args []string) { var alerts map[string]api.Alert client, err := api.NewCrudClientFromConfig(&AuthenticationOpts) if err != nil { logging.GetLogger().Criticalf(err.Error()) } if err := client.List("alert", &alerts); err != nil { logging.GetLogger().Errorf(err.Error()) os.Exit(1) } printJSON(alerts) }, }
AlertList skydive alert list command
var (
AuthenticationOpts shttp.AuthenticationOpts
)
AuthenticationOpts Authentication options
var CaptureCmd = &cobra.Command{ Use: "capture", Short: "Manage captures", Long: "Manage captures", SilenceUsage: false, }
CaptureCmd skdyive capture root command
var CaptureCreate = &cobra.Command{ Use: "create", Short: "Create capture", Long: "Create capture", PreRun: func(cmd *cobra.Command, args []string) { if nodeTID != "" { if gremlinQuery != "" { logging.GetLogger().Fatal("Options --node and --gremlin are exclusive") } gremlinQuery = fmt.Sprintf("g.V().Has('TID', '%s')", nodeTID) } }, Run: func(cmd *cobra.Command, args []string) { client, err := api.NewCrudClientFromConfig(&AuthenticationOpts) if err != nil { logging.GetLogger().Fatalf(err.Error()) } capture := api.NewCapture(gremlinQuery, bpfFilter) capture.Name = captureName capture.Description = captureDescription capture.Type = captureType capture.Port = port if err := validator.Validate(capture); err != nil { logging.GetLogger().Fatalf(err.Error()) } if err := client.Create("capture", &capture); err != nil { logging.GetLogger().Fatalf(err.Error()) } printJSON(&capture) }, }
CaptureCreate skydive capture creates command
var CaptureDelete = &cobra.Command{ Use: "delete [capture]", Short: "Delete capture", Long: "Delete capture", PreRun: func(cmd *cobra.Command, args []string) { if len(args) == 0 { cmd.Usage() os.Exit(1) } }, Run: func(cmd *cobra.Command, args []string) { client, err := api.NewCrudClientFromConfig(&AuthenticationOpts) if err != nil { logging.GetLogger().Fatalf(err.Error()) } if err := client.Delete("capture", args[0]); err != nil { logging.GetLogger().Fatalf(err.Error()) } }, }
CaptureDelete skydive capture delete command
var CaptureGet = &cobra.Command{ Use: "get [capture]", Short: "Display capture", Long: "Display capture", PreRun: func(cmd *cobra.Command, args []string) { if len(args) == 0 { cmd.Usage() os.Exit(1) } }, Run: func(cmd *cobra.Command, args []string) { var capture api.Capture client, err := api.NewCrudClientFromConfig(&AuthenticationOpts) if err != nil { logging.GetLogger().Fatalf(err.Error()) } if err := client.Get("capture", args[0], &capture); err != nil { logging.GetLogger().Fatalf(err.Error()) } printJSON(&capture) }, }
CaptureGet skydive capture get command
var CaptureList = &cobra.Command{ Use: "list", Short: "List captures", Long: "List captures", Run: func(cmd *cobra.Command, args []string) { var captures map[string]api.Capture client, err := api.NewCrudClientFromConfig(&AuthenticationOpts) if err != nil { logging.GetLogger().Fatalf(err.Error()) } if err := client.List("capture", &captures); err != nil { logging.GetLogger().Fatalf(err.Error()) } printJSON(captures) }, }
CaptureList skydive capture list command
var ErrNotFound = errors.New("No result found")
ErrNotFound error no result found
var PacketInjectorCmd = &cobra.Command{ Use: "inject-packet", Short: "inject packets", Long: "inject packets", SilenceUsage: false, Run: func(cmd *cobra.Command, args []string) { client, err := api.NewCrudClientFromConfig(&AuthenticationOpts) if err != nil { logging.GetLogger().Criticalf(err.Error()) } packet := &api.PacketParamsReq{ Src: srcNode, Dst: dstNode, SrcIP: srcIP, SrcMAC: srcMAC, DstIP: dstIP, DstMAC: dstMAC, Type: packetType, Payload: payload, ID: id, Count: count, Interval: interval, } if err = validator.Validate(packet); err != nil { fmt.Fprintf(os.Stderr, "Error: %s", err.Error()) cmd.Usage() os.Exit(1) } if err := client.Create("injectpacket", &packet); err != nil { logging.GetLogger().Errorf(err.Error()) os.Exit(1) } printJSON(packet) }, }
PacketInjectorCmd skydive inject-packet root command
var PcapCmd = &cobra.Command{ Use: "pcap", Short: "Import flows from PCAP file", Long: "Import flows from PCAP file", PreRun: func(cmd *cobra.Command, args []string) { if pcapTrace == "" { logging.GetLogger().Error("You need to specify a PCAP file") cmd.Usage() os.Exit(1) } }, Run: func(cmd *cobra.Command, args []string) { client, err := api.NewCrudClientFromConfig(&AuthenticationOpts) if err != nil { logging.GetLogger().Fatal(err) } file, err := os.Open(pcapTrace) if err != nil { logging.GetLogger().Fatal(err) } defer file.Close() resp, err := client.Request("POST", "api/pcap", file, nil) if err != nil { logging.GetLogger().Fatal(err) } if resp.StatusCode == http.StatusOK { fmt.Printf("%s was successfully imported\n", pcapTrace) } else { content, _ := ioutil.ReadAll(resp.Body) logging.GetLogger().Errorf("Failed to import %s: %s", pcapTrace, string(content)) } }, }
PcapCmd skydive pcap root command
var ShellCmd = &cobra.Command{ Use: "shell", Short: "Shell Command Line Interface", Long: "Skydive Shell Command Line Interface, yet another shell", SilenceUsage: false, Run: func(cmd *cobra.Command, args []string) { shellMain() }, }
ShellCmd skydive shell root command
var TopologyCmd = &cobra.Command{ Use: "topology", Short: "Request on topology", Long: "Request on topology", SilenceUsage: false, }
TopologyCmd skydive topology root command
var TopologyRequest = &cobra.Command{ Use: "query", Short: "query topology", Long: "query topology", Run: func(cmd *cobra.Command, args []string) { queryHelper := NewGremlinQueryHelper(&AuthenticationOpts) switch outputFormat { case "json": var value interface{} if err := queryHelper.Query(gremlinQuery, &value); err != nil { logging.GetLogger().Fatalf(err.Error()) } printJSON(value) case "dot": header := make(http.Header) header.Set("Accept", "vnd.graphviz") resp, err := queryHelper.Request(gremlinQuery, header) if err != nil { logging.GetLogger().Fatalf(err.Error()) } defer resp.Body.Close() data, _ := ioutil.ReadAll(resp.Body) fmt.Println(string(data)) default: logging.GetLogger().Fatalf("Invalid output format %s", outputFormat) } }, }
TopologyRequest skydive topology query command
Functions ¶
This section is empty.
Types ¶
type GremlinQueryHelper ¶
type GremlinQueryHelper struct {
// contains filtered or unexported fields
}
GremlinQueryHelper describes a gremlin query request query helper mechanism
func NewGremlinQueryHelper ¶
func NewGremlinQueryHelper(authOptions *shttp.AuthenticationOpts) *GremlinQueryHelper
NewGremlinQueryHelper creates a new Gremlin query helper based on authentication
func (*GremlinQueryHelper) GetFlowMetric ¶
func (g *GremlinQueryHelper) GetFlowMetric(query string) (m *flow.FlowMetric, _ error)
GetFlowMetric from Gremlin query
func (*GremlinQueryHelper) GetFlows ¶
func (g *GremlinQueryHelper) GetFlows(query string) (flows []*flow.Flow, err error)
GetFlows form the Gremlin query
func (*GremlinQueryHelper) GetMetric ¶
func (g *GremlinQueryHelper) GetMetric(query string) (*common.TimedMetric, error)
GetMetric from Gremlin query
func (*GremlinQueryHelper) GetMetrics ¶
func (g *GremlinQueryHelper) GetMetrics(query string) (map[string][]*common.TimedMetric, error)
GetMetrics from Gremlin query
func (*GremlinQueryHelper) GetNode ¶
func (g *GremlinQueryHelper) GetNode(query string) (node *graph.Node, _ error)
GetNode from the Gremlin query
func (*GremlinQueryHelper) GetNodes ¶
func (g *GremlinQueryHelper) GetNodes(query string) ([]*graph.Node, error)
GetNodes from the Gremlin query
func (*GremlinQueryHelper) Query ¶
func (g *GremlinQueryHelper) Query(query string, values interface{}) error
Query the topology API