Ngx.shared_dict.get_keys usage

Hi,

I’m trying to use the lua module in combination with ngx.shared.DICT
feature to record some statistics for nginx (and upstreams’) health
monitoring.

When I do dict.get_keys(100), I see the following error in nginx
error.log:

2014/08/06 06:27:55 [error] 13446#0: *1 lua entry thread aborted:
runtime
error: /opt/inmobi/nginx/customlua/logging.lua:56: bad argument #1 to
‘get_keys’ (userdata expected, got number)
stack traceback:
coroutine 0:
[C]: in function ‘get_keys’
/opt/inmobi/nginx/customlua/logging.lua:56: in function
‘get_all_plots’
[string “content_by_lua”]:3: in function <[string
“content_by_lua”]:1>, client: 127.0.0.1, server: , request: “GET /stat2
HTTP/1.1”, host: “localhost”

I’m using ngx_openresty version: ngx_openresty/1.2.4.11

Could someone please guide me how to use the get_keys method of the
shared
dict in nginx/lua?

Cheers,

-Suraj

[1] Much in the spirit of
http://blog.cloudflare.com/pushing-nginx-to-its-limit-with-lua


An Onion is the Onion skin and the Onion under the skin until the Onion
Skin without any Onion underneath.


The information contained in this communication is intended solely for
the
use of the individual or entity to whom it is addressed and others
authorized to receive it. It may contain confidential or legally
privileged
information. If you are not the intended recipient you are hereby
notified
that any disclosure, copying, distribution or taking any action in
reliance
on the contents of this information is strictly prohibited and may be
unlawful. If you have received this communication in error, please
notify
us immediately by responding to this email and then delete it from your
system. The firm is neither liable for the proper and complete
transmission
of the information contained in this communication nor for any delay in
its
receipt.

On Wed, Aug 6, 2014 at 12:14 PM, Suraj K. [email protected]
wrote:

When I do dict.get_keys(100), I see the following error in nginx error.log:

Never mind. I figured one must do dict:get_keys() and not
dict.get_keys()

That makes my first question and my first answer on this list on the
same
thread! :wink:

Thanks,

-Suraj


The information contained in this communication is intended solely for
the
use of the individual or entity to whom it is addressed and others
authorized to receive it. It may contain confidential or legally
privileged
information. If you are not the intended recipient you are hereby
notified
that any disclosure, copying, distribution or taking any action in
reliance
on the contents of this information is strictly prohibited and may be
unlawful. If you have received this communication in error, please
notify
us immediately by responding to this email and then delete it from your
system. The firm is neither liable for the proper and complete
transmission
of the information contained in this communication nor for any delay in
its
receipt.

hmmm… also you’d better to upgrade the openresty version. it’ too old.
:slight_smile:


smallfish http://chenxiaoyu.org