2 # +------------------------------------------------------------------+
3 # | ____ _ _ __ __ _ __ |
4 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
5 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
6 # | | |___| | | | __/ (__| < | | | | . \ |
7 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
9 # | Copyright Mathias Kettner 2014 mk@mathias-kettner.de |
10 # +------------------------------------------------------------------+
12 # This file is part of Check_MK.
13 # The official homepage is at http://mathias-kettner.de/check_mk.
15 # check_mk is free software; you can redistribute it and/or modify it
16 # under the terms of the GNU General Public License as published by
17 # the Free Software Foundation in version 2. check_mk is distributed
18 # in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
19 # out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
20 # PARTICULAR PURPOSE. See the GNU General Public License for more de-
21 # tails. You should have received a copy of the GNU General Public
22 # License along with GNU Make; see the file COPYING. If not, write
23 # to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
24 # Boston, MA 02110-1301 USA.
26 # Run and *send* only once every __ seconds
27 .
$MK_CONFDIR/mk_inventory.cfg
2>/dev
/null || true
29 # Default to four hours
30 INTERVAL
=${INVENTORY_INTERVAL:-14400}
32 FLAGFILE
=$MK_VARDIR/mk_inventory.last.
$REMOTE
33 LAST_RUN
=$
(stat
-c %Y
$FLAGFILE)
35 UNTIL
=$
((NOW
+ INTERVAL
+ 600))
37 if [ $
(( NOW
- LAST_RUN
)) -ge $INTERVAL ]
41 # List of DEB packages
42 if type dpkg-query
>/dev
/null
; then
43 echo "<<<lnx_packages:sep(124):persist($UNTIL)>>>"
44 dpkg-query
--show --showformat='${Package}|${Version}|${Architecture}|deb|-|${Summary}|${Status}\n'
47 # List of RPM packages in same format
48 if type rpm
>/dev
/null
; then
49 echo "<<<lnx_packages:sep(9):persist($UNTIL)>>>"
50 rpm
-qa --qf '%{NAME}\t%{VERSION}\t%{ARCH}\trpm\t%{RELEASE}\t%{SUMMARY}\t-\n'
53 # List Gentoo packages
54 if type equery
>/dev
/null
; then
55 echo "<<<lnx_packages:sep(124):persist($UNTIL)>>>"
56 equery
-C list
--format '$category/$name|$fullversion|$mask2|ebuild|Repository $repo|installed' \
* |
head -n -1
59 # Information about distribution
60 echo "<<<lnx_distro:sep(124):persist($UNTIL)>>>"
61 for f
in {/etc
/{oracle-release
,debian_version
,gentoo-release
,lsb-release
,redhat-release
,SuSE-release
,os-release
},/usr
/share
/cma
/version
} ; do
64 tr \\n \|
< $f |
sed 's/|$//' ; echo
68 # CPU Information. We need just the first one
69 if [ -e /proc
/cpuinfo
] ; then
70 echo "<<<lnx_cpuinfo:sep(58):persist($UNTIL)>>>"
71 sed 's/[[:space:]]*:[[:space:]]*/:/' < /proc
/cpuinfo
74 # Information about main board, memory, etc.
75 if type dmidecode
>/dev
/null
; then
76 echo "<<<dmidecode:sep(58):persist($UNTIL)>>>"
77 dmidecode
-q |
sed 's/\t/:/g'
80 # Information about kernel architecture
81 if type uname
>/dev
/null
; then
82 echo "<<<lnx_uname:persist($UNTIL)>>>"
86 if type lspci
> /dev
/null
; then
87 echo "<<<lnx_video:sep(58):persist($UNTIL)>>>"
88 lspci
-v -s $
(lspci |
grep VGA | cut
-d" " -f 1)
91 # Some networking information
92 if type ip
> /dev
/null
; then
93 echo "<<<lnx_ip_a:persist($UNTIL)>>>"
95 echo "<<<lnx_ip_r:persist($UNTIL)>>>"