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

Use memory purge redis command when initializing new kb #452

Merged
merged 5 commits into from
Mar 15, 2021

Conversation

ArnoStiefvater
Copy link
Member

@ArnoStiefvater ArnoStiefvater commented Mar 9, 2021

What:

Use memory purge redis command when initializing new kb.

Why:

Handle issue of redis memory not being released to the OS again.

How:

Running the following script with a target of 5 hosts with ospd-openvas. Redis will use about 800M memory.

if(description) {
  script_oid("1.3.6.1.4.1.25623.1.0.999999");
  script_version("2019-09-09T06:03:58+0000");
  script_name("test redis memory");
  script_category(ACT_SCANNER);
  script_family("Port scanners");
  script_copyright("This script is Copyright (C) 2009 Greenbone Networks GmbH");
  script_tag(name:"last_modification", value:"2019-09-09 06:03:58 +0000 (Mon, 09 Sep 2019)");
  script_tag(name:"creation_date", value:"2009-10-26 10:02:32 +0100 (Mon, 26 Oct 2009)");
  script_tag(name:"cvss_base", value:"0.0");
  script_tag(name:"cvss_base_vector", value:"AV:N/AC:L/Au:N/C:N/I:N/A:N");
  script_tag(name:"summary", value:"some value");
  exit(0);
}

include("misc_func.inc"); # for rand_str()

i = 0;
key  = "key";
value = rand_str(length: 1000);

a = rand();
b = rand();
for (; i<100000; i++ ) {
    set_kb_item(name: key+i+a+b, value:value+b+a);
}

Check the memory via e.g. redis-cli -s /run/redis-openvas/redis.sock info memory | grep used_memory_rss.
Run some other script which does not use much memory. The memory will probably not decrease to the baseline again.

With the PR the memory will imiidiately decrease to the baseline again if a script was started which does not use much memory after the initial script was called.

Checklist:

@jjnicola jjnicola marked this pull request as draft March 9, 2021 14:10
@ArnoStiefvater ArnoStiefvater changed the title Add support for memory purge redis command Use memory purge redis command when initializing new kb Mar 10, 2021
@ArnoStiefvater ArnoStiefvater marked this pull request as ready for review March 10, 2021 10:33
@jjnicola jjnicola added the backport-to-stable This pull request will be backported to the 21.04 branch label Mar 15, 2021
@jjnicola jjnicola merged commit aa4f735 into greenbone:master Mar 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-to-stable This pull request will be backported to the 21.04 branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants