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
89870efb
Commit
89870efb
authored
Jul 02, 2021
by
root
Browse files
Added check for if reboot is needed
parent
52b789c9
Changes
1
Hide whitespace changes
Inline
Side-by-side
linux/host-monitor.sh
View file @
89870efb
...
...
@@ -69,6 +69,30 @@ CPUBugs="$(egrep "^bugs" /proc/cpuinfo | cut -d: -f2 | cut -c2- | uniq)"
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
)
"
# Is reboot required?
UbuntuReboot
()
{
if
[
-f
/var/run/reboot-required
]
;
then
RebootRequired
=
"Yes"
else
RebootRequired
=
"No"
fi
}
RedHatReboot
()
{
if
[
-x
/bin/needs-restarting
]
;
then
if
[
-n
"
$(
needs-restarting
-r
2>/dev/null | egrep
-i
"reboot"
| egrep
"not necessary"
)
"
]
;
then
RebootRequired
=
"No"
else
RebootRequired
=
"Yes"
fi
fi
}
case
"
$(
echo
"
${
OS
,,
}
"
|
cut
-c-6
)
"
in
"centos"
)
RedHatReboot
;;
"red ha"
)
RedHatReboot
;;
"ubuntu"
)
UbuntuReboot
;;
esac
# 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/^ *//'
)
"
...
...
@@ -154,7 +178,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
\"
,
\"
Uptime-days:
$Uptime
\"
"
Flags="
\
"selinux:
$SELinux
\"
,
\"
kernel:
${
Kernel
}
\"
$CPUBugsStr
,
\"
arch:
${
Architecture
:-
--
}
\"
,
\"
fail2ban:
$Fail2Ban
\"
,
\"
Uptime-days:
$Uptime
\"
,
\"
Reboot-required:
$RebootRequired
\"
"
# 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