Skip to content

Instantly share code, notes, and snippets.

@ep4sh
Created June 25, 2018 09:11
Show Gist options
  • Save ep4sh/5a34cbbf8f2294766027bfa511623c3a to your computer and use it in GitHub Desktop.
Save ep4sh/5a34cbbf8f2294766027bfa511623c3a to your computer and use it in GitHub Desktop.
Try to loop in icinga with posgtres clusters and databases
apply Service "pg-NOW()-check" {
check_command = "pgsql"
// var db_dict = { "db1" = 5432, "db2" = 5433, "db3" = 5434, "db4" = 5435 }
for (db_key => db_value in db_dict) {
//need to out into host file
vars.pgsql_hostname = host.address
vars.pgsql_database = db_key
vars.pgsql_port = db_value
// monit user & password
vars.pgsql_username = "xxx"
vars.pgsql_password = "xxx"
vars.pgsql_query = "select now();"
vars.pgsql_warning = 2
}
assign where host.vars.db_type == "postgres"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment