Created
December 15, 2012 22:20
-
-
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.
This file contains 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 | |
# 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