Skip to content

Instantly share code, notes, and snippets.

@rodrigolang
Created December 15, 2012 22:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rodrigolang/4299831 to your computer and use it in GitHub Desktop.
Save rodrigolang/4299831 to your computer and use it in GitHub Desktop.
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