vulogov / zas_agent

Zabbix Agent Simulator
GNU General Public License v2.0
43 stars 16 forks source link

Can't bind address in daemonize mode #3

Closed alexanderzobnin closed 8 years ago

alexanderzobnin commented 8 years ago

When zas_agent is started normally all works fine. But if I try to start with --daemonize agent can't bind address. But procees is running:

[root@myhost zas_agent]# zas_agent.py --start --port 10060 --scenario '/etc/zas_scenario.cfg' --daemonize --pid '/tmp/zas_agent.pid' 
[root@myhost zas_agent]# netstat -lnt4
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State      
tcp        0      0 0.0.0.0:10050           0.0.0.0:*               LISTEN     
tcp        0      0 0.0.0.0:10051           0.0.0.0:*               LISTEN     
tcp        0      0 0.0.0.0:3306            0.0.0.0:*               LISTEN     
tcp        0      0 127.0.0.1:6379          0.0.0.0:*               LISTEN     
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN     
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN     
[root@myhost zas_agent]# ps -ely | grep zas
S   996 25866     1  0  80   0 10172 54132 skb_re ?        00:00:00 zas_agent.py
vulogov commented 8 years ago

After start, zas_agent will change user/group. The default user/group for the daemon is zabbix/zabbix do you have those user/group in your system ?

vulogov commented 8 years ago

Also, can you check lsof -i|grep 10060 before and after you start. Basically, what I am looking for, the evidences if other instance of zas_agent not exited cleanly and still grab the port. What will happens if you'll try to bind to 10061 ?

vulogov commented 8 years ago

I've added some checkups. Please start an agent and look in logfile if you have an error during the bind. Because if you do, the agent shall exit now.

alexanderzobnin commented 8 years ago

@vulogov I have no any errors - log file aren't created. I just see started process, but port is not bound. If I run zas agent without --daemonize it's all right.

alexanderzobnin commented 8 years ago

@vulogov I tried just now but the same issue - no log file created and port not bound.

alexanderzobnin commented 8 years ago

@vulogov I also have zabbix:zabbix user/group on my server (zabbix instance runnig here). I use CentOS 7 and python 2.7.5.

vulogov commented 8 years ago

What about lsof -i|grep 10060 ? Or bind to a 10061 ?

vulogov commented 8 years ago

I see the problem

alexanderzobnin commented 8 years ago

Same problem when I trying to bind to any unused port.

vulogov commented 8 years ago

The problem is in read access rights to the configuration file. Main process were tried to read /etc/zas_scenario.conf and if it can not, it catches the trace. Creating a checking code and ensure if there is a traceback here, daemon shall exit.

vulogov commented 8 years ago
  1. Check-out last update
  2. Fix the permissions to your /etc/zas_scenario.cfg. User under which you running the agent shall be able to read this file.
  3. Try again and let me know if problem fixed.

BTW, thank you for the bug reports.

alexanderzobnin commented 8 years ago

@vulogov Now --daemonize works! Many thanks!

alexanderzobnin commented 8 years ago

This tool is really helps me. I need to perform zabbix instance with multiple hosts ang groups for my project demo (Grafana plugin for zabbix). You can look at generated data here.

vulogov commented 8 years ago

Sure, one of the reasons this tool exists is demo, development and a testing. Good luck, let me know if anything else is broken.

vulogov commented 8 years ago

Resolved.