diff --git a/check_elasticsearch b/check_elasticsearch index a1d39a2..34e9558 100755 --- a/check_elasticsearch +++ b/check_elasticsearch @@ -1,5 +1,6 @@ #!/usr/bin/env python +import re import urllib2 from nagioscheck import NagiosCheck, UsageError @@ -612,9 +613,9 @@ def get_json(uri): def version(version_string): - """Accept a typical version string (ex: 1.0.1) and return a tuple - of ints, allowing for reasonable comparison.""" - return tuple([int(i) for i in version_string.split('.')]) + """Accept a typical version string (ex: 1.0.1 or 5.0.0-alpha1) and return a + tuple of ints, allowing for reasonable comparison.""" + return tuple([int(re.findall(r'^\d+', i)[0]) for i in version_string.split('.')]) if __name__ == '__main__':