Add the path of nagios.cfg in case of vanilla installation from source

125 views
Skip to first unread message

Abhinav Upadhyay

unread,
Jul 30, 2012, 2:59:05 AM7/30/12
to pynag-...@googlegroups.com
Inside the Parser module, Pynag tries to prob the path of the nagios.cfg file in case the user of the module did not supply it. In the list of the paths where pynag checks for the nagios.cfg file, I think we need to add '/usr/local/nagios/etc/nagios.cfg' as well, since this is the default path of the configuration files in case someone installs nagios directly by building from the sources.

Since this path has been missing in the Parser module, all of the example programs supplied with pynag have been failing on my system. I hope you would accept the small patch so that this problem is solved in the upcoming releases of pynag. :)


pynag_config_filepath.diff

Páll Sigurðsson

unread,
Jul 30, 2012, 6:30:38 AM7/30/12
to pynag-...@googlegroups.com
Thanks Abhinav,

I will add this path, Do you want to be named in the changelog ?

Kind regards,
Pall Sigurdsson

Abhinav Upadhyay

unread,
Jul 30, 2012, 6:31:30 AM7/30/12
to pynag-...@googlegroups.com
Yes, that would be very nice of you :)

Thanks
Abhinav

Páll Sigurðsson

unread,
Jul 30, 2012, 7:43:27 AM7/30/12
to pynag-...@googlegroups.com
ok changes made and pushed to code.google.com.

If you have the chance, it would be much appreciated to get feedback on the quality of the examples.

Also i have the feeling that many new coders go directly to the Parsers module and miss what is in the Model module, please let me know if that was the case for you :)




$ git show 7d7652c8b7f7e212efba42a964d18575c6b633e1
commit 7d7652c8b7f7e212efba42a964d18575c6b633e1
Author: Pall Sigurdsson <pa...@opensource.is>
Date:   Mon Jul 30 11:22:14 2012 +0000

    /usr/local/nagios/etc/ added to paths where nagios.cfg might be found (Thanks Abhinav Upadhyay)

diff --git a/pynag/Parsers/__init__.py b/pynag/Parsers/__init__.py
index 4d9f8df..787ec33 100644
--- a/pynag/Parsers/__init__.py
+++ b/pynag/Parsers/__init__.py
@@ -38,7 +38,7 @@ class config:
 
                # If nagios.cfg is not set, lets do some minor autodiscover.
                if self.cfg_file is None:
-                       possible_files = ('/etc/nagios/nagios.cfg','/etc/nagios3/nagios.cfg','/usr/local/nagios/nagios.cfg','/nagios/etc/nagios/nagios.cfg')
+                       possible_files = ('/etc/nagios/nagios.cfg','/etc/nagios3/nagios.cfg','/usr/local/nagios/etc/nagios.cfg','/nagios/etc/nagios/nagios.cfg')
                        for file in possible_files:
                                if os.path.isfile(file):
                                        self.cfg_file = file

Abhinav Upadhyay

unread,
Jul 31, 2012, 1:04:40 AM7/31/12
to pynag-...@googlegroups.com
Thanks.

I took the advice in the README and tried out examples of the Model module before checking out Parsers. The examples are very handy and also give a nice overview of how to use the pynag library. However, one problem I faced was with the Parsers module's examples. Therein the path of the main config file is hard coded to '/etc/nagios/nagios.cfg', which on my system is not there. May be there also you could do some probing to find out the location of the config file, if you want to make sure that the examples work out of the box for your users :-)

--
Abhinav
Reply all
Reply to author
Forward
0 new messages