Asked
Active
Viewed 52 times
-1
How can I track the date in Zabbix?
There is a need to track application certificates and personal user certificates.
Perhaps it is worth creating an Item and assigning a certain date to it, and then in the Trigger to track the occurrence of this date. But date() doesn't work exactly as I expected, and now() only works with Epoth.
Any ideas?

Alex1__1
- 17
- 6
1 Answers
1
Use now()
to know the difference between the certificate expiration date (as a Unix timestamp) and the time the item was last checked. This item can have a daily interval.
See https://www.zabbix.com/documentation/6.0/en/manual/appendix/functions/time
Update: sample script to get expiration date as Unix timestamp.
#!/bin/bash
url="$1" # example.com
# Retrieve the certificate and extract the expiration date
expiration_date=$(echo | openssl s_client -connect $url:443 -servername $url 2>/dev/null | openssl x509 -noout -enddate | cut -d "=" -f 2)
# Convert the expiration date to Unix timestamp
expiration_timestamp=$(date -d "$expiration_date" +"%s")
# Print the results
echo "$expiration_timestamp"
Using timestamp
as the Item unit in Zabbix, allows Zabbix to display the timestamp as human readable in Latest Data.

Iron Bishop
- 1,749
- 1
- 7
- 16
-
To use now(), you will have to convert all certificate issue dates to Epoch(Number of seconds since the Epoch (00:00:00 UTC, January 1, 1970)) format. This is inconvenient and difficult to track. Perhaps there are other ways? – Alex1__1 Jul 05 '23 at 09:51
-
1Debatable. Epoch is the Unix way, looks good to Linux people. Using "timestamp" as unit in Zabbix, it does the conversion back by itself in Latest Data. Adding a script to the answer. – Iron Bishop Jul 06 '23 at 08:31