Creating Custom Low Level Discovery Rules - Part 2
Video Lecture
Create A New Template
It is now time to create a template that uses the new service.discovery UserParameter as the key.
Configuration --> Templates --> Create Template
Key | Value |
---|---|
Name | Linux Services by Sean |
groups | Linux Servers |
Press ADD
Create A New Application
Select the Applications tab, and press the 'Create Application' button.
Name it anything you want. services is a good name.
Create A New Discovery Rule
Go into it's Discovery Rules tab and press the 'Create Discovery Rule' button.
Key | Value |
---|---|
Name | Service Discovery |
Type | Zabbix Agent |
key | service.discovery |
Update Interval | 1h |
Press ADD
Create Prototypes
Using the other 2 UserParameters from the last lesson, we can create prototypes that will use them.
Test that the two extra UserParameters work.
1 | zabbix_agentd -t service.isactive[zabbix-agent] |
1 = Yes and 0 = No
1 | zabbix_agentd -t service.activatedtime[zabbix-agent] |
Each time the service is restarted, the activatedtime is reset to now.
Item Prototypes
Now to create some item prototypes.
Go to the 'Item Prototypes' tab and press the 'Create Item Prototype' button.
Is Service Active
This item will be used to check if a service status is active or not.
Key | Value |
---|---|
Name | Service Active : {#SERVICE} |
Type | Zabbix Agent |
Key | service.isactive["{#SERVICE}"] |
Type of info | Numeric (unsigned) |
Update Interval | 1m |
Applications | services (this is the application name you created a few moments ago) |
Create Enabled | Unticked (optional) |
Press ADD
Service Activated Time
This item will be used to detect when a service is restarted since the ActiveEnterTimestampMonotonic property returned by the systemctl command will have changed.
Key | Value |
---|---|
Name | Service Activated Time : {#SERVICE} |
Type | Zabbix Agent |
Key | service.activatedtime["{#SERVICE}"] |
Type of info | Numeric (unsigned) |
Update Interval | 1m |
Applications | services (this is the application name you created a few moments ago) |
Create Enabled | Unticked (optional) |
Press ADD
Trigger Prototypes
Now to create a trigger prototype that monitors the new items that will bre created.
Go to the 'Trigger Prototypes' tab and press the 'Create Item Prototype' button.
Trigger Service Not Active
This trigger will fire when the service is not active.
Key | Value |
---|---|
Name | Service Not Active : {#SERVICE} |
Severity | Disaster (Optional) |
Expression | {Linux Services by Sean:service.isactive["{#SERVICE}"].last()}=0 |
OK event generation | Expression |
Create Enabled | Unticked (optional) |
Trigger Service Restarted
This trigger will fire when the service.activatedtime for a service changes.
Key | Value |
---|---|
Name | Service Restarted : {#SERVICE} |
Severity | Warning (Optional) |
Expression | {Linux Services by Sean:service.activatedtime["{#SERVICE}"].diff()}=1 |
OK event generation | Expression |
Create Enabled | Unticked (optional) |
Add The Template To A Host
Go into Configuration --> Hosts, select your host, and add the Service Discovery template.
Now select the hosts 'Discovery Rules' tab, select the new Service Discovery rule and run the 'Execute Now' option.
If all is well, this will generate the items and triggers for the host and there will be no errors.
You can inspect the new data using the Monitoring --> Latest Data tab and also see the Host items by filtering for the application name set earlier.