You are on page 1of 75

The Enterprise class Monitoring Solution for Everyone

www.zabbix.com

Zabbix 5.0
Certified Specialist course

LAB Manual Day 4


LAB 21
Inventory collection
INVENTORY COLLECTION
Go to Configuration -> Templates
Create a new template
• Name: Template Basic module system info
• Group: Training/Templates
Create new item on the template
Fill required fields:
• Name: System OS
• Type: Zabbix agent
• Key: system.sw.os[name]
• Type of information: Character
• Update interval: 1h
• New application: Operational System
• Populates host invent...:OS

Press Add to create item

ZABBIX 5.0 Lab Manual 3


INVENTORY COLLECTION
Create another item on Template Basic module system info
Fill required fields:
• Name: System hostname
• Type: Zabbix agent
• Key: system.hostname
• Type of information: Character
• Update interval: 1h
• New application: Operational System
• Populates host invent...:Name

Press Add to create item

Link Template Basic module system info


to Template Basic

ZABBIX 5.0 Lab Manual 4


INVENTORY COLLECTION
Select all Training-VM hosts and press Mass update

Set Inventory mode to Automatic and change location field

Press Update

ZABBIX 5.0 Lab Manual 5


INVENTORY COLLECTION
Click on Items for one of the Training-VM hosts
Adjust filters
• Host groups: Training/Servers
• Application: Operational System
Select all items and press Execute now

ZABBIX 5.0 Lab Manual 6


INVENTORY COLLECTION
Go to Monitoring -> Hosts
Click on the host name for Training-VM-XX host and select Inventory

Select Details tab

ZABBIX 5.0 Lab Manual 7


CONGRATULATIONS!
Inventory Lab is complete !
LAB 22
Actions
ACTIONS
Go to Administration -> Media Types and Press Create media type

It is possible to customize existing Email media, but for training purposes a new media will
be created
Zabbix 5.0 supports a lot of media types out of box.

ZABBIX 5.0 Lab Manual 10


ACTIONS
Fill required fields
• Name: Training email
• Type: Email
• SMTP server: training.lan
• SMTP server port: 25
• SMTP helo: training.lan
• SMTP email: trainingXX@training.lan
• Message format: HTML

Switch to Message templates tab

ZABBIX 5.0 Lab Manual 11


ACTIONS
Click Add to add message type
Fill required fields:
• Message type: Problem
• Subject: Problem: {EVENT.NAME}
• Message
<b>Problem started</b> at {EVENT.TIME} on {EVENT.DATE}<br>
<b>Problem name:</b> {EVENT.NAME}<br>
<b>Host:</b> {HOST.NAME}<br>
<b>Severity:</b> {EVENT.SEVERITY}<br>
<b>Operational data:</b> {EVENT.OPDATA}<br>
<b>Original problem ID:</b> {EVENT.ID}<br>
<b>Location:</b> {INVENTORY.LOCATION}<br>
<b>Operational System:</b> {INVENTORY.OS}

In Zabbix 5.0 you can define your own message formats using frontend
HTML or plain text format can be used for messages

Press Add on Message template form

ZABBIX 5.0 Lab Manual 12


ACTIONS
Click Add to add another message type
Fill required fields:
• Message type: Problem recovery
• Subject: Resolved: {EVENT.NAME}
• Message
<b>Problem has been resolved</b>
at {EVENT.RECOVERY.TIME} on {EVENT.RECOVERY.DATE}<br>
<b>Problem name:</b> {EVENT.NAME}<br>
<b>Problem duration:</b> {EVENT.DURATION}<br>
<b>Host:</b> {HOST.NAME}<br>
<b>Severity:</b> {EVENT.SEVERITY}<br>
<b>Location:</b> {INVENTORY.LOCATION}<br>
<b>Operational System:</b> {INVENTORY.OS}

Press Add on Message template form


You must define message templates for every message type you will be using !

Press Add on Media types form


13
ZABBIX 5.0 Lab Manual
ACTIONS
Go to User settings
Select Media tab and click on Add

Fill required fields:


