Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Script para low-level discovery de bancos de dados do PostgreSQL no Zabbix 2.0.
#!/bin/bash
# Autor: Rodrigo Lang
# Data: 08/12/2012
lines=$(psql --dbname postgres -Atc '\l' | grep '|' | cut -d'|' -f1 | wc -l)
loop=1
inicio="{\"data\":["
for i in $(psql --dbname postgres -Atc '\l' | grep '|' | cut -d'|' -f1); do
loop=$(($loop+1))
if [ $loop -gt $lines ]; then
data=${data}"{\"{#DBNAME}\":\"$i\"}"
else
data=${data}"{\"{#DBNAME}\":\"$i\"},"
fi
done
final="]}"
echo $inicio$data$final
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.