port

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2022 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Host is the host to monitor
	Host string `json:"host"`
	// Port is the Port to monitor
	Port uint64 `json:"port"`
	// Protocol is the protocol to use
	Protocol NetworkProtocol `json:"protocol"`
}

Config is the config for the Port monitor

type JSONConfig

type JSONConfig struct {
	monitors.JSONBaseConfig
	Host     string          `json:"host"`
	Port     uint64          `json:"port"`
	Protocol NetworkProtocol `json:"protocol"`
}

JSONConfig is the config for the Ping monitor

type Monitor

type Monitor struct {
	monitors.BaseMonitor
	Config *Config
}

Monitor is a monitor that monitors ports it implements the Monitor interface

func (*Monitor) CheckPort

func (m *Monitor) CheckPort() error

CheckPort checks if a port is open

func (*Monitor) GetConfig

func (m *Monitor) GetConfig() interface{}

GetConfig returns the config for the monitor

func (*Monitor) GetNotificationBody

func (m *Monitor) GetNotificationBody(state *monitors.State) *monitors.NotificationBody

GetNotificationBody returns the notification body

func (*Monitor) Init

func (m *Monitor) Init() error

Init initializes the monitor

func (*Monitor) Process

func (m *Monitor) Process() error

Process runs the monitor

func (*Monitor) SetConfig

func (m *Monitor) SetConfig(config interface{}) error

SetConfig sets the config for the monitor

type NetworkProtocol

type NetworkProtocol string

NetworkProtocol returns the network protocol

const (
	// TCP is the tcp protocol
	TCP NetworkProtocol = "tcp"
	// UDP is the udp protocol
	UDP NetworkProtocol = "udp"
)

func (NetworkProtocol) GetProtocol

func (n NetworkProtocol) GetProtocol(p string) NetworkProtocol

GetProtocol returns the protocol Defaults to tcp

func (NetworkProtocol) String

func (n NetworkProtocol) String() string

String returns the string representation of the protocol

Jump to

Keyboard shortcuts

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