Skip to content

Commit b14482e

Browse files
authored
[AI-6527] Fix crash when encountering defunct process (DataDog#22543)
* Add test case for defunct process * add fix and changelog
1 parent f6e18eb commit b14482e

3 files changed

Lines changed: 12 additions & 2 deletions

File tree

ibm_mq/changelog.d/22543.fixed

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix crash when encountering defunct processes.

ibm_mq/datadog_checks/ibm_mq/process_matcher.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ class QueueManagerProcessMatcher(ConditionLimiter):
2424
def condition(self, pattern, logger):
2525
logger.debug('Searching for a process that matches: %s', pattern.pattern)
2626
for process in psutil.process_iter(['cmdline']):
27+
if not process.info['cmdline']:
28+
continue
2729
command = join_command_args(process.info['cmdline'])
2830
if pattern.search(command):
2931
logger.debug('Process found: %s', command)

ibm_mq/tests/test_ibm_mq_int.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -439,11 +439,18 @@ def test_channel_status_no_duplicates(aggregator, get_check, instance, dd_run_ch
439439
aggregator.assert_service_check("ibm_mq.channel.status", check.OK, tags=tags, count=1)
440440

441441

442-
def test_queue_manager_process_not_found(aggregator, get_check, instance, dd_run_check):
442+
@pytest.mark.parametrize(
443+
'cmdline_value',
444+
[
445+
pytest.param(['amqpcsea', 'baz'], id='wrong process'),
446+
pytest.param(None, id='defunct process'),
447+
],
448+
)
449+
def test_queue_manager_process_not_found(aggregator, get_check, instance, dd_run_check, cmdline_value):
443450
class ProcessMock(object):
444451
@property
445452
def info(self):
446-
return {'cmdline': ['amqpcsea', 'baz']}
453+
return {'cmdline': cmdline_value}
447454

448455
instance['queue_manager'] = 'foo'
449456
instance['queue_manager_process'] = 'amqpcsea {}'.format(instance['queue_manager'])

0 commit comments

Comments
 (0)