Skip to content

Commit

Permalink
fixes #1
Browse files Browse the repository at this point in the history
  • Loading branch information
jpcw committed Apr 12, 2015
1 parent 5dd200e commit 5d95621
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Check OpenBGPD Nagios|Icinga|shinken|etc plugin.
usage
-------

This check *runs bgpctl show* and check that all bgp sessions are up.
This check runs **bgpctl show** and checks that all bgp sessions are up.


sample outputs :
Expand Down Expand Up @@ -67,7 +67,7 @@ sample outputs :
::
$ check_openbgpd
CHECKBGPCTL CRITICAL - OTHER-PEER is idle (outside range 0:) | 'PEER-1'=529918;;;0 'OTHER-PEER'=None;;;0
CHECKBGPCTL CRITICAL - OTHER-PEER is U (outside range 0:) | 'PEER-1'=529918;;;0 'OTHER-PEER'=U;;;0
+ Unknown
Expand Down
2 changes: 1 addition & 1 deletion docs/CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Changelog
0.7 (unreleased)
----------------

- Nothing changed yet.
- fix 'idle' breaks performance data rendering https://github.com/jpcw/checkopenbgpd/issues/1


0.6 (2015-04-09)
Expand Down
7 changes: 4 additions & 3 deletions src/checkopenbgpd/checkopenbgpd.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,18 @@ def _get_sessions(self):

def check_session(self, session):
"""check session is up, or not in idle list if idle."""
result = 'U'
state = session.State_PrfRcvd

if state.isdigit():
return int(state)
result = int(state)

if state == 'Idle':
if self.idle_list is not None:
if session.Neighbor in self.idle_list:
return 0
result = 0

return 'idle'
return result

def probe(self):
"""."""
Expand Down
8 changes: 4 additions & 4 deletions src/checkopenbgpd/tests/test_checkopenbgpd.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def test_check_idle_session_not_in_idle_list(self):
_popen.return_value = output, ''
sessions = check._get_sessions()
result = check.check_session(sessions[0])
self.assertIsNone(result)
self.assertEquals(result, 'U')

def test_check_probe_without_idle_list(self):
check = checkopenbgpd.CheckBgpCtl(None)
Expand All @@ -92,11 +92,11 @@ def test_check_probe_without_idle_list(self):
probe = check.probe()
first = next(probe)
self.assertEqual(type(first), Metric)
self.assertIsNone(first.value)
self.assertEquals(first.value, 'U')
second = next(probe)
self.assertEquals(second.value, 529001)
third = next(probe)
self.assertEquals(third.value, 'idle')
self.assertEquals(third.value, 'U')

def test_check_probe_with_idle_list(self):
check = checkopenbgpd.CheckBgpCtl(['THIRD'])
Expand All @@ -108,7 +108,7 @@ def test_check_probe_with_idle_list(self):
probe = check.probe()
first = next(probe)
self.assertEqual(type(first), Metric)
self.assertIsNone(first.value)
self.assertEquals(first.value, 'U')
second = next(probe)
self.assertEquals(second.value, 529001)
third = next(probe)
Expand Down

0 comments on commit 5d95621

Please sign in to comment.