Refactoring: Changed all check parameters starting with an 'o' to the new rulespec...
[check_mk.git] / agents / plugins / mk_inventory.solaris
blob302d01eaf79604ebfab3268e917b6725cb9353f4
1 #!/bin/bash
2 # +------------------------------------------------------------------+
3 # | ____ _ _ __ __ _ __ |
4 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
5 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
6 # | | |___| | | | __/ (__| < | | | | . \ |
7 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
8 # | |
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 if [ `uname -r` = "5.10" ]; then
34 NOW=$(truss /usr/bin/date 2>&1 | grep ^time | awk -F"= " '{print $2}')
35 else
36 NOW=`date +%s`
38 UNTIL=$((NOW + INTERVAL + 600))
40 #check if flagfile exits
41 if [ -e "$FLAGFILE" ]; then
42 LAST_RUN=$(cat $FLAGFILE)
43 else
44 #First run of the script
45 LAST_RUN=0
48 if [ $(( NOW - LAST_RUN )) -ge $INTERVAL ]
49 then
50 echo $NOW > $FLAGFILE
52 echo "<<<solaris_uname:sep(61):persist($UNTIL)>>>"
53 uname -X
55 if zoneadm list | grep global >/dev/null 2>&1
56 then
57 if type prtdiag > /dev/null; then
58 echo "<<<solaris_prtdiag:sep(10):persist($UNTIL)>>>"
59 if type sneep >/dev/null 2>&1; then
60 SN=$(sneep -t serial)
61 else
62 SN=$(smbios -t SMB_TYPE_SYSTEM | grep 'Serial Number:' | awk '{print substr($0, index($0,$3))}')
64 echo "SerialNumber: $SN"
65 prtdiag -v
68 if type prtpicl > /dev/null; then
69 echo "<<<solaris_prtpicl:persist($UNTIL)>>>"
70 prtpicl -v
74 if type psrinfo > /dev/null; then
75 echo "<<<solaris_psrinfo:persist($UNTIL)>>>"
76 psrinfo -p -v
79 if type pkginfo >/dev/null ; then
80 echo "<<<solaris_pkginfo:sep(58):persist($UNTIL)>>>"
81 pkginfo -l
84 echo "<<<solaris_addresses:persist($UNTIL)>>>"
85 ifconfig -a
87 echo "<<<solaris_routes:persist($UNTIL)>>>"
88 netstat -nr