File: kdump_mem_estimator

package info (click to toggle)
kdump-tools 1%3A1.10.7
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 316 kB
  • sloc: sh: 1,441; makefile: 59
file content (19 lines) | stat: -rwxr-xr-x 783 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/bin/sh
KDUMP_DIR="/var/lib/kdump"

if [ ! -x "$(command -v systemctl)" ]; then
	echo "Couldn't find systemctl" 1>&2
	exit 1
fi

# Notice that memory estimation would only be useful and represent the reality
# if a /proc/meminfo snapshot is collected early on boot, hence we have the
# check below - basically, we shouldn't collect the snapshot in case this
# is executed later by the users (manually or via restarting kdump-tools).
if ! systemctl is-active basic.target 1>/dev/null 2>&1; then
	# It's very likely this directory is already created, but if for some
	# reason it isn't, we will fail the memory estimator. So, create the
	# directory anyway - if it's already there, then this is a NOP.
	mkdir -p "${KDUMP_DIR}"
	cat /proc/meminfo 1> "${KDUMP_DIR}/mem-$(uname -r)"
fi