Skip to content
Snippets Groups Projects
Commit ed2ff78a authored by Jan Philipp Timme's avatar Jan Philipp Timme
Browse files

Add more vendor files for later use

parent 3910f088
No related branches found
No related tags found
No related merge requests found
#!/usr/bin/python
# -*- encoding: utf-8; py-indent-offset: 4 -*-
# +------------------------------------------------------------------+
# | ____ _ _ __ __ _ __ |
# | / ___| |__ ___ ___| | __ | \/ | |/ / |
# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
# | | |___| | | | __/ (__| < | | | | . \ |
# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
# | |
# | Copyright Mathias Kettner 2014 mk@mathias-kettner.de |
# +------------------------------------------------------------------+
#
# This file is part of Check_MK.
# The official homepage is at http://mathias-kettner.de/check_mk.
#
# check_mk is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation in version 2. check_mk is distributed
# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE. See the GNU General Public License for more de-
# tails. You should have received a copy of the GNU General Public
# License along with GNU Make; see the file COPYING. If not, write
# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301 USA.
# Check_MK-Agent-Plugin - Apache Server Status
#
# Fetches the server-status page from detected or configured apache
# processes to gather status information about this apache process.
#
# To make this agent plugin work you have to load the status_module
# into your apache process. It is also needed to enable the "server-status"
# handler below the URL "/server-status".
#
# By default this plugin tries to detect all locally running apache processes
# and to monitor them. If this is not good for your environment you might
# create an apache_status.cfg file in MK_CONFDIR and populate the servers
# list to prevent executing the detection mechanism.
#
# It is also possible to override or extend the ssl_ports variable to make the
# check contact other ports than 443 with HTTPS requests.
import os
import re
import socket
import sys
import urllib2
config_dir = os.getenv("MK_CONFDIR", "/etc/check_mk")
config_file = config_dir + "/apache_status.conf"
if not os.path.exists(config_file):
config_file = config_dir + "/apache_status.cfg"
# We have to deal with socket timeouts. Python > 2.6
# supports timeout parameter for the urllib2.urlopen method
# but we are on a python 2.5 system here which seem to use the
# default socket timeout. We are local here so set it to 1 second.
socket.setdefaulttimeout(5.0)
# None or list of (proto, ipaddress, port) tuples.
# proto is 'http' or 'https'
servers = None
ssl_ports = [443]
if os.path.exists(config_file):
execfile(config_file)
def try_detect_servers():
results = []
for line in os.popen('netstat -tlnp 2>/dev/null').readlines():
parts = line.split()
# Skip lines with wrong format
if len(parts) < 7 or '/' not in parts[6]:
continue
pid, proc = parts[6].split('/', 1)
to_replace = re.compile('^.*/')
proc = to_replace.sub('', proc)
procs = [
'apache2',
'httpd',
'httpd-prefork',
'httpd2-prefork',
'httpd2-worker',
'httpd.worker',
'fcgi-pm',
]
# the pid/proc field length is limited to 19 chars. Thus in case of
# long PIDs, the process names are stripped of by that length.
# Workaround this problem here
procs = [ p[:19 - len(pid) - 1] for p in procs ]
# Skip unwanted processes
if proc not in procs:
continue
address, port = parts[3].rsplit(':', 1)
port = int(port)
# Use localhost when listening globally
if address == '0.0.0.0':
address = '127.0.0.1'
elif address == '::':
address = '[::1]'
elif ':' in address:
address = '[%s]' % address
# Switch protocol if port is SSL port. In case you use SSL on another
# port you would have to change/extend the ssl_port list
if port in ssl_ports:
proto = 'https'
else:
proto = 'http'
results.append((proto, address, port))
return results
if servers is None:
servers = try_detect_servers()
if not servers:
sys.exit(0)
sys.stdout.write('<<<apache_status>>>\n')
for server in servers:
if isinstance(server, tuple):
proto, address, port = server
page = 'server-status'
else:
proto = server['protocol']
address = server['address']
port = server['port']
page = server.get('page', 'server-status')
portspec = port and ":%d" % port or ""
try:
url = '%s://%s%s/%s?auto' % (proto, address, portspec, page)
is_local = address in ("127.0.0.1", "[::1]", "localhost")
# Try to fetch the status page for each server
try:
request = urllib2.Request(url, headers={"Accept" : "text/plain"})
if is_local and proto == 'https':
import ssl
no_cert_context = ssl.create_default_context()
no_cert_context.check_hostname = False
no_cert_context.verify_mode = ssl.CERT_NONE
fd = urllib2.urlopen(url, context=no_cert_context)
else:
fd = urllib2.urlopen(request)
except urllib2.URLError, e:
if 'unknown protocol' in str(e):
# HACK: workaround misconfigurations where port 443 is used for
# serving non ssl secured http
url = 'http://%s%s/server-status?auto' % (address, portspec)
fd = urllib2.urlopen(url)
else:
raise
for line in fd.read().split('\n'):
if not line.strip():
continue
if line.lstrip()[0] == '<':
# Seems to be html output. Skip this server.
break
sys.stdout.write("%s %s %s\n" % (address, port, line))
except urllib2.HTTPError, e:
sys.stderr.write('HTTP-Error (%s%s): %s %s\n' % (address, portspec, e.code, e))
except Exception, e:
sys.stderr.write('Exception (%s%s): %s\n' % (address, portspec, e))
......@@ -442,3 +442,4 @@ then
echo
done
fi
#!/bin/bash
# Check for APT updates (Debian, Ubuntu)
# +------------------------------------------------------------------+
# | ____ _ _ __ __ _ __ |
# | / ___| |__ ___ ___| | __ | \/ | |/ / |
# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
# | | |___| | | | __/ (__| < | | | | . \ |
# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
# | |
# | Copyright Mathias Kettner 2014 mk@mathias-kettner.de |
# +------------------------------------------------------------------+
#
# This file is part of Check_MK.
# The official homepage is at http://mathias-kettner.de/check_mk.
#
# check_mk is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation in version 2. check_mk is distributed
# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE. See the GNU General Public License for more de-
# tails. You should have received a copy of the GNU General Public
# License along with GNU Make; see the file COPYING. If not, write
# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301 USA.
# TODO:
# Einstellungen:
# - upgrade oder dist-upgrade
# - vorher ein update machen
# Bakery:
# - Bakelet anlegen
# - Async-Zeit einstellbar machen und das Ding immer async laufen lassen
# Check programmieren:
# * Schwellwerte auf Anzahlen
# * Regexen auf Pakete, die zu CRIT/WARN führen
# - Graph malen mit zwei Kurven
# This variable can either be "upgrade" or "dist-upgrade"
UPGRADE=upgrade
DO_UPDATE=yes
function check_apt_update {
if [ "$DO_UPDATE" = yes ] ; then
# NOTE: Even with -qq, apt-get update can output several lines to
# stderr, e.g.:
#
# W: There is no public key available for the following key IDs:
# 1397BC53640DB551
apt-get update -qq 2> /dev/null
fi
apt-get -o 'Debug::NoLocking=true' -o 'APT::Get::Show-User-Simulation-Note=false' -s -qq "$UPGRADE" | grep -v '^Conf'
}
if type apt-get > /dev/null ; then
echo '<<<apt:sep(0)>>>'
out=$(check_apt_update)
if [ -z "$out" ]; then
echo "No updates pending for installation"
else
echo "$out"
fi
fi
if [ -r /var/run/haproxy.sock ]; then
if [ -r /var/run/haproxy.stat ]; then
echo "<<<haproxy:sep(44)>>>"
echo "show stat" | socat - UNIX-CONNECT:/var/run/haproxy.sock
fi
......
#!/bin/bash
# +------------------------------------------------------------------+
# | ____ _ _ __ __ _ __ |
# | / ___| |__ ___ ___| | __ | \/ | |/ / |
# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
# | | |___| | | | __/ (__| < | | | | . \ |
# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
# | |
# | Copyright Mathias Kettner 2014 mk@mathias-kettner.de |
# +------------------------------------------------------------------+
#
# This file is part of Check_MK.
# The official homepage is at http://mathias-kettner.de/check_mk.
#
# check_mk is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation in version 2. check_mk is distributed
# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE. See the GNU General Public License for more de-
# tails. You should have received a copy of the GNU General Public
# License along with GNU Make; see the file COPYING. If not, write
# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301 USA.
if type who >/dev/null; then
echo "<<<logins>>>"
who | wc -l
fi
This diff is collapsed.
#!/bin/bash
# +------------------------------------------------------------------+
# | ____ _ _ __ __ _ __ |
# | / ___| |__ ___ ___| | __ | \/ | |/ / |
# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
# | | |___| | | | __/ (__| < | | | | . \ |
# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
# | |
# | Copyright Mathias Kettner 2014 mk@mathias-kettner.de |
# +------------------------------------------------------------------+
#
# This file is part of Check_MK.
# The official homepage is at http://mathias-kettner.de/check_mk.
#
# check_mk is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation in version 2. check_mk is distributed
# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE. See the GNU General Public License for more de-
# tails. You should have received a copy of the GNU General Public
# License along with GNU Make; see the file COPYING. If not, write
# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301 USA.
if type zypper > /dev/null ; then
echo '<<<zypper:sep(124)>>>'
if grep -q '^VERSION = 10' < /etc/SuSE-release
then
ZYPPER='waitmax 10 zypper --no-gpg-checks --non-interactive --terse'
REFRESH=`$ZYPPER refresh 2>&1`
if [ "$REFRESH" ]
then
echo "ERROR: $REFRESH"
else
{ $ZYPPER pchk || [ $? = 100 -o $? = 101 ] && $ZYPPER lu ; } \
| egrep '(patches needed|\|)' | egrep -v '^(#|Repository |Catalog )'
fi
else
ZYPPER='waitmax 10 zypper --no-gpg-checks --non-interactive --quiet'
REFRESH=`$ZYPPER refresh 2>&1`
if [ "$REFRESH" ]
then
echo "ERROR: $REFRESH"
else
{ { $ZYPPER pchk || [ $? = 100 -o $? = 101 ] && $ZYPPER lp ; } ; $ZYPPER ll ; } \
| egrep '(patches needed|\|)' | egrep -v '^(#|Repository)'
fi
fi
fi
#!/bin/sh
# +------------------------------------------------------------------+
# | ____ _ _ __ __ _ __ |
# | / ___| |__ ___ ___| | __ | \/ | |/ / |
# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
# | | |___| | | | __/ (__| < | | | | . \ |
# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
# | |
# | Copyright Mathias Kettner 2014 mk@mathias-kettner.de |
# +------------------------------------------------------------------+
#
# This file is part of Check_MK.
# The official homepage is at http://mathias-kettner.de/check_mk.
#
# check_mk is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation in version 2. check_mk is distributed
# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE. See the GNU General Public License for more de-
# tails. You should have received a copy of the GNU General Public
# License along with GNU Make; see the file COPYING. If not, write
# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301 USA.
# This is not part of the standard agent since it can take very
# long to run if your TCP/UDP table is large. Netstat seems to
# have an execution time complexity of at least O(n^2) on Linux.
echo '<<<netstat>>>'
netstat -ntua | egrep '^(tcp|udp)' | sed -e 's/LISTEN/LISTENING/g'
#!/usr/bin/python
# -*- encoding: utf-8; py-indent-offset: 4 -*-
# +------------------------------------------------------------------+
# | ____ _ _ __ __ _ __ |
# | / ___| |__ ___ ___| | __ | \/ | |/ / |
# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
# | | |___| | | | __/ (__| < | | | | . \ |
# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
# | |
# | Copyright Mathias Kettner 2014 mk@mathias-kettner.de |
# +------------------------------------------------------------------+
#
# This file is part of Check_MK.
# The official homepage is at http://mathias-kettner.de/check_mk.
#
# check_mk is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation in version 2. check_mk is distributed
# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE. See the GNU General Public License for more de-
# tails. You should have received a copy of the GNU General Public
# License along with GNU Make; see the file COPYING. If not, write
# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301 USA.
# Check_MK-Agent-Plugin - Nginx Server Status
#
# Fetches the stub nginx_status page from detected or configured nginx
# processes to gather status information about this process.
#
# Take a look at the check man page for details on how to configure this
# plugin and check.
#
# By default this plugin tries to detect all locally running processes
# and to monitor them. If this is not good for your environment you might
# create an nginx_status.cfg file in MK_CONFDIR and populate the servers
# list to prevent executing the detection mechanism.
import os
import re
import sys
import urllib2
# tell urllib2 not to honour "http(s)_proxy" env variables
urllib2.getproxies = lambda: {}
config_dir = os.getenv("MK_CONFDIR", "/etc/check_mk")
config_file = config_dir + "/nginx_status.cfg"
# None or list of (proto, ipaddress, port) tuples.
# proto is 'http' or 'https'
servers = None
ssl_ports = [
443,
]
if os.path.exists(config_file):
execfile(config_file)
def try_detect_servers():
pids = []
results = []
for netstat_line in os.popen('netstat -tlnp 2>/dev/null').readlines():
parts = netstat_line.split()
# Skip lines with wrong format
if len(parts) < 7 or '/' not in parts[6]:
continue
pid, proc = parts[6].split('/', 1)
to_replace = re.compile('^.*/')
proc = to_replace.sub('', proc)
procs = ['nginx', 'nginx:', 'nginx.conf']
# the pid/proc field length is limited to 19 chars. Thus in case of
# long PIDs, the process names are stripped of by that length.
# Workaround this problem here
procs = [p[:19 - len(pid) - 1] for p in procs]
# Skip unwanted processes
if proc not in procs:
continue
# Add only the first found port of a single server process
if pid in pids:
continue
pids.append(pid)
server_proto = 'http'
server_address, server_port = parts[3].rsplit(':', 1)
server_port = int(server_port)
# Use localhost when listening globally
if server_address == '0.0.0.0':
server_address = '127.0.0.1'
elif server_address == '::':
server_address = '::1'
# Switch protocol if port is SSL port. In case you use SSL on another
# port you would have to change/extend the ssl_port list
if server_port in ssl_ports:
server_proto = 'https'
results.append((server_proto, server_address, server_port))
return results
if servers is None:
servers = try_detect_servers()
if not servers:
sys.exit(0)
sys.stdout.write('<<<nginx_status>>>\n')
for server in servers:
if isinstance(server, tuple):
proto, address, port = server
page = 'nginx_status'
else:
proto = server['protocol']
address = server['address']
port = server['port']
page = server.get('page', 'nginx_status')
try:
url = '%s://%s:%s/%s' % (proto, address, port, page)
# Try to fetch the status page for each server
try:
request = urllib2.Request(url, headers={"Accept": "text/plain"})
fd = urllib2.urlopen(request)
except urllib2.URLError, e:
if 'SSL23_GET_SERVER_HELLO:unknown protocol' in str(e):
# HACK: workaround misconfigurations where port 443 is used for
# serving non ssl secured http
url = 'http://%s:%s/%s' % (address, port, page)
fd = urllib2.urlopen(url)
else:
raise
for line in fd.read().split('\n'):
if not line.strip():
continue
if line.lstrip()[0] == '<':
# seems to be html output. Skip this server.
break
sys.stdout.write("%s %s %s\n" % (address, port, line))
except urllib2.HTTPError, e:
sys.stderr.write('HTTP-Error (%s:%d): %s %s\n' % (address, port, e.code, e))
except Exception, e:
sys.stderr.write('Exception (%s:%d): %s\n' % (address, port, e))
#!/bin/bash
# +------------------------------------------------------------------+
# | ____ _ _ __ __ _ __ |
# | / ___| |__ ___ ___| | __ | \/ | |/ / |
# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
# | | |___| | | | __/ (__| < | | | | . \ |
# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
# | |
# | Copyright Mathias Kettner 2014 mk@mathias-kettner.de |
# +------------------------------------------------------------------+
#
# This file is part of Check_MK.
# The official homepage is at http://mathias-kettner.de/check_mk.
#
# check_mk is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation in version 2. check_mk is distributed
# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE. See the GNU General Public License for more de-
# tails. You should have received a copy of the GNU General Public
# License along with GNU Make; see the file COPYING. If not, write
# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301 USA.
# This will be called on LSI based raidcontrollers and accesses
# the SMART data of SATA disks attached to a SAS Raid HBA via
# SCSI protocol interface.
megaraid_info()
{
#PDINFO=$(MegaCli -PDlist -a0)
if [ -z "$1" ]; then
PDINFO=$(megacli -PDlist -a0 -NoLog)
else
PDINFO=$($1 -PDlist -a0 -NoLog)
fi
echo "$PDINFO" | \
while read line ; do
case "$line" in
# FIRST LINE
"Enclosure Device ID"*) #Enclosure Device ID: 252
ENC=$( echo "$line" | awk '{print $4}')
unset SLOT LOG_DEV_ID VEND MODEL
;;
"Slot Number"*) #Slot Number: 7
SLOT=$( echo "$line" | awk '{print $3}')
;;
# Identify the logical device ID. smartctl needs it to access the disk.
"Device Id"*) #Device Id: 19
LOG_DEV_ID=$( echo "$line" | awk '{print $3}')
;;
"PD Type"*) #PD Type: SATA
VEND=$( echo "$line" | awk '{print $3}')
;;
# This is the last value, generate output here
"Inquiry Data"*)
#Inquiry Data: WD-WCC1T1035197WDC WD20EZRX-00DC0B0 80.00A80
# $4 seems to be better for some vendors... wont be possible to get this perfect.
MODEL=$( echo "$line" | awk '{print $3}')
# /dev/sdc ATA SAMSUNG_SSD_830 5 Reallocated_Sector_Ct 0x0033 100 100 010 Pre-fail Always -
smartctl -d megaraid,${LOG_DEV_ID} -v 9,raw48 -A /dev/sg0 | \
grep Always | egrep -v '^190(.*)Temperature(.*)' | \
sed "s|^|Enc${ENC}/Slot${SLOT} $VEND $MODEL |"
;;
esac
done
}
# Only handle always updated values, add device path and vendor/model
if which smartctl > /dev/null 2>&1 ; then
#
# if the 3ware-utility is found
# get the serials for all disks on the controller
#
if which tw_cli > /dev/null 2>&1 ; then
# support for only one controller at the moment
TWAC=$(tw_cli show | awk 'NR < 4 { next } { print $1 }' | head -n 1)
# - add a trailing zero to handle case of unused slot
# trailing zeros are part of the device links in /dev/disk/by-id/... anyway
# - only the last 9 chars seem to be relevant
# (hopefully all this doesn't change with new kernels...)
eval `tw_cli /$TWAC show drivestatus | grep -E '^p[0-9]' | awk '{print $1 " " $7 "0"}' | while read twaminor serial ; do
twaminor=${twaminor#p}
serial=${serial:(-9)}
serial=AMCC_${serial}00000000000
echo "$serial=$twaminor"
done`
else:
echo "tw_cli not found" >&2
fi
echo '<<<smart>>>'
SEEN=
for D in /dev/disk/by-id/{scsi,ata}-*; do
[ "$D" != "${D%scsi-\*}" ] && continue
[ "$D" != "${D%ata-\*}" ] && continue
[ "$D" != "${D%-part*}" ] && continue
N=$(readlink $D)
N=${N##*/}
if [ -r /sys/block/$N/device/vendor ]; then
VEND=$(tr -d ' ' < /sys/block/$N/device/vendor)
else
# 2012-01-25 Stefan Kaerst CDJ - in case $N does not exist
VEND=ATA
fi
if [ -r /sys/block/$N/device/model ]; then
MODEL=$(sed -e 's/ /_/g' -e 's/_*$//g' < /sys/block/$N/device/model)
else
MODEL=$(smartctl -a $D | grep -i "device model" | sed -e "s/.*:[ ]*//g" -e "s/\ /_/g")
fi
# Excluded disk models for SAN arrays or certain RAID luns that are also not usable..
if [ "$MODEL" = "iSCSI_Disk" -o "$MODEL" = "LOGICAL_VOLUME" ]; then
continue
fi
# Avoid duplicate entries for same device
if [ "${SEEN//.$N./}" != "$SEEN" ] ; then
continue
fi
SEEN="$SEEN.$N."
# strip device name for final output
DNAME=${D#/dev/disk/by-id/scsi-}
DNAME=${DNAME#/dev/disk/by-id/ata-}
# 2012-01-25 Stefan Kaerst CDJ - special option in case vendor is AMCC
CMD=
if [ "$VEND" == "AMCC" -a -n "$TWAC" ]; then
DNAME=${DNAME#1}
[ -z "${!DNAME}" ] && continue
CMD="smartctl -d 3ware,${!DNAME} -v 9,raw48 -A /dev/twa0"
# create nice device name including model
MODEL=$(tw_cli /$TWAC/p${!DNAME} show model | head -n 1 | awk -F= '{ print $2 }')
MODEL=${MODEL## }
MODEL=${MODEL// /-}
DNAME=${DNAME#AMCC_}
DNAME="AMCC_${MODEL}_${DNAME%000000000000}"
elif [ "$VEND" != "ATA" ] ; then
TEMP=
# create temperature output as expected by checks/smart
# this is a hack, TODO: change checks/smart to support SCSI-disks
eval `smartctl -d scsi -i -A $D | while read a b c d e ; do
[ "$a" == Serial ] && echo SN=$c
[ "$a" == Current -a "$b" == Drive -a "$c" == Temperature: ] && echo TEMP=$d
done`
[ -n "$TEMP" ] && CMD="echo 194 Temperature_Celsius 0x0000 000 000 000 Old_age Always - $TEMP (0 0 0 0)"
DNAME="${VEND}_${MODEL}_${SN}"
else
CMD="smartctl -d ata -v 9,raw48 -A $D"
fi
[ -n "$CMD" ] && $CMD | grep Always | egrep -v '^190(.*)Temperature(.*)' | sed "s|^|$DNAME $VEND $MODEL |"
done 2>/dev/null
# Call MegaRaid submodule if conditions are met
if type MegaCli >/dev/null 2>&1; then
MegaCli_bin="MegaCli"
elif type MegaCli64 >/dev/null 2>&1; then
MegaCli_bin="MegaCli64"
elif type megacli >/dev/null 2>&1; then
MegaCli_bin="megacli"
else
MegaCli_bin="unknown"
fi
if [ "$MegaCli_bin" != "unknown" ]; then
megaraid_info "$MegaCli_bin"
fi
else
echo "ERROR: smartctl not found" >&2
fi
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment