-
Notifications
You must be signed in to change notification settings - Fork 0
/
memory
59 lines (47 loc) · 2.5 KB
/
memory
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/bash
##Script to show information regarding the computer's memory hierarchy.
#Prof. Filippo Valiante Filho
#https://prof.valiante.info
#Version 1.12
#2024-10-08
#Previous verification of swap configuration.
#The % of use of the main memory where the system starts to use swap is calculated using $((100-valorswap)).
valorswap=$(cat /proc/sys/vm/swappiness)
isswap=$(wc -l < /proc/swaps) #check if swap is configured
#Beginning of information
clear
echo -e "\nMemory Hierarchy of computer [$(hostname)]:\n"
#CACHE MEMORY
echo -e "\nCACHE MEMORY\n"
echo -e -n "Microprocessor ["$(lscpu | grep -iE 'nome|name')"] with "$(nproc --all)" CPU(s) and the following cache memory configuration:\n\n"
lscpu -C --output-all 2> /dev/null || lscpu | grep cache
#MAIN MEMORY
echo -e "\n\nMAIN MEMORY\n"
lsmem
echo ""
free -h | head -n2
#SECONDARY MEMORY
echo -e "\n\nSECONDARY MEMORY\n"
lsblk --output VENDOR,MODEL,STATE,TRAN,NAME,TYPE,SIZE,FSTYPE,MOUNTPOINT,HOTPLUG --exclude 7
echo -e "\n\nTo see information about the secondary memory run 'df -hT'. If you want something more readable try df -haT | head -n1 && df -haT | grep -iE '/sd|/mnt|/mmc|/sr|/sg|/xvd|/hd|/ssd|/md|/dev/root' to get:\n"
df -hT | head -n1 && df -hT | grep -iE '/sd|/mnt|/mmc|/sr|/sg|/xvd|/hd|/ssd|/md|/dev/root'
echo -e "\n\nTo see more information regarding your memory's hardware run 'lshw' as administrator (sudo lshw). Information will be easier to visualize if you run 'sudo lshw -html > hwinfo.html' and open the file in the web browser.\n\n"
#Waits for a key before continuing.
read -r -p "*** Press any key to see information about VIRTUAL MEMORY. ***" -n 1
#MEMÓRIA VIRTUAL
echo -e "\n\n\nVIRTUAL MEMORY - SWAP\n"
if [ $isswap -eq 1 ]
then
echo -e -n "\nSwap is not configured!\n"
else
echo -e -n "\nSwap configured in ["$(cut -c 1-14 < /proc/swaps | tail -n1)"].\n"
free -h | head -n1
free -h | grep -i swap
fi
echo -e "\n\nVIRTUAL MEMORY - TOTAL\n"
free -ht | head -n1
free -ht | tail -n1
echo -e "\n\nThe address space is organized as follows:\n"
cat /proc/cpuinfo | grep address | head -n1
echo -e "\n\nYour system is configured to start using swap with [$((100-valorswap))%] of use of the main memory."
echo -e "\nTo alter this, edit the file /etc/sysctl.conf as superuser and add, or uncomment, the line vm.swappiness. E.g. vm.swappiness=10 tells the system to start using swap only after using 90% of the main memory. The standard value of 60 tells the system to start using swap with just 40% of main memory's usage.\n\n"