Do not parse resource.cfg

21 views
Skip to first unread message

Abhinav Upadhyay

unread,
Jul 31, 2012, 1:42:20 AM7/31/12
to pynag-...@googlegroups.com
Hi

Pynag tries to parse the resource.cfg file along with the rest of the configuration files. The objective of the resource.cfg file is to define $USER macros which are usually the username, passwords etc.which you may not like to hard code everywhere. The permissions of this file are 600 and it can only be read or written by the nagios user. 

If I try to run my code as an ordinary user (not as nagios), pynag gives a parse error, because it can't read resource.cfg. May be there should be an option to say that it does not need to parse special files like resource.cfg ?

Thanks
Abhinav

Tommi

unread,
Jul 31, 2012, 6:56:43 AM7/31/12
to pynag-...@googlegroups.com
We use resource.cfg to resolve actual command lines being run so parsing it is necesary.

What I have done in this situation is that usually the resource.cfg is readable by a "nagios group". Just add your user to the nagios group (I run pynag as my own user all the time).

If resource.cfg isn't readable by the group, just set it to 640.

---
Tommi

Páll Sigurðsson

unread,
Jul 31, 2012, 9:24:19 AM7/31/12
to pynag-...@googlegroups.com
I have created a new issue for this, http://code.google.com/p/pynag/issues/detail?id=29 will take a look at it soon.

Páll Sigurðsson

unread,
Jul 31, 2012, 11:51:26 AM7/31/12
to pynag-...@googlegroups.com
There is a proposed fix in git commit 8b5a2f96c956ba5b34eed47226d78fc8032de0db

What it does is that Parsers.config.parse() will now handle any permission errors softly if the file in question is a resource file (as they are most commonly with special permssions).

Error will be appended to Parsers.config.errors instead of raising an exception.

If permission denied is encountered in Model.*.get_effective_check_command there is an exception like before.


Abhinav, if you have time, please verify that the patch works as expected. In the meantime i will close the case.

Abhinav Upadhyay

unread,
Jul 31, 2012, 3:01:56 PM7/31/12
to pynag-...@googlegroups.com
Thanks. Just tried out the pynag(1) (the command line utility), which I was able to run as ordinary user without any problems. Previously it would die, giving the permission error.

I will try out my own code tomorrow. 

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