1. Perl / Говнокод #22316

    −98

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    #!/usr/bin/perl
    #
    # Plugin to monitor thermal sensors inside ThinkPad
    #
    # Origional Author: Kamen Naydenov @pau4o
    # Contributors:
    #
    #
    
    use warnings;
    use strict;
    
    if ($ARGV[0] and $ARGV[0] eq "autoconf")
      {
        if (-r "/proc/acpi/ibm/thermal")
          {
    	print "yes\n";
    	exit 0;
          }
        else
          {
    	print "/proc/acpi/ibm/thermal not found\n You must load ibm_acpi kernel module\n";
    	exit 1;
          }
      }
    
    my ($i, $val, @sensors, @values);
    
    @sensors=qw/CPU MiniPCI HDD GPU Bat0 Na0 Bat1 Na1/;
    $val=qx|cat /proc/acpi/ibm/thermal|;
    
    if ($ARGV[0] and $ARGV[0] eq "config")
      {
        print "graph_args --base 1000 -l 0 --vertical-label Temp\n";
        print "graph_title Some temperatures in ThinkPad\n";
        print "graph_category sensors\n";
        print "graph_info There is some themperatures detected by ibm_acpi kernel module. The location of sensors may vary on other models (these are for R51)\n";
        print "graph_order @sensors\n";
        print "graph_scale off\n";
        for (@sensors) {
          print "$_.label $_\n";
          print "$_.info Temperature near $_\n";
          print "$_.max 100\n";
        }
        exit 0;
      }
    
    @values=split(/:|\s+/,$val);
    shift @values;
    shift @values;
    
    for ($i=0; $i <= 7; $i++) {
      if ($values[$i]=~/^-(\d*)$/) {
        print "$sensors[$i].value $1\n";
      } else {
        print "$sensors[$i].value $values[$i]\n";
      }
    }

    Запостил: munin, 12 Февраля 2017

    Комментарии (0) RSS

    Добавить комментарий

    Ошибка компиляции комментария:
    1. Гости могут высказаться только в понедельник, среду, четверг или воскресение
    ava Семь раз отмерь — один отрежь, guest!
    А не использовать ли нам bbcode?
    • [b]жирный[/b] — жирный
    • [i]курсив[/i] — курсив
    • [u]подчеркнутый[/u] — подчеркнутый
    • [s]перечеркнутый[/s] — перечеркнутый
    • [blink]мигающий[/blink] — мигающий
    • [color=red]цвет[/color] — цвет (подробнее)
    • [size=20]размер[/size] — размер (подробнее)
    • [code=<language>]some code[/code] (подробнее)
    Проверочный код