~ev/charms/precise/postgresql/non-fatal-sysctl

« back to all changes in this revision

Viewing changes to hooks/hooks.py

[stub] Initialize backup log file on install to silence spurious nagios alert, per https://code.launchpad.net/~stub/charms/precise/postgresql/bug-1329816-backup-log-spurious-alert/+merge/223210

Show diffs side-by-side

added added

removed removed

Lines of Context:
1011
1011
        os.path.join(postgresql_scripts_dir, 'pg_backup_job'),
1012
1012
        backup_job, perms=0755)
1013
1013
    install_postgresql_crontab(postgresql_crontab)
 
1014
 
 
1015
    # Create this empty log file on installation to avoid triggering
 
1016
    # spurious monitoring system alerts, per Bug #1329816.
 
1017
    if not os.path.exists(backup_log):
 
1018
        host.write_file(backup_log, '', 'postgres', 'postgres', 0664)
 
1019
 
1014
1020
    hookenv.open_port(get_service_port())
1015
1021
 
1016
1022
    # Ensure at least minimal access granted for hooks to run.
2202
2208
            .format(get_service_port()))
2203
2209
    # pgsql backups
2204
2210
    nrpe_check_file = '/etc/nagios/nrpe.d/check_pgsql_backups.cfg'
2205
 
    backup_log = "{}/backups.log".format(postgresql_logs_dir)
2206
2211
    # XXX: these values _should_ be calculated from the backup schedule
2207
2212
    #      perhaps warn = backup_frequency * 1.5, crit = backup_frequency * 2
2208
2213
    warn_age = 172800
2331
2336
juju_log_dir = "/var/log/juju"
2332
2337
external_volume_mount = "/srv/data"
2333
2338
 
 
2339
backup_log = os.path.join(postgresql_logs_dir, "backups.log")
 
2340
 
2334
2341
 
2335
2342
if __name__ == '__main__':
2336
2343
    # Hook and context overview. The various replication and client