Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Marcus Klang
Host Monitor
Commits
24ca1307
Commit
24ca1307
authored
Jun 30, 2021
by
root
Browse files
Added flafg for uptime-days
parent
af9d3070
Changes
1
Hide whitespace changes
Inline
Side-by-side
linux/host-monitor.sh
View file @
24ca1307
...
...
@@ -37,10 +37,10 @@ CPUModel="$(egrep "^model name" /proc/cpuinfo | sort -u | cut -d: -f2 | sed -e '
# Number of CPU:s (NbrCPUs=2):
NbrCPUs
=
$(
egrep
"^processor"
/proc/cpuinfo |
wc
-l
)
# Size of memory [kB]
RAM
=
$(
/usr/sbin/dmidecode
-t
17 |
grep
"Size.*MB"
|
awk
'{s+=$2} END {print s * 1024}'
)
# Ex: RAM=4194304
if
[
$RAM
-eq
0
]
;
then
RAM
=
$(
egrep
"^MemTotal"
/proc/meminfo |
awk
'{print $2}'
)
fi
##
RAM=$(/usr/sbin/dmidecode -t 17 | grep "Size.*MB" | awk '{s+=$2} END {print s * 1024}') # Ex: RAM=4194304
##
if [ $RAM -eq 0 ]; then
RAM
=
$(
egrep
-i
"^MemTotal"
/proc/meminfo |
awk
'{print $2}'
)
##
fi
# Kind of memory (ECC='No ECC' or ECC='Multi-bit ECC'):
ECC
=
"
$(
/usr/sbin/dmidecode
-t
memory | egrep
"Error Correction Type"
|
sort
-u
|
cut
-d
:
-f2
|
sed
-e
's/^ //'
-e
's/None/No ECC/'
)
"
# What kind of authentication? Ex: Authentication=Lucat
...
...
@@ -68,6 +68,7 @@ CPUBugs="$(egrep "^bugs" /proc/cpuinfo | cut -d: -f2 | cut -c2- | uniq)"
# Ex: CPUBugs='cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf mds swapgs itlb_multihit'
Kernel
=
"
$(
uname
-r
2>/dev/null
)
"
# Ex: Kernel=5.4.0-62-generic
Architecture
=
"
$(
uname
-m
2>/dev/null
)
"
# Ex: Architecture=x86_64
Uptime
=
"
$(
awk
'{print int($1/86400)}'
/proc/uptime
)
"
# Are we in a Virtual environment? This one is a bit tricky since there are many ways to cover this.
# Read this for more info: http://unix.stackexchange.com/questions/89714/easy-way-to-determine-virtualization-technology
VMenv
=
"
$(
dmesg 2>/dev/null |
grep
-i
" Hypervisor detected: "
2>/dev/null |
cut
-d
:
-f2
|
sed
's/^ *//'
)
"
...
...
@@ -153,7 +154,7 @@ FWrules="$(ufw status verbose 2>/dev/null | egrep "(ALLOW|DENY) IN" | awk '{prin
# Create a string for the CPU Bugs (to make the final assemble shorter)
CPUBugsStr
=
"
$(
if
[
-n
"
$CPUBugs
"
]
;
then
echo
",
\"
cpu-bugs:
${
CPUBugs
// /\
",
\"
cpu-bugs:}
\"
"
; fi)
"
# Assemble the Flags string
Flags="
\
"selinux:
$SELinux
\"
,
\"
kernel:
${
Kernel
}
\"
$CPUBugsStr
,
\"
arch:
${
Architecture
:-
--
}
\"
,
\"
fail2ban:
$Fail2Ban
\"
"
Flags="
\
"selinux:
$SELinux
\"
,
\"
kernel:
${
Kernel
}
\"
$CPUBugsStr
,
\"
arch:
${
Architecture
:-
--
}
\"
,
\"
fail2ban:
$Fail2Ban
\"
,
\"
Uptime-days:
$Uptime
\"
"
# partitions
OUTPUT=
""
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment