3

Is there a log file that logs information when the values set in /etc/security/limits.conf are exceeded?

If the values are too tight in the above file the clients using the website hosted on the server sees errors such as [FATAL] failed to allocate memory . But I wont be intimidated about it. So is there a log?

If not is there a way to make it log when the values are exceeded?

Stormvirux
  • 133
  • 5

3 Answers3

3

limits.conf is a too blunt an instrument for what you are trying to do.

cgroups will set limits and provide accounting for you, but the documentation is a little obtuse! https://www.kernel.org/doc/Documentation/cgroups/memory.txt

herestom
  • 156
  • 2
2

Is there a log file that logs information when the values set in /etc/security/limits.conf are exceeded?

Nope.

All those values go at last to process resource limits (man setrlimit) and when they met there's no universal mechanism to issue an warning to be logged.

poige
  • 9,448
  • 2
  • 25
  • 52
-1

if your issue is about memory allocation failed you could also use this script to monitor percentage of free memory left

#!/bin/bash
# you can adjust 0.20 meaning 20% to percentage of memory free you want 
output=$(free | grep "Swap" | awk '{if (($4/$2) < 0.20) print "memory low"}')
if [[ "$output" != "" ]]; then
    echo "..." | mail -s "Memory low on <host>" <monitoring email>
fi

save it to script file (ex. memmon.sh) and add to crontab it will send email and write log file when detect free memory low as conditioned)

# Ex. monitor every 3 min.
*/3 * * * * /home/user/memmon.sh >> /home/user/memmon.log
Wutiphong
  • 109
  • 3