42_SMARTMON.pm 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768
  1. ################################################################
  2. #
  3. # Copyright notice
  4. #
  5. # (c) 2014 Alexander Schulz
  6. #
  7. # This script is free software; you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation; either version 2 of the License, or
  10. # (at your option) any later version.
  11. #
  12. # The GNU General Public License can be found at
  13. # http://www.gnu.org/copyleft/gpl.html.
  14. # A copy is found in the textfile GPL.txt and important notices to the license
  15. # from the author is found in LICENSE.txt distributed with these scripts.
  16. #
  17. # This script is distributed in the hope that it will be useful,
  18. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. # GNU General Public License for more details.
  21. #
  22. # This copyright notice MUST APPEAR in all copies of the script!
  23. #
  24. ################################################################
  25. # $Id: 42_SMARTMON.pm 14440 2017-05-31 18:49:20Z hexenmeister $
  26. package main;
  27. use strict;
  28. use warnings;
  29. use Data::Dumper;
  30. my $VERSION = "0.9.5";
  31. my $DEFAULT_INTERVAL = 60; # in minuten
  32. sub SMARTMON_refreshReadings($);
  33. sub SMARTMON_obtainParameters($);
  34. sub SMARTMON_getSmartDataReadings($$);
  35. sub SMARTMON_interpretKnownData($$$);
  36. sub SMARTMON_readSmartData($;$);
  37. sub SMARTMON_readDeviceData($%);
  38. sub SMARTMON_sec2Dauer($);
  39. sub SMARTMON_hour2Dauer($);
  40. sub SMARTMON_execute($$);
  41. sub SMARTMON_Initialize($)
  42. {
  43. my ($hash) = @_;
  44. Log 5, "SMARTMON Initialize";
  45. $hash->{DefFn} = "SMARTMON_Define";
  46. $hash->{UndefFn} = "SMARTMON_Undefine";
  47. $hash->{GetFn} = "SMARTMON_Get";
  48. #$hash->{SetFn} = "SMARTMON_Set";
  49. $hash->{AttrFn} = "SMARTMON_Attr";
  50. $hash->{AttrList} = "show_raw:0,1,2 disable:0,1 include parameters ".$readingFnAttributes;
  51. }
  52. sub SMARTMON_Log($$$) {
  53. my ( $hash, $loglevel, $text ) = @_;
  54. my $xline = ( caller(0) )[2];
  55. my $xsubroutine = ( caller(1) )[3];
  56. my $sub = ( split( ':', $xsubroutine ) )[2];
  57. $sub =~ s/SMARTMON_//;
  58. my $instName = ( ref($hash) eq "HASH" ) ? $hash->{NAME} : $hash;
  59. Log3 $hash, $loglevel, "SMARTMON $instName: $sub.$xline " . $text;
  60. }
  61. my $device;
  62. sub SMARTMON_Define($$)
  63. {
  64. my ($hash, $def) = @_;
  65. SMARTMON_Log($hash, 4, "Define $def");
  66. my @a = split("[ \t][ \t]*", $def);
  67. SMARTMON_Log($hash, 5, "Define: ".Dumper(@a));
  68. return "Usage: define <name> SMARTMON <device> [M1]" if(@a < 3);
  69. $hash->{DEVICE} = $a[2];
  70. if(int(@a)>=4)
  71. {
  72. $hash->{INTERVAL} = $a[3]*60;
  73. } else {
  74. $hash->{INTERVAL} = $DEFAULT_INTERVAL*60;
  75. }
  76. $hash->{STATE} = "Initialized";
  77. RemoveInternalTimer($hash);
  78. # erstes update zeitversetzt starten
  79. InternalTimer(gettimeofday()+10, "SMARTMON_Update", $hash, 0);
  80. return undef;
  81. }
  82. sub SMARTMON_Undefine($$)
  83. {
  84. my ($hash, $arg) = @_;
  85. SMARTMON_Log($hash, 4, "Undefine");
  86. RemoveInternalTimer($hash);
  87. return undef;
  88. }
  89. sub SMARTMON_Get($@)
  90. {
  91. # http://www.linux-community.de/Internal/Artikel/Print-Artikel/LinuxUser/2004/10/Die-Zuverlaessigkeit-von-Festplatten-ueberwachen-mit-smartmontools
  92. my ($hash, @a) = @_;
  93. my $name = $a[0];
  94. if(@a < 2)
  95. {
  96. return "$name: get needs at least one parameter";
  97. }
  98. my $cmd= $a[1];
  99. SMARTMON_Log($hash, 5, "Get: ".Dumper(@a));
  100. if($cmd eq "update")
  101. {
  102. SMARTMON_refreshReadings($hash);
  103. return undef;
  104. }
  105. my $param="";
  106. if($hash->{PARAMETERS}) {$param=" ".$hash->{PARAMETERS};}
  107. if($cmd eq "list")
  108. {
  109. if(@a<3) {return "$name: get list needs at least one parameter"; }
  110. my $subcmd=$a[2];
  111. my @t;
  112. my $r;
  113. if($subcmd eq "info") {
  114. my $tdev = $hash->{DEVICE};
  115. if(@a>3) {$tdev=$a[3];}
  116. ($r, @t) = SMARTMON_execute($hash, "sudo smartctl -i".$param." ".$tdev);
  117. }
  118. if($subcmd eq "data") {
  119. my $tdev = $hash->{DEVICE};
  120. if(@a>3) {$tdev=$a[3];}
  121. ($r, @t) = SMARTMON_execute($hash, "sudo smartctl -A".$param." ".$tdev);
  122. }
  123. if($subcmd eq "health") {
  124. my $tdev = $hash->{DEVICE};
  125. if(@a>3) {$tdev=$a[3];}
  126. ($r, @t) = SMARTMON_execute($hash, "sudo smartctl -H".$param." ".$tdev);
  127. }
  128. if($subcmd eq "devices") {
  129. ($r, @t) = SMARTMON_execute($hash, "sudo smartctl --scan");
  130. }
  131. my $tt;
  132. if(defined($t[0])) {
  133. if(scalar(@t)>0) {
  134. $tt = join('',@t);
  135. }
  136. }
  137. if(!$tt) {return "unknown parameter";}
  138. return $tt."\nreturn code: ".$r;
  139. }
  140. if($cmd eq "version")
  141. {
  142. return $VERSION;
  143. }
  144. return "Unknown argument $cmd, choose one of update:noArg version:noArg list:devices,info,data,health";
  145. }
  146. sub SMARTMON_Attr($$$) {
  147. my ($cmd, $name, $attrName, $attrVal) = @_;
  148. $attrVal= "" unless defined($attrVal);
  149. Log 5, "SMARTMON Attr: $cmd $name $attrName $attrVal";
  150. my $hash = $main::defs{$name};
  151. my $orig = AttrVal($name, $attrName, "");
  152. if( $cmd eq "set" ) {# set, del
  153. if( $orig ne $attrVal ) {
  154. $attr{$name}{$attrName} = $attrVal;
  155. if($attrName eq "disable") {
  156. # NOP
  157. }
  158. if($attrName eq "parameters") {
  159. $hash->{PARAMETERS}=$attrVal;
  160. }
  161. if($attrName eq "show_raw") {
  162. SMARTMON_refreshReadings($hash);
  163. }
  164. if($attrName eq "include") {
  165. SMARTMON_refreshReadings($hash);
  166. }
  167. #return $attrName ." set to ". $attrVal;
  168. return undef;
  169. }
  170. }
  171. if( $cmd eq "del" ) {# set,
  172. if($attrName eq "show_raw") {
  173. delete $attr{$name}{$attrName};
  174. SMARTMON_refreshReadings($hash);
  175. }
  176. if($attrName eq "include") {
  177. delete $attr{$name}{$attrName};
  178. SMARTMON_refreshReadings($hash);
  179. }
  180. if($attrName eq "parameters") {
  181. delete $hash->{PARAMETERS};
  182. }
  183. }
  184. return;
  185. }
  186. sub SMARTMON_Update($)
  187. {
  188. my ($hash) = @_;
  189. SMARTMON_Log($hash, 5, "Update");
  190. my $name = $hash->{NAME};
  191. RemoveInternalTimer($hash);
  192. InternalTimer(gettimeofday()+$hash->{INTERVAL}, "SMARTMON_Update", $hash, 1);
  193. SMARTMON_refreshReadings($hash);
  194. }
  195. # Alle Readings neuerstellen
  196. sub SMARTMON_refreshReadings($) {
  197. my ($hash) = @_;
  198. SMARTMON_Log($hash, 5, "Refresh readings");
  199. my $name = $hash->{NAME};
  200. readingsBeginUpdate($hash);
  201. if( AttrVal($name, "disable", "") eq "1" ) {
  202. SMARTMON_Log($hash, 5, "Update disabled");
  203. $hash->{STATE} = "Inactive";
  204. } else {
  205. # Parameter holen
  206. my $map = SMARTMON_obtainParameters($hash);
  207. $hash->{STATE} = "Active";
  208. foreach my $aName (keys %{$map}) {
  209. my $value = $map->{$aName};
  210. #SMARTMON_Log($hash, 5, "Update: ".$value);
  211. # Nur aktualisieren, wenn ein gueltiges Value vorliegt
  212. if(defined $value) {
  213. readingsBulkUpdate($hash,$aName,$value);
  214. }
  215. }
  216. # Alle anderen Readings entfernen
  217. foreach my $rName (sort keys %{$hash->{READINGS}}) {
  218. if(!defined($map->{$rName})) {
  219. delete $hash->{READINGS}->{$rName};
  220. }
  221. }
  222. }
  223. readingsEndUpdate($hash,1);
  224. }
  225. # Alle Readings erstellen
  226. sub SMARTMON_obtainParameters($) {
  227. my ($hash) = @_;
  228. SMARTMON_Log($hash, 5, "Obtain parameters");
  229. my $map;
  230. # /usr/sbin/smartctl in /etc/sudoers aufnehmen
  231. # fhem ALL=(ALL) NOPASSWD: [...,] /usr/sbin/smartctl
  232. # Natuerlich muss der user auch der Gruppe "sudo" angehören.
  233. # Health
  234. my $param="";
  235. if($hash->{PARAMETERS}) {$param=" ".$hash->{PARAMETERS};}
  236. my ($rcode, @adev_health) = SMARTMON_execute($hash, "sudo smartctl -H".$param." ".$hash->{DEVICE}." | grep 'test result:'");
  237. my $dev_health;
  238. my $tt;
  239. if(defined($adev_health[0])) {
  240. if(scalar(@adev_health)>0) {
  241. $dev_health = join('',@adev_health);
  242. }
  243. }
  244. delete $map->{"overall_health_test"};
  245. if(defined($dev_health)) {
  246. SMARTMON_Log($hash, 5, "health: $dev_health");
  247. if($dev_health=~m/test\s+result:\s+(\S+).*/) {
  248. $map->{"overall_health_test"} = $1;
  249. }
  250. }
  251. $map = SMARTMON_getSmartDataReadings($hash, $map);
  252. return $map;
  253. }
  254. # Readings zu gelesenen RAW-Daten
  255. sub SMARTMON_getSmartDataReadings($$) {
  256. my ($hash, $map) = @_;
  257. my $name = $hash->{NAME};
  258. # Attribut lesen, splitten, als Keys eines Hashes setzen
  259. my $t_include = AttrVal($name, "include", undef);
  260. my %h_include;
  261. if(defined($t_include)) {
  262. my @a_include = split(/,\s*/, trim($t_include));
  263. %h_include = map { int($_) => 1 } @a_include; # 1 oder 001 soll gleichwertig sein
  264. }
  265. # S.M.A.R.T. RAW-Daten auslesen
  266. my $dmap = SMARTMON_readSmartData($hash, defined($t_include)?\%h_include:undef);
  267. #$dmap->{1}->{failed}="FAILING_NOW";
  268. # Bekannte Werte einspielen
  269. # per Referenz uebergeben!
  270. my $done_map = SMARTMON_interpretKnownData($hash, \%{$dmap}, \%{$map});
  271. my $cnt_oldage=0;
  272. my $cnt_prefail=0;
  273. my $sr = AttrVal($name, "show_raw", "0");
  274. foreach my $id (sort keys %{$dmap}) {
  275. if($id eq "RC") {next}
  276. # warnings zaehlen
  277. if($dmap->{$id}->{failed} ne "-") {
  278. if($dmap->{$id}->{type} eq "Pre-fail") {$cnt_prefail++;}
  279. if($dmap->{$id}->{type} eq "Old_age") {$cnt_oldage++;}
  280. }
  281. # restlichen RAW-Werte ggf. einspielen, per Attribut (show_raw) abschaltbar
  282. if( $sr eq "1" || $sr eq "2" ) {
  283. # nur wenn noch nicht frueher interpretiert werden,
  284. # oder wenn explizit erwuenscht (Attribut show_raw)
  285. if(!defined($done_map->{$id}) || $sr eq "2") {
  286. my $m = $dmap->{$id};
  287. my $rName = $m->{name};
  288. #my $raw = $dmap->{$id}->{raw};
  289. $map->{sprintf("%03d_%s",$id,$rName)} =
  290. sprintf("Flag: %s Val: %s Worst: %s Thresh: %s ".
  291. "Type: %s Updated: %s When_Failed: %s Raw: %s",
  292. $m->{flag},$m->{value},$m->{worst},$m->{thresh},$m->{type},
  293. $m->{updated},$m->{failed},$m->{raw});
  294. }
  295. }
  296. }
  297. $map->{warnings}="Pre-fail: $cnt_prefail Old_age: $cnt_oldage";
  298. SMARTMON_readDeviceData($hash, \%{$map});
  299. return $map;
  300. }
  301. sub SMARTMON_readDeviceData($%) {
  302. my ($hash, $map) = @_;
  303. my $param="";
  304. if($hash->{PARAMETERS}) {$param=" ".$hash->{PARAMETERS};}
  305. my ($r, @dev_data) = SMARTMON_execute($hash, "sudo smartctl -i".$param." ".$hash->{DEVICE});
  306. SMARTMON_Log($hash, 5, "device data: ".Dumper(@dev_data));
  307. if(defined($dev_data[0])) {
  308. while(scalar(@dev_data)>0) {
  309. my $line = $dev_data[0];
  310. shift @dev_data;
  311. my($k,$v) = split(/:\s*/,$line);
  312. if($k eq "Device Model") {
  313. $hash->{DEVICE_MODEL}=$v;
  314. }
  315. if($k eq "Serial Number") {
  316. $hash->{DEVICE_SERIAL}=$v;
  317. }
  318. if($k eq "Firmware Version") {
  319. $hash->{DEVICE_FIRMARE}=$v;
  320. }
  321. if($k eq "User Capacity") {
  322. $hash->{DEVICE_CAPACITY}=$v;
  323. }
  324. }
  325. }
  326. }
  327. # Readings zu bekannten Werten erstellen
  328. sub SMARTMON_interpretKnownData($$$) {
  329. my ($hash, $dmap, $map) = @_;
  330. my $known;
  331. #$map->{TEST}="TestX";
  332. # smartctl 5.41 2011-06-09 r3365 [armv7l-linux-3.4.98-sun7i+] (local build)
  333. # Copyright (C) 2002-11 by Bruce Allen, http://smartmontools.sourceforge.net
  334. #
  335. # === START OF READ SMART DATA SECTION ===
  336. # SMART Attributes Data Structure revision number: 16
  337. # Vendor Specific SMART Attributes with Thresholds:
  338. # ID# ATTRIBUTE_NAME FLAG VALUE WORST THRESH TYPE UPDATED WHEN_FAILED RAW_VALUE
  339. # 1 Raw_Read_Error_Rate 0x002f 200 200 051 Pre-fail Always - 0
  340. # 3 Spin_Up_Time 0x0027 184 183 021 Pre-fail Always - 1800
  341. # 4 Start_Stop_Count 0x0032 100 100 000 Old_age Always - 28
  342. # 5 Reallocated_Sector_Ct 0x0033 200 200 140 Pre-fail Always - 0
  343. # 7 Seek_Error_Rate 0x002e 200 200 000 Old_age Always - 0
  344. # 9 Power_On_Hours 0x0032 096 096 000 Old_age Always - 3444
  345. # 10 Spin_Retry_Count 0x0032 100 253 000 Old_age Always - 0
  346. # 11 Calibration_Retry_Count 0x0032 100 253 000 Old_age Always - 0
  347. # 12 Power_Cycle_Count 0x0032 100 100 000 Old_age Always - 28
  348. # 192 Power-Off_Retract_Count 0x0032 200 200 000 Old_age Always - 20
  349. # 193 Load_Cycle_Count 0x0032 200 200 000 Old_age Always - 7
  350. # 194 Temperature_Celsius 0x0022 103 097 000 Old_age Always - 44
  351. # 196 Reallocated_Event_Count 0x0032 200 200 000 Old_age Always - 0
  352. # 197 Current_Pending_Sector 0x0032 200 200 000 Old_age Always - 0
  353. # 198 Offline_Uncorrectable 0x0030 100 253 000 Old_age Offline - 0
  354. # 199 UDMA_CRC_Error_Count 0x0032 200 200 000 Old_age Always - 0
  355. # 200 Multi_Zone_Error_Rate 0x0008 100 253 000 Old_age Offline - 0
  356. if($dmap->{3}) {
  357. $map->{spin_up_time} = $dmap->{3}->{raw};
  358. $known->{3}=1;
  359. }
  360. if($dmap->{4}) {
  361. $map->{start_stop_count} = $dmap->{4}->{raw};
  362. $known->{4}=1;
  363. }
  364. if($dmap->{5}) {
  365. $map->{reallocated_sector_count} = $dmap->{5}->{raw};
  366. $known->{5}=1;
  367. }
  368. if($dmap->{9}) {
  369. $map->{power_on_hours} = $dmap->{9}->{raw};
  370. $map->{power_on_text} = SMARTMON_hour2Dauer($dmap->{9}->{raw});
  371. $known->{9}=1;
  372. }
  373. if($dmap->{10}) {
  374. $map->{spin_retry_count} = $dmap->{10}->{raw};
  375. $known->{10}=1;
  376. }
  377. if($dmap->{12}) {
  378. $map->{power_cycle_count} = $dmap->{12}->{raw};
  379. $known->{12}=1;
  380. }
  381. if($dmap->{190}) {
  382. $map->{airflow_temperature} = $dmap->{190}->{raw};
  383. $known->{190}=1;
  384. }
  385. if($dmap->{194}) {
  386. $map->{temperature} = $dmap->{194}->{raw};
  387. $known->{194}=1;
  388. }
  389. # TODO
  390. if($dmap->{"RC"}) {
  391. $map->{last_exit_code} = $dmap->{"RC"}->{raw};
  392. $known->{"RC"}=1;
  393. }
  394. return $known;
  395. }
  396. # Ausrechnet aus der Zahl der Sekunden Anzeige in Tagen:Stunden:Minuten:Sekunden.
  397. sub SMARTMON_sec2Dauer($){
  398. my ($t) = @_;
  399. my $d = int($t/86400);
  400. my $r = $t-($d*86400);
  401. my $h = int($r/3600);
  402. $r = $r - ($h*3600);
  403. my $m = int($r/60);
  404. my $s = $r - $m*60;
  405. return sprintf("%02d Tage %02d Std. %02d Min. %02d Sec.",$d,$h,$m,$s);
  406. }
  407. # Ausrechnet aus der Zahl der Stunden Anzeige in Tagen:Stunden:Minuten:Sekunden.
  408. sub SMARTMON_hour2Dauer($){
  409. my ($t) = @_;
  410. #return SMARTMON_sec2Dauer($t*3600);
  411. $t =~ /([0-9]*)/;
  412. my $d=int($1/24);
  413. $t = $1-($d*24);
  414. #my $d=int($t/24);
  415. #$t = $t-($d*24);
  416. my $y=int($d/365);
  417. $d = $d-($y*365);
  418. return sprintf("%d Jahre %d Tage %d Std.",$y,$d,$t);
  419. }
  420. # liest RAW-Daten
  421. # Params:
  422. # HASH: Device-HASH
  423. # Include-HASH: Wenn definiert,werden nur die ID zurueckgegeben, die in
  424. # diesem HASH enthalten sind.
  425. sub SMARTMON_readSmartData($;$) {
  426. my ($hash, $include) = @_;
  427. my $map;
  428. my $param="";
  429. if($hash->{PARAMETERS}) {$param=" ".$hash->{PARAMETERS};}
  430. my ($r, @dev_data) = SMARTMON_execute($hash, "sudo smartctl -A".$param." ".$hash->{DEVICE});
  431. SMARTMON_Log($hash, 5, "device SMART data: ".Dumper(@dev_data));
  432. if(defined($r)) {$map->{"RC"}->{raw} = $r;}
  433. if(defined($dev_data[0])) {
  434. while(scalar(@dev_data)>0) {
  435. shift @dev_data;
  436. if(scalar(@dev_data)>0 && $dev_data[0]=~m/ID#.*/) {
  437. shift @dev_data;
  438. while(scalar(@dev_data)>0) {
  439. my ($d_id, $d_attr_name, $d_flag, $d_value, $d_worst, $d_thresh,
  440. $d_type, $d_updated, $d_when_failed, $d_raw_value)
  441. = split(/\s+/, trim($dev_data[0]));
  442. shift @dev_data;
  443. if(!defined($include) || defined($include->{$d_id})) {
  444. if(defined($d_attr_name)) {
  445. #$map->{$d_attr_name} = "Value: $d_value, Worst: $d_worst, Type: $d_type, Raw: $d_raw_value";
  446. $map->{$d_id}->{name} = $d_attr_name;
  447. $map->{$d_id}->{flag} = $d_flag;
  448. $map->{$d_id}->{value} = $d_value;
  449. $map->{$d_id}->{worst} = $d_worst;
  450. $map->{$d_id}->{thresh} = $d_thresh;
  451. $map->{$d_id}->{type} = $d_type;
  452. $map->{$d_id}->{updated} = $d_updated;
  453. $map->{$d_id}->{failed} = $d_when_failed;
  454. $map->{$d_id}->{raw} = $d_raw_value;
  455. }
  456. }
  457. }
  458. }
  459. }
  460. }
  461. return $map;
  462. }
  463. # BS-Befehl ausfuehren
  464. sub SMARTMON_execute($$) {
  465. my ($hash, $cmd) = @_;
  466. SMARTMON_Log($hash, 5, "Execute: $cmd");
  467. local $SIG{'CHLD'}='DEFAULT';
  468. my @ret = qx($cmd);
  469. my $rcode = $?>>8;
  470. SMARTMON_Log($hash, 5, "Returncode: ".$rcode);
  471. return ($rcode,@ret);
  472. }
  473. 1;
  474. =pod
  475. =item device
  476. =item summary provides some statistics about the S.M.A.R.T. capable drive
  477. =item summary_DE liefert einige Statistiken ueber S.M.A.R.T. kompatible Geräte
  478. =begin html
  479. <!-- ================================ -->
  480. <a name="SMARTMON"></a>
  481. <h3>SMARTMON</h3>
  482. <ul>
  483. This module is a FHEM frontend to the Linux tool smartctl.
  484. It provides various information on the SMART System of the hard drive.
  485. <br><br>
  486. <b>Define</b>
  487. <br><br>
  488. <code>define &lt;name&gt; SMARTMON &lt;device&gt; [&lt;Interval&gt;]</code><br>
  489. <br>
  490. This statement creates a new SMARTMON instance.
  491. The parameters specify a device to be monitored and the update interval in minutes.<br>
  492. <br>
  493. Example: <code>define sm SMARTMON /dev/sda 60</code>
  494. <br>
  495. <br>
  496. <b>Readings:</b>
  497. <br><br>
  498. <ul>
  499. <li>last_exit_code<br>
  500. Exit code of smartctl.
  501. </li>
  502. <li>overall_health_test<br>
  503. Specifies the general condition of the HDD (PASSED or FAILED).
  504. </li>
  505. <br>
  506. <li>warnings<br>
  507. Specifies the number of stored alerts.
  508. </li>
  509. <br>
  510. Furthermore, the available SMART parameters can be displayed as Readings (RAW and / or (partially) interpreted).
  511. </ul>
  512. <br>
  513. <b>Get:</b><br><br>
  514. <ul>
  515. <li>version<br>
  516. Displays the module version.
  517. </li>
  518. <br>
  519. <li>update<br>
  520. Updates all readings.
  521. </li>
  522. <br>
  523. <li>list<br>
  524. Displays various information:
  525. <ul>
  526. <li>devices:<br>List of available devices in the system.</li>
  527. </ul><br>
  528. <ul>
  529. <li>info:<br>Information about the current device.</li>
  530. </ul><br>
  531. <ul>
  532. <li>data:<br>List of SMART parameters for the current device.</li>
  533. </ul><br>
  534. <ul>
  535. <li>health:<br>Information about overall health status for the device.</li>
  536. </ul><br>
  537. For the Last 3 commands can also be another Device specified (as an additional parameter).
  538. </li>
  539. <br>
  540. </ul><br>
  541. <b>Attributes:</b><br><br>
  542. <ul>
  543. <li>show_raw<br>
  544. Valid values: 0: no RAW Readings (default), 1: show all, are not included in interpreted Readings, 2: show all.
  545. </li>
  546. <br>
  547. <li>include<br>
  548. Comma separated list of IDs for desired SMART parameters. If nothing passed, all available values are displayed.
  549. </li>
  550. <br>
  551. <li>disable<br>
  552. Valid values: 0: Module active (default), 1: module is disabled (no updates).
  553. </li>
  554. <br>
  555. <li>parameters<br>
  556. Additional values for smartctl.
  557. </li>
  558. <br>
  559. </ul><br>
  560. For more information see cmartctrl documentation.
  561. </ul>
  562. <!-- ================================ -->
  563. =end html
  564. =begin html_DE
  565. <a name="SMARTMON"></a>
  566. <h3>SMARTMON</h3>
  567. <ul>
  568. Dieses Modul ist ein FHEM-Frontend zu dem Linux-Tool smartctl.
  569. Es liefert diverse Informationen zu dem S.M.A.R.T. System einer Festplatte.
  570. <br><br>
  571. <b>Define</b>
  572. <br><br>
  573. <code>define &lt;name&gt; SMARTMON &lt;device&gt; [&lt;Interval&gt;]</code><br>
  574. <br>
  575. Diese Anweisung erstellt eine neue SMARTMON-Instanz.
  576. Die Parameter geben ein zu &uuml;berwachenden Ger&auml;t und den Aktualisierungsinterval in Minuten an.<br>
  577. <br>
  578. Beispiel: <code>define sm SMARTMON /dev/sda 60</code>
  579. <br>
  580. <br>
  581. <b>Readings:</b>
  582. <br><br>
  583. <ul>
  584. <li>last_exit_code<br>
  585. Gibt den Exitcode bei der letzten Ausf&uuml;hrung vom smartctl.
  586. </li>
  587. <br>
  588. <li>overall_health_test<br>
  589. Gibt den allgemeinen Zustand der Platte an. Kann PASSED oder FAILED sein.
  590. </li>
  591. <br>
  592. <li>warnings<br>
  593. Gibt die Anzahl der vermerkten Warnungen an.
  594. </li>
  595. <br>
  596. Weiterhin k&ouml;nnen die verf&uuml;gbaren SMART-Parameter als Readings angezeigt werden (RAW und/oder (teilweise) interpretiert).
  597. </ul>
  598. <br>
  599. <b>Get:</b><br><br>
  600. <ul>
  601. <li>version<br>
  602. Zeigt die verwendete Modul-Version an.
  603. </li>
  604. <br>
  605. <li>update<br>
  606. Veranlasst die Aktualisierung der gelesenen Parameter.
  607. </li>
  608. <br>
  609. <li>list<br>
  610. Zeigt verschiedenen Informationen an:
  611. <ul>
  612. <li>devices:<br>Liste der im System verf&uuml;gbaren Ger&auml;ten.</li>
  613. </ul><br>
  614. <ul>
  615. <li>info:<br>Information zu dem aktuellen Ger&auml;t.</li>
  616. </ul><br>
  617. <ul>
  618. <li>data:<br>Liste der SMART-Parameter zu dem aktuellen Ger&auml;t.</li>
  619. </ul><br>
  620. <ul>
  621. <li>health:<br>Information zu dem allgemeinen Gesundheitsstatus f&uuml;r das verwendete Ger&auml;t.</li>
  622. </ul><br>
  623. F&uuml;r letzten 3 Befehle kann auch noch ein anderes Ger&auml;t als zus&auml;tzliche Parameter mitgegeben werden.
  624. </li>
  625. <br>
  626. </ul><br>
  627. <b>Attributes:</b><br><br>
  628. <ul>
  629. <li>show_raw<br>
  630. G&uuml;ltige Werte: 0: keine RAW-Readings anzeigen (default), 1: alle anzeigen, die nicht in interpretierten Readings enthalten sind, 2: alle anzeigen.
  631. </li>
  632. <br>
  633. <li>include<br>
  634. Kommaseparierte Liste der IDs gew&uuml;nschten SMART-Parameter. Wenn nichts angegeben, werden alle verf&uuml;gbaren angezeigt.
  635. </li>
  636. <br>
  637. <li>disable<br>
  638. G&uuml;ltige Werte: 0: Modul aktiv (default), 1: Modul deaktiviert (keine Aktualisierungen).
  639. </li>
  640. <br>
  641. <li>parameters<br>
  642. Zusatzparameter f&uuml;r den Aufruf von smartctl.
  643. </li>
  644. <br>
  645. </ul><br>
  646. F&uuml;r weitere Informationen wird die cmartctrl-Dokumentation empfohlen.
  647. </ul>
  648. =end html_DE
  649. =cut