Avoir les info SMART des disques dans phpsysinfo
Pour le tuto il faut:- ubuntu
- phpsysinfo (et donc apache)
Version 3.0.19 MAX- smartctl
un petit aperçu de smartctl qui sera notre pierre angulaire
Citation :
Usage: smartctl [options] device
============================================ SHOW INFORMATION OPTIONS =====
-h, --help, --usage
Display this help and exit
-V, --version, --copyright, --license
Print license, copyright, and version information and exit
-i, --info
Show identity information for device
-a, --all
Show all SMART information for device
-x, --xall
Show all information for device
--scan
Scan for devices
--scan-open
Scan for devices and try to open each device
================================== SMARTCTL RUN-TIME BEHAVIOR OPTIONS =====
-q TYPE, --quietmode=TYPE (ATA)
Set smartctl quiet mode to one of: errorsonly, silent, noserial
-d TYPE, --device=TYPE
Specify device type to one of: ata, scsi, sat[,N][+TYPE], usbcypress[,X], usbjmicron[,x][,N], usbsunplus, marvell, areca,N, 3ware,N, hpt,L/M/N, megaraid,N, cciss,N, auto, test
-T TYPE, --tolerance=TYPE (ATA)
Tolerance: normal, conservative, permissive, verypermissive
-b TYPE, --badsum=TYPE (ATA)
Set action on bad checksum to one of: warn, exit, ignore
-r TYPE, --report=TYPE
Report transactions (see man page)
-n MODE, --nocheck=MODE (ATA)
No check if: never, sleep, standby, idle (see man page)
============================== DEVICE FEATURE ENABLE/DISABLE COMMANDS =====
-s VALUE, --smart=VALUE
Enable/disable SMART on device (on/off)
-o VALUE, --offlineauto=VALUE (ATA)
Enable/disable automatic offline testing on device (on/off)
-S VALUE, --saveauto=VALUE (ATA)
Enable/disable Attribute autosave on device (on/off)
======================================= READ AND DISPLAY DATA OPTIONS =====
-H, --health
Show device SMART health status
-c, --capabilities (ATA)
Show device SMART capabilities
-A, --attributes
Show device SMART vendor-specific Attributes and values
-f FORMAT, --format=FORMAT (ATA)
Set output format for attributes to one of: old, brief
-l TYPE, --log=TYPE
Show device log. TYPE: error, selftest, selective, directory[,g|s],
background, sasphy[,reset], sataphy[,reset],
scttemp[sts,hist], scterc[,N,M],
gplog,N[,RANGE], smartlog,N[,RANGE],
xerror[,N][,error], xselftest[,N][,selftest]
-v N,OPTION , --vendorattribute=N,OPTION (ATA)
Set display OPTION for vendor Attribute N (see man page)
-F TYPE, --firmwarebug=TYPE (ATA)
Use firmware bug workaround: none, samsung, samsung2,
samsung3, swapid
-P TYPE, --presets=TYPE (ATA)
Drive-specific presets: use, ignore, show, showall
-B [+]FILE, --drivedb=[+]FILE (ATA)
Read and replace [add] drive database from FILE
[default is +/etc/smart_drivedb.h
and then /usr/share/smartmontools/drivedb.h]
============================================ DEVICE SELF-TEST OPTIONS =====
-t TEST, --test=TEST
Run test. TEST: offline short long conveyance vendor,N select,M-N
pending,N afterselect,[on|off] scttempint,N[,p]
-C, --captive
Do test in captive mode (along with -t)
-X, --abort
Abort any non-captive test on device
=================================================== SMARTCTL EXAMPLES =====
smartctl --all /dev/hda (Prints all SMART information)
smartctl --smart=on --offlineauto=on --saveauto=on /dev/hda
(Enables SMART on first disk)
smartctl --test=long /dev/hda (Executes extended disk self-test)
smartctl --attributes --log=selftest --quietmode=errorsonly /dev/hda
(Prints Self-Test & Attribute errors)
smartctl --all --device=3ware,2 /dev/sda
smartctl --all --device=3ware,2 /dev/twe0
smartctl --all --device=3ware,2 /dev/twa0
smartctl --all --device=3ware,2 /dev/twl0
(Prints all SMART info for 3rd ATA disk on 3ware RAID controller)
smartctl --all --device=hpt,1/1/3 /dev/sda
(Prints all SMART info for the SATA disk attached to the 3rd PMPort
of the 1st channel on the 1st HighPoint RAID controller)
smartctl --all --device=areca,3 /dev/sg2
(Prints all SMART info for 3rd ATA disk on Areca RAID controller)
Bon c'est parti !!
- 1 - On cherche les disques et leur connection au system (souvent y'a des surprise)
Code :
smartctl --scan-open
/dev/sda -d sat # /dev/sda [SAT], ATA device
/dev/sdb -d sat # /dev/sdb [SAT], ATA device
/dev/sdc -d sat # /dev/sdc [SAT], ATA device
/dev/sdd -d sat # /dev/sdd [SAT], ATA device
/dev/sde -d sat # /dev/sde [SAT], ATA device
/dev/sdf -d scsi # /dev/sdf, SCSI device
/dev/sdg -d scsi # /dev/sdg, SCSI device
/dev/sdh -d scsi # /dev/sdh, SCSI device
/dev/sdi -d scsi # /dev/sdi, SCSI device
Ne sorte donc que les disques directement accessible par le system
- 2 - On test chacun des disques (enfin par controleur)
Explication:
smartctl --all /dev/sda --> on sort toutes les info du smart sans specifier le type de connexion
smartctl --all -d scsi /dev/sdi --> Pareil mais carte vue comme Scsi (Dell Perc 5ir)
smartctl --all -d cciss,0 /dev/cciss/c0d0 --> plus compliqué C0D0 est mon raid 5 hard de la HP P400 SAS, je sort donc les info smart dispo pour le port 0 jusqu'a 8 si utlisé
On test donc et quand cela marche on a ceci (faut scroller les gars !!)
Citation :
sudo smartctl --all /dev/sda[sudo] password for biour:
smartctl 5.41 2011-06-09 r3365 [x86_64-linux-3.0.0-13-generic] (local build)
Copyright (C) 2002-11 by Bruce Allen,
http://smartmontools.sourceforge.net=== START OF INFORMATION SECTION ===
Model Family: Maxtor MaXLine Pro 500
Device Model: Maxtor 7H500F0
Serial Number: H80V4B7H
LU WWN Device Id: 0 150500 70e408d8d
Firmware Version: HA431DD0
User Capacity: 500 107 862 016 bytes [500 GB]
Sector Size: 512 bytes logical/physical
Device is: In smartctl database [for details use: -P show]
ATA Version is: 7
ATA Standard is: ATA/ATAPI-7 T13 1532D revision 0
Local Time is: Fri Sep 28 20:49:33 2012 CEST
SMART support is: Available - device has SMART capability.
SMART support is: Enabled
=== START OF READ SMART DATA SECTION ===
SMART overall-health self-assessment test result: PASSED
General SMART Values:
Offline data collection status: (0x82) Offline data collection activity
was completed without error.
Auto Offline Data Collection: Enabled.
Self-test execution status: ( 0) The previous self-test routine completed
without error or no self-test has ever
been run.
Total time to complete Offline
data collection: ( 9003) seconds.
Offline data collection
capabilities: (0x5b) SMART execute Offline immediate.
Auto Offline data collection on/off support.
Suspend Offline collection upon new
command.
Offline surface scan supported.
Self-test supported.
No Conveyance Self-test supported.
Selective Self-test supported.
SMART capabilities: (0x0003) Saves SMART data before entering
power-saving mode.
Supports SMART auto save timer.
Error logging capability: (0x01) Error logging supported.
General Purpose Logging supported.
Short self-test routine
recommended polling time: ( 2) minutes.
Extended self-test routine
recommended polling time: ( 206) minutes.
SCT capabilities: (0x0021) SCT Status supported.
SCT Data Table supported.
SMART Attributes Data Structure revision number: 32
Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE_NAME FLAG VALUE WORST THRESH TYPE UPDATED WHEN_FAILED RAW_VALUE
3 Spin_Up_Time 0x0027 217 170 063 Pre-fail Always - 8069
4 Start_Stop_Count 0x0032 253 253 000 Old_age Always - 706
5 Reallocated_Sector_Ct 0x0033 253 253 063 Pre-fail Always - 0
7 Seek_Error_Rate 0x000a 253 251 000 Old_age Always - 0
8 Seek_Time_Performance 0x0027 250 236 187 Pre-fail Always - 36151
9 Power_On_Hours 0x0032 132 132 000 Old_age Always - 42214
10 Spin_Retry_Count 0x002b 253 243 157 Pre-fail Always - 0
11 Calibration_Retry_Count 0x002b 253 252 223 Pre-fail Always - 0
12 Power_Cycle_Count 0x0032 250 250 000 Old_age Always - 1337
189 High_Fly_Writes 0x003a 100 100 000 Old_age Always - 0
190 Airflow_Temperature_Cel 0x0022 054 034 000 Old_age Always - 46 (Min/Max 40/49)
192 Power-Off_Retract_Count 0x0032 253 253 000 Old_age Always - 0
193 Load_Cycle_Count 0x0032 253 253 000 Old_age Always - 0
194 Temperature_Celsius 0x0032 040 253 000 Old_age Always - 46195 Hardware_ECC_Recovered 0x000a 253 252 000 Old_age Always - 1781
196 Reallocated_Event_Count 0x0008 253 253 000 Old_age Offline - 0
197 Current_Pending_Sector 0x0008 253 253 000 Old_age Offline - 0
198 Offline_Uncorrectable 0x0008 252 252 000 Old_age Offline - 1
199 UDMA_CRC_Error_Count 0x0008 199 199 000 Old_age Offline - 0
200 Multi_Zone_Error_Rate 0x000a 253 252 000 Old_age Always - 0
201 Soft_Read_Error_Rate 0x000a 253 252 000 Old_age Always - 0
202 Data_Address_Mark_Errs 0x000a 253 252 000 Old_age Always - 0
203 Run_Out_Cancel 0x000b 253 252 180 Pre-fail Always - 0
204 Soft_ECC_Correction 0x000a 253 252 000 Old_age Always - 0
205 Thermal_Asperity_Rate 0x000a 253 252 000 Old_age Always - 0
207 Spin_High_Current 0x002a 253 252 000 Old_age Always - 0
208 Spin_Buzz 0x002a 253 252 000 Old_age Always - 0
210 Unknown_Attribute 0x0032 253 252 000 Old_age Always - 0
211 Unknown_Attribute 0x0032 253 252 000 Old_age Always - 0
212 Unknown_Attribute 0x0032 253 001 000 Old_age Always - 0
SMART Error Log Version: 1
ATA Error Count: 5
CR = Command Register [HEX]
FR = Features Register [HEX]
SC = Sector Count Register [HEX]
SN = Sector Number Register [HEX]
CL = Cylinder Low Register [HEX]
CH = Cylinder High Register [HEX]
DH = Device/Head Register [HEX]
DC = Device Command Register [HEX]
ER = Error register [HEX]
ST = Status register [HEX]
Powered_Up_Time is measured from power on, and printed as
DDd+hh:mm:SS.sss where DD=days, hh=hours, mm=minutes,
SS=sec, and sss=millisec. It "wraps" after 49.710 days.
Error 5 occurred at disk power-on lifetime: 25936 hours (1080 days + 16 hours)
When the command that caused the error occurred, the device was in an unknown state.
After command completion occurred, registers were:
ER ST SC SN CL CH DH
-- -- -- -- -- -- --
40 51 b8 88 65 be e0 Error: UNC 184 sectors at LBA = 0x00be6588 = 12477832
Commands leading to the command that caused the error were:
CR FR SC SN CL CH DH DC Powered_Up_Time Command/Feature_Name
-- -- -- -- -- -- -- -- ---------------- --------------------
25 00 b8 87 65 be e0 00 00:00:38.208 READ DMA EXT
27 00 00 00 00 00 e0 00 00:00:38.148 READ NATIVE MAX ADDRESS EXT
ec 00 00 00 00 00 a0 00 00:00:38.128 IDENTIFY DEVICE
ef 03 42 00 00 00 a0 00 00:00:38.108 SET FEATURES [Set transfer mode]
27 00 00 00 00 00 e0 00 00:00:37.928 READ NATIVE MAX ADDRESS EXT
Error 4 occurred at disk power-on lifetime: 25936 hours (1080 days + 16 hours)
When the command that caused the error occurred, the device was in an unknown state.
After command completion occurred, registers were:
ER ST SC SN CL CH DH
-- -- -- -- -- -- --
40 51 b8 88 65 be e0 Error: UNC 184 sectors at LBA = 0x00be6588 = 12477832
Commands leading to the command that caused the error were:
CR FR SC SN CL CH DH DC Powered_Up_Time Command/Feature_Name
-- -- -- -- -- -- -- -- ---------------- --------------------
25 00 b8 87 65 be e0 00 00:00:34.096 READ DMA EXT
27 00 00 00 00 00 e0 00 00:00:34.036 READ NATIVE MAX ADDRESS EXT
ec 00 00 00 00 00 a0 00 00:00:34.016 IDENTIFY DEVICE
ef 03 42 00 00 00 a0 00 00:00:33.996 SET FEATURES [Set transfer mode]
27 00 00 00 00 00 e0 00 00:00:33.815 READ NATIVE MAX ADDRESS EXT
Error 3 occurred at disk power-on lifetime: 25936 hours (1080 days + 16 hours)
When the command that caused the error occurred, the device was in an unknown state.
After command completion occurred, registers were:
ER ST SC SN CL CH DH
-- -- -- -- -- -- --
40 51 b8 88 65 be e0 Error: UNC 184 sectors at LBA = 0x00be6588 = 12477832
Commands leading to the command that caused the error were:
CR FR SC SN CL CH DH DC Powered_Up_Time Command/Feature_Name
-- -- -- -- -- -- -- -- ---------------- --------------------
25 00 b8 87 65 be e0 00 00:00:29.984 READ DMA EXT
27 00 00 00 00 00 e0 00 00:00:29.924 READ NATIVE MAX ADDRESS EXT
ec 00 00 00 00 00 a0 00 00:00:29.904 IDENTIFY DEVICE
ef 03 42 00 00 00 a0 00 00:00:29.884 SET FEATURES [Set transfer mode]
27 00 00 00 00 00 e0 00 00:00:29.633 READ NATIVE MAX ADDRESS EXT
Error 2 occurred at disk power-on lifetime: 25936 hours (1080 days + 16 hours)
When the command that caused the error occurred, the device was in an unknown state.
After command completion occurred, registers were:
ER ST SC SN CL CH DH
-- -- -- -- -- -- --
00 50 00 00 00 00 a0
Commands leading to the command that caused the error were:
CR FR SC SN CL CH DH DC Powered_Up_Time Command/Feature_Name
-- -- -- -- -- -- -- -- ---------------- --------------------
ec 00 00 00 00 00 a0 00 00:00:41.670 IDENTIFY DEVICE
25 00 b8 87 65 be e0 00 00:00:37.949 READ DMA EXT
27 00 00 00 00 00 e0 00 00:00:37.799 READ NATIVE MAX ADDRESS EXT
ec 00 00 00 00 00 a0 00 00:00:37.770 IDENTIFY DEVICE
ef 03 42 00 00 00 a0 00 00:00:37.759 SET FEATURES [Set transfer mode]
Error 1 occurred at disk power-on lifetime: 25936 hours (1080 days + 16 hours)
When the command that caused the error occurred, the device was in an unknown state.
After command completion occurred, registers were:
ER ST SC SN CL CH DH
-- -- -- -- -- -- --
40 51 b8 88 65 be e0 Error: UNC 184 sectors at LBA = 0x00be6588 = 12477832
Commands leading to the command that caused the error were:
CR FR SC SN CL CH DH DC Powered_Up_Time Command/Feature_Name
-- -- -- -- -- -- -- -- ---------------- --------------------
25 00 b8 87 65 be e0 00 00:00:30.026 READ DMA EXT
25 00 00 3f 5f be e0 00 00:00:29.926 READ DMA EXT
27 00 00 00 00 00 e0 00 00:00:29.866 READ NATIVE MAX ADDRESS EXT
ec 00 00 00 00 00 a0 00 00:00:29.845 IDENTIFY DEVICE
ef 03 42 00 00 00 a0 00 00:00:29.825 SET FEATURES [Set transfer mode]
SMART Self-test log structure revision number 1
Num Test_Description Status Remaining LifeTime(hours) LBA_of_first_error
# 1 Short offline Completed without error 00% 23626 -
SMART Selective self-test log data structure revision number 1
SPAN MIN_LBA MAX_LBA CURRENT_TEST_STATUS
1 0 0 Not_testing
2 0 0 Not_testing
3 0 0 Not_testing
4 0 0 Not_testing
5 0 0 Not_testing
Selective self-test flags (0x0):
After scanning selected spans, do NOT read-scan remainder of disk.
If Selective self-test is pending on power-up, resume after 0 minute delay.
Bingo !!
Et quand cela ne veux pas (méthode de plus en plus bourrine)
Citation :
sudo smartctl --all -d scsi /dev/sdismartctl 5.41 2011-06-09 r3365 [x86_64-linux-3.0.0-13-generic] (local build)
Copyright (C) 2002-11 by Bruce Allen,
http://smartmontools.sourceforge.netUser Capacity: 500 107 862 016 bytes [500 GB]
Logical block size: 512 bytes
Logical Unit id: 0x5000cca357e29fda
Serial number: GEA534Rxxx
Device type: disk
Local Time is: Fri Sep 28 20:51:29 2012 CEST
Device supports SMART and is Enabled
Temperature Warning Disabled or Not Supported
SMART Health Status: OK
Error Counter logging not supported
Device does not support Self Test logging
sudo smartctl --all -d scsi /dev/sdi -T verypermissivesmartctl 5.41 2011-06-09 r3365 [x86_64-linux-3.0.0-13-generic] (local build)
Copyright (C) 2002-11 by Bruce Allen,
http://smartmontools.sourceforge.netUser Capacity: 500 107 862 016 bytes [500 GB]
Logical block size: 512 bytes
Logical Unit id: 0x5000cca357e29fda
Serial number: GEA534xxx
Device type: disk
Local Time is: Fri Sep 28 20:51:41 2012 CEST
Device supports SMART and is Enabled
Temperature Warning Disabled or Not Supported
SMART Health Status: OK
Error Counter logging not supported
Device does not support Self Test logging
sudo smartctl --all -d scsi /dev/sdi -T verypermissive -s onsmartctl 5.41 2011-06-09 r3365 [x86_64-linux-3.0.0-13-generic] (local build)
Copyright (C) 2002-11 by Bruce Allen,
http://smartmontools.sourceforge.netUser Capacity: 500 107 862 016 bytes [500 GB]
Logical block size: 512 bytes
Logical Unit id: 0x5000cca357e29fda
Serial number: GEA534xxx
Device type: disk
Local Time is: Fri Sep 28 20:51:47 2012 CEST
Device supports SMART and is Enabled
Temperature Warning Disabled or Not Supported
Informational Exceptions (SMART) enabled
Temperature warning disabled
SMART Health Status: OK
Error Counter logging not supported
Device does not support Self Test logging
Mais la j'ai pas encore reussi
Et pour voir au travers d'une grappe (ici sur carte HP)
Citation :
sudo smartctl --all -d cciss,0 /dev/cciss/c0d0smartctl 5.41 2011-06-09 r3365 [x86_64-linux-3.0.0-13-generic] (local build)
Copyright (C) 2002-11 by Bruce Allen,
http://smartmontools.sourceforge.netUser Capacity: 2 000 398 934 016 bytes [2,00 TB]
Logical block size: 512 bytes
Logical Unit id: 0x5000c5002fef4d80
Serial number: 5YD2Kxxx
Device type: disk
Local Time is: Fri Sep 28 20:54:26 2012 CEST
Device supports SMART and is Enabled
Temperature Warning Disabled or Not Supported
SMART Health Status: OK
Current Drive Temperature: 30 CRead defect list: asked for grown list but didn't get it
Error Counter logging not supported
Bingo !!
- 3 - On passe la modif des fichiers de config de phpsysinfo (tres bien commenté)
A la racine on ouvre
config.php et on cherche la ligne PSI_Plugins pour ajouter
SMARTCode :
define('PSI_PLUGINS', 'UpdateNotifier,PSStatus,[b]SMART[/b],MDStatus');
Ensuite on ouvre SMART.config.php dans
/var/www/phpsysinfo/plugins/SMART et passe de
'command' a 'data'et la ligne du dessous (device) on a joute nos disques (ou nos nom de disque par ex HP400:1 pour disque 1 de la carte HP400)
Code :
define('PSI_PLUGIN_SMART_ACCESS', 'data');
/**
* Smartctl devices to monitor
* If the smartctl support is enabled, those disks information will be displayed
* - define('PSI_PLUGIN_SMART_DEVICES', '/dev/hda,/dev/hdb'); // Will display those two disks informations
*/
define('PSI_PLUGIN_SMART_DEVICES', '/dev/sda,/dev/sdb,/dev/sdc,/dev/sdd,/dev/sde,/dev/sdf,/dev/sdg,/dev/sdh,/dev/sdi,/HP400:1,/HP400:2,/HP400:3,/HP400:4');
on sauvegarde
- 4 - cree un fichier executable qui va nous crees des Txt au bon endroit pour phpsysinfo
Donc on cree dans
Code :
/usr/local/bin/
un fichier (ici smarttxt)
faire un
Code :
sudo chmod -x
dessus
un petit coup de nano (on transfert les resultats du smart dans un fichier txt)
et on ajoute les lignes de commande pour chaque disques dans l'ordre (le numero correspond a l'ordre du fichier SMART.config ligne device)
Code :
sudo smartctl --all /dev/sda >/var/www/phpsysinfo/data/SMART0.txt
sudo smartctl --all /dev/sdb >/var/www/phpsysinfo/data/SMART1.txt
sudo smartctl --all /dev/sdc >/var/www/phpsysinfo/data/SMART2.txt
sudo smartctl --all /dev/sdd >/var/www/phpsysinfo/data/SMART3.txt
sudo smartctl --all /dev/sde >/var/www/phpsysinfo/data/SMART4.txt
sudo smartctl --all -d scsi /dev/sdf >/var/www/phpsysinfo/data/SMART5.txt
sudo smartctl --all -d scsi /dev/sdg >/var/www/phpsysinfo/data/SMART6.txt
sudo smartctl --all -d scsi /dev/sdh >/var/www/phpsysinfo/data/SMART7.txt
sudo smartctl --all -d scsi /dev/sdi >/var/www/phpsysinfo/data/SMART8.txt
sudo smartctl --all -d cciss,0 /dev/cciss/c0d0 >/var/www/phpsysinfo/data/SMART9.txt
sudo smartctl --all -d cciss,1 /dev/cciss/c0d0 >/var/www/phpsysinfo/data/SMART10.txt
sudo smartctl --all -d cciss,2 /dev/cciss/c0d0 >/var/www/phpsysinfo/data/SMART11.txt
sudo smartctl --all -d cciss,3 /dev/cciss/c0d0 >/var/www/phpsysinfo/data/SMART12.txt
Il est imperatif de placer les fichier texte dans le repertoire 'data' de phpsysinfo, et le fichier texte doit etre SMARTnb.txt impérativement lui aussifaire :
Code :
sudo crontab -e
et ajouter cette ligne
Code :
*/1 * * * * /usr/local/bin/smarttxt @reboot
on vas exécuter le fichier script toutes les minutes en mode root (effectif apres reboot)
le fait d'avoir placer le fichier dans /usr/local/bin/ permet aussi de le lancer a la mano de n'importe ou
et voila
http://biour.dyndns.org/phpsysinfo/index.php+++
Pour vous amuser vous pouvez choisir les info SMART a remonter (a la fin du fichier SMART.config.php)
mais courage de ce coté la
Version 3.1
fichier SMART0.txt deviennent smart0.txt
modif de phpsysinfo.ini en lien est place de config.php et SMART.config.php
syntaxe a peu pres pariel ^^
Code :
PLUGINS="MDStatus,PSStatus,SMART,UpdateNotifier"
[smart]
; SMART Plugin configuration
ACCESS="data"
DEVICES="sda (Maxtor 7H500F0),/dev/sdb/"