Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Monitoring programs specified with group #79

Open
aspyatkin opened this issue Apr 25, 2016 · 1 comment
Open

Monitoring programs specified with group #79

aspyatkin opened this issue Apr 25, 2016 · 1 comment
Labels

Comments

@aspyatkin
Copy link

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.

aspyatkin added a commit to aspyatkin/superlance that referenced this issue Apr 25, 2016
@mnaberez mnaberez added the memmon label Sep 4, 2016
mnaberez added a commit that referenced this issue Sep 5, 2016
sbraz pushed a commit to sbraz/superlance that referenced this issue Sep 6, 2016
@failedguidedog
Copy link

@aspyatkin Thank you for this fix! Can't believe this is still open after a year :(
I've ended up using your fork instead of official package and it works great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

3 participants