• Type: Training email
• Send to: your email address
• When active: 1-5,09:00-18:00
• Use if severity: Uncheck Informational severity
Press Add on Media form

Press Update on User profile form

ZABBIX 5.0 Lab Manual 14


ACTIONS
Go to Configuration -> Actions and press Create Action

Trigger actions needs to be selected as action type !


Type Report Training hosts problems in the Name field

Click on Add to add new condition

ZABBIX 5.0 Lab Manual 15


ACTIONS
Create condition by clicking on Add
• Type: Host group
• Operator: Equals
• Host groups: Training/Servers
• Press Add on New condition form

Create another condition


• Type: Trigger severity
• Operator: is greater than or equals
• Severity: Warning
• Press Add on New condition form

Two conditions are now defined


• Type of calculation must be A and B

ZABBIX 5.0 Lab Manual 16


ACTIONS
Switch to Operations tab
Click on Add for Operations

Fill required fields


• Operator type: Send message
• Steps: 1-1
• Step duration: 1m
• Send to Users
• Click on Add and select student-XX
• Send only to: Training email

Press Add on Operation details form

ZABBIX 5.0 Lab Manual 17


ACTIONS
Click on Add for to add another step

Fill required fields


• Operator type: Remote Command
• Steps: 2-2
• Step duration: 0
• Target list: Check current host
• Type: Custom script
• Execute on: Zabbix server
• Commands: echo {EVENT.TIME} {HOST.NAME} {EVENT.NAME} >> /var/log/zabbix/zabbix_problems.log
• Conditions: Click Add and fill form
• Type: Event acknowledged
• Operator: Equals
• Acknowledged: No
• Press Add on New condition form

Press Add on Operation details form


ZABBIX 5.0 Lab Manual 18
ACTIONS
Click on Add on Recover operations section to add Recovery operation

Fill required fields


• Operation type: Notify all involved
• Custom message: Unchecked
• Press Add on Operation details form

It is recommended to create recovery operations on actions to inform that problem is solved

ZABBIX 5.0 Lab Manual 19


ACTIONS
Now you have Action for Training/Servers host group with 2 steps and recovery operation

Click Add to create action

ZABBIX 5.0 Lab Manual 20


ACTIONS
Open SSH console and generate high CPU load

# cat /dev/urandom | md5sum

Go to Monitoring -> Problems


Wait for the problem to appear and look at the Actions column
In a few minutes two actions will be executed
• Training email
• Remote command

Press Ctrl + C in SSH console to stop CPU load simulation

ZABBIX 5.0 Lab Manual 21


ACTIONS
Go to Reports -> Action log
All Actions are displayed here

Remote command created log file, you can check it


# cat /var/log/zabbix/zabbix_problems.log

12:08:49 Training-VM-XX CPU Load is very high on Training-VM-XX


12:22:19 Training-VM-XX CPU Load is high on Training-VM-XX

ZABBIX 5.0 Lab Manual 22


CONGRATULATIONS!
Actions Lab is complete!
LAB 23
Internal Actions
INTERNAL ACTIONS
First you need to define message template for internal actions
Go to Administration -> Media types

You can use filters to find media types faster


Click on Training email

ZABBIX 5.0 Lab Manual 25


INTERNAL ACTIONS
Click on Add to create new message template

Fill required fields


• Message type: Internal problem
• Subject: {ITEM.STATE}: {HOST.NAME}:{ITEM.NAME}
• Message:
Host: {HOST.NAME}
Item: {ITEM.NAME}
Key: {ITEM.KEY}
State: {ITEM.STATE}

Press Add

ZABBIX 5.0 Lab Manual 26


INTERNAL ACTIONS
Add another template for recovery
Fill required fields
• Message type: Internal problem recovery
• Subject: {ITEM.STATE}: {HOST.NAME}:{ITEM.NAME}
• Message:
Host: {HOST.NAME}
Item: {ITEM.NAME}
Key: {ITEM.KEY}
State: {ITEM.STATE}

Press Add

Press Update on Media types page to update media types

ZABBIX 5.0 Lab Manual 27


INTERNAL ACTIONS
Go to Configuration -> Actions and choose Internal actions

It is very important to choose right action type when creating action !


Press Create action

ZABBIX 5.0 Lab Manual 28


INTERNAL ACTIONS
Fill the Name field: Report not supported SSH items

Click Add to add condition


• Type: Application
• Operator: equals
• Value: SSH checks
• Press Add on New condition form
Click Add to add second condition
• Type: Event type
• Operator: equals
• Value: Item in "not supported" state
• Press Add on New condition form

ZABBIX 5.0 Lab Manual 29


INTERNAL ACTIONS
Switch to Operations tab

Add Operation
• Send to Users: student-XX
• Send only to: Training email

Add Recovery Operation


• Operation type: Notify all involved

ZABBIX 5.0 Lab Manual 30


INTERNAL ACTIONS
Press Add to create action

Internal action is created

ZABBIX 5.0 Lab Manual 31


INTERNAL ACTIONS
Open SSH console and change password used for SSH checks to NEWremoteXX

# passwd monitor

Changing password for user monitor.


New password: NEWremoteXX
Retype new password: NEWremoteXX
passwd: all authentication tokens updated successfully.

Go to Configuration -> Hosts and look at ssh items for Training-VM-XX server
Both SSH items will turn to unsupported state in 1 minute (click on i to see details)
You can select item and press Execute now to do it faster

ZABBIX 5.0 Lab Manual 32


INTERNAL ACTIONS
Go to Reports -> Action log

Emails are sent for both SSH items


Open SSH console and restore password
# passwd monitor

Changing password for user monitor.


New password: sshremoteXX
Retype new password: sshremoteXX
passwd: all authentication tokens updated successfully.

ZABBIX 5.0 Lab Manual 33


INTERNAL ACTIONS
Go to Configuration -> Hosts and open Items for Training-VM-XX host
Select both SSH items and press Execute now

The items will become supported

ZABBIX 5.0 Lab Manual 34


INTERNAL ACTIONS
Go to Configuration -> Hosts and open Items for Training-VM-XX hosts
Emails are also sent about items returning to normal status

ZABBIX 5.0 Lab Manual 35


CONGRATULATIONS!
Internal actions Lab is complete!
LAB 24
Custom media types
INTERNAL ACTIONS
Open SSH console and create a new alert script
# vi /usr/lib/zabbix/alertscripts/logfile.sh

filename=$1
message=$2
now=$(date +"%D %T")
echo "$now $message" >> "/var/log/zabbix/$filename.log"

Make the file executable


# chmod +x /usr/lib/zabbix/alertscripts/logfile.sh

Go to Administration -> Media types and create a new media type


• Name: Write to log file
• Type: Script
• Script name: logfile.sh
• Script parameters:
• {ALERT.SENDTO}
• {ALERT.MESSAGE}

ZABBIX 5.0 Lab Manual 38


INTERNAL ACTIONS
Switch to Message templates tab
Add problem message type
• Message type: Problem
• Message: Host: {HOST.NAME} Problem: {EVENT.NAME}

Add problem recovery message type


• Message type: Problem recovery
• Message: Host: {HOST.NAME} Resolved: {EVENT.NAME}

Press Add to create new media type


ZABBIX 5.0 Lab Manual 39
INTERNAL ACTIONS
Go to User profile and switch to Media tab
Click Add to add another media

Fill required fields:


• Type: Write to log file
• Send to: student-xx
Press Add on Media form

Press Update on User profile form

ZABBIX 5.0 Lab Manual 40


INTERNAL ACTIONS
Go to Configuration -> Actions and click on Report training host problems action

Switch to Operations tab and edit Run remote commands on current host step

ZABBIX 5.0 Lab Manual 41


INTERNAL ACTIONS
Change Operation type to Send message for step 2
• Click Edit
• Change Operation type to Send message
Fill required fields
• Send to users: student-xx
• Send only to: Write to log file
Press Update on Operation details form

Press Update on Action form


Open SSH console and generate CPU load

# cat /dev/urandom | md5sum

ZABBIX 5.0 Lab Manual 42


INTERNAL ACTIONS
Go to Reports -> Action log
After one minute Action with type Write to log file must succeed

Stop generating CPU load (press CTRL+C on SSH console}


Look at log file
# cat /var/log/zabbix/student-xx.log

06/02/20 15:44:22 Host: Training-VM-XX Problem: CPU Load is high on Training-VM-XX


06/02/20 15:45:52 Host: Training-VM-XX Resolved: CPU Load is high on Training-VM-XX

The recovery message may appear after some time, recheck the log file

ZABBIX 5.0 Lab Manual 43


CONGRATULATIONS!
Custom media types Lab is complete
LAB 25
Maintenance
MAINTENANCE
Go to Configuration -> Maintenance and press Create maintenance period

Fill required fields


• Name: Training maintenance
• Maintenance type: With data collection
• Active since: Today at 00:00
• Active till: 2025-01-01 at 00:00

Switch to Periods tab

ZABBIX 5.0 Lab Manual 46


MAINTENANCE
Click on Add next to period type
Fill required fields in popup form
• Period type: One time only
• Date: Now + 5 minutes
• Maintenance period length: 0 Days 1 Hours 0 Minutes

Press Add on Maintenance period popup form


Switch to Hosts and groups tab
ZABBIX 5.0 Lab Manual 47
MAINTENANCE
Enter Training-VM-XX into Hosts field
You can click select and choose host from the list, or input host name directly in the field

Press Add to create maintenance period


Maintenance periods must be created before problem actually happens !

ZABBIX 5.0 Lab Manual 48


MAINTENANCE
Maintenance period is created

Open SSH console and generate a problem by using Zabbix sender


Zabbix sender is another simple way how to test trigger behavior
# zabbix_sender -z student-xx -s Training-VM-XX -k persons -o 1

Response from "student-xx:10051": "processed: 1; failed: 0; total: 1; seconds spent: 0.000135"


sent: 1; skipped: 0; total: 1

Go to Monitoring -> Problems

The problem is not displayed ! Is it now not detected at all ?

ZABBIX 5.0 Lab Manual 49


MAINTENANCE
The problem is hidden because it is suppressed !
Click on filter for Problems page and check Show suppressed problems
Press Apply

Notice that yellow wrench icon is displayed next to the host name. This means that this
host is in maintenance and problem is suppressed

ZABBIX 5.0 Lab Manual 50


MAINTENANCE
Ask on of your neighbors to send value 1 to his host name on your server
# zabbix_sender -z student-xx -s Training-VM-XY -k persons -o 1

Response from "student-xy:10051": "processed: 1; failed: 0; total: 1; seconds spent: 0.000135"


sent: 1; skipped: 0; total: 1

This command must be executed from host student-xy and sent to your server to host named
Training-VM-XY, otherwise it will be not accepted
The problem on another host is not in maintenance mode

Go to Monitoring -> Hosts


The maintenance symbol when host is in
maintenance mode is displayed in multiple places in
Zabbix frontend

ZABBIX 5.0 Lab Manual 51


CONGRATULATIONS!
Maintenance Lab is complete!
LAB 26
Business level monitoring
BUSINESS LEVEL MONITORING
Go to Configuration -> Services
Click Add child

Enter required information


• Name: Zabbix training SLA
• Status calculation algorithm: Problem, if at least one child has a problem
• Calculate SLA, acceptable SLA (in %): Check 95

ZABBIX 5.0 Lab Manual 54


BUSINESS LEVEL MONITORING
Switch to Time tab
Enter New service time
• Period type: Uptime
• From: Monday Time 10:00
• Till: Monday Time 18:00

Define times for other working days the same way


• From: <day> Time 09:00
• Till: <day> Time 18:00
Repeat for every working day

ZABBIX 5.0 Lab Manual 55


