1. bash / Говнокод #22372

    −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
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    #!/bin/sh
    # 
    # Plugin to monitor the queues of a virtual_host in RabbitMQ
    #
    # Usage: Link or copy into /etc/munin/node.d/
    #
    # Parameters
    #     env.vhost <AMQ virtual host>
    #     env.queue_warn <warning queuesize>
    #     env.queue_crit <critical queuesize>
    #
    # Magic markers (optional - only used by munin-config and some
    # installation scripts):
    #
    #%# family=auto
    #%# capabilities=autoconf
    
    # If run with the "autoconf"-parameter, give our opinion on wether we
    # should be run on this system or not. This is optinal, and only used by
    # munin-config. In the case of this plugin, we should most probably
    # always be included.
    
    if [ "$1" = "autoconf" ]; then
    	echo yes
    	exit 0
    fi
    
    # If run with the "config"-parameter, give out information on how the
    # graphs should look. 
    
    HOME=/tmp/
    VHOST=${vhost:-"/"}
    QUEUES=$(HOME=$HOME rabbitmqctl list_queues -p $VHOST name | \
    		grep -v '^Listing' | \
    		grep -v 'done\.$' | sed -e 's/[.=-]/_/g' )
     
    if [ "$1" = "config" ]; then
            QUEUE_WARN=${queue_warn:-100}
            QUEUE_CRIT=${queue_crit:-500}
    
    	# The host name this plugin is for. (Can be overridden to have
    	# one machine answer for several)
    
    	# The title of the graph
    	echo "graph_title RabbitMQ $VHOST consumers"
    	# Arguments to "rrdtool graph". In this case, tell it that the
    	# lower limit of the graph is '0', and that 1k=1000 (not 1024)
    	echo 'graph_args --base 1000 -l 0'
    	# The Y-axis label
    	echo 'graph_vlabel consumers'
    	# We want Cur/Min/Avg/Max unscaled (i.e. 0.42 load instead of
    	# 420 milliload)
    	#echo 'graph_scale no'
    	echo 'graph_category RabbitMQ'
    
    	for queue in $QUEUES; do
    		echo "$queue.label $queue"
    		echo "$queue.warning $QUEUE_WARN"
    		echo "$queue.critical $QUEUE_CRIT"
    		echo "$queue.info Active consumers for $queue"
    	done
    
    	echo 'graph_info Lists active consumers for a queue.'
    	# Last, if run with the "config"-parameter, quit here (don't
    	# display any data)
    	exit 0
    fi
    
    # If not run with any parameters at all (or only unknown ones), do the
    # real work - i.e. display the data. Almost always this will be
    # "value" subfield for every data field.
    
    HOME=$HOME rabbitmqctl list_queues -p $VHOST name consumers| grep -v "^Listing" | grep -v "done.$" | grep -v "\.\.\." | sed "s/[\t]/.value /g"

    Запостил: munin, 19 Февраля 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] (подробнее)
    Проверочный код