-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix trigger in Zabbix 4.0 LTS, add support to systemd 219 (CentOS 7) #37
base: master
Are you sure you want to change the base?
Conversation
I've tested this in systemd version 219. To be honest the script marked as "old" is also compatible with recent systemd versions, but I'm not bold enough to rewrite that. Again: this change does NOT change any already-in-use script.
The template of Zabbix version 4.0 LTS checks the wrong systemd status value. The value is supposed to be: - 1 if the service is running - 0 if the service is NOT running And in fact the template of version 5.0 checks that, since it checks last()=0. Instead, the template of version 4.0 checks if last()<>0. This change has NO impact on the template 5.0.
# Don't alert if the server has just been restarted | ||
uptime=$(date +%s -d "$(systemctl show --value -p ActiveEnterTimestamp sysinit.target)") | ||
uptime=$(date +%s -d "$uptime_value") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've just extracted the variable
@@ -195,7 +195,7 @@ | |||
<tags/> | |||
</trigger_prototype> | |||
<trigger_prototype> | |||
<expression>{SystemD service monitoring template:systemd.service.status[{#SERVICE}].last()}<>0</expression> | |||
<expression>{SystemD service monitoring template:systemd.service.status[{#SERVICE}].last()}=0</expression> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now Zabbix 4 checks the last()=0
. Note that Zabbix 5 also checks that:
<expression>{last()}=0</expression> |
I don't know why v4 was last()<>0
. Probably the related v4 script had different return values than the current version. By the way now it's correct (1 = running, 0 = stopped).
Do you have any question? |
Changes included in this pull request (batteries included):
I've splitted my pull request in multiple very small commits to help maintainer in reviewing.
NOTE: I've NOT modified the template of version 5 or the scripts for version 5. If you want, you can test my scripts also in a recent version and I think it will work, so you can adopt my "old" scripts for both versions. But, to be more friendly, I have not taken this decision for you, so I'm keeping both.
Thank you :)