BUSINESS LEVEL MONITORING
The working time for training is defined
Now define lunch breaks for every day (replace <day> with working days
• Period type: Downtime
• From: <day> Time 12:00
• Till <day> Time 13:00

Repeat for every working day

ZABBIX 5.0 Lab Manual 56


BUSINESS LEVEL MONITORING
The final schedule will look like this:

Press Add

ZABBIX 5.0 Lab Manual 57


BUSINESS LEVEL MONITORING
Click Add child for Zabbix training SLA

Fill required fields


• Name: Student-XX
• Trigger: Press Select

Press Add
ZABBIX 5.0 Lab Manual 58
BUSINESS LEVEL MONITORING
Select correct Host - Training-VM-XX
Select CPU Load is very high on Training-VM-XX

Press Add

ZABBIX 5.0 Lab Manual 59


BUSINESS LEVEL MONITORING
Click on small triangle to expand list

Repeat the same steps for Training-VM-XY and Training-VM-XZ hosts


• remember to choose correct host in trigger selection form !

Zabbix training SLA will fall down, if any of the SLA for student hosts will fall down

ZABBIX 5.0 Lab Manual 60


BUSINESS LEVEL MONITORING
Go to Monitoring -> Services
Generate high CPU load on your machine

# cat /dev/urandom | md5sum

When CPU usage will be detected on one of the hosts, SLA for Zabbix training will start to
fall down

ZABBIX 5.0 Lab Manual 61


CONGRATULATIONS!
Business level monitoring Lab is complete !
LAB 27
Low Level Discovery
LOW LEVEL DISCOVERY
Link Template Module Linux filesystems by Zabbix agent to Training-VM-XX host

Press Update

Click on Discovery for Training-VM-XX host

ZABBIX 5.0 Lab Manual 64


LOW LEVEL DISCOVERY
Select Mounted filesystem discovery and press Execute now

Wait a few seconds and click on Items

Items and triggers for / filesystem are created automatically


Do not forget about configuration cache ! Items are created in database, and you need to reload
configuration cache or wait up to 1 minute before they will start collecting data

ZABBIX 5.0 Lab Manual 65


LOW LEVEL DISCOVERY
Data are also displayed in Latest data section for Training-VM-XX host

Now you have only one filesystem, but it is possible to add more
Open SSH console and issue command
# mkdir /zabbixlogs
# mount --bind /var/log/zabbix/ /zabbixlogs/
# mount -l | grep zabbix

/dev/vda1 on /zabbixlogs type xfs (rw,relatime,attr2,inode64,noquota)

This is a fake filesystem mounted only for training purposes !

ZABBIX 5.0 Lab Manual 66


LOW LEVEL DISCOVERY
Click on Discovery for Training-VM-XX host again
Select Mounted filesystem discovery and press Execute now

New filesystem will be discovered automatically in 1 hour, but we do not have so much time
Wait a few seconds and click on Items
New file system is discovered and monitored!

ZABBIX 5.0 Lab Manual 67


CONGRATULATIONS!
Low Level Discovery Lab is complete !
LAB 28
XML import / export
LOW LEVEL DISCOVERY
Go to Configuration -> Hosts
Select Training-VM-XX host and press Export

Host will be saved in downloads folder for your web browser


The file name will be zbx_export_hosts.xml

The file name is always zbx_export_hosts, hostname is defined inside XML file !

ZABBIX 5.0 Lab Manual 70


LOW LEVEL DISCOVERY
Open the file using text editor (like notepad)
Do not use MS WORD or other advanced text editors, they may add they own tags to the file and
break XML syntax
Change values for <host> and <name> fields

Change value for <dns> field

Save the zbx_export_hosts.xml file

ZABBIX 5.0 Lab Manual 71


LOW LEVEL DISCOVERY
Press Import on Configuration -> Hosts page

Press Choose file and browse the file

Press Import

ZABBIX 5.0 Lab Manual 72


LOW LEVEL DISCOVERY
Go to Configuration -> Hosts and search for the new host

Open configuration for Trainers Name VM host

Check that all hosts details including tags and macros are imported
ZABBIX 5.0 Lab Manual 73
CONGRATULATIONS!
XML import / export is complete !
The Enterprise class Monitoring Solution for Everyone
www.zabbix.com

Zabbix 5.0
Certified Specialist course

End of Day 4

You might also like