mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-23 06:35:42 +00:00
Improved munin state file handling
This commit is contained in:
parent
c169373f21
commit
61241b8082
1 changed files with 18 additions and 8 deletions
|
@ -119,9 +119,7 @@ if debug:
|
||||||
|
|
||||||
conf = {
|
conf = {
|
||||||
'git_path': os.getenv('git_path', '/usr/bin/git'),
|
'git_path': os.getenv('git_path', '/usr/bin/git'),
|
||||||
'state_file': os.getenv('MUNIN_STATEFILE',
|
'state_file': os.getenv('MUNIN_STATEFILE')
|
||||||
'/var/lib/munin-node/plugin-state/nobody/' +
|
|
||||||
'git_commit_behind.state')
|
|
||||||
}
|
}
|
||||||
|
|
||||||
repo_codes = set(re.search('repo\.([^.]+)\..*', elem).group(1)
|
repo_codes = set(re.search('repo\.([^.]+)\..*', elem).group(1)
|
||||||
|
@ -201,6 +199,10 @@ def get_info():
|
||||||
|
|
||||||
|
|
||||||
def check_update_repos():
|
def check_update_repos():
|
||||||
|
if not conf['state_file']:
|
||||||
|
logging.error('Munin state file unavailable')
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
if len(sys.argv) > 2:
|
if len(sys.argv) > 2:
|
||||||
max_interval = int(sys.argv[2])
|
max_interval = int(sys.argv[2])
|
||||||
else:
|
else:
|
||||||
|
@ -245,14 +247,22 @@ if len(sys.argv) > 1:
|
||||||
if action == 'config':
|
if action == 'config':
|
||||||
print_config()
|
print_config()
|
||||||
elif action == 'autoconf':
|
elif action == 'autoconf':
|
||||||
|
errors = []
|
||||||
|
|
||||||
|
if not conf['state_file']:
|
||||||
|
errors.append('munin state file unavailable')
|
||||||
|
|
||||||
if os.access(conf['git_path'], os.X_OK):
|
if os.access(conf['git_path'], os.X_OK):
|
||||||
test_git = call([conf['git_path'], '--version'], stdout=DEVNULL)
|
test_git = call([conf['git_path'], '--version'], stdout=DEVNULL)
|
||||||
if test_git == 0:
|
if test_git != 0:
|
||||||
|
errors.append('git seems to be broken ?!')
|
||||||
|
else:
|
||||||
|
errors.append('git is missing or not executable')
|
||||||
|
|
||||||
|
if errors:
|
||||||
|
print('no (%s)' % ', '.join(errors))
|
||||||
|
else:
|
||||||
print('yes')
|
print('yes')
|
||||||
else:
|
|
||||||
print('no (git seems to be broken ?!)')
|
|
||||||
else:
|
|
||||||
print('no (git is missing or not executable)')
|
|
||||||
elif action == 'version':
|
elif action == 'version':
|
||||||
print('Git commit behind Munin plugin, version {0}'.format(
|
print('Git commit behind Munin plugin, version {0}'.format(
|
||||||
plugin_version))
|
plugin_version))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue