check_upstart_job does not alert CRITICAL when service is stopped

Bug #1425110 reported by Mick Gregg on 2015-02-24
14
This bug affects 3 people
Affects Status Importance Assigned to Milestone
nrpe-external-master (Juju Charms Collection)
Undecided
Unassigned

Bug Description

check_upstart_job does not alert CRITICAL when service is stopped

upstart.get_properties() throws exeception
  com.ubuntu.Upstart0_6.Error.UnknownInstance: Unknown instance
on
  job.GetInstance([], dbus_interface='com.ubuntu.Upstart0_6.Job')

Then, with len(states) and states.values().count('running') both to be zero, the script eventually returns
  OK: 0 instances of <service> running

Q&D hack to work-around added at lines 58-61
 41 try:
...
 54 except dbus.DBusException as e:
 55 instances = upstart.get_job_instances(sys.argv[1])
 56 propses = [upstart.get_job_instance_properties(instance) for instance in instances]
 57 states = dict([(props['name'], props['state']) for props in propses])
 58 # Dirty hack by macgreagoir to alert CRITICAL on stopped
 59 if len(states) == 0:
 60 print 'CRITICAL: 0 instances of %s running' % sys.argv[1]
 61 sys.exit(2)
 62 if len(states) != states.values().count('running'):
...

Related branches

Mick Gregg (macgreagoir) on 2015-03-04
tags: added: canonical-bootstack
Changed in nrpe-external-master (Juju Charms Collection):
status: New → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers