root / plugins / disk / megaraid-hdd-temperature-using-megacli @ 17f78427
Historique | Voir | Annoter | Télécharger (1,9 ko)
| 1 | d37f5311 | pro cabales | #!/bin/bash |
|---|---|---|---|
| 2 | |||
| 3 | # Plugin to monitor harddrive temperatures connected to a MegaRAID controller |
||
| 4 | 17f78427 | Lars Kruse | # |
| 5 | # Plugin must be ran as root so add these configuration in |
||
| 6 | d37f5311 | pro cabales | # /etc/munin/plugin-conf.d/munin-node. |
| 7 | # |
||
| 8 | # [megacli*] |
||
| 9 | # user root |
||
| 10 | # |
||
| 11 | # ----------- |
||
| 12 | # 2011-06-10 ver 1.0 |
||
| 13 | # - initial version |
||
| 14 | |||
| 15 | |||
| 16 | # TODO |
||
| 17 | # - allow override of tool path via config |
||
| 18 | |||
| 19 | # 32-bit or 64-bit |
||
| 20 | if [[ $( uname -a | grep x86_64 ) ]] |
||
| 21 | then |
||
| 22 | MEGACLI='/opt/MegaRAID/MegaCli/MegaCli64' |
||
| 23 | else |
||
| 24 | MEGACLI='/opt/MegaRAID/MegaCli/MegaCli' |
||
| 25 | fi |
||
| 26 | |||
| 27 | if [[ ! -x $MEGACLI ]] |
||
| 28 | then |
||
| 29 | echo "FATAL ERROR: $MEGACLI not found or not executable!" |
||
| 30 | exit 1 |
||
| 31 | fi |
||
| 32 | |||
| 33 | declare -a output |
||
| 34 | |||
| 35 | IFS=$'\n' |
||
| 36 | output=($($MEGACLI -PDList -aALL -NoLog | grep -E 'Inquiry Data:|Drive Temperature' | cut -f2 -d:)) |
||
| 37 | unset IFS |
||
| 38 | |||
| 39 | # TODO |
||
| 40 | # - if array size is odd, there's a problem, exit? |
||
| 41 | output_size=${#output[*]}
|
||
| 42 | |||
| 43 | if [ "$1" = "config" ] |
||
| 44 | then |
||
| 45 | |||
| 46 | echo 'graph_title MegaCli HDD temperature' |
||
| 47 | echo 'graph_args --base 1000 -l 0' |
||
| 48 | echo 'graph_vlabel temp in °C' |
||
| 49 | echo 'graph_category sensors' |
||
| 50 | |||
| 51 | i=0 |
||
| 52 | while [[ $i -lt $output_size ]] |
||
| 53 | do |
||
| 54 | if [ $((i % 2)) -eq 0 ] |
||
| 55 | then |
||
| 56 | |||
| 57 | label=$( echo ${output[$i]} | perl -ne \
|
||
| 58 | 's/^\s*|\s*$//; print;' ) |
||
| 59 | |||
| 60 | # TODO: |
||
| 61 | # - add other brands?? |
||
| 62 | |||
| 63 | # remove brand name, just model and serial number |
||
| 64 | label_graph=$( echo ${output[$i]} | perl -ne \
|
||
| 65 | 's/SEAGATE|MAXTOR|WDC//i; s/^\s*|\s*$//; print;' ) |
||
| 66 | |||
| 67 | echo $(echo $label | tr ' ' _).label $label_graph |
||
| 68 | fi |
||
| 69 | |||
| 70 | (( i++ )) |
||
| 71 | done |
||
| 72 | |||
| 73 | exit 0 |
||
| 74 | fi |
||
| 75 | |||
| 76 | # print label and corresponding value |
||
| 77 | # - even -> label |
||
| 78 | # - odd -> value |
||
| 79 | i=0 |
||
| 80 | while [[ $i -lt $output_size ]] |
||
| 81 | do |
||
| 82 | if [ $((i % 2)) -eq 0 ] |
||
| 83 | then |
||
| 84 | label=$( echo ${output[$i]} | perl -ne 's/^\s*|\s*$//; print;' )
|
||
| 85 | echo -n $(echo $label | tr ' ' _).value |
||
| 86 | else |
||
| 87 | value=$( echo ${output[$i]} | cut -f1 -dC )
|
||
| 88 | echo " $value" |
||
| 89 | fi |
||
| 90 | |||
| 91 | (( i++ )) |
||
| 92 | done |
