Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
nikimaxim authored Apr 1, 2020
1 parent c314353 commit bd2f76d
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 42 deletions.
40 changes: 20 additions & 20 deletions Template smartmonitor.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<zabbix_export>
<version>4.4</version>
<date>2020-03-13T05:49:23Z</date>
<date>2020-03-31T10:04:28Z</date>
<groups>
<group>
<name>Templates Users</name>
Expand Down Expand Up @@ -35,7 +35,7 @@
</applications>
<triggers>
<trigger>
<expression>{change()}=1</expression>
<expression>{diff()}=1</expression>
<name>Version of smartctl was changed on {HOST.NAME}</name>
<priority>INFO</priority>
</trigger>
Expand Down Expand Up @@ -72,15 +72,15 @@
<trigger_prototypes>
<trigger_prototype>
<expression>{str(&quot;FAILING_NOW&quot;)}=1</expression>
<name>{#STORAGE.NAME}: one or more SMART attributes are FAILING_NOW</name>
<name>{#STORAGE.NAME}: One or more SMART attributes are FAILING_NOW</name>
<priority>AVERAGE</priority>
<dependencies>
<dependency>
<name>{#STORAGE.NAME}: SMART status is not OK</name>
<expression>{Template SMARTMONTOOLS:storage.health[&quot;{#STORAGE.CMD}&quot;].str({$SMARTCTL_OK_STATUS:&quot;SATA&quot;})}=0 and {Template SMARTMONTOOLS:storage.health[&quot;{#STORAGE.CMD}&quot;].str({$SMARTCTL_OK_STATUS:&quot;SAS&quot;})}=0</expression>
</dependency>
<dependency>
<name>{#STORAGE.NAME}: SMART test status: FAILED!</name>
<name>{#STORAGE.NAME}: SMART test status FAILED</name>
<expression>{Template SMARTMONTOOLS:storage.health[&quot;{#STORAGE.CMD}&quot;].str(&quot;FAILED!&quot;)}=1</expression>
</dependency>
</dependencies>
Expand Down Expand Up @@ -117,14 +117,14 @@
<manual_close>YES</manual_close>
<dependencies>
<dependency>
<name>{#STORAGE.NAME}: SMART test status: FAILED!</name>
<name>{#STORAGE.NAME}: SMART test status FAILED</name>
<expression>{Template SMARTMONTOOLS:storage.health[&quot;{#STORAGE.CMD}&quot;].str(&quot;FAILED!&quot;)}=1</expression>
</dependency>
</dependencies>
</trigger_prototype>
<trigger_prototype>
<expression>{str(&quot;FAILED!&quot;)}=1</expression>
<name>{#STORAGE.NAME}: SMART test status: FAILED!</name>
<name>{#STORAGE.NAME}: SMART test status FAILED</name>
<priority>AVERAGE</priority>
</trigger_prototype>
</trigger_prototypes>
Expand Down Expand Up @@ -213,10 +213,10 @@ NVME</description>
</master_item>
<trigger_prototypes>
<trigger_prototype>
<expression>{diff()}&lt;&gt;0</expression>
<expression>{diff()}=1</expression>
<recovery_mode>RECOVERY_EXPRESSION</recovery_mode>
<recovery_expression>{last()}=0 or {delta(864000)}=0</recovery_expression>
<name>{#STORAGE.NAME}: SMART Reallocated Sectors Count has been registered</name>
<name>{#STORAGE.NAME}: SMART reallocated sectors count has been registered</name>
<priority>AVERAGE</priority>
<manual_close>YES</manual_close>
<dependencies>
Expand All @@ -225,7 +225,7 @@ NVME</description>
<expression>{Template SMARTMONTOOLS:storage.health[&quot;{#STORAGE.CMD}&quot;].str({$SMARTCTL_OK_STATUS:&quot;SATA&quot;})}=0 and {Template SMARTMONTOOLS:storage.health[&quot;{#STORAGE.CMD}&quot;].str({$SMARTCTL_OK_STATUS:&quot;SAS&quot;})}=0</expression>
</dependency>
<dependency>
<name>{#STORAGE.NAME}: SMART test status: FAILED!</name>
<name>{#STORAGE.NAME}: SMART test status FAILED</name>
<expression>{Template SMARTMONTOOLS:storage.health[&quot;{#STORAGE.CMD}&quot;].str(&quot;FAILED!&quot;)}=1</expression>
</dependency>
</dependencies>
Expand Down Expand Up @@ -291,7 +291,7 @@ NVME</description>
<trigger_prototypes>
<trigger_prototype>
<expression>{delta(7d)}&gt;0</expression>
<name>{#STORAGE.NAME}: SMART Spin Retry Count has been registered</name>
<name>{#STORAGE.NAME}: SMART spin retry count has been registered</name>
<priority>AVERAGE</priority>
<manual_close>YES</manual_close>
</trigger_prototype>
Expand Down Expand Up @@ -324,7 +324,7 @@ NVME</description>
<trigger_prototypes>
<trigger_prototype>
<expression>{avg(5m)}&gt;{$TEMP_CRIT} and&#13;
{last()}&lt;100</expression>
{last()}&lt;=100</expression>
<recovery_mode>RECOVERY_EXPRESSION</recovery_mode>
<recovery_expression>{avg(5m)}&lt;{$TEMP_CRIT}-3</recovery_expression>
<name>{#STORAGE.NAME}: Disk temperature: {ITEM.LASTVALUE}</name>
Expand All @@ -342,7 +342,7 @@ NVME</description>
<dependency>
<name>{#STORAGE.NAME}: Disk temperature: {ITEM.LASTVALUE}</name>
<expression>{Template SMARTMONTOOLS:storage[&quot;{#STORAGE.CMD}&quot;, 190/194 Temperature_Celsius].avg(5m)}&gt;{$TEMP_CRIT} and&#13;
{Template SMARTMONTOOLS:storage[&quot;{#STORAGE.CMD}&quot;, 190/194 Temperature_Celsius].last()}&lt;100</expression>
{Template SMARTMONTOOLS:storage[&quot;{#STORAGE.CMD}&quot;, 190/194 Temperature_Celsius].last()}&lt;=100</expression>
<recovery_expression>{Template SMARTMONTOOLS:storage[&quot;{#STORAGE.CMD}&quot;, 190/194 Temperature_Celsius].avg(5m)}&lt;{$TEMP_CRIT}-3</recovery_expression>
</dependency>
</dependencies>
Expand Down Expand Up @@ -375,21 +375,21 @@ NVME</description>
<trigger_prototypes>
<trigger_prototype>
<expression>{delta(3d)}&gt;0</expression>
<name>{#STORAGE.NAME}: SMART Current Pending Sector counter incremented</name>
<name>{#STORAGE.NAME}: SMART current pending sector counter has been registered</name>
<priority>WARNING</priority>
<manual_close>YES</manual_close>
<dependencies>
<dependency>
<name>{#STORAGE.NAME}: SMART Reallocated Sectors Count has been registered</name>
<expression>{Template SMARTMONTOOLS:storage[&quot;{#STORAGE.CMD}&quot;, 05 Reallocated_Sector_Ct].diff()}&lt;&gt;0</expression>
<name>{#STORAGE.NAME}: SMART reallocated sectors count has been registered</name>
<expression>{Template SMARTMONTOOLS:storage[&quot;{#STORAGE.CMD}&quot;, 05 Reallocated_Sector_Ct].diff()}=1</expression>
<recovery_expression>{Template SMARTMONTOOLS:storage[&quot;{#STORAGE.CMD}&quot;, 05 Reallocated_Sector_Ct].last()}=0 or {Template SMARTMONTOOLS:storage[&quot;{#STORAGE.CMD}&quot;, 05 Reallocated_Sector_Ct].delta(864000)}=0</recovery_expression>
</dependency>
<dependency>
<name>{#STORAGE.NAME}: SMART status is not OK</name>
<expression>{Template SMARTMONTOOLS:storage.health[&quot;{#STORAGE.CMD}&quot;].str({$SMARTCTL_OK_STATUS:&quot;SATA&quot;})}=0 and {Template SMARTMONTOOLS:storage.health[&quot;{#STORAGE.CMD}&quot;].str({$SMARTCTL_OK_STATUS:&quot;SAS&quot;})}=0</expression>
</dependency>
<dependency>
<name>{#STORAGE.NAME}: SMART test status: FAILED!</name>
<name>{#STORAGE.NAME}: SMART test status FAILED</name>
<expression>{Template SMARTMONTOOLS:storage.health[&quot;{#STORAGE.CMD}&quot;].str(&quot;FAILED!&quot;)}=1</expression>
</dependency>
</dependencies>
Expand Down Expand Up @@ -423,7 +423,7 @@ SSD</description>
<trigger_prototypes>
<trigger_prototype>
<expression>{delta(7d)}&gt;0</expression>
<name>{#STORAGE.NAME}: SMART (Offline) Uncorrectable Sector Count has been registered</name>
<name>{#STORAGE.NAME}: SMART uncorrectable sector count has been registered</name>
<priority>AVERAGE</priority>
<manual_close>YES</manual_close>
<dependencies>
Expand All @@ -432,7 +432,7 @@ SSD</description>
<expression>{Template SMARTMONTOOLS:storage.health[&quot;{#STORAGE.CMD}&quot;].str({$SMARTCTL_OK_STATUS:&quot;SATA&quot;})}=0 and {Template SMARTMONTOOLS:storage.health[&quot;{#STORAGE.CMD}&quot;].str({$SMARTCTL_OK_STATUS:&quot;SAS&quot;})}=0</expression>
</dependency>
<dependency>
<name>{#STORAGE.NAME}: SMART test status: FAILED!</name>
<name>{#STORAGE.NAME}: SMART test status FAILED</name>
<expression>{Template SMARTMONTOOLS:storage.health[&quot;{#STORAGE.CMD}&quot;].str(&quot;FAILED!&quot;)}=1</expression>
</dependency>
</dependencies>
Expand Down Expand Up @@ -466,7 +466,7 @@ SSD</description>
<trigger_prototypes>
<trigger_prototype>
<expression>{last()}&gt;100 and {delta(1d)}&gt;0</expression>
<name>{#STORAGE.NAME}: SMART UltraDMA CRC Error Count too high: {ITEM.LASTVALUE}. Check cable!</name>
<name>{#STORAGE.NAME}: SMART UDMA CRC error count too high has been registered</name>
<priority>AVERAGE</priority>
<manual_close>YES</manual_close>
</trigger_prototype>
Expand All @@ -475,7 +475,7 @@ SSD</description>
</item_prototypes>
<graph_prototypes>
<graph_prototype>
<name>Smartctl {#STORAGE.NAME} Temperature</name>
<name>{#STORAGE.NAME}: Smartctl temperature</name>
<graph_items>
<graph_item>
<color>1A7C11</color>
Expand Down
Binary file modified img/2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified img/3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified img/4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 19 additions & 13 deletions smartctl-storage-discovery.ps1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<#
.VERSION
0.2
0.3
.DESCRIPTION
Author: Nikitin Maksim
Expand All @@ -15,7 +15,7 @@
$CTL = "C:\Program Files\smartmontools\bin\smartctl.exe"

if ((Get-Command $CTL -ErrorAction SilentlyContinue) -eq $null) {
Write-Host "Not find smartctl!"
Write-Host "Could not find path: $CTL"
exit
}

Expand All @@ -30,27 +30,31 @@ foreach ($device in $smart_scan) {
# Remove non-working disks
# Example: "# /dev/sdb -d scsi"
if (!$device.StartsWith("# ")) {
$idx++
$storage_args = ""
$storage_name = ""
$storage_type = 0
$storage_model = ""
$storage_sn = ""
$storage_model = ""
$storage_name = ""
$storage_args = ""
$storage_smart = 0
$storage_type = 0

# Extract and concatenate args
if ($device -match '(-d) ([A-Za-z0-9/,\+]+)') {
$storage_args = $matches[1] + $matches[2]
}

$storage_name = $device.Substring(0,$device.IndexOf(" "))
# Get device name
$storage_name = $device.Substring(0, $device.IndexOf(" "))
$info = & $CTL "-i" $storage_name $storage_args

# Device sn
# Get device SN
$sn = ($info | Select-String "serial number:") -ireplace "serial number:"

# Сheck empty SN
# Check empty SN
if ($sn) {
# Number disks
$idx++
$storage_sn = $sn.Trim()

# Check duplicate storage
if (!$disk_sn_all.Contains($storage_sn)) {
if ($disk_sn_all) {
Expand All @@ -59,17 +63,18 @@ foreach ($device in $smart_scan) {
$disk_sn_all = $storage_sn
}

# Device smart
# Device SMART
if ($info | Select-String "SMART.+Enabled$") {
$storage_smart = 1
}

# Device NVMe and SMART
if ($storage_args -like "*nvme*" -or $storage_name -like "*nvme*") {
$storage_type = 1
$storage_smart = 1
}

# Device Model
# Get device model(For different types of devices)
$d = (($info | Select-String "Device Model:") -replace "Device Model:")
if ($d) {
$storage_model = $d.Trim()
Expand All @@ -86,7 +91,7 @@ foreach ($device in $smart_scan) {
if ($v) {
$storage_model = $v.Trim()
} else {
$storage_model = "Not find"
$storage_model = "Not find!"
}
}
}
Expand All @@ -101,6 +106,7 @@ foreach ($device in $smart_scan) {
$storage_type = 1
}

# Adding a split sign when multiple disks are detected
if ($idx -ne 1) {
$json += ",`n"
}
Expand Down
23 changes: 14 additions & 9 deletions smartctl-storage-discovery.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
#
# .VERSION
# 0.2
# 0.3
#
# .DESCRIPTION
# Author: Nikitin Maksim
Expand All @@ -22,26 +22,30 @@ LLDSmart()

IFS=";"
for device in ${smart_scan}; do
device=$(/bin/echo $device | grep -iE "^(\w*|\d*).")

storage_args=""
storage_sn=""
storage_model=""
storage_name=""
storage_cmd=""
storage_type=0
storage_model=""
storage_sn=""
storage_smart=0
storage_type=0
storage_args=""

device=$(/bin/echo $device | grep -iE "^(\w*|\d*).")

# Remove non-working disks
# Example: "# /dev/sdb -d scsi"
if [[ ! ${device} =~ (^\s*#|^#) ]]; then
# Extract and concatenate args
storage_args=$(/bin/echo ${device} | cut -f 1 -d'#' | awk '{print $2 $3}')
# Get device name
storage_name=$(/bin/echo ${device} | cut -f 1 -d'#' | awk '{print $1}')

temp_info=$($CTL -i $storage_name $storage_args)

# Get device SN
storage_sn=$(/bin/echo ${temp_info} | grep "Serial Number:" | cut -f2 -d":" | sed -e 's/^\s*//')

# Check duplicate storage
if [[ ! -z $storage_sn ]] && [[ ! $disk_sn_all == *"$storage_sn"* ]]; then
if [ -z $disk_sn_all ]; then
disk_sn_all=$storage_sn
Expand All @@ -51,17 +55,18 @@ LLDSmart()

storage_cmd="${storage_name} ${storage_args}"

# Device smart
# Device SMART
if [ -n $(/bin/echo $temp_info | grep -iE "^SMART support is:.+Enabled\s*$") ]; then
storage_smart=1
fi

# Device NVMe and SMART
if [[ $storage_args == *"nvme"* ]] || [[ $storage_name == *"nvme"* ]]; then
storage_type=1
storage_smart=1
fi

# Device Model
# Get device model(For different types of devices)
d=$(/bin/echo $temp_info | grep "Device Model:" | cut -f2 -d":" | sed -e 's/^\s*//')
if [ -n $d ]; then
storage_model=$d
Expand Down

0 comments on commit bd2f76d

Please sign in to comment.