sous-chefs / zabbix-agent

Development repository for the zabbix-agent cookbook
https://supermarket.chef.io/cookbooks/zabbix-agent
Apache License 2.0
8 stars 24 forks source link

PID name #3

Closed jeffmacdonald closed 9 years ago

jeffmacdonald commented 9 years ago

I'm still new with CHEF so I may be reporting something that is actually a non bug.

The PID file that the agent creates by default is /var/run/zabbix/zabbix-agent.pid , but the configuration file has /var/run/zabbix/zabbix_agentd.pid (notice the d)..

I added this to my default attributes file:

default[:zabbix][:agent][:pid_file] = ['/var/run/zabbix/zabbix-agent.pid']

The thing is, it doesn't seem to get picked up at all.

TD-4242 commented 9 years ago

What install method are you using? Let me dig in and have a look.

Ohh, and it shouldn't be equal to an array. That's what having the pid file in [] means. http://www.tutorialspoint.com/ruby/ was really helpful for me when I was first learning ruby.

TD-4242 commented 9 years ago

The deb package for ubuntu's init script has the following at the top:

NAME=zabbix_agentd
DAEMON=/usr/sbin/$NAME
DESC="Zabbix agent"

test -x $DAEMON || exit 0

DIR=/var/run/zabbix
PID=$DIR/$NAME.pid

This should create the correct PID file as:

/var/run/zabbix/zabbix-agent.pid

for the default.

According to https://www.zabbix.com/documentation/2.4/manual/appendix/config/zabbix_agentd the default location that the agent (without specifying in the config) is /tmp/zabbix_agentd.pid.

PidFile no      /tmp/zabbix_agentd.pid  Name of PID file.

If you look in the ./attributes/default.rb you'll see that that is commented out of the config section and the /var/run/zabbix/zabbix_agentd.pid is filled in.

My guess is that you are not getting what you expect because you are assigning the default[:zabbix][:agent][:pid_file] to an array rather than a string. Try removing the [] from your assignment:

default[:zabbix][:agent][:pid_file] = '/var/run/zabbix/zabbix-agent.pid'

and it should get you want you're looking for.

I'd also recommend setting this in an environment or creating a wrapper cookbook rather than editing the supermarket cookbook directly. Try not to edit public cookbooks unless you are fixing bugs and plan to submit a pull request, otherwise it will be difficult for you to upgrade to a newer version.

TD-4242 commented 9 years ago

After reviewing code and seeing the array assignment, closing due to missconfiguration.

jeffmacdonald commented 9 years ago

I think I have a tiny bit more information to add that may be useful. (Even tho your recommendations are correct)

Version .9 of your cookbook - when zabbix started it created zabbix-agent.pid Version .10 - it makes zabbix-agentd.pid.

The confusion for me arose because calling "service zabbix-agent restart" or letting Chef restart zabbix didn't happen correctly, because the init script could not find a PID to kill and would not start it again cause it was still running. On each server that I went from .9 to .10 on, I had to issue a kill and then a service start of zabbix-agent then it all worked again fine.

Thanks for the cookbook!

Jeff.

TD-4242 commented 9 years ago

No problem, thanks for using and submitting issues. 0.9.0 was still a bit rough as I had only just started using it myself full time. Please let me know right away if you have any other questions or issues.

jeffmacdonald commented 9 years ago

Hi Bill,

I'm now trying to auto enrol my zabbix agents with a zabbix server. The server is not under chefs control. I'm reading the code on github but was curious if you have any draft documents I could look at or if you could offer some guidance. Thanks!

Jeff.

On Tue Jan 06 2015 at 10:41:39 AM Bill Warner notifications@github.com wrote:

No problem, thanks for using and submitting issues. 0.9.0 was still a bit rough as I had only just started using it myself full time. Please let me know right away if you have any other questions or issues.

— Reply to this email directly or view it on GitHub https://github.com/TD-4242/zabbix-agent/issues/3#issuecomment-68872953.

TD-4242 commented 9 years ago

The code in the LWRPs were all forked from the original https://github.com/laradji/zabbix cookbook noted in the readme. Although I fear the documentation there is just as scarce. I am (slowly) working on migrating it into https://github.com/TD-4242/cookbook-libzabbix cookbook where it should be more manageable. As it is it currently does not work and requires extensive code changes to get it functional in the zabbix-agent cookbook.

I will be removing the LWRPs from zabbix-agent soon and create a dependancy to libzabbix. Currently it stretches me to the extents of my ruby knowledge and a bit beyond. so the porting is rather slow. I also have a bit less time to dedicate to this task. Any help you could contribute would be greatly appreciated.

jeffmacdonald commented 9 years ago

It used prefork and worked fine. It was originally the cacti cookbook that I was using that called on apache2 and perhaps it tried to do funny things with php or apache2. in anycase its good now.

TD-4242 commented 9 years ago

I pushed a new release with the LWRPs move to libzabbix. let me know ASAP if you have any changes

lock[bot] commented 5 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.