├── COPYING ├── README ├── debian ├── changelog ├── compat ├── control ├── copyright ├── docs ├── encled.install ├── encled.manpages ├── rules └── source │ └── format ├── encled ├── encled.8 └── sdled /COPYING: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc. 5 | 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Library General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | 294 | Copyright (C) 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License 307 | along with this program; if not, write to the Free Software 308 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 309 | 310 | 311 | Also add information on how to contact you by electronic and paper mail. 312 | 313 | If the program is interactive, make it output a short notice like this 314 | when it starts in an interactive mode: 315 | 316 | Gnomovision version 69, Copyright (C) year name of author 317 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 318 | This is free software, and you are welcome to redistribute it 319 | under certain conditions; type `show c' for details. 320 | 321 | The hypothetical commands `show w' and `show c' should show the appropriate 322 | parts of the General Public License. Of course, the commands you use may 323 | be called something other than `show w' and `show c'; they could even be 324 | mouse-clicks or menu items--whatever suits your program. 325 | 326 | You should also get your employer (if you work as a programmer) or your 327 | school, if any, to sign a "copyright disclaimer" for the program, if 328 | necessary. Here is a sample; alter the names: 329 | 330 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 331 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 332 | 333 | , 1 April 1989 334 | Ty Coon, President of Vice 335 | 336 | This General Public License does not permit incorporating your program into 337 | proprietary programs. If your program is a subroutine library, you may 338 | consider it more useful to permit linking proprietary applications with the 339 | library. If this is what you want to do, use the GNU Library General 340 | Public License instead of this License. 341 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | Encled - utility to change location / fault LED for enclosure. 2 | 3 | I'm not sure if it works with every available enclosures, but at least it 4 | works with Supermicro chases with SAS enclosures (LSI). 5 | 6 | Encled heavily depends on linux kernel's /sys/class/enclosure 7 | 8 | Previous name was sdled, but now it supports not only 'sd' devices 9 | but empty disk slots too. 10 | 11 | Usage: 12 | 13 | encled (without options) - display all slots devices status and disk letter 14 | encled enclosure/slot - display status of requested device 15 | encled enclosure/slot fault - set led indicator to 'faulty' 16 | this WILL NOT make device faulty, just set 17 | enclosure led to 'FAULTY' status. 18 | encled enclosure/slot locate - set led indicator to 'locate' status 19 | encled enclosure/slot off - turn off faulty/locate status 20 | encled device locate/fault/off will work with sd device (sda, sde) 21 | 22 | encled ALL off 23 | encled GOOD off - turns off leds only on devices where fault led is off 24 | encled ALL fault 25 | encled ALL locate - turn all devices to that status (note CAPS ALL) 26 | 27 | examples: 28 | encled 4:0:1:0/12 - show status for enclosure 4:0:1:0 slot 12 29 | encled ALL off - disable all indication for all slots in all enclosures 30 | encled 5:0:24:0/24 fault - set fault indicator for enclosure 5:0:24:0 slot 24 31 | encled 5:0:24:0/12 locate - set location indicator for enclosure 5:0:24:0 slot 12 32 | encled sda locate - enable 'locate' for slot with sda block device 33 | encled /dev/sdbz fault - enable fault indicator slot with sdbz block device 34 | -------------------------------------------------------------------------------- /debian/changelog: -------------------------------------------------------------------------------- 1 | encled (0.1) unstable; urgency=low 2 | 3 | * Initial release 4 | 5 | -- George Shuklin Tue, 07 Jul 2015 18:38:19 +0300 6 | -------------------------------------------------------------------------------- /debian/compat: -------------------------------------------------------------------------------- 1 | 9 2 | -------------------------------------------------------------------------------- /debian/control: -------------------------------------------------------------------------------- 1 | Source: encled 2 | Section: admin 3 | Priority: optional 4 | Maintainer: George Shuklin 5 | Build-Depends: debhelper (>= 9) 6 | Standards-Version: 3.9.6 7 | Homepage: https://github.com/amarao/sdled 8 | Vcs-Git: https://github.com/amarao/sdled 9 | 10 | Package: encled 11 | Architecture: any 12 | Depends: python 13 | Description: utility to control enclosure LEDs 14 | Encled uses features of ses.ko module of kernel 15 | to query and control LED indicators of the enclosure 16 | slots on backplanes of many servers. 17 | It will works only with SAS/SCSI enclosures and will 18 | not work with builtin SATA-controllers. 19 | Encled was tested with many Supermicro servers and 20 | JBODs together with LSI (mpt2sas) HBAs, but it should 21 | works with other vendors too. 22 | -------------------------------------------------------------------------------- /debian/copyright: -------------------------------------------------------------------------------- 1 | Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ 2 | Upstream-Name: encled 3 | Source: https://github.com/amarao/sdled 4 | 5 | Files: * 6 | Copyright: 2012-2015 George Shuklin 7 | License: GPL-2 or any newer version of GPL 8 | 9 | Files: debian/* 10 | Copyright: 2015 George Shuklin 11 | License: GPL-2 or any newer version of GPL 12 | 13 | License: GPL-2 14 | GNU GENERAL PUBLIC LICENSE 15 | Version 2, June 1991 16 | 17 | Copyright (C) 1989, 1991 Free Software Foundation, Inc. 18 | 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | Everyone is permitted to copy and distribute verbatim copies 20 | of this license document, but changing it is not allowed. 21 | 22 | Preamble 23 | 24 | The licenses for most software are designed to take away your 25 | freedom to share and change it. By contrast, the GNU General Public 26 | License is intended to guarantee your freedom to share and change free 27 | software--to make sure the software is free for all its users. This 28 | General Public License applies to most of the Free Software 29 | Foundation's software and to any other program whose authors commit to 30 | using it. (Some other Free Software Foundation software is covered by 31 | the GNU Library General Public License instead.) You can apply it to 32 | your programs, too. 33 | 34 | When we speak of free software, we are referring to freedom, not 35 | price. Our General Public Licenses are designed to make sure that you 36 | have the freedom to distribute copies of free software (and charge for 37 | this service if you wish), that you receive source code or can get it 38 | if you want it, that you can change the software or use pieces of it 39 | in new free programs; and that you know you can do these things. 40 | 41 | To protect your rights, we need to make restrictions that forbid 42 | anyone to deny you these rights or to ask you to surrender the rights. 43 | These restrictions translate to certain responsibilities for you if you 44 | distribute copies of the software, or if you modify it. 45 | 46 | For example, if you distribute copies of such a program, whether 47 | gratis or for a fee, you must give the recipients all the rights that 48 | you have. You must make sure that they, too, receive or can get the 49 | source code. And you must show them these terms so they know their 50 | rights. 51 | 52 | We protect your rights with two steps: (1) copyright the software, and 53 | (2) offer you this license which gives you legal permission to copy, 54 | distribute and/or modify the software. 55 | 56 | Also, for each author's protection and ours, we want to make certain 57 | that everyone understands that there is no warranty for this free 58 | software. If the software is modified by someone else and passed on, we 59 | want its recipients to know that what they have is not the original, so 60 | that any problems introduced by others will not reflect on the original 61 | authors' reputations. 62 | 63 | Finally, any free program is threatened constantly by software 64 | patents. We wish to avoid the danger that redistributors of a free 65 | program will individually obtain patent licenses, in effect making the 66 | program proprietary. To prevent this, we have made it clear that any 67 | patent must be licensed for everyone's free use or not licensed at all. 68 | 69 | The precise terms and conditions for copying, distribution and 70 | modification follow. 71 | 72 | GNU GENERAL PUBLIC LICENSE 73 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 74 | 75 | 0. This License applies to any program or other work which contains 76 | a notice placed by the copyright holder saying it may be distributed 77 | under the terms of this General Public License. The "Program", below, 78 | refers to any such program or work, and a "work based on the Program" 79 | means either the Program or any derivative work under copyright law: 80 | that is to say, a work containing the Program or a portion of it, 81 | either verbatim or with modifications and/or translated into another 82 | language. (Hereinafter, translation is included without limitation in 83 | the term "modification".) Each licensee is addressed as "you". 84 | 85 | Activities other than copying, distribution and modification are not 86 | covered by this License; they are outside its scope. The act of 87 | running the Program is not restricted, and the output from the Program 88 | is covered only if its contents constitute a work based on the 89 | Program (independent of having been made by running the Program). 90 | Whether that is true depends on what the Program does. 91 | 92 | 1. You may copy and distribute verbatim copies of the Program's 93 | source code as you receive it, in any medium, provided that you 94 | conspicuously and appropriately publish on each copy an appropriate 95 | copyright notice and disclaimer of warranty; keep intact all the 96 | notices that refer to this License and to the absence of any warranty; 97 | and give any other recipients of the Program a copy of this License 98 | along with the Program. 99 | 100 | You may charge a fee for the physical act of transferring a copy, and 101 | you may at your option offer warranty protection in exchange for a fee. 102 | 103 | 2. You may modify your copy or copies of the Program or any portion 104 | of it, thus forming a work based on the Program, and copy and 105 | distribute such modifications or work under the terms of Section 1 106 | above, provided that you also meet all of these conditions: 107 | 108 | a) You must cause the modified files to carry prominent notices 109 | stating that you changed the files and the date of any change. 110 | 111 | b) You must cause any work that you distribute or publish, that in 112 | whole or in part contains or is derived from the Program or any 113 | part thereof, to be licensed as a whole at no charge to all third 114 | parties under the terms of this License. 115 | 116 | c) If the modified program normally reads commands interactively 117 | when run, you must cause it, when started running for such 118 | interactive use in the most ordinary way, to print or display an 119 | announcement including an appropriate copyright notice and a 120 | notice that there is no warranty (or else, saying that you provide 121 | a warranty) and that users may redistribute the program under 122 | these conditions, and telling the user how to view a copy of this 123 | License. (Exception: if the Program itself is interactive but 124 | does not normally print such an announcement, your work based on 125 | the Program is not required to print an announcement.) 126 | 127 | These requirements apply to the modified work as a whole. If 128 | identifiable sections of that work are not derived from the Program, 129 | and can be reasonably considered independent and separate works in 130 | themselves, then this License, and its terms, do not apply to those 131 | sections when you distribute them as separate works. But when you 132 | distribute the same sections as part of a whole which is a work based 133 | on the Program, the distribution of the whole must be on the terms of 134 | this License, whose permissions for other licensees extend to the 135 | entire whole, and thus to each and every part regardless of who wrote it. 136 | 137 | Thus, it is not the intent of this section to claim rights or contest 138 | your rights to work written entirely by you; rather, the intent is to 139 | exercise the right to control the distribution of derivative or 140 | collective works based on the Program. 141 | 142 | In addition, mere aggregation of another work not based on the Program 143 | with the Program (or with a work based on the Program) on a volume of 144 | a storage or distribution medium does not bring the other work under 145 | the scope of this License. 146 | 147 | 3. You may copy and distribute the Program (or a work based on it, 148 | under Section 2) in object code or executable form under the terms of 149 | Sections 1 and 2 above provided that you also do one of the following: 150 | 151 | a) Accompany it with the complete corresponding machine-readable 152 | source code, which must be distributed under the terms of Sections 153 | 1 and 2 above on a medium customarily used for software interchange; or, 154 | 155 | b) Accompany it with a written offer, valid for at least three 156 | years, to give any third party, for a charge no more than your 157 | cost of physically performing source distribution, a complete 158 | machine-readable copy of the corresponding source code, to be 159 | distributed under the terms of Sections 1 and 2 above on a medium 160 | customarily used for software interchange; or, 161 | 162 | c) Accompany it with the information you received as to the offer 163 | to distribute corresponding source code. (This alternative is 164 | allowed only for noncommercial distribution and only if you 165 | received the program in object code or executable form with such 166 | an offer, in accord with Subsection b above.) 167 | 168 | The source code for a work means the preferred form of the work for 169 | making modifications to it. For an executable work, complete source 170 | code means all the source code for all modules it contains, plus any 171 | associated interface definition files, plus the scripts used to 172 | control compilation and installation of the executable. However, as a 173 | special exception, the source code distributed need not include 174 | anything that is normally distributed (in either source or binary 175 | form) with the major components (compiler, kernel, and so on) of the 176 | operating system on which the executable runs, unless that component 177 | itself accompanies the executable. 178 | 179 | If distribution of executable or object code is made by offering 180 | access to copy from a designated place, then offering equivalent 181 | access to copy the source code from the same place counts as 182 | distribution of the source code, even though third parties are not 183 | compelled to copy the source along with the object code. 184 | 185 | 4. You may not copy, modify, sublicense, or distribute the Program 186 | except as expressly provided under this License. Any attempt 187 | otherwise to copy, modify, sublicense or distribute the Program is 188 | void, and will automatically terminate your rights under this License. 189 | However, parties who have received copies, or rights, from you under 190 | this License will not have their licenses terminated so long as such 191 | parties remain in full compliance. 192 | 193 | 5. You are not required to accept this License, since you have not 194 | signed it. However, nothing else grants you permission to modify or 195 | distribute the Program or its derivative works. These actions are 196 | prohibited by law if you do not accept this License. Therefore, by 197 | modifying or distributing the Program (or any work based on the 198 | Program), you indicate your acceptance of this License to do so, and 199 | all its terms and conditions for copying, distributing or modifying 200 | the Program or works based on it. 201 | 202 | 6. Each time you redistribute the Program (or any work based on the 203 | Program), the recipient automatically receives a license from the 204 | original licensor to copy, distribute or modify the Program subject to 205 | these terms and conditions. You may not impose any further 206 | restrictions on the recipients' exercise of the rights granted herein. 207 | You are not responsible for enforcing compliance by third parties to 208 | this License. 209 | 210 | 7. If, as a consequence of a court judgment or allegation of patent 211 | infringement or for any other reason (not limited to patent issues), 212 | conditions are imposed on you (whether by court order, agreement or 213 | otherwise) that contradict the conditions of this License, they do not 214 | excuse you from the conditions of this License. If you cannot 215 | distribute so as to satisfy simultaneously your obligations under this 216 | License and any other pertinent obligations, then as a consequence you 217 | may not distribute the Program at all. For example, if a patent 218 | license would not permit royalty-free redistribution of the Program by 219 | all those who receive copies directly or indirectly through you, then 220 | the only way you could satisfy both it and this License would be to 221 | refrain entirely from distribution of the Program. 222 | 223 | If any portion of this section is held invalid or unenforceable under 224 | any particular circumstance, the balance of the section is intended to 225 | apply and the section as a whole is intended to apply in other 226 | circumstances. 227 | 228 | It is not the purpose of this section to induce you to infringe any 229 | patents or other property right claims or to contest validity of any 230 | such claims; this section has the sole purpose of protecting the 231 | integrity of the free software distribution system, which is 232 | implemented by public license practices. Many people have made 233 | generous contributions to the wide range of software distributed 234 | through that system in reliance on consistent application of that 235 | system; it is up to the author/donor to decide if he or she is willing 236 | to distribute software through any other system and a licensee cannot 237 | impose that choice. 238 | 239 | This section is intended to make thoroughly clear what is believed to 240 | be a consequence of the rest of this License. 241 | 242 | 8. If the distribution and/or use of the Program is restricted in 243 | certain countries either by patents or by copyrighted interfaces, the 244 | original copyright holder who places the Program under this License 245 | may add an explicit geographical distribution limitation excluding 246 | those countries, so that distribution is permitted only in or among 247 | countries not thus excluded. In such case, this License incorporates 248 | the limitation as if written in the body of this License. 249 | 250 | 9. The Free Software Foundation may publish revised and/or new versions 251 | of the General Public License from time to time. Such new versions will 252 | be similar in spirit to the present version, but may differ in detail to 253 | address new problems or concerns. 254 | 255 | Each version is given a distinguishing version number. If the Program 256 | specifies a version number of this License which applies to it and "any 257 | later version", you have the option of following the terms and conditions 258 | either of that version or of any later version published by the Free 259 | Software Foundation. If the Program does not specify a version number of 260 | this License, you may choose any version ever published by the Free Software 261 | Foundation. 262 | 263 | 10. If you wish to incorporate parts of the Program into other free 264 | programs whose distribution conditions are different, write to the author 265 | to ask for permission. For software which is copyrighted by the Free 266 | Software Foundation, write to the Free Software Foundation; we sometimes 267 | make exceptions for this. Our decision will be guided by the two goals 268 | of preserving the free status of all derivatives of our free software and 269 | of promoting the sharing and reuse of software generally. 270 | 271 | NO WARRANTY 272 | 273 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 274 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 275 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 276 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 277 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 278 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 279 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 280 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 281 | REPAIR OR CORRECTION. 282 | 283 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 284 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 285 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 286 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 287 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 288 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 289 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 290 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 291 | POSSIBILITY OF SUCH DAMAGES. 292 | 293 | END OF TERMS AND CONDITIONS 294 | 295 | How to Apply These Terms to Your New Programs 296 | 297 | If you develop a new program, and you want it to be of the greatest 298 | possible use to the public, the best way to achieve this is to make it 299 | free software which everyone can redistribute and change under these terms. 300 | 301 | To do so, attach the following notices to the program. It is safest 302 | to attach them to the start of each source file to most effectively 303 | convey the exclusion of warranty; and each file should have at least 304 | the "copyright" line and a pointer to where the full notice is found. 305 | 306 | 307 | Copyright (C) 308 | 309 | This program is free software; you can redistribute it and/or modify 310 | it under the terms of the GNU General Public License as published by 311 | the Free Software Foundation; either version 2 of the License, or 312 | (at your option) any later version. 313 | 314 | This program is distributed in the hope that it will be useful, 315 | but WITHOUT ANY WARRANTY; without even the implied warranty of 316 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 317 | GNU General Public License for more details. 318 | 319 | You should have received a copy of the GNU General Public License 320 | along with this program; if not, write to the Free Software 321 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 322 | 323 | 324 | Also add information on how to contact you by electronic and paper mail. 325 | 326 | If the program is interactive, make it output a short notice like this 327 | when it starts in an interactive mode: 328 | 329 | Gnomovision version 69, Copyright (C) year name of author 330 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 331 | This is free software, and you are welcome to redistribute it 332 | under certain conditions; type `show c' for details. 333 | 334 | The hypothetical commands `show w' and `show c' should show the appropriate 335 | parts of the General Public License. Of course, the commands you use may 336 | be called something other than `show w' and `show c'; they could even be 337 | mouse-clicks or menu items--whatever suits your program. 338 | 339 | You should also get your employer (if you work as a programmer) or your 340 | school, if any, to sign a "copyright disclaimer" for the program, if 341 | necessary. Here is a sample; alter the names: 342 | 343 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 344 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 345 | 346 | , 1 April 1989 347 | Ty Coon, President of Vice 348 | 349 | This General Public License does not permit incorporating your program into 350 | proprietary programs. If your program is a subroutine library, you may 351 | consider it more useful to permit linking proprietary applications with the 352 | library. If this is what you want to do, use the GNU Library General 353 | Public License instead of this License. 354 | -------------------------------------------------------------------------------- /debian/docs: -------------------------------------------------------------------------------- 1 | README 2 | -------------------------------------------------------------------------------- /debian/encled.install: -------------------------------------------------------------------------------- 1 | encled /usr/bin/ 2 | -------------------------------------------------------------------------------- /debian/encled.manpages: -------------------------------------------------------------------------------- 1 | encled.8 2 | -------------------------------------------------------------------------------- /debian/rules: -------------------------------------------------------------------------------- 1 | #!/usr/bin/make -f 2 | DPKG_EXPORT_BUILDFLAGS = 1 3 | include /usr/share/dpkg/default.mk 4 | %: 5 | dh $@ 6 | -------------------------------------------------------------------------------- /debian/source/format: -------------------------------------------------------------------------------- 1 | 3.0 (native) 2 | -------------------------------------------------------------------------------- /encled: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | import os 3 | import sys 4 | 5 | HELP = """ 6 | 7 | encled - utility to change fault/location led for supermicro/LSI backplanes 8 | 9 | Usage: 10 | 11 | encled (without options) - display all slots devices status and disk letter 12 | encled enclosure/slot - display status of requested device 13 | encled enclosure/slot fault - set led indicator to 'faulty' 14 | this WILL NOT make device faulty, just set 15 | enclosure led to 'FAULTY' status. 16 | encled enclosure/slot locate - set led indicator to 'locate' status 17 | encled enclosure/slot off - turn off faulty/locate status 18 | encled enclosure/slot fault_off - turn off fault status 19 | encled enclosure/slot locate_off - turn off locate status 20 | 21 | encled device locate/fault/off will work with sd device (sda, sde) 22 | 23 | encled ALL off 24 | encled GOOD off - turns off leds only on devices where fault led is off 25 | encled ALL fault 26 | encled ALL locate - turn all devices to that status (note CAPS ALL) 27 | 28 | examples: 29 | encled 4:0:1:0/12 - show status for enclosure 4:0:1:0 slot 12 30 | encled ALL off - disable all indication for all slots in all enclosures 31 | encled 5:0:24:0/24 fault - set fault indicator for enclosure 5:0:24:0 slot 24 32 | encled 5:0:24:0/12 locate - set location indicator for enclosure 5:0:24:0 slot 12 33 | encled sda locate - enable 'locate' for slot with sda block device 34 | encled /dev/sdbz fault - enable fault indicator slot with sdbz block device 35 | 36 | """ 37 | 38 | CLASS = '/sys/class/enclosure/' 39 | SLOT = 'Slot ' # with space 40 | 41 | 42 | def enc_list(): 43 | ''' 44 | return list of all enclosure in system 45 | ''' 46 | return os.listdir(CLASS) 47 | 48 | 49 | def slot_list(enc): 50 | ''' 51 | return list of all slots for given enclosure 52 | list will contain numbers, not strings 53 | ''' 54 | slot_list = [] 55 | for elem in os.listdir(os.path.join(CLASS, enc)): 56 | slot = os.path.join(CLASS, enc, elem) 57 | if os.path.isdir(slot) and not os.path.islink(slot) and os.path.isfile(os.path.join(slot, 'type')): 58 | slot_list.append(elem) 59 | else: 60 | try: 61 | slot_list.append(int(elem)) # naming type '001', only numbers pass 62 | except ValueError: 63 | pass 64 | return slot_list 65 | 66 | 67 | def find_name(enc, slot): 68 | ''' 69 | Attempt to denormalize given slot number 70 | for enclosure enc 71 | 1-> 01 or 1->001, 1->0001 or 1->00001 72 | first mach wins 73 | return full path to slot (with CLASS) 74 | or None 75 | ''' 76 | name = str(slot) 77 | if os.path.isfile(os.path.join(CLASS, enc, name, 'type')): 78 | return os.path.join(CLASS, enc, name) 79 | for z in range(0, 4): 80 | if os.path.isfile(os.path.join(CLASS, enc, SLOT + name, 'type')): # naming type 'Slot 01' 81 | return os.path.join(CLASS, enc, SLOT + name) 82 | if os.path.isfile(os.path.join(CLASS, enc, name, 'type')): # naming type '001' 83 | return os.path.join(CLASS, enc, name) 84 | name = '0' + name # try same name with more zeroes at front 85 | return None 86 | 87 | 88 | def get_status(path): 89 | ''' 90 | return status and block device name of given path 91 | return touple: 92 | (block device, fault, locate) or None if no slot found. 93 | block device may be None (no block device) (or 'sd..') 94 | fault may be None (no fault available) or 'FAULT_ON ', or 'fault_off' 95 | locate may be None or 'LOCATE_ON ' or 'locate_off' 96 | ''' 97 | try: 98 | if not os.path.isfile(os.path.join(path, 'type')): 99 | return None 100 | except: 101 | return None 102 | try: 103 | block = os.listdir(os.path.join(path, 'device', 'block'))[0] 104 | except OSError: 105 | block = '----' 106 | try: 107 | if int(open(os.path.join(path, 'fault'), 'r').readline().strip()): 108 | fault = ' FAULT_ON' 109 | else: 110 | fault = 'fault_off' 111 | except OSError: 112 | fault = 'fault_N/A' 113 | try: 114 | if int(open(os.path.join(path, 'locate'), 'r').readline().strip()): 115 | locate = ' LOCATE_ON' 116 | else: 117 | locate = 'locate_off' 118 | except: 119 | locate = 'locate_N/A' 120 | return (block, fault, locate) 121 | 122 | 123 | def set_status(path, status): 124 | ''' 125 | Set status for given path 126 | status is 'fault' or 'locate' or 'off' 127 | ''' 128 | if status == 'fault': 129 | open(os.path.join(path, 'fault'), 'w').write('1') 130 | elif status == 'locate' or status == 'loc': 131 | open(os.path.join(path, 'locate'), 'w').write('1') 132 | elif status == 'off': 133 | open(os.path.join(path, 'fault'), 'w').write('0') 134 | open(os.path.join(path, 'locate'), 'w').write('0') 135 | elif status == 'fault_off': 136 | open(os.path.join(path, 'fault'), 'w').write('0') 137 | elif status == 'locate_off': 138 | open(os.path.join(path, 'locate'), 'w').write('0') 139 | else: 140 | print(f"encled: Wrong status {status}") 141 | return -1 142 | 143 | 144 | def print_status(enc, slot, status): 145 | out = str(enc)+'/' + str(slot)+'\t' 146 | if status: 147 | out = out + str(status[0]) + '\t' + str(status[1]) + '\t' + str(status[2]) 148 | else: 149 | out = out + '(Not available)' 150 | out = out 151 | print(out) 152 | 153 | 154 | def list_all(): 155 | devlist = [] 156 | for e in enc_list(): 157 | for s in slot_list(e): 158 | path = find_name(e, s) 159 | status = get_status(path) 160 | devlist.append((e, s, path, status)) 161 | return devlist 162 | 163 | 164 | def main(argv): 165 | if len(argv) > 1 and argv[1] in ('--help', '-h', '-help', '/?', '?', 'help', '-v', '--version', '-V'): 166 | print (HELP) 167 | return(0) 168 | 169 | if not os.path.isdir(CLASS): 170 | print("encled: Unable to find any enclosure device") 171 | return(-1) 172 | 173 | devlist = list_all() 174 | if len(argv) < 2: 175 | if not devlist: 176 | print ("No enclosure devices found") 177 | return(-1) 178 | print ("ENCLOSURE/SLOT\tDEV\tFAULT_LED\tLOCATION_LED") 179 | print ("-"*52) 180 | for d in devlist: 181 | print_status(d[0], d[1], d[3]) 182 | return(0) 183 | 184 | if argv[1].upper() == 'GOOD' and argv[2].lower() == 'off': 185 | for d in devlist: 186 | if ((d[3][1]).upper()).replace(" ", "") != 'FAULT_ON': 187 | result = set_status(d[2], argv[2].lower()) 188 | if result: return(result) 189 | elif ((d[3][1]).upper()).replace(" ", "") == 'FAULT_ON' and argv[2].upper().replace(" ", "") == 'LOCATE': 190 | result = set_status(d[2], argv[2].lower()) 191 | if result: return(result) 192 | return(0) 193 | 194 | if argv[1].upper() == 'ALL': 195 | for d in devlist: 196 | result = set_status(d[2], argv[2].lower()) 197 | if result: return(result) 198 | return(0) 199 | 200 | if 'sd' in argv[1] or '/dev' in argv[1]: 201 | name = argv[1].lower().split('/')[-1] 202 | for d in devlist: 203 | if(d[3][0] == name): 204 | dev = d 205 | break 206 | else: 207 | print(f"encled: Unable to find device {name} in enclosure slots. (note: on-board SATA ports are not supported)") 208 | return(-1) 209 | 210 | elif '/' in argv[1]: 211 | (enc, slot) = argv[1].split('/') 212 | path = find_name(enc, slot) 213 | dev = (enc, slot, path, get_status(path)) 214 | else: 215 | print ("encled: Incorrect enclosure/slot or device syntax") 216 | print (HELP) 217 | return(-1) 218 | 219 | if len(argv) < 3: 220 | print_status(dev[0], dev[1], dev[3]) 221 | else: 222 | set_status(dev[2], argv[2]) 223 | 224 | 225 | if __name__ == '__main__': 226 | sys.exit(main(sys.argv)) 227 | -------------------------------------------------------------------------------- /encled.8: -------------------------------------------------------------------------------- 1 | .TH encled "8" "Jun 2015" "encled\-0.1" ENCLED 2 | .SH NAME 3 | encled \- SCSI Enclosure indicators (SES LED) control 4 | .SH SYNOPSIS 5 | .B encled 6 | [\fI\-\-help\fR] [\fIenclosure/slot|disk name|ALL\fR] [\fIlocate|fault|off\fR] 7 | .SH DESCRIPTION 8 | .\" Add any additional description here 9 | Encled uses information in sysfs from ses.ko module to enumerate and control 10 | enclosure indication for disks. 11 | .br 12 | SES is SCSI Enclosure Services, specialized protocol between enclosure 13 | (backplane) and HBA (controller). It allows to enable/disable indication 14 | on hot-swap slots for disks. 15 | .SH INDICATION TYPES 16 | There is two types of indication: fault and locate. Third indication (activity) 17 | unavailable for control from host. If one indicator is enabled, other is 18 | automatically disabled. Keywords used: 'fault', 'locate' and 'off'. 19 | .SH ENUMERATION 20 | Enclosure enumeration is based on /sys/class/enclosure, and slot number is 21 | reconstructed from 'Slot' name of enclosure. 22 | Usually it looks like this: 6:0:23:0/14, where: 23 | 6:0:23:0 is enclosure address, and '/14' is 14th slot. 24 | Note: Enumeration in encled may differ from sas2ircu or labels on the actual 25 | backplane. Don't rely on the slot numbers! 26 | .PP 27 | .SH DISK NAME 28 | There is two ways to indicate disk in encled: by using drive name (/dev/sdaz) 29 | or by using slot number (6:0:24:0/20). Special word 'all' is reserved for 30 | controlling all indications (command 'encled all off' clears all indications). 31 | .SH EXAMPLES 32 | \fIencled /dev/sda fault\fR - enable fault indication for /dev/sda 33 | .br 34 | \fIencled /dev/sdfa locate\fR - enable locate indication for /dev/sdfa 35 | .br 36 | \fIencled /dev/sdz off\fR - clear indication for /dev/sdz 37 | .br 38 | \fIencled /dev/sdg\fR - view status of indication for /dev/sdg 39 | .br 40 | \fIencled 3:0:23:0/1 fault\fR - enable fault indication for the Slot 1 in enclosure 3:0:23:0 41 | .br 42 | \fIencled 3:0:23:0/2 locate\fR - enable locate indication for the Slot 2 in enclosure 3:0:23:0 43 | .br 44 | \fIencled 3:0:23:0/3 off\fR - clear indication for the Slot 3 in enclosure 3:0:23:0 45 | .br 46 | \fIencled 3:0:23:0/4\fR - view status of indication for the Slot 4 in enclosure 3:0:23:0 47 | .br 48 | \fIencled all fault\fR - enable fault indication for all slots in all enclosures 49 | .br 50 | \fIencled\fR - view status of all slots in all enclosures. 51 | .br 52 | .br 53 | Example of the output: 54 | .br 55 | ENCLOSURE/SLOT DEV FAULT_LED LOCATION_LED 56 | .br 57 | ---------------------------------------------------- 58 | .br 59 | 6:0:23:0/1 sdd fault_off locate_off 60 | .br 61 | 6:0:23:0/2 sde fault_off locate_off 62 | .br 63 | 6:0:23:0/3 sdf fault_off LOCATE_ON 64 | .br 65 | 6:0:23:0/4 sdg FAULT_ON locate_off 66 | .SH NOTES 67 | Encled supports only enclosure based devices (SAS/SATA). Desktop SATA controllers 68 | (AHCI), and direct-attach disks in SCSI are not supported. 69 | .br 70 | Older name for encled was sdled. 71 | .SH AUTHOR 72 | Written by George Shuklin 73 | .SH "REPORTING BUGS" 74 | Report bugs to https://github.com/amarao/sdled 75 | .SH COPYRIGHT 76 | Copyright \(co 2012\-2015 George Shuklin 77 | .br 78 | This software is distributed under the GPL version 2 or 3. There is NO 79 | warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 80 | -------------------------------------------------------------------------------- /sdled: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | import os,sys 3 | 4 | help=""" 5 | Usage: 6 | sdled (without options) - display all sd* devices status 7 | sdled /dev/sd[letter] - display status of requested device 8 | sdled /dev/sd[letter] faul - set led indicator to 'faulty' 9 | this WILL NOT make device faulty, just set 10 | enclosure led to 'FAULTY' status. 11 | sdled /dev/sd[letter] locate - set led indicator to 'locate' status 12 | sdled /dev/sd[letter] off - turn off faulty/locate status 13 | 14 | sdled ALL off 15 | sdled ALL fault 16 | sdled ALL locate - turn all devices to that status (note CAPS ALL) 17 | 18 | sample usage : sdled /dev/sde (show status) 19 | sdled /dev/sde locate (turn on 'locate' indicator) 20 | """ 21 | 22 | def sd_list(): 23 | """ 24 | return list of all sd devices in /sys/block 25 | """ 26 | return [x for x in os.listdir("/sys/block") if "sd" in x] 27 | 28 | def go_to_enc(dev): 29 | enc="enclosure_device" #magik string to access enclosure data 30 | try: 31 | os.chdir("/sys/block/"+dev+"/device") 32 | l=[x for x in os.listdir(".") if enc in x] 33 | os.chdir(l[0]) 34 | return True 35 | except: 36 | return False 37 | 38 | 39 | def get_status(dev): 40 | """ 41 | return status ("N/A", "Off", "Faul", "Locate") for given device 42 | """ 43 | if not go_to_enc(dev): 44 | return "N/A" #No magic path, can't get status 45 | try: 46 | fault=int(open("fault",'r').readline()) 47 | locate=int(open("locate",'r').readline()) 48 | if(fault): 49 | return "fault" 50 | if(locate): 51 | return "locate" 52 | return "off" 53 | except: 54 | return "N/A" #any error means we can't get status 55 | 56 | def set_status(device, status): 57 | if not go_to_enc(device): 58 | print(f"Device {device} not supported") 59 | return False 60 | if status == "off": 61 | open("locate","w").write('0') 62 | return True 63 | if not status in ("fault", "locate"): 64 | print("bad status. Use: off, fault, locate") 65 | return False 66 | open(status, "w").write('1') 67 | return True #no try/exect - if something wrong, do not hide it 68 | 69 | sys.stderr.write("sdled is deprecated. Use encled\n") 70 | 71 | if len(sys.argv)<2: 72 | print("DEVICE NAME STATUS") 73 | for d in sd_list(): 74 | print("/dev/"+d.ljust(17) + get_status(d)) 75 | sys.exit(0) 76 | if len(sys.argv)==3: 77 | if sys.argv[1]=="--help" or sys.argv[1]=="-h": 78 | print(help) 79 | sys.exit(0) 80 | 81 | if sys.argv[1]=="ALL": 82 | for d in sd_list(): 83 | try: 84 | set_status(d,sys.argv[2]) 85 | except: 86 | pass 87 | sys.exit(0) 88 | 89 | if ("/" in sys.argv[1]): 90 | device = sys.argv[1].split('/')[-1] 91 | else: 92 | device = sys.argv[1] 93 | 94 | if len(sys.argv)==2: 95 | print(get_status(device)) 96 | sys.exit(-1) 97 | 98 | set_status(device,sys.argv[2]) 99 | --------------------------------------------------------------------------------