Skip to content

Monitoring programs specified with group #79

Open
@aspyatkin

Description

@aspyatkin

Hello, I believe I've found a bug in memmon plugin.
For a program argument in memmon call, it's said that it's possible to specify group name to avoid ambiguity, with the format group_name:program_name. However, the documentation placed in the code suggests otherwise - process_name:group_name. At last I figured out that the first variant is the correct one.

When I tried to use memmon plugin for my program, I noticed that the following exception had been emmitted to the eventlistener log:

Checking programs app:backend-0=83886080
RSS of app:backend-0 is 79663104
Traceback (most recent call last):
  File "/home/vagrant/test-superlance/bin/memmon", line 11, in <module>
    sys.exit(main())
  File "/home/vagrant/test-superlance/lib/python2.7/site-packages/superlance/memmon.py", line 402, in main
    memmon.runforever()
  File "/home/vagrant/test-superlance/lib/python2.7/site-packages/superlance/memmon.py", line 169, in runforever
    if  rss > self.programs[name]:
KeyError: 'backend-0'

As far as I've understood, this is the line of code which throws an error because the program is being looked up without group name.

To reproduce the issue, I've written an extra test:

def test_runforever_tick_program_with_group(self):
    programs = {'foo:foo': 0 }
    groups = {}
    _any = None
    memmon = self._makeOnePopulated(programs, groups, _any)
    memmon.stdin.write('eventname:TICK len:0\n')
    memmon.stdin.seek(0)
    memmon.runforever(test=True)
    lines = memmon.stderr.getvalue().split('\n')
    self.assertEqual(len(lines), 4)
    self.assertEqual(lines[0], 'Checking programs foo:foo=0')
    self.assertEqual(lines[1], 'RSS of foo:foo is 2264064')
    self.assertEqual(lines[2], 'Restarting foo:foo')
    self.assertEqual(lines[3], '')

The fix is quite simple, I can make a pull request, if you like.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions