win_services

package
v1.21.0 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2021 License: MIT Imports: 0 Imported by: 11

README

Windows Services Input Plugin

Reports information about Windows service status.

Monitoring some services may require running Telegraf with administrator privileges.

Configuration

[[inputs.win_services]]
  ## Names of the services to monitor. Leave empty to monitor all the available services on the host. Globs accepted. Case sensitive.
  service_names = [
    "LanmanServer",
    "TermService",
    "Win*",
  ]
  excluded_service_names = ['WinRM'] # optional, list of service names to exclude
Measurements & Fields
  • win_services
    • state : integer
    • startup_mode : integer

The state field can have the following values:

  • 1 - stopped
  • 2 - start pending
  • 3 - stop pending
  • 4 - running
  • 5 - continue pending
  • 6 - pause pending
  • 7 - paused

The startup_mode field can have the following values:

  • 0 - boot start
  • 1 - system start
  • 2 - auto start
  • 3 - demand start
  • 4 - disabled
Tags
  • All measurements have the following tags:
    • service_name
    • display_name
Example Output
win_services,host=WIN2008R2H401,display_name=Server,service_name=LanmanServer state=4i,startup_mode=2i 1500040669000000000
win_services,display_name=Remote\ Desktop\ Services,service_name=TermService,host=WIN2008R2H401 state=1i,startup_mode=3i 1500040669000000000
TICK Scripts

A sample TICK script for a notification about a not running service. It sends a notification whenever any service changes its state to be not running and when it changes that state back to running. The notification is sent via an HTTP POST call.

stream
    |from()
        .database('telegraf')
        .retentionPolicy('autogen')
        .measurement('win_services')
        .groupBy('host','service_name')
    |alert()
        .crit(lambda: "state" != 4)
        .stateChangesOnly()
        .message('Service {{ index .Tags "service_name" }} on Host {{ index .Tags "host" }} is in state {{ index .Fields "state" }} ')
        .post('http://localhost:666/alert/service')

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsPermission

func IsPermission(err error) bool

Types

type ManagerProvider

type ManagerProvider interface {
	Connect() (WinServiceManager, error)
}

ManagerProvider sets interface for acquiring manager instance, like mgr.Mgr

type MgProvider

type MgProvider struct {
}

MgProvider is an implementation of WinServiceManagerProvider interface returning WinSvcMgr

func (*MgProvider) Connect

func (rmr *MgProvider) Connect() (WinServiceManager, error)

type ServiceErr

type ServiceErr struct {
	Message string
	Service string
	Err     error
}

func (*ServiceErr) Error

func (e *ServiceErr) Error() string

type ServiceInfo

type ServiceInfo struct {
	ServiceName string
	DisplayName string
	State       int
	StartUpMode int
}

type WinService

type WinService interface {
	Close() error
	Config() (mgr.Config, error)
	Query() (svc.Status, error)
}

WinService provides interface for svc.Service

type WinServiceManager

type WinServiceManager interface {
	Disconnect() error
	OpenService(name string) (WinService, error)
	ListServices() ([]string, error)
}

WinServiceManager provides interface for mgr.Mgr

type WinServices

type WinServices struct {
	Log telegraf.Logger

	ServiceNames         []string `toml:"service_names"`
	ServiceNamesExcluded []string `toml:"excluded_service_names"`
	// contains filtered or unexported fields
}

WinServices is an implementation if telegraf.Input interface, providing info about Windows Services

func (*WinServices) Description

func (m *WinServices) Description() string

func (*WinServices) Gather

func (m *WinServices) Gather(acc telegraf.Accumulator) error

func (*WinServices) Init added in v1.17.0

func (m *WinServices) Init() error

func (*WinServices) SampleConfig

func (m *WinServices) SampleConfig() string

type WinSvcMgr

type WinSvcMgr struct {
	// contains filtered or unexported fields
}

WinSvcMgr is wrapper for mgr.Mgr implementing WinServiceManager interface

func (*WinSvcMgr) Disconnect

func (m *WinSvcMgr) Disconnect() error

func (*WinSvcMgr) ListServices

func (m *WinSvcMgr) ListServices() ([]string, error)

func (*WinSvcMgr) OpenService

func (m *WinSvcMgr) OpenService(name string) (WinService, error)

Jump to

Keyboard shortcuts

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