-
Notifications
You must be signed in to change notification settings - Fork 3
/
zabbix_kmod
executable file
·43 lines (34 loc) · 919 Bytes
/
zabbix_kmod
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
#!/bin/bash
#
# Zabbix agent extension for monitoring which kernel modules are loaded
BUFFER=/tmp/zabbix-kmod
SOFTWARE="sed"
# Add /usr/sbin to PATH to make this run on RHEL based systems
PATH="$PATH:/usr/sbin"
function getdata() {
mkdir $BUFFER.$$; chmod 750 $BUFFER.$$
cd $BUFFER.$$
lsmod | sed '1d; s/ .*//' > loaded_modules
test -d $BUFFER && mv $BUFFER $BUFFER.old
mv $BUFFER.$$ $BUFFER
rm -rf $BUFFER.old
}
function sanity_check() {
ok=1
for prog in $SOFTWARE
do
which $prog > /dev/null || { echo "Missing program $prog."; ok=0; }
done
test -f $CONFIG || { echo "Missing configfile $CONFIG"; ok=0; }
test $ok -ne 1 && { echo "Sanity check failed. Aboring." ; exit 1; }
}
sanity_check
action=$1
case "$action" in
getdata)
getdata
;;
kmod.loaded-modules)
test -f $BUFFER/loaded_modules && cat $BUFFER/loaded_modules
;;
esac