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

SASL support #27

Open
kazeno opened this issue Dec 23, 2022 · 2 comments
Open

SASL support #27

kazeno opened this issue Dec 23, 2022 · 2 comments
Assignees
Labels
bug Something isn't working enhancement New feature or request help wanted Extra attention is needed

Comments

@kazeno
Copy link

kazeno commented Dec 23, 2022

Is your feature request related to a problem?

Currently it's not possible to connect to a SASL enabled server.

Describe the solution you'd like

Being able to set SASL user and password, preferably per server or cluster, but could be globally.

Describe alternatives you've considered

I actually built an image on top of this that adds the following code to Library_Command_Memcached::__construct():

$user = getenv('MEMCACHED_SASL_USER');
$pass = getenv('MEMCACHED_SASL_PASS');
if ($user && $pass) {
    self::$_memcache->setOption(Memcached::OPT_BINARY_PROTOCOL, true);
    self::$_memcache->setSaslAuthData($user, $pass);
}

and runs the following inside its Dockerfile:

RUN apt-get update && apt-get install --no-install-recommends -y \
    libmemcached-dev \
    libsasl2-modules \
    libzip-dev \
    zip \
    && pecl install memcached \
    && docker-php-ext-enable memcached.so \
    && docker-php-ext-install zip \
    && rm -rf /var/lib/apt/lists/*

and setting the env variables MEMCACHED_SASL_USER and MEMCACHED_SASL_PASS, and configuring the GUI to use PECL Memcached for each function did get me connected to the SASL authenticated server. However all the stat graphs are broken, showing instead Warning: A non-numeric value encountered in /var/www/html/Library/Data/Analysis.php on line 56

However, the table near the bottom with the NAME, SIZE, %MEM (etc.) columns does work, so there's probably some incompatibility in the PECL Memcached code pathway.

Additional context

Screenshot of my hack in action, just for reference
image

@kazeno kazeno added the enhancement New feature or request label Dec 23, 2022
@hatamiarash7
Copy link
Owner

Hi @kazeno. Thanks for the report.

Currently, I don't have any instance with SASL to test this situation. But you can debug $previous and $actual arrays that pass to diff() here and check data. I think one of these arrays ( maybe both ) is empty or contains useless data.

Those arrays are created in this section

@hatamiarash7 hatamiarash7 added bug Something isn't working help wanted Extra attention is needed labels Dec 23, 2022
@kazeno
Copy link
Author

kazeno commented Dec 23, 2022

I made a var_dump() of both arrays and they do contain data, though some of the rows are strings and that's what was creating the notices. By checking if they're numeric or empty here and through liberal use of ?: 0 on lines 57, 87, 99, 113 and 126 of that same file I did get rid of all the notices... however the graphs are still missing.

Here's my var_dump of $previous and $actual, just in case the cause of the missing graphs is readily apparent:

array(2) {
  ["previous"]=>
  array(93) {
	["pid"]=>
	int(1)
	["uptime"]=>
	int(71551)
	["time"]=>
	int(1671818760)
	["version"]=>
	string(6) "1.6.17"
	["libevent"]=>
	string(13) "2.1.12-stable"
	["pointer_size"]=>
	int(64)
	["rusage_user"]=>
	float(15.973152)
	["rusage_system"]=>
	float(12.231043)
	["max_connections"]=>
	int(2000)
	["curr_connections"]=>
	int(2)
	["total_connections"]=>
	int(22567)
	["rejected_connections"]=>
	int(0)
	["connection_structures"]=>
	int(10)
	["response_obj_oom"]=>
	int(0)
	["response_obj_count"]=>
	int(1)
	["response_obj_bytes"]=>
	int(65536)
	["read_buf_count"]=>
	int(15)
	["read_buf_bytes"]=>
	int(245760)
	["read_buf_bytes_free"]=>
	int(163840)
	["read_buf_oom"]=>
	int(0)
	["reserved_fds"]=>
	int(20)
	["cmd_get"]=>
	int(46805)
	["cmd_set"]=>
	int(37992)
	["cmd_flush"]=>
	int(0)
	["cmd_touch"]=>
	int(0)
	["cmd_meta"]=>
	int(0)
	["get_hits"]=>
	int(19293)
	["get_misses"]=>
	int(27512)
	["get_expired"]=>
	int(1209)
	["get_flushed"]=>
	int(0)
	["delete_misses"]=>
	string(0) ""
	["delete_hits"]=>
	string(0) ""
	["incr_misses"]=>
	string(0) ""
	["incr_hits"]=>
	string(0) ""
	["decr_misses"]=>
	string(0) ""
	["decr_hits"]=>
	string(0) ""
	["cas_misses"]=>
	string(0) ""
	["cas_hits"]=>
	string(0) ""
	["cas_badval"]=>
	string(0) ""
	["touch_hits"]=>
	int(0)
	["touch_misses"]=>
	int(0)
	["store_too_large"]=>
	int(0)
	["store_no_memory"]=>
	int(0)
	["auth_cmds"]=>
	int(1047)
	["auth_errors"]=>
	int(0)
	["bytes_read"]=>
	int(6848638802)
	["bytes_written"]=>
	int(48389082)
	["limit_maxbytes"]=>
	int(480247808)
	["accepting_conns"]=>
	int(1)
	["listen_disabled_num"]=>
	int(0)
	["time_in_listen_disabled_us"]=>
	int(0)
	["threads"]=>
	int(4)
	["conn_yields"]=>
	int(0)
	["hash_power_level"]=>
	int(16)
	["hash_bytes"]=>
	int(524288)
	["hash_is_expanding"]=>
	int(0)
	["slab_reassign_rescues"]=>
	int(0)
	["slab_reassign_chunk_rescues"]=>
	int(0)
	["slab_reassign_evictions_nomem"]=>
	int(0)
	["slab_reassign_inline_reclaim"]=>
	int(0)
	["slab_reassign_busy_items"]=>
	int(0)
	["slab_reassign_busy_deletes"]=>
	int(0)
	["slab_reassign_running"]=>
	int(0)
	["slabs_moved"]=>
	int(0)
	["lru_crawler_running"]=>
	int(0)
	["lru_crawler_starts"]=>
	int(51)
	["lru_maintainer_juggles"]=>
	int(547646)
	["malloc_fails"]=>
	int(0)
	["log_worker_dropped"]=>
	int(0)
	["log_worker_written"]=>
	int(0)
	["log_watcher_skipped"]=>
	int(0)
	["log_watcher_sent"]=>
	int(0)
	["log_watchers"]=>
	int(0)
	["unexpected_napi_ids"]=>
	int(0)
	["round_robin_fallback"]=>
	int(0)
	["bytes"]=>
	int(4126848)
	["curr_items"]=>
	int(5558)
	["total_items"]=>
	int(37992)
	["slab_global_page_pool"]=>
	int(0)
	["expired_unfetched"]=>
	int(7042)
	["evicted_unfetched"]=>
	int(0)
	["evicted_active"]=>
	int(0)
	["evictions"]=>
	int(0)
	["reclaimed"]=>
	int(12249)
	["crawler_reclaimed"]=>
	int(0)
	["crawler_items_checked"]=>
	int(4572)
	["lrutail_reflocked"]=>
	int(26)
	["moves_to_cold"]=>
	int(41535)
	["moves_to_warm"]=>
	int(7526)
	["moves_within_lru"]=>
	int(1653)
	["direct_reclaims"]=>
	int(0)
	["lru_bumps_dropped"]=>
	int(0)
	["query_time"]=>
	float(487.08915710449)
  }
  ["actual"]=>
  array(93) {
	["pid"]=>
	int(1)
	["uptime"]=>
	int(71556)
	["time"]=>
	int(1671818765)
	["version"]=>
	string(6) "1.6.17"
	["libevent"]=>
	string(13) "2.1.12-stable"
	["pointer_size"]=>
	int(64)
	["rusage_user"]=>
	float(15.97541)
	["rusage_system"]=>
	float(12.232771)
	["max_connections"]=>
	int(2000)
	["curr_connections"]=>
	int(2)
	["total_connections"]=>
	int(22569)
	["rejected_connections"]=>
	int(0)
	["connection_structures"]=>
	int(10)
	["response_obj_oom"]=>
	int(0)
	["response_obj_count"]=>
	int(1)
	["response_obj_bytes"]=>
	int(65536)
	["read_buf_count"]=>
	int(15)
	["read_buf_bytes"]=>
	int(245760)
	["read_buf_bytes_free"]=>
	int(163840)
	["read_buf_oom"]=>
	int(0)
	["reserved_fds"]=>
	int(20)
	["cmd_get"]=>
	int(46805)
	["cmd_set"]=>
	int(37992)
	["cmd_flush"]=>
	int(0)
	["cmd_touch"]=>
	int(0)
	["cmd_meta"]=>
	int(0)
	["get_hits"]=>
	int(19293)
	["get_misses"]=>
	int(27512)
	["get_expired"]=>
	int(1209)
	["get_flushed"]=>
	int(0)
	["delete_misses"]=>
	string(0) ""
	["delete_hits"]=>
	string(0) ""
	["incr_misses"]=>
	string(0) ""
	["incr_hits"]=>
	string(0) ""
	["decr_misses"]=>
	string(0) ""
	["decr_hits"]=>
	string(0) ""
	["cas_misses"]=>
	string(0) ""
	["cas_hits"]=>
	string(0) ""
	["cas_badval"]=>
	string(0) ""
	["touch_hits"]=>
	int(0)
	["touch_misses"]=>
	int(0)
	["store_too_large"]=>
	int(0)
	["store_no_memory"]=>
	int(0)
	["auth_cmds"]=>
	int(1048)
	["auth_errors"]=>
	int(0)
	["bytes_read"]=>
	int(6848638967)
	["bytes_written"]=>
	int(48392989)
	["limit_maxbytes"]=>
	int(480247808)
	["accepting_conns"]=>
	int(1)
	["listen_disabled_num"]=>
	int(0)
	["time_in_listen_disabled_us"]=>
	int(0)
	["threads"]=>
	int(4)
	["conn_yields"]=>
	int(0)
	["hash_power_level"]=>
	int(16)
	["hash_bytes"]=>
	int(524288)
	["hash_is_expanding"]=>
	int(0)
	["slab_reassign_rescues"]=>
	int(0)
	["slab_reassign_chunk_rescues"]=>
	int(0)
	["slab_reassign_evictions_nomem"]=>
	int(0)
	["slab_reassign_inline_reclaim"]=>
	int(0)
	["slab_reassign_busy_items"]=>
	int(0)
	["slab_reassign_busy_deletes"]=>
	int(0)
	["slab_reassign_running"]=>
	int(0)
	["slabs_moved"]=>
	int(0)
	["lru_crawler_running"]=>
	int(0)
	["lru_crawler_starts"]=>
	int(51)
	["lru_maintainer_juggles"]=>
	int(547854)
	["malloc_fails"]=>
	int(0)
	["log_worker_dropped"]=>
	int(0)
	["log_worker_written"]=>
	int(0)
	["log_watcher_skipped"]=>
	int(0)
	["log_watcher_sent"]=>
	int(0)
	["log_watchers"]=>
	int(0)
	["unexpected_napi_ids"]=>
	int(0)
	["round_robin_fallback"]=>
	int(0)
	["bytes"]=>
	int(4126848)
	["curr_items"]=>
	int(5558)
	["total_items"]=>
	int(37992)
	["slab_global_page_pool"]=>
	int(0)
	["expired_unfetched"]=>
	int(7042)
	["evicted_unfetched"]=>
	int(0)
	["evicted_active"]=>
	int(0)
	["evictions"]=>
	int(0)
	["reclaimed"]=>
	int(12249)
	["crawler_reclaimed"]=>
	int(0)
	["crawler_items_checked"]=>
	int(4572)
	["lrutail_reflocked"]=>
	int(26)
	["moves_to_cold"]=>
	int(41535)
	["moves_to_warm"]=>
	int(7526)
	["moves_within_lru"]=>
	int(1655)
	["direct_reclaims"]=>
	int(0)
	["lru_bumps_dropped"]=>
	int(0)
	["query_time"]=>
	float(486.41204833984)
  }
}

In any case thanks for the help so far, and if you're ever interested in testing SASL, it's super easy with the bitnami/memcached Docker image: you just set the MEMCACHED_USERNAME and MEMCACHED_PASSWORD env variables, and SASL gets automatically enabled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants