~lazypower/charms/precise/nrpe/fix-lp-1287393

« back to all changes in this revision

Viewing changes to hooks/config-changed

  • Committer: Clint Byrum
  • Date: 2012-07-26 23:19:54 UTC
  • Revision ID: clint@ubuntu.com-20120726231954-y1oht4a1hybv8zec
don't monitor swap on boxes that don't have swap configured

Show diffs side-by-side

added added

removed removed

Lines of Context:
71
71
    if 'nrpe' not in out_remotes:
72
72
        out_remotes['nrpe'] = {}
73
73
    if mclass == 'swap':
74
 
        # singles
75
 
        out_remotes['nrpe'][mclass] = {'command': 'check_%s' % mclass}
 
74
        # is there even swap on this box?
 
75
        with open('/proc/swaps') as pswaps:
 
76
            for line in pswaps:
 
77
                # skip headers
 
78
                if line[0] != '/':
 
79
                    continue
 
80
                # We have at least one swap partition
 
81
                out_remotes['nrpe'][mclass] = {'command': 'check_swap'}
 
82
                break
76
83
    elif mclass == 'mem':
77
84
        out_remotes['nrpe'][mclass] = {'command': make_command(mclass, {})}
78
85
    else: