graphios icon indicating copy to clipboard operation
graphios copied to clipboard

OMD python install - 'no post install could be performed'

Open christrotter opened this issue 10 years ago • 4 comments

  • This is OMD v1.10...but I suspect that any current version of OMD will have this issue.
  • git clone https://github.com/shawn-sterling/graphios
  • python setup.py install

I get this:

copying build/scripts-2.6/graphios.py -> /usr/bin
changing mode of /usr/bin/graphios.py to 755
Running post install task
sorry I couldn't find the nagios.cfg file
NO POST INSTALL COULD BE PERFORMED

So I edited setup.py: (see omd path)

def _post_install():
    """
    tries to find the nagios.cfg and insert graphios perf commands/cfg
    """
    lookin = ['/etc/nagios/', '/opt/nagios/', '/usr/local/nagios',
              '/usr/nagios', '/omd/sites/SITENAMEHERE/etc/nagios']
    nag_cfg = find_nagios_cfg(lookin)
    if nag_cfg is None:
        print("sorry I couldn't find the nagios.cfg file")
        print("NO POST INSTALL COULD BE PERFORMED")

Ran it again: python setup.py install

Running post install task
found nagios.cfg in /omd/sites/SITENAMEHERE/etc/nagios/nagios.cfg
Traceback (most recent call last):
  File "setup.py", line 176, in <module>
    https://github.com/shawn-sterling/graphios'
  File "/usr/lib64/python2.6/distutils/core.py", line 152, in setup
    dist.run_commands()
  File "/usr/lib64/python2.6/distutils/dist.py", line 975, in run_commands
    self.run_command(cmd)
  File "/usr/lib64/python2.6/distutils/dist.py", line 995, in run_command
    cmd_obj.run()
  File "setup.py", line 131, in run
    self.execute(_post_install, [], msg="Running post install task")
  File "/usr/lib64/python2.6/distutils/cmd.py", line 358, in execute
    util.execute(func, args, msg, dry_run=self.dry_run)
  File "/usr/lib64/python2.6/distutils/util.py", line 408, in execute
    func(*args)
  File "setup.py", line 103, in _post_install
    print("parsed nagcfg, nagios_log is at %s" % nconfig['log_file'])
KeyError: 'log_file'

So it's something in here:

 print("found nagios.cfg in %s" % nag_cfg)
        nconfig = parse_nagios_cfg(nag_cfg)
        print("parsed nagcfg, nagios_log is at %s" % nconfig['log_file'])
        if backup_file(nag_cfg):
            add_perfdata_config(nconfig, nag_cfg)
        else:
            print("Backup failed, add modify nagios.cfg manually.")

Checking that nagios.cfg file - it's OMD-generated:

# Nagios main configuration file

# This file will be read in after the files in nagios.d.
# Variables you set here will override settings in those
# files. Better do not edit the files in nagios.d but rather
# copy variables from there to here. That will save you
# trouble when updating your sites to new versions.

#use_regexp_matching=1

So it's expecting to see something...but OMD uses conf.d and nagios.d for configs. I suspect you could just put stuff straight in here... (the OMD documentation appears a little pieced-together - initially mentions OMD 1.2x, later on mentions OMD 5.6...)

Guessing this function is actually what's failing...

def add_perfdata_config(nconfig, nag_cfg):
    """
    adds the graphios perfdata cfg to the nagios.cfg
    """

I'll play around, see if I can get it working - will update.

Update: Oh yeah, here's the folder structure if you were curious:

[root@server nagios]# pwd
/omd/sites/SITENAMEHERE/etc/nagios
[root@server nagios]# ls -h
apache.conf  cgi.cfg  conf.d  config.inc.php  nagios.cfg  nagios.d  resource.cfg  ssi
[root@server nagios]# ls conf.d/
check_mk_objects.cfg  check_mk_templates.cfg  commands.cfg  jmx4perl_nagios.cfg  notification_commands.cfg  pnp4nagios.cfg  templates.cfg  thruk_templates.cfg  timeperiods.cfg
[root@server nagios]# ls nagios.d
dependency.cfg  eventhandler.cfg  flapping.cfg  freshness.cfg  logging.cfg  misc.cfg  mk-livestatus.cfg  obsess.cfg  omd.cfg  pnp4nagios.cfg  retention.cfg  timing.cfg  tuning.cfg

christrotter avatar Dec 19 '14 15:12 christrotter

Yeah, OMD's preference is to put user overrides into the nagios.cfg:

# Please do not change settings here. Copy the variables
# you want to override to ../nagios.cfg and edit them there.
# Settings in nagios.cfg have always precedence.

So dere ya go!

christrotter avatar Dec 19 '14 15:12 christrotter

Hi there Chris, sorry for the late reply.

Thank you for doing all the troubleshooting for me. :) I think the right way to go would be to try and detect omd and ignore if we can't find the log_file key in the nagios config. I should be able to add this over the weekend.

shawn-sterling avatar Jan 20 '15 08:01 shawn-sterling

Hey,

In Debian 8.0 nagios is installed under /etc/nagios3/ added it manually but it would be great if you could include that too.

madonius avatar Oct 26 '15 00:10 madonius

Hi, may I ask how we can workaround this issue? My OMD server does not have internet access. Now, i am getting the same issue when installing graphios by issuing "python setup.py install".

Any update is highly appreciated.

xixjxj avatar Feb 26 '18 08:02 xixjxj