Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docker.cstatus[Up] value 1 when you don't have any container #74

Closed
kubadawczynski opened this issue Jun 22, 2017 · 9 comments
Closed

Comments

@kubadawczynski
Copy link

Whan any container is running

docker ps 
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
docker ps -a 
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES

you get info from key docker.cstatus[Up] that one container is running

zabbix_agentd -c /etc/zabbix/zabbix_agentd.conf -t 'docker.cstatus[Up]'
docker.cstatus[Up]                            [u|1]

Info from docker.socket

curl --unix-socket /var/run/docker.sock -X GET http:/v1.24/containers/json?all=0
[]
@jangaraj
Copy link
Member

Please start zabbix agent in debug mode and then provide agent logs. Please test it with zabbix_get utility.

@kubadawczynski
Copy link
Author

Hi @jangaraj

 14593:20170622:162803.398 Requested [docker.cstatus[Up]]
 14593:20170622:162803.398 In zbx_module_docker_cstatus()
 14593:20170622:162803.398 In zbx_module_docker_socket_query()
 14593:20170622:162803.398 Docker's socket query: GET /containers/json?all=0 HTTP/1.0
 14593:20170622:162803.399 Docker's socket response: []

@jangaraj
Copy link
Member

Could you add more log lines please? There is docker query and docker response, which is good. I would like to see there also agent response. Thanks.

@kubadawczynski
Copy link
Author

