modgearman

package module
v1.3.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 15, 2024 License: GPL-3.0 Imports: 40 Imported by: 0

README

Mod-Gearman-Worker

Build Status Go Report Card

this is a Mod-Gearman-Worker rewrite in golang. It supports all original command line parameters and therefor can be replace the c-worker without any config changes. Since it uses a go routines model instead of preforking workers, it uses much less ressources than the original worker.

Embedded Perl

This worker does support embedded perl as well. This is done by a (managed) perl epn daemon which will handle the perl plugins.

Negate

To make checks more efficient, this worker has implemented its own negate plugin. Whenever the command line starts with something like .../negate (if the basename of the first command equals "negate") it will use the internal negate instead of running the specified negate command. All options are similar to the official negate implementation:

Prometheus

Prometheus metrics will get exported when started with the prometheus-server option.

%> .../mod_gearman_worker --prometheus_server=127.0.0.1:8001

Build Instructions / Installation

Either use go install like:

%> go install github.com/ConSol/mod-gearman-worker-go/cmd/mod_gearman_worker
%> go install github.com/ConSol/mod-gearman-worker-go/cmd/send_gearman

Or clone the repository and build it manually:

%> go get github.com/ConSol/mod-gearman-worker-go
%> cd $GOPATH/src/ConSol/mod-gearman-worker-go
%> make
Windows Builds

Windows builds, for example a send_gearman.exe can be created by cloning the repository and running:

# 64bit windows builds
%> make build-windows-amd64

# 32bit windows builds
%> make build-windows-i386

Documentation

Index

Constants

View Source
const (
	LogLevelInfo   = 0
	LogLevelDebug  = 1
	LogLevelTrace  = 2
	LogLevelTrace2 = 3
)

define the available log level

View Source
const (
	// DefaultConnectionTimeout sets the default connection timeout for tcp connections
	DefaultConnectionTimeout = 30

	// UtilizationWatermarkLow sets the lower mark when deciding if worker should be reduced
	UtilizationWatermarkLow = 90
)
View Source
const (
	// VERSION contains the actual lmd version
	VERSION = "1.3.9"

	// ExitCodeError is used for erroneous exits
	ExitCodeError = 2

	// ExitCodeUnknown is used for unknown exits
	ExitCodeUnknown = 3

	// ConnectionRetryInterval sets the number seconds in between connection retries
	ConnectionRetryInterval = 3

	// OpenFilesBase sets the approximate number of open files excluded open files from worker
	OpenFilesBase = 50

	// OpenFilesPerWorker sets the expected number of file handles per worker (1 gearman connection, 2 fifo pipes for stderr/stdout, one on /dev/null, one sparse)
	OpenFilesPerWorker = 5

	// OpenFilesExtraPercent adds 30% safety level when calculating required open files
	OpenFilesExtraPercent = 1.2

	// ResultServerWorker sets the number of result worker
	ResultServerWorker = 10

	// ResultServerQueueSize sets the queue size for results
	ResultServerQueueSize = 1000

	// BlockProfileRateInterval sets the profiling interval when started with -profile
	BlockProfileRateInterval = 10
)
View Source
const EncryptionBlockSize = 16
View Source
const (
	// EncryptionKeySize defines the exact size of the encryption key
	EncryptionKeySize = 32
)
View Source
const NegateDefaultTimeout = 11

NegateDefaultTimeout sets the default timeout if negate is used

View Source
const ServiceAnswerSize = 4

Variables

View Source
var LogFormat string

LogFormat sets the log format

Functions

func ParseNegate added in v1.3.3

func ParseNegate(com *command)

func Sendgearman

func Sendgearman(build string)

Sendgearman starts the mod_gearman_worker program

func Worker

func Worker(build string)

Worker starts the mod_gearman_worker program

Types

type CommandExecType added in v1.3.3

type CommandExecType int

CommandExecType is used to set the execution path

const (
	// Shell uses /bin/sh
	Shell CommandExecType = iota

	// Exec uses exec without a shell
	Exec

	// EPN is the embedded perl interpreter
	EPN

	// Internal is for internal checks
	Internal
)

type EPNCacheItem added in v1.3.3

type EPNCacheItem struct {
	Mtime int64
	EPN   bool
}

type EPNDaemon added in v1.3.3

type EPNDaemon struct {
	Lock   sync.RWMutex
	Cmd    *exec.Cmd
	Socket string
	Pid    int
}

func (*EPNDaemon) Stop added in v1.3.3

func (d *EPNDaemon) Stop(gracefulSeconds int64)

type InternalCheck added in v1.3.4

type InternalCheck interface {
	Check(ctx context.Context, output *bytes.Buffer, args []string) int
}

type InternalCheckDummy added in v1.3.4

type InternalCheckDummy struct{}

func (*InternalCheckDummy) Check added in v1.3.4

func (chk *InternalCheckDummy) Check(_ context.Context, output *bytes.Buffer, args []string) (rc int)

type InternalCheckNSCWeb added in v1.3.4

type InternalCheckNSCWeb struct{}

func (*InternalCheckNSCWeb) Check added in v1.3.4

func (chk *InternalCheckNSCWeb) Check(ctx context.Context, output *bytes.Buffer, args []string) int

type MainStateType

type MainStateType int

MainStateType is used to set different states of the main loop

const (
	// Reload flag if used after a sighup
	Reload MainStateType = iota

	// Shutdown is used when sigint received
	Shutdown

	// ShutdownGraceFully is used when sigterm received
	ShutdownGraceFully

	// Resume is used when signal does not change main state
	Resume
)

type Negate added in v1.3.3

type Negate struct {
	Timeout        int
	TimeoutResult  string
	OKStatus       string
	WarningStatus  string
	CriticalStatus string
	UnknownStatus  string
	Substitute     bool
}

func NewNegate added in v1.3.3

func NewNegate() *Negate

func (*Negate) Apply added in v1.3.3

func (n *Negate) Apply(result *answer)

func (*Negate) ApplyNewCode added in v1.3.3

func (n *Negate) ApplyNewCode(result *answer, from string, to string)

func (*Negate) ConvertStatusNumber added in v1.3.3

func (n *Negate) ConvertStatusNumber(arg string) string

func (*Negate) DefineFlags added in v1.3.3

func (n *Negate) DefineFlags(fs *flag.FlagSet)

func (*Negate) Parse added in v1.3.3

func (n *Negate) Parse(args []string) error

func (*Negate) SetTimeoutReturnCode added in v1.3.3

func (n *Negate) SetTimeoutReturnCode(result *answer)

func (*Negate) Status2Int added in v1.3.3

func (n *Negate) Status2Int(status string) int

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL