Nagviz on nagios xi

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
tonyyarusso
Posts: 1128
Joined: Wed Mar 03, 2010 12:38 pm
Location: St. Paul, MN, USA
Contact:

Re: Nagviz on nagios xi

Post by tonyyarusso »

mmestnik's post looks right. For reference, this is what I have right now for modifying the configuration by script (it's Python):

Code: Select all

#!/usr/bin/env python

import re

config = open('/usr/local/nagios/share/nagvis/etc/nagvis.ini.php', 'r')
configlines = config.readlines()
config.close()

whitespace = re.compile('^\s*$') # Matches a blank line
defre = re.compile('^;?\[defaults\]\S*') # Matches default settings section
bere = re.compile('^;?backend\S*') # Matches default backend setting
bendo1re = re.compile('^;?\[backend_ndomy_1\]\S*') # Matches first ndomy backend
betypere = re.compile('^;?backendtype\S*') # Matches backend type
dbure = re.compile('^;?dbuser\S*') # Matches database user name
dbpre = re.compile('^;?dbpass\S*') # Matches database password
dbinre = re.compile('^;?dbinstancename\S*') # Matches database instance name

# Find section for [defaults]

for line in configlines:
	if defre.match(line) != None:
		defaultstart = configlines.index(line)
		break

for line in configlines[defaultstart:]:
	if whitespace.match(line) != None:
		defaultend = configlines[defaultstart:].index(line) + defaultstart
		break
		
# Edit [defaults] section

for line in configlines[defaultstart:defaultend]:
	if bere.match(line) != None:
		configlines[ defaultstart + configlines[defaultstart:defaultend].index(line) ] = 'backend="ndomy_1"\n'
		
# Find section for [backend_ndomy_1]

for line in configlines:
	if bendo1re.match(line) != None:
		backendstart = configlines.index(line)
		break

for line in configlines[backendstart:]:
	if whitespace.match(line) != None:
		backendend = configlines[backendstart:].index(line) + backendstart
		break
		
# Edit [backend_ndomy_1] section

for line in configlines[backendstart:backendend]:
	if betypere.match(line) != None:
		configlines[ backendstart + configlines[backendstart:backendend].index(line) ] = 'backendtype="ndomy"\n'
	elif dbure.match(line) != None:
		configlines[ backendstart + configlines[backendstart:backendend].index(line) ] = 'dbuser="ndoutils"\n'
	elif dbpre.match(line) != None:
		configlines[ backendstart + configlines[backendstart:backendend].index(line) ] = 'dbpass="n@gweb"\n'
	elif dbinre.match(line) != None:
		configlines[ backendstart + configlines[backendstart:backendend].index(line) ] = 'dbinstancename="localhost"\n'

# Write out changes
config = open('/usr/local/nagios/share/nagvis/etc/nagvis.ini.php', 'w')
config.writelines(configlines)
config.close()
Tony Yarusso
Technical Services
___
TIES
Web: http://ties.k12.mn.us/
afamily
Posts: 14
Joined: Tue Mar 09, 2010 9:36 pm

Re: Nagviz on nagios xi

Post by afamily »

Thank you! That is what I needed. Its working now but I have not built it into nagios xi interface.
Thank you for the help.
D
tonyyarusso
Posts: 1128
Joined: Wed Mar 03, 2010 12:38 pm
Location: St. Paul, MN, USA
Contact:

Re: Nagviz on nagios xi

Post by tonyyarusso »

One fix I just applied was to make the hosts in the nagvis map link to their status detail in XI instead of Core. Still not exactly "integration", but a step forward.
Tony Yarusso
Technical Services
___
TIES
Web: http://ties.k12.mn.us/
tonyyarusso
Posts: 1128
Joined: Wed Mar 03, 2010 12:38 pm
Location: St. Paul, MN, USA
Contact:

Re: Nagviz on nagios xi

Post by tonyyarusso »

See also http://support.nagios.com/forum/viewtopic.php?f=8&t=309 to discuss the now-available documentation.
Tony Yarusso
Technical Services
___
TIES
Web: http://ties.k12.mn.us/
Locked