I had two containers but i deleted them to check this issue, i only use active checks, but all checks for docker.cstatus[Up] have been done with zabbix_get

 25008:20170622:172326.517 Starting Zabbix Agent [davka]. Zabbix 3.2.6 (revision 67849).
 25008:20170622:172326.517 **** Enabled features ****
 25008:20170622:172326.517 IPv6 support:          YES
 25008:20170622:172326.517 TLS support:           YES
 25008:20170622:172326.517 **************************
 25008:20170622:172326.517 using configuration file: /etc/zabbix/zabbix_agentd.conf
 25008:20170622:172326.517 In zbx_load_modules()
 25008:20170622:172326.517 loading module "/etc/zabbix//modules/zabbix_module_docker.so"
 25008:20170622:172326.517 In zbx_module_api_version()
 25008:20170622:172326.517 In zbx_module_init()
 25008:20170622:172326.517 zabbix_module_docker v0.6.6, compilation time: Jun 22 2017 10:35:32
 25008:20170622:172326.517 In zbx_docker_dir_detect()
 25008:20170622:172326.517 Detected docker stat directory: /sys/fs/cgroup/
 25008:20170622:172326.517 Detected used docker driver dir: docker/
 25008:20170622:172326.517 Detected JoinController cpu,cpuacct
 25008:20170622:172326.517 In zbx_docker_api_detect()
 25008:20170622:172326.517 In zbx_docker_perm()
 25008:20170622:172326.517 zabbix agent user has docker perm
 25008:20170622:172326.517 In zbx_module_docker_socket_query()
 25008:20170622:172326.517 Docker's socket query: GET /_ping HTTP/1.0
 25008:20170622:172326.517 Docker's socket response: OK
 25008:20170622:172326.517 Docker's socket works - extended docker metrics are available
 25008:20170622:172326.517 In zbx_module_item_list()
 25008:20170622:172326.517 In zbx_module_item_timeout()
 25008:20170622:172326.518 cannot find "zbx_module_history_write_cbs()" function in module "zabbix_module_docker.so": /etc/zabbix//modules/zabbix_module_docker.so: undefined symbol: zbx_module_history_write_cbs
 25008:20170622:172326.518 loaded modules: zabbix_module_docker.so
 25008:20170622:172326.518 End of zbx_load_modules():SUCCEED
 25008:20170622:172326.518 In init_collector_data()
 25008:20170622:172326.518 In zbx_dshm_create() proj_id:112 size:0
 25008:20170622:172326.518 End of zbx_dshm_create():SUCCEED shmid:-1
 25008:20170622:172326.518 End of init_collector_data()
 25008:20170622:172326.518 agent #0 started [main process]
 25012:20170622:172326.518 agent #2 started [listener #1]
 25011:20170622:172326.518 agent #1 started [collector]
 25012:20170622:172326.518 In zbx_tls_init_child()
 25011:20170622:172326.518 In init_cpu_collector()
 25014:20170622:172326.518 agent #3 started [listener #2]
 25011:20170622:172326.518 End of init_cpu_collector():SUCCEED
 25014:20170622:172326.518 In zbx_tls_init_child()
 25011:20170622:172326.518 __zbx_zbx_setproctitle() title:'collector [processing data]'
 25011:20170622:172326.518 In update_cpustats()
 25016:20170622:172326.519 agent #5 started [listener #4]
 25011:20170622:172326.519 End of update_cpustats()
 25016:20170622:172326.519 In zbx_tls_init_child()
 25011:20170622:172326.519 __zbx_zbx_setproctitle() title:'collector [idle 1 sec]'
 25015:20170622:172326.519 agent #4 started [listener #3]
 25015:20170622:172326.519 In zbx_tls_init_child()
 25014:20170622:172326.519 OpenSSL library (version OpenSSL 1.0.2g  1 Mar 2016) initialized
 25014:20170622:172326.519 End of zbx_tls_init_child()
 25014:20170622:172326.519 __zbx_zbx_setproctitle() title:'listener #2 [waiting for connection]'
 25018:20170622:172326.520 agent #6 started [listener #5]
 25012:20170622:172326.520 OpenSSL library (version OpenSSL 1.0.2g  1 Mar 2016) initialized
 25018:20170622:172326.520 In zbx_tls_init_child()
 25019:20170622:172326.520 agent #7 started [active checks #1]
 25012:20170622:172326.520 End of zbx_tls_init_child()
 25019:20170622:172326.520 In zbx_tls_init_child()
 25012:20170622:172326.520 __zbx_zbx_setproctitle() title:'listener #1 [waiting for connection]'
 25015:20170622:172326.520 OpenSSL library (version OpenSSL 1.0.2g  1 Mar 2016) initialized
 25015:20170622:172326.520 End of zbx_tls_init_child()
 25015:20170622:172326.520 __zbx_zbx_setproctitle() title:'listener #3 [waiting for connection]'
 25016:20170622:172326.520 OpenSSL library (version OpenSSL 1.0.2g  1 Mar 2016) initialized
 25016:20170622:172326.520 End of zbx_tls_init_child()
 25016:20170622:172326.520 __zbx_zbx_setproctitle() title:'listener #4 [waiting for connection]'
 25018:20170622:172326.521 OpenSSL library (version OpenSSL 1.0.2g  1 Mar 2016) initialized
 25019:20170622:172326.521 OpenSSL library (version OpenSSL 1.0.2g  1 Mar 2016) initialized
 25018:20170622:172326.521 End of zbx_tls_init_child()
 25018:20170622:172326.521 __zbx_zbx_setproctitle() title:'listener #5 [waiting for connection]'
 25019:20170622:172326.521 End of zbx_tls_init_child()
 25019:20170622:172326.521 In init_active_metrics()
 25019:20170622:172326.521 buffer: first allocation for 100 elements
 25019:20170622:172326.521 End of init_active_metrics()
 25019:20170622:172326.521 In send_buffer() host:'xxxxxxxxxxxxxxx' port:10051 entries:0/100
 25019:20170622:172326.521 End of send_buffer():SUCCEED
 25019:20170622:172326.521 __zbx_zbx_setproctitle() title:'active checks #1 [getting list of active checks]'
 25019:20170622:172326.521 In refresh_active_checks() host:'xxxxxxxxxxx' port:10051
 25019:20170622:172326.549 sending [{"request":"active checks","host":"davka"}]
 25019:20170622:172326.549 before read
 25019:20170622:172326.578 got [{"response":"success","data":[{"key":"docker.cstatus[All]","delay":60,"lastlogsize":0,"mtime":0},{"key":"docker.cstatus[Up]","delay":60,"lastlogsize":0,"mtime":0},{"key":"docker.discovery","delay":120,"lastlogsize":0,"mtime":0},{"key":"docker.up[/salt-master]","delay":30,"lastlogsize":0,"mtime":0},{"key":"docker.up[/slave-centos-7-2]","delay":30,"lastlogsize":0,"mtime":0},{"key":"docker.up[/slave-ubuntu-16-04]","delay":30,"lastlogsize":0,"mtime":0}]}]
 25019:20170622:172326.578 In parse_list_of_checks()
 25019:20170622:172326.578 In add_check() key:'docker.cstatus[All]' refresh:60 lastlogsize:0 mtime:0
 25019:20170622:172326.578 End of add_check()
 25019:20170622:172326.578 In add_check() key:'docker.cstatus[Up]' refresh:60 lastlogsize:0 mtime:0
 25019:20170622:172326.578 End of add_check()
 25019:20170622:172326.578 In add_check() key:'docker.discovery' refresh:120 lastlogsize:0 mtime:0
 25019:20170622:172326.578 End of add_check()
 25019:20170622:172326.578 In add_check() key:'docker.up[/salt-master]' refresh:30 lastlogsize:0 mtime:0
 25019:20170622:172326.578 End of add_check()
 25019:20170622:172326.578 In add_check() key:'docker.up[/slave-centos-7-2]' refresh:30 lastlogsize:0 mtime:0
 25019:20170622:172326.578 End of add_check()
 25019:20170622:172326.578 In add_check() key:'docker.up[/slave-ubuntu-16-04]' refresh:30 lastlogsize:0 mtime:0
 25019:20170622:172326.578 End of add_check()
 25019:20170622:172326.578 End of parse_list_of_checks():SUCCEED
 25019:20170622:172326.578 End of refresh_active_checks():SUCCEED
 25019:20170622:172326.578 __zbx_zbx_setproctitle() title:'active checks #1 [processing active checks]'
 25019:20170622:172326.578 In process_active_checks() server:'xxxxxxxxxxx' port:10051
 25019:20170622:172326.578 In zbx_module_docker_cstatus()
 25019:20170622:172326.578 In zbx_module_docker_socket_query()
 25019:20170622:172326.578 Docker's socket query: GET /containers/json?all=1 HTTP/1.0
 25019:20170622:172326.578 Docker's socket response: []
 25019:20170622:172326.578 Count of containers in All status: 1
 25019:20170622:172326.578 for key [docker.cstatus[All]] received value [1]
 25019:20170622:172326.578 In process_value() key:'davka:docker.cstatus[All]' value:'1'
 25019:20170622:172326.578 In send_buffer() host:'xxxxxxxxxxx' port:10051 entries:0/100
 25019:20170622:172326.578 End of send_buffer():SUCCEED
 25019:20170622:172326.578 buffer: new element 0
 25019:20170622:172326.578 End of process_value():SUCCEED
 25019:20170622:172326.578 In need_meta_update() key:docker.cstatus[All]
 25019:20170622:172326.578 End of need_meta_update():FAIL
 25019:20170622:172326.578 In zbx_module_docker_cstatus()
 25019:20170622:172326.578 In zbx_module_docker_socket_query()
 25019:20170622:172326.578 Docker's socket query: GET /containers/json?all=0 HTTP/1.0
 25019:20170622:172326.579 Docker's socket response: []
 25019:20170622:172326.579 Count of containers in Up status: 1
 25019:20170622:172326.579 for key [docker.cstatus[Up]] received value [1]
 25019:20170622:172326.579 In process_value() key:'davka:docker.cstatus[Up]' value:'1'
 25019:20170622:172326.579 In send_buffer() host:'xxxxxxxxxxx' port:10051 entries:1/100
 25019:20170622:172326.579 send_buffer() now:1498145006 lastsent:1498145006 now-lastsent:0 BufferSend:5; will not send now
 25019:20170622:172326.579 End of send_buffer():SUCCEED
 25019:20170622:172326.579 buffer: new element 1
 25019:20170622:172326.579 End of process_value():SUCCEED
 25019:20170622:172326.579 In need_meta_update() key:docker.cstatus[Up]
 25019:20170622:172326.579 End of need_meta_update():FAIL
 25019:20170622:172326.579 In zbx_module_docker_discovery_extended()
 25019:20170622:172326.579 In zbx_module_docker_socket_query()
 25019:20170622:172326.579 Docker's socket query: GET /containers/json?all=0 HTTP/1.0
 25019:20170622:172326.579 Docker's socket response: []
 25019:20170622:172326.579 for key [docker.discovery] received value [{"data":[]}]
 25019:20170622:172326.579 In process_value() key:'davka:docker.discovery' value:'{"data":[]}'
 25019:20170622:172326.579 In send_buffer() host:'xxxxxxxxxxx' port:10051 entries:2/100
 25019:20170622:172326.579 send_buffer() now:1498145006 lastsent:1498145006 now-lastsent:0 BufferSend:5; will not send now
 25019:20170622:172326.579 End of send_buffer():SUCCEED
 25019:20170622:172326.579 buffer: new element 2
 25019:20170622:172326.579 End of process_value():SUCCEED
 25019:20170622:172326.579 In need_meta_update() key:docker.discovery
 25019:20170622:172326.579 End of need_meta_update():FAIL
 25019:20170622:172326.579 In zbx_module_docker_up()
 25019:20170622:172326.579 In zbx_module_docker_get_fci()
 25019:20170622:172326.579 Translating container name to fci by using docker.inspect
 25019:20170622:172326.579 In zbx_module_docker_inspect_exec()
 25019:20170622:172326.579 In zbx_module_docker_socket_query()
 25019:20170622:172326.579 Docker's socket query: GET /containers/salt-master/json HTTP/1.0
 25019:20170622:172326.579 Docker's socket response: {"message":"No such container: salt-master"}
 25019:20170622:172326.579 Cannot find the [Id] item in the received JSON object
 25019:20170622:172326.579 Default fci will be used, because zbx_module_docker_inspect_exec FAIL: Cannot find the [Id] item in the received JSON object
 25019:20170622:172326.579 Metric source file: /sys/fs/cgroup/cpu,cpuacct/docker//salt-master/cpuacct.stat
 25019:20170622:172326.579 Cannot open metric file: '/sys/fs/cgroup/cpu,cpuacct/docker//salt-master/cpuacct.stat', container doesn't run
 25019:20170622:172326.579 for key [docker.up[/salt-master]] received value [0]
 25019:20170622:172326.579 In process_value() key:'davka:docker.up[/salt-master]' value:'0'
 25019:20170622:172326.579 In send_buffer() host:'xxxxxxxxxxx' port:10051 entries:3/100
 25019:20170622:172326.579 send_buffer() now:1498145006 lastsent:1498145006 now-lastsent:0 BufferSend:5; will not send now
 25019:20170622:172326.579 End of send_buffer():SUCCEED
 25019:20170622:172326.579 buffer: new element 3
 25019:20170622:172326.579 End of process_value():SUCCEED
 25019:20170622:172326.579 In need_meta_update() key:docker.up[/salt-master]
 25019:20170622:172326.579 End of need_meta_update():FAIL
 25019:20170622:172326.579 In zbx_module_docker_up()
 25019:20170622:172326.579 In zbx_module_docker_get_fci()
 25019:20170622:172326.579 Translating container name to fci by using docker.inspect
 25019:20170622:172326.579 In zbx_module_docker_inspect_exec()
 25019:20170622:172326.579 In zbx_module_docker_socket_query()
 25019:20170622:172326.579 Docker's socket query: GET /containers/slave-centos-7-2/json HTTP/1.0
 25019:20170622:172326.579 Docker's socket response: {"message":"No such container: slave-centos-7-2"}
 25019:20170622:172326.579 Cannot find the [Id] item in the received JSON object
 25019:20170622:172326.579 Default fci will be used, because zbx_module_docker_inspect_exec FAIL: Cannot find the [Id] item in the received JSON object
 25019:20170622:172326.579 Metric source file: /sys/fs/cgroup/cpu,cpuacct/docker//slave-centos-7-2/cpuacct.stat
 25019:20170622:172326.579 Cannot open metric file: '/sys/fs/cgroup/cpu,cpuacct/docker//slave-centos-7-2/cpuacct.stat', container doesn't run
 25019:20170622:172326.579 for key [docker.up[/slave-centos-7-2]] received value [0]
 25019:20170622:172326.579 In process_value() key:'davka:docker.up[/slave-centos-7-2]' value:'0'
 25019:20170622:172326.579 In send_buffer() host:'xxxxxxxxxxx' port:10051 entries:4/100
 25019:20170622:172326.579 send_buffer() now:1498145006 lastsent:1498145006 now-lastsent:0 BufferSend:5; will not send now
 25019:20170622:172326.579 End of send_buffer():SUCCEED
 25019:20170622:172326.579 buffer: new element 4
 25019:20170622:172326.579 End of process_value():SUCCEED
 25019:20170622:172326.579 In need_meta_update() key:docker.up[/slave-centos-7-2]
 25019:20170622:172326.579 End of need_meta_update():FAIL
 25019:20170622:172326.579 In zbx_module_docker_up()
 25019:20170622:172326.579 In zbx_module_docker_get_fci()
 25019:20170622:172326.579 Translating container name to fci by using docker.inspect
 25019:20170622:172326.579 In zbx_module_docker_inspect_exec()
 25019:20170622:172326.579 In zbx_module_docker_socket_query()
 25019:20170622:172326.579 Docker's socket query: GET /containers/slave-ubuntu-16-04/json HTTP/1.0
 25019:20170622:172326.579 Docker's socket response: {"message":"No such container: slave-ubuntu-16-04"}
 25019:20170622:172326.579 Cannot find the [Id] item in the received JSON object
 25019:20170622:172326.579 Default fci will be used, because zbx_module_docker_inspect_exec FAIL: Cannot find the [Id] item in the received JSON object
 25019:20170622:172326.579 Metric source file: /sys/fs/cgroup/cpu,cpuacct/docker//slave-ubuntu-16-04/cpuacct.stat
 25019:20170622:172326.579 Cannot open metric file: '/sys/fs/cgroup/cpu,cpuacct/docker//slave-ubuntu-16-04/cpuacct.stat', container doesn't run
 25019:20170622:172326.579 for key [docker.up[/slave-ubuntu-16-04]] received value [0]
 25019:20170622:172326.579 In process_value() key:'davka:docker.up[/slave-ubuntu-16-04]' value:'0'
 25019:20170622:172326.579 In send_buffer() host:'xxxxxxxxxxx' port:10051 entries:5/100
 25019:20170622:172326.579 send_buffer() now:1498145006 lastsent:1498145006 now-lastsent:0 BufferSend:5; will n send now
 25019:20170622:172326.579 End of send_buffer():SUCCEED
 25019:20170622:172326.579 buffer: new element 5
 25019:20170622:172326.579 End of process_value():SUCCEED
 25019:20170622:172326.579 In need_meta_update() key:docker.up[/slave-ubuntu-16-04]
 25019:20170622:172326.579 End of need_meta_update():FAIL
 25019:20170622:172326.579 End of process_active_checks()
 25019:20170622:172326.580 In get_min_nextcheck()
 25019:20170622:172326.580 End of get_min_nextcheck():1498145036
 25019:20170622:172326.580 __zbx_zbx_setproctitle() title:'active checks #1 [idle 1 sec]'
 25011:20170622:172327.519 __zbx_zbx_setproctitle() title:'collector [processing data]'
 25011:20170622:172327.519 In update_cpustats()
 25011:20170622:172327.519 End of update_cpustats()
 25011:20170622:172327.519 __zbx_zbx_setproctitle() title:'collector [idle 1 sec]'
 25019:20170622:172327.580 In send_buffer() host:'xxxxxxxxxxx' port:10051 entries:6/100
 25019:20170622:172327.580 send_buffer() now:1498145007 lastsent:1498145006 now-lastsent:1 BufferSend:5; will not send now
 25019:20170622:172327.580 End of send_buffer():SUCCEED
 25019:20170622:172327.580 __zbx_zbx_setproctitle() title:'active checks #1 [idle 1 sec]'
 25011:20170622:172328.519 __zbx_zbx_setproctitle() title:'collector [processing data]'
 25011:20170622:172328.519 In update_cpustats()
 25011:20170622:172328.519 End of update_cpustats()
 25011:20170622:172328.519 __zbx_zbx_setproctitle() title:'collector [idle 1 sec]'
 25019:20170622:172328.580 In send_buffer() host:'xxxxxxxxxxx' port:10051 entries:6/100
 25019:20170622:172328.580 send_buffer() now:1498145008 lastsent:1498145006 now-lastsent:2 BufferSend:5; will not send now
 25019:20170622:172328.580 End of send_buffer():SUCCEED
 25019:20170622:172328.580 __zbx_zbx_setproctitle() title:'active checks #1 [idle 1 sec]'
 25016:20170622:172329.254 __zbx_zbx_setproctitle() title:'listener #4 [processing request]'
 25016:20170622:172329.254 Requested [docker.cstatus[Up]]
 25016:20170622:172329.254 In zbx_module_docker_cstatus()
 25016:20170622:172329.254 In zbx_module_docker_socket_query()
 25016:20170622:172329.254 Docker's socket query: GET /containers/json?all=0 HTTP/1.0
 25016:20170622:172329.254 Docker's socket response: []
 25016:20170622:172329.254 Count of containers in Up status: 1
 25016:20170622:172329.254 Sending back [1]
 25016:20170622:172329.254 __zbx_zbx_setproctitle() title:'listener #4 [waiting for connection]'
 25011:20170622:172329.519 __zbx_zbx_setproctitle() title:'collector [processing data]'
 25011:20170622:172329.519 In update_cpustats()
 25011:20170622:172329.519 End of update_cpustats()
 25011:20170622:172329.519 __zbx_zbx_setproctitle() title:'collector [idle 1 sec]'
 25019:20170622:172329.580 In send_buffer() host:'xxxxxxxxxxx' port:10051 entries:6/100
 25019:20170622:172329.580 send_buffer() now:1498145009 lastsent:1498145006 now-lastsent:3 BufferSend:5; will not send now
 25019:20170622:172329.580 End of send_buffer():SUCCEED
 25019:20170622:172329.580 __zbx_zbx_setproctitle() title:'active checks #1 [idle 1 sec]'
 25014:20170622:172330.150 __zbx_zbx_setproctitle() title:'listener #2 [processing request]'
 25014:20170622:172330.150 Requested [docker.cstatus[Up]]
 25014:20170622:172330.150 In zbx_module_docker_cstatus()
 25014:20170622:172330.150 In zbx_module_docker_socket_query()
 25014:20170622:172330.150 Docker's socket query: GET /containers/json?all=0 HTTP/1.0
 25014:20170622:172330.150 Docker's socket response: []
 25014:20170622:172330.150 Count of containers in Up status: 1
 25014:20170622:172330.150 Sending back [1]
 25014:20170622:172330.150 __zbx_zbx_setproctitle() title:'listener #2 [waiting for connection]'
 25011:20170622:172330.519 __zbx_zbx_setproctitle() title:'collector [processing data]'
 25011:20170622:172330.519 In update_cpustats()
 25011:20170622:172330.519 End of update_cpustats()
 25011:20170622:172330.519 __zbx_zbx_setproctitle() title:'collector [idle 1 sec]'
 25019:20170622:172330.580 In send_buffer() host:'xxxxxxxxxxx' port:10051 entries:6/100
 25019:20170622:172330.580 send_buffer() now:1498145010 lastsent:1498145006 now-lastsent:4 BufferSend:5; will not send now
 25019:20170622:172330.580 End of send_buffer():SUCCEED
 25019:20170622:172330.580 __zbx_zbx_setproctitle() title:'active checks #1 [idle 1 sec]'
 25016:20170622:172330.846 __zbx_zbx_setproctitle() title:'listener #4 [processing request]'
 25016:20170622:172330.846 Requested [docker.cstatus[Up]]
 25016:20170622:172330.846 In zbx_module_docker_cstatus()
 25016:20170622:172330.846 In zbx_module_docker_socket_query()
 25016:20170622:172330.846 Docker's socket query: GET /containers/json?all=0 HTTP/1.0
 25016:20170622:172330.846 Docker's socket response: []
 25016:20170622:172330.846 Count of containers in Up status: 1
 25016:20170622:172330.846 Sending back [1]
 25016:20170622:172330.846 __zbx_zbx_setproctitle() title:'listener #4 [waiting for connection]'
 25011:20170622:172331.520 __zbx_zbx_setproctitle() title:'collector [processing data]'
 25011:20170622:172331.520 In update_cpustats()
 25011:20170622:172331.520 End of update_cpustats()
 25011:20170622:172331.520 __zbx_zbx_setproctitle() title:'collector [idle 1 sec]'
 25019:20170622:172331.580 In send_buffer() host:'xxxxxxxxxxx' port:10051 entries:6/100
 25019:20170622:172331.608 JSON before sending [{"request":"agent data","data":[{"host":"davka","key":"docker.cstatus[All]","value":"1","clock":1498145006,"ns":578872487},{"host":"davka","key":"docker.cstatus[Up]","value":"1","clock":1498145006,"ns":579094216},{"host":"davka","key":"docker.discovery","value":"{\"data\":[]}","clock":1498145006,"ns":579288547},{"host":"davka","key":"docker.up[/salt-master]","value":"0","clock":1498145006,"ns":579547821},{"host":"davka","key":"docker.up[/slave-centos-7-2]","value":"0","clock":1498145006,"ns":579766498},{"host":"davka","key":"docker.up[/slave-ubuntu-16-04]","value":"0","clock":1498145006,"ns":579984834}],"clock":1498145011,"ns":608263801}]
 25019:20170622:172331.650 JSON back [{"response":"success","info":"processed: 6; failed: 0; total: 6; seconds spent: 0.014679"}]
 25019:20170622:172331.650 In check_response() response:'{"response":"success","info":"processed: 6; failed: 0; total: 6; seconds spent: 0.014679"}'
 25019:20170622:172331.650 info from server: 'processed: 6; failed: 0; total: 6; seconds spent: 0.014679'
 25019:20170622:172331.650 End of check_response():SUCCEED
 25019:20170622:172331.650 OK
 25019:20170622:172331.650 End of send_buffer():SUCCEED
 25019:20170622:172331.650 __zbx_zbx_setproctitle() title:'active checks #1 [idle 1 sec]'
 25011:20170622:172332.520 __zbx_zbx_setproctitle() title:'collector [processing data]'
 25011:20170622:172332.520 In update_cpustats()
 25011:20170622:172332.520 End of update_cpustats()
 25011:20170622:172332.520 __zbx_zbx_setproctitle() title:'collector [idle 1 sec]'
 25019:20170622:172332.650 In send_buffer() host:'xxxxxxxxxxx' port:10051 entries:0/100
 25019:20170622:172332.650 End of send_buffer():SUCCEED
 25019:20170622:172332.650 __zbx_zbx_setproctitle() title:'active checks #1 [idle 1 sec]'
 25011:20170622:172333.520 __zbx_zbx_setproctitle() title:'collector [processing data]'
 25011:20170622:172333.520 In update_cpustats()
 25011:20170622:172333.520 End of update_cpustats()
 25011:20170622:172333.520 __zbx_zbx_setproctitle() title:'collector [idle 1 sec]'
 25019:20170622:172333.650 In send_buffer() host:'xxxxxxxxxxx' port:10051 entries:0/100
 25019:20170622:172333.651 End of send_buffer():SUCCEED
 25019:20170622:172333.651 __zbx_zbx_setproctitle() title:'active checks #1 [idle 1 sec]'
 25011:20170622:172334.520 __zbx_zbx_setproctitle() title:'collector [processing data]'
 25011:20170622:172334.520 In update_cpustats()
 25011:20170622:172334.520 End of update_cpustats()
 25011:20170622:172334.520 __zbx_zbx_setproctitle() title:'collector [idle 1 sec]'
 25019:20170622:172334.651 In send_buffer() host:'xxxxxxxxxxx' port:10051 entries:0/100
 25019:20170622:172334.651 End of send_buffer():SUCCEED
 25019:20170622:172334.651 __zbx_zbx_setproctitle() title:'active checks #1 [idle 1 sec]'
 25011:20170622:172335.520 __zbx_zbx_setproctitle() title:'collector [processing data]'
 25011:20170622:172335.520 In update_cpustats()
 25011:20170622:172335.521 End of update_cpustats()
 25011:20170622:172335.521 __zbx_zbx_setproctitle() title:'collector [idle 1 sec]'
 25019:20170622:172335.651 In send_buffer() host:'xxxxxxxxxxx' port:10051 entries:0/100
 25019:20170622:172335.651 End of send_buffer():SUCCEED
 25019:20170622:172335.651 __zbx_zbx_setproctitle() title:'active checks #1 [idle 1 sec]'
 25008:20170622:172336.319 Got signal [signal:15(SIGTERM),sender_pid:25057,sender_uid:0,reason:0]. Exiting ...
 25008:20170622:172336.319 zbx_on_exit() called
 25011:20170622:172336.319 Got signal [signal:15(SIGTERM),sender_pid:25008,sender_uid:122,reason:0]. Exiting ...
 25012:20170622:172336.319 Got signal [signal:15(SIGTERM),sender_pid:25008,sender_uid:122,reason:0]. Exiting ...
 25014:20170622:172336.319 Got signal [signal:15(SIGTERM),sender_pid:25008,sender_uid:122,reason:0]. Exiting ...
 25016:20170622:172336.319 Got signal [signal:15(SIGTERM),sender_pid:25008,sender_uid:122,reason:0]. Exiting ...
 25019:20170622:172336.319 Got signal [signal:15(SIGTERM),sender_pid:25008,sender_uid:122,reason:0]. Exiting ...
 25015:20170622:172336.319 Got signal [signal:15(SIGTERM),sender_pid:25008,sender_uid:122,reason:0]. Exiting ...
 25018:20170622:172336.320 Got signal [signal:15(SIGTERM),sender_pid:25008,sender_uid:122,reason:0]. Exiting ...
 25008:20170622:172336.320 In zbx_dshm_destroy() shmid:-1
 25008:20170622:172336.320 End of zbx_dshm_destroy():SUCCEED
 25008:20170622:172336.320 In zbx_unload_modules()
 25008:20170622:172336.321 In zbx_module_uninit()
 25008:20170622:172336.321 /var/run/netns: [2] No such file or directory
 25008:20170622:172336.321 End of zbx_unload_modules()
 25008:20170622:172336.321 Zabbix Agent stopped. Zabbix 3.2.6 (revision 67849).

We found that issue, is with json parser
When docker returns []+new line, strlen for this return 3 after removal of all whitespaces it has value 2

and in src/libs/zbxjson/json.c

int	zbx_json_count(const struct zbx_json_parse *jp)
{
	int		num = 0;
	const char	*p = NULL;

	while (NULL != (p = zbx_json_next(jp, p)))
		num++;

	return num;
}
const char	*zbx_json_next(const struct zbx_json_parse *jp, const char *p)
{
	int	level = 0;
	int	state = 0;	/* 0 - outside string; 1 - inside string */

	if (1 == jp->end - jp->start)	/* empty object or array */
		return NULL;

value is compared to 1 but the value is 2 that's why it's returning 1 as value for checks when answer from docker is []

@kubadawczynski kubadawczynski changed the title docker.cstatus[Up] value 1 whan you don't have any container docker.cstatus[Up] value 1 when you don't have any container Jun 22, 2017
@jangaraj
Copy link
Member

You are right. I can replicate it as well.

[root@dockerhost ~]# docker rm -f $(docker ps -aq)
dfeaded9b7e0
844f1ebaab24
50d059f0a3ec
[root@dockerhost ~]# zabbix_get -s 127.0.0.1 -k docker.cstatus[Up]
1
[root@dockerhost ~]# docker run -d busybox sleep 300
323823af0ea73602da55d37bc9ec1d1f0daf83e967971c66e43ff2871dc3f875
[root@dockerhost ~]# zabbix_get -s 127.0.0.1 -k docker.cstatus[Up]
1
[root@dockerhost ~]# docker run -d busybox sleep 300
77b234c39c78001e37b5fceaaf132d522d34d12152a80d60bdb587bcb6c9720d
^[[A[root@dockerhost zabbix_get -s 127.0.0.1 -k docker.cstatus[Up]
2
[root@dockerhost ~]# docker run -d busybox sleep 300
0bd2eab482be746211a1059d99774d1e14e2796ece9eda47184eecb591edc447
[root@dockerhost ~]# zabbix_get -s 127.0.0.1 -k docker.cstatus[Up]
3

@kubadawczynski
Copy link
Author

For other statuses like all etc.. when you have this empty answer [], it returns 0 as well due this parser

@jangaraj
Copy link
Member

Please test cstatus branch.

[root@dockerhost zabbix_module_docker]# zabbix_get -s 127.0.0.1 -k docker.cstatus[Exited]
0
[root@dockerhost zabbix_module_docker]# zabbix_get -s 127.0.0.1 -k docker.cstatus[Crashed]
0
[root@dockerhost zabbix_module_docker]# zabbix_get -s 127.0.0.1 -k docker.cstatus[All]
0
[root@dockerhost zabbix_module_docker]# zabbix_get -s 127.0.0.1 -k docker.cstatus[Up]
0
[root@dockerhost zabbix_module_docker]# zabbix_get -s 127.0.0.1 -k docker.cstatus[Paused]
0

@kubadawczynski
Copy link
Author

Works fine

@jangaraj
Copy link
Member

Fixed in the v0.6.7 release - #76

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants