Hello Zabbix forum users!
I’m new to Zabbix and not a coder, but for my first post I hope my issue is a rookie mistake and not just something I did really dumb.
The problem I am having is that Macro values seem like they are not getting passed to the alert script properly, but the script functions correctly other than that.
Zabbix 3.4.2 on CentOS server
Alert script Bash, file permissions 760
Zabbix user account set to super admin, assigned to media type MediaName
Problem: Zabbix macro is getting pulled into alert script as text
If I type “Server Offline” into the correct Zabbix media type field, the alert script will process the data correctly into the service now ticket and “Server Offline” will be in the correct place.
If the Macro {TRIGGER.DESCRIPTION} is in the Zabbix media type field, the service now ticket places "{TRIGGER.DESCRIPTION}" instead of “Server Offline” in the correct place.
The description of the trigger is verified to have “Server Offline” in the description field.
Note “ “ are only used here for readability
Has anyone ever come across this issue before?
Thank you all for your time and for any guidance or hints you can provide.
Media type-----------------------
Name: MediaName
Type: script
Scriptname: PleaseLetMeWork.sh
Script parameters: parameter
{ALERT.SENDTO}
{TRIGGER.DESCRIPTION}
{INVENTORY.VENDOR}
{INVENTORY.INSTALLER.NAME}
{INVENTORY.VENDOR}
Add
Enabled checked
AlertScript-----------------------
#!/bin/bash
# Zabbix alertscript for ServiceNow
# PleaseLetMeWork.sh v.01
# params from zabbix
TargetURL=$1 # {ALERT.SENDTO}
details=$2 # {TRIGGER.DESCRIPTION}
affected_ci=$3 # {INVENTORY.VENDOR}
category=$4 # {INVENTORY.INSTALLER.NAME}
division=$5 # {INVENTORY.VENDOR}
user=IsAssignedSomwhere
pass=IsAssignedSomwhere2
#directory to store id/user for events
dir="TheDirItReadsTo"
if [[ "$TriggerStatus" = "PROBLEM"* ]]; then
json='{
"category":"'${category}'",
"cmdb_ci":"'${affected_ci}'",
"u_division":"'${division}'",
"description":"'${details}'"
}'
response=$(curl -s -u "${user}:${pass}" -H "Content-Type: application/json" "${TargetURL}/api/now/table/incident" -d "${json}")
echo ${response} | jq -r '.[] | .sys_id' >> ${dir}/${id}.id
echo ${response} | jq -r '.[] | .opened_by["value"]' >> ${dir}/${id}.user
fi
)
I’m new to Zabbix and not a coder, but for my first post I hope my issue is a rookie mistake and not just something I did really dumb.
The problem I am having is that Macro values seem like they are not getting passed to the alert script properly, but the script functions correctly other than that.
Zabbix 3.4.2 on CentOS server
Alert script Bash, file permissions 760
Zabbix user account set to super admin, assigned to media type MediaName
Problem: Zabbix macro is getting pulled into alert script as text
If I type “Server Offline” into the correct Zabbix media type field, the alert script will process the data correctly into the service now ticket and “Server Offline” will be in the correct place.
If the Macro {TRIGGER.DESCRIPTION} is in the Zabbix media type field, the service now ticket places "{TRIGGER.DESCRIPTION}" instead of “Server Offline” in the correct place.
The description of the trigger is verified to have “Server Offline” in the description field.
Note “ “ are only used here for readability
Has anyone ever come across this issue before?
Thank you all for your time and for any guidance or hints you can provide.
Media type-----------------------
Name: MediaName
Type: script
Scriptname: PleaseLetMeWork.sh
Script parameters: parameter
{ALERT.SENDTO}
{TRIGGER.DESCRIPTION}
{INVENTORY.VENDOR}
{INVENTORY.INSTALLER.NAME}
{INVENTORY.VENDOR}
Add
Enabled checked
AlertScript-----------------------
#!/bin/bash
# Zabbix alertscript for ServiceNow
# PleaseLetMeWork.sh v.01
# params from zabbix
TargetURL=$1 # {ALERT.SENDTO}
details=$2 # {TRIGGER.DESCRIPTION}
affected_ci=$3 # {INVENTORY.VENDOR}
category=$4 # {INVENTORY.INSTALLER.NAME}
division=$5 # {INVENTORY.VENDOR}
user=IsAssignedSomwhere
pass=IsAssignedSomwhere2
#directory to store id/user for events
dir="TheDirItReadsTo"
if [[ "$TriggerStatus" = "PROBLEM"* ]]; then
json='{
"category":"'${category}'",
"cmdb_ci":"'${affected_ci}'",
"u_division":"'${division}'",
"description":"'${details}'"
}'
response=$(curl -s -u "${user}:${pass}" -H "Content-Type: application/json" "${TargetURL}/api/now/table/incident" -d "${json}")
echo ${response} | jq -r '.[] | .sys_id' >> ${dir}/${id}.id
echo ${response} | jq -r '.[] | .opened_by["value"]' >> ${dir}/${id}.user
fi
)