MAGIC OF THE NEW ZABBIX AGENT

43
MAGIC OF THE NEW ZABBIX AGENT

Transcript of MAGIC OF THE NEW ZABBIX AGENT

Page 1: MAGIC OF THE NEW ZABBIX AGENT

MAGIC OF THENEW ZABBIX AGENT

Page 2: MAGIC OF THE NEW ZABBIX AGENT

MAGIC OF THENEW ZABBIX AGENT

WHAT IS ZABBIX AGENT?

Page 3: MAGIC OF THE NEW ZABBIX AGENT

3

Zabbix Agent

• Is a daemon, that gathers metrics locally from the OS

• Available for UNIX-like and Windows operating systems

• Low resource consumption.

• Can customize time intervals with a help of Flexible/Scheduled intervals option

Page 4: MAGIC OF THE NEW ZABBIX AGENT

4

What Zabbix Agent can gather?

• Disk statistics, NIC statistics…

• Memory consumption, CPU usage…

• Generic metrics like hostname or OS release

• Listening port state

Page 5: MAGIC OF THE NEW ZABBIX AGENT

5

What Zabbix Agent can gather?

• Read logs or simple file contents

• Read Windows event logs

• Gather stats from a friendly Zabbix Server/Proxy

• and more (Read The Lovely Manual!)

Page 6: MAGIC OF THE NEW ZABBIX AGENT

6

Still not enough? Hungry for more?

Can be extended using

Custom modules

User Parameters

system.run[*]

Page 7: MAGIC OF THE NEW ZABBIX AGENT

7

Custom modules – coding jedies!

• As fast as native Zabbix Agent metrics

• But learn how to C

main {

printf("How to C learn, young padawan!")

}

Page 8: MAGIC OF THE NEW ZABBIX AGENT

8

User Parameters – scripting ninja!

• Can run any command respecting Zabbix Agent user privileges

• Runs as fork

• Better to be Active

Page 9: MAGIC OF THE NEW ZABBIX AGENT

9

User Parameters

UserParameter=awesome.command, sleep 45 && echo "I'm a scripting genius!"

Page 10: MAGIC OF THE NEW ZABBIX AGENT

10

system.run[*] – simple yet powerful!

• No need to worry if UserParameter line or if file had been deployed to the config

• No need to restart Zabbix Agent if you like to change command

• "With great power comes great responsibility"

Page 11: MAGIC OF THE NEW ZABBIX AGENT

11

system.run[*]

• Server=0.0.0.0/0

• EnableRemoteCommands=1

• LogRemoteCommands=0

• User=root

• AllowRoot=1

• shell> iptables –F

• shell> systemctl stop firewalld

• shell> setenforce 0

Page 12: MAGIC OF THE NEW ZABBIX AGENT

12

system.run[*]

Page 13: MAGIC OF THE NEW ZABBIX AGENT

MAGIC OF THENEW ZABBIX AGENT

CURRENT CHALLENGES

Page 14: MAGIC OF THE NEW ZABBIX AGENT

14

Limitations of current Zabbix Agent

• Lack of ability to receive 3rd party traps

• No Scheduled/Custom intervals for Active checks

• One active checks process for each Zabbix Server/Proxy record.

• Not everybody wants to learn/knows C language

Page 15: MAGIC OF THE NEW ZABBIX AGENT

MAGIC OF THENEW ZABBIX AGENT

MEET THE BRAND NEW AGENT

Page 16: MAGIC OF THE NEW ZABBIX AGENT

16

Page 17: MAGIC OF THE NEW ZABBIX AGENT

17

Yes, NEW!

• It’s not C anymore

• It’s Go!

Page 18: MAGIC OF THE NEW ZABBIX AGENT

18

Why Go?

• Compile into a single binary and deploy!*• In our days Go is one of the most popular

development languages• A little bit easier than C.

*dependency limitations may apply in certain variations

Page 19: MAGIC OF THE NEW ZABBIX AGENT

19

Limitless Zabbix Agent 2

• Scheduled/Flexible intervals for both types of checks

• Support of older .conf file

• Multiple parallel log file reading

• systemd monitoring out of the box!

• Timeouts implemented on plugin level

Page 20: MAGIC OF THE NEW ZABBIX AGENT

20

Components

• Connector:

• Manages communication with server

• Item configuration• Metrics buffer• 1 connector per 1 ServerActive

Page 21: MAGIC OF THE NEW ZABBIX AGENT

21

Components

• Listener• Accepts passive requests and forwards them to

