Get Available/Used Memory for alert

We’re having problems with memory alerts. I tried to create an alert on the mem free value. However, our systems are highly using free memory for file system caches. This makes a difference of around 32 GB between the "free“ command fields.

[email protected]:~# free -m
total used free shared buff/cache available
Mem: 64422 26703 469 0 37249 36999

As the documentation states, "available" is not an available metric currently. Also "used" doesn’t seem to be available.

So can this field be available in the Linux systems metrics plugin, too? Alternatively, can we get the "used" metric and calculate a percent value of used/total to effectively trigger an alarm?

--- asked by KPS.com

Comments

  • Wei LiWei Li admin

    You could use shell monitor to get the "available" memory of the server. Adding the following config to agent.json should do it.

    {
    "monitors": [
    {
    "module": "scalyr_agent.builtin_monitors.shell_monitor",
    "id": "report available memory",
    "command": "free -m | grep Mem | awk '{print $7}'"
    }
    ]
    }

    Basically, it executes the bash command on the server and Scalyr will ingest the returning output. Then, you can then use the output value to set up the alert.

    Here is a sample log event of the shell monitor using the above monitor configuration.
    image

    The field "value" is taken from the "available" output of "free-m".
    [[email protected] ~]$ free -m
    total used free shared buff/cache available
    Mem: 990 383 65 56 540 361

    Here is the documentation for shell monitor
    https://www.scalyr.com/help/monitors/shell

Sign In or Register to comment.