Hello,
I have a zabbix external script item to get certificates data.
It works. But I need to create a trigger to send alert relates expiration date. But I cannot find properly trigger expression.
"
#!/bin/bash
# Function to fetch certificate expiration dates
get_cert_expiration_dates() {
# Perform curl command and extract certificate information
certificates=$(curl -s -X POST \
-H "Content-Type: application/json" \
-H "Authorization: Bearer Token" \
-d '{"objectTypeId": "265", "attributesToDisplay": {"attributesToDisplayIds": []},"page": 1,"asc": 1,"resultsPerPage": 300,"includeAttributes": false,"objectSchemaId": "3","qlQuery": ""}' \
https://URL/rest/insight/1.0/object/navlist/iql \
| jq -r '.objectEntries[] | "\(.name), Expiration Date: \(.updated)"')
# Print each certificate and expiration date separately
while IFS= read -r line; do
echo "$line"
done <<< "$certificates"
}
# Call the function and print output for Zabbix
get_cert_expiration_dates
"
Response:
"
*domain.com, Expiration Date: 2023-12-06T10:59:39.400Z
domain2.com, Expiration Date: 2023-11-13T13:56:25.830Z
"
I have a zabbix external script item to get certificates data.
It works. But I need to create a trigger to send alert relates expiration date. But I cannot find properly trigger expression.
"
#!/bin/bash
# Function to fetch certificate expiration dates
get_cert_expiration_dates() {
# Perform curl command and extract certificate information
certificates=$(curl -s -X POST \
-H "Content-Type: application/json" \
-H "Authorization: Bearer Token" \
-d '{"objectTypeId": "265", "attributesToDisplay": {"attributesToDisplayIds": []},"page": 1,"asc": 1,"resultsPerPage": 300,"includeAttributes": false,"objectSchemaId": "3","qlQuery": ""}' \
https://URL/rest/insight/1.0/object/navlist/iql \
| jq -r '.objectEntries[] | "\(.name), Expiration Date: \(.updated)"')
# Print each certificate and expiration date separately
while IFS= read -r line; do
echo "$line"
done <<< "$certificates"
}
# Call the function and print output for Zabbix
get_cert_expiration_dates
"
Response:
"
*domain.com, Expiration Date: 2023-12-06T10:59:39.400Z
domain2.com, Expiration Date: 2023-11-13T13:56:25.830Z
"