Documentation ¶
Index ¶
- Constants
- Variables
- func Attack(cfg *StressConfig) chan WorkerData
- func NewFile(filename string) *os.File
- func SaveFileReport(r *Report)
- func Worker(thread int, request <-chan WorkerData, response chan<- WorkerData, ...)
- type Headers
- type Option
- type OutputSaver
- type Report
- type Stats
- type StressConfig
- type WorkerData
Constants ¶
View Source
const ChannelTimeout = 5
ChannelTimeout is a last resort method of killing goroutines
View Source
const ( // HTTPfolder - the folder where the reports will be dumped HTTPfolder = "./data/" // Would be nice to generate absolute path via code || gopath )
Variables ¶
View Source
var ( InvalidOptionType = errors.New("Invalid option value has been given") InvalidOptionName = errors.New("Option with that name does not exist") )
View Source
var (
Tr = &http.Transport{}
)
Functions ¶
func SaveFileReport ¶
func SaveFileReport(r *Report)
SaveFileReport it will save the report as json on local storage
func Worker ¶
func Worker( thread int, request <-chan WorkerData, response chan<- WorkerData, group *sync.WaitGroup, )
Worker is a goroutine that receives from request channel configuration for probing URL and sends its response via response chan
Types ¶
type Option ¶
type Option func(*StressConfig) error
type Report ¶
type Report struct { UUID uuid.UUID `json:"uuid"` TimeStamp time.Time `json:"timestamp"` Config *StressConfig `json:"config"` Stats Stats `json:"stats"` Duration float64 `json:"durationTotal"` Data []WorkerData `json:"data"` Completed bool `json:"completed"` }
Report structure
func NewReport ¶
func NewReport(cfg *StressConfig, saveFunc OutputSaver, tickerSave int) (*Report, error)
NewReport probes an endpoint and generates a new report saveFunc will be called every [tickerSave]ms meant for handling the report in real time
type Stats ¶
type Stats struct { Median float64 `json:"median"` PercentileA float64 `json:"50_percentile"` PercentileB float64 `json:"75_percentile"` PercentileC float64 `json:"95_percentile"` PercentileD float64 `json:"99_percentile"` ErrorPercentage float64 `json:"error_percentage"` CodesCount map[int]int `json:"codes_count"` }
Stats Structure
type StressConfig ¶
type StressConfig struct { // URL to probe URL string `json:"url"` Method string `json:"method"` // Number of request to be sent to the victim Requests int `json:"requests"` // Ho many treads to be used (dependent on the image resources) Threads int `json:"threads"` // similar to curl --resolve Force resolve of HOST:PORT to ADDRESS Resolve string `json:"resolve"` // insecure Insecure bool `json:"insecure"` // payload Payload string `json:"payload"` // Headers Headers Headers `json:"headers"` Duration int `json:"duration"` // Minutes Frequency int `json:"frequency"` // Miliseconds // If each worker should capture response WithResponse bool `json:"withResponse"` // contains filtered or unexported fields }
MonkeyConfig structure
func NewStressConfig ¶
func NewStressConfig(opts ...Option) (*StressConfig, error)
func (*StressConfig) StopAttack ¶
func (s *StressConfig) StopAttack()
func (*StressConfig) ValidateConfig ¶
func (cfg *StressConfig) ValidateConfig() error
ValidateConfig ...
type WorkerData ¶
type WorkerData struct { Request int `json:"request"` Status int `json:"status"` // json:"status,omitempty" Thread int `json:"thread"` Duration float64 `json:"duration"` Error string `json:"error"` //`json:"error,omitempty"` ResponseBody string `json:"response"` StressConfig *StressConfig `json:"-"` // monkey cfg }
WorkerData structure is used to track worker work
Click to show internal directories.
Click to hide internal directories.