scheduler

Page 22: MAGIC OF THE NEW ZABBIX AGENT

22

Components

• Scheduler• Manages the task queue respecting schedule and

task concurrency• Only one Scheduler per agent

Page 23: MAGIC OF THE NEW ZABBIX AGENT

23

Passive checks

Page 24: MAGIC OF THE NEW ZABBIX AGENT

24

Active checks

Page 25: MAGIC OF THE NEW ZABBIX AGENT

25

Queue the task

• Two level queue:• Each plugin has a queue of the requested check• Scheduler has a queue of active plugins

Page 26: MAGIC OF THE NEW ZABBIX AGENT

26

Queue the task

• When a task cannot be executed because of concurrency limits the plugin is taken from scheduler queue and returned only when next task can be executed.

Page 27: MAGIC OF THE NEW ZABBIX AGENT

MAGIC OF THENEW ZABBIX AGENT

IT’S ALL ABOUT THE PLUGINS

Page 28: MAGIC OF THE NEW ZABBIX AGENT

29

brand new means BRAND NEW!

• It’s not just “yet another Zabbix Agent”!

• It’s the whole new platform!

Page 29: MAGIC OF THE NEW ZABBIX AGENT

30

Everyone is a Dev right now

• Writing your own plugins for Zabbix Agent never been that easy.

• Multiple plugin interfaces for different types of tasks.

Page 30: MAGIC OF THE NEW ZABBIX AGENT

31

Framework for every purpose.

• Exporter

• Runner

• Watcher

• Collector

Page 31: MAGIC OF THE NEW ZABBIX AGENT

32

Exporter

• Performs poll and returns:• nothing• an error• single/multiple values

Page 32: MAGIC OF THE NEW ZABBIX AGENT

33

Watcher

• Allows to implement your own gathering method. • Listen to a specific port. • Good for supporting different trap-based

communication methods

Page 33: MAGIC OF THE NEW ZABBIX AGENT

34

Collector

• Use it when you need to gather data on a regular basis. For example, CPU related metrics.

Page 34: MAGIC OF THE NEW ZABBIX AGENT

35

Runner

• For example plugin could start/stop some background goroutine by implementing Runner interface.

Page 35: MAGIC OF THE NEW ZABBIX AGENT

36

Just Go with it

1.Write the codereturn string("Hello World!")

2. Register the metricplugin.RegisterMetrics(&impl, "HelloWorld","helloworld", "My hello to the World!")

3. Place your plugin into the source folder

4. Add your plugin to the list_ "zabbix/plugins/helloworld"

5. Compile./configure --enable-agent2 && make install

6. Run and reuse your old .conf file

Page 36: MAGIC OF THE NEW ZABBIX AGENT

37

package helloworld

import (

"zabbix/pkg/plugin"

)

type Plugin struct {

plugin.Base

}

var impl Plugin

func (p *Plugin) Export(key string, params []string, ctx plugin.ContextProvider) (result interface{}, err error) {

return string("Hello World!"),nil

}

func init() {

plugin.RegisterMetrics(&impl, "helloworld", "helloworld", "My hello to the World!")

}

Page 37: MAGIC OF THE NEW ZABBIX AGENT

38

Availability

• Named as Zabbix Agent 2• 4.4 – experimental, 5.0 – production ready• Currently only Linux-like systems. • Zabbix Agent 2 for Windows – already in development!• Documentation - coming soon. Checkout our git!

https://git.zabbix.com

Page 38: MAGIC OF THE NEW ZABBIX AGENT

MAGIC OF THENEW ZABBIX AGENT

TUTIN’, ROOTIN’, PLUGIN BOOTIN’

Page 39: MAGIC OF THE NEW ZABBIX AGENT

40

Who? What? Where?

• Date: 11.10.2019

• Time:• Session 1: 8:30 AM• Session 2: 9:30 AM

Page 40: MAGIC OF THE NEW ZABBIX AGENT

41

What should I bring?

• Yourself ;)

• Awesome mood is a must!

• Mad skils are welcome but not mandatory

• Laptop with Zabbix Appliance

Page 41: MAGIC OF THE NEW ZABBIX AGENT

42

Our plan

•We will not learn Go, sorry :D

•To build a very simple yet functional Goplugin for brand new Zabbix Agent!

Page 42: MAGIC OF THE NEW ZABBIX AGENT

43

Our goal

•Make it work!

•Have fun!

Page 43: MAGIC OF THE NEW ZABBIX AGENT

THANK YOU!