Created
February 19, 2017 16:55
-
-
Save sesukovs/4fad54c051c92b14c26e2ca2c42e166c to your computer and use it in GitHub Desktop.
Bash script that creates JSON document for Zabbix discovery
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
VHOST_CONFIG_PATH='/etc/nginx/sites-enabled/' | |
echo "{" | |
echo ' "data":[' | |
FIRST=1 | |
while read line; do | |
if [ $FIRST != 0 ]; then | |
FIRST=0 | |
else | |
ELEMENT="{ \"{#DOMAIN}\":\"$DOMAIN\" }," | |
echo " $ELEMENT" | |
fi | |
DOMAIN=$line | |
done <<< "$(find $VHOST_CONFIG_PATH -type f | awk -F '/' '{print $5}')" | |
ELEMENT="{ \"{#DOMAIN}\":\"$DOMAIN\" }" | |
echo " $ELEMENT" | |
echo ' ]' | |
echo "}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment