1. Список говнокодов пользователя munin

    Всего: 55

  2. bash / Говнокод #22373

    −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:-10000}
            QUEUE_CRIT=${queue_crit:-20000}
    
    	# 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 list_queues"
    	# 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 queue_size'
    	# 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 Queue size for $queue"
    	done
    
    	echo 'graph_info Lists how many messages are in each 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 | grep -v "^Listing" | grep -v "done.$" | grep -v "\.\.\." | sed "s/[\t]/.value /g"

    munin, 19 Февраля 2017

    Комментарии (0)
  3. 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)
  4. bash / Говнокод #22371

    −97

    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
    #!/bin/sh
    # 
    # Plugin to monitor the number of connections to RabbitMQ
    #
    # Usage: Link or copy into /etc/munin/node.d/
    #
    # Parameters
    #     env.conn_warn <warning connections>
    #     env.conn_crit <critical connections>
    #
    if [ "$1" = "autoconf" ]; then
    	echo yes
    	exit 0
    fi
    
    HOME=/tmp/
    
    # If run with the "config"-parameter, give out information on how the
    # graphs should look. 
    
    if [ "$1" = "config" ]; then
            CONN_WARN=${queue_warn:-500}
            CONN_CRIT=${queue_crit:-1000}
    
    	# 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 connections'
    	# 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 connections'
    	# We want Cur/Min/Avg/Max unscaled (i.e. 0.42 load instead of
    	# 420 milliload)
    	#echo 'graph_scale no'
    	echo 'graph_category RabbitMQ'
    
    	echo "connections.label Connections"
    	echo "connections.warning $CONN_WARN"
    	echo "connections.critical $CONN_CRIT"
    	echo "connections.info Number of active connections"
    
    	echo 'graph_info Shows the number of connections to RabbitMQ'
    	# 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.
    
    echo "connections.value $(HOME=$HOME rabbitmqctl list_connections | grep -v "^Listing" | grep -v "done.$" | wc -l)"

    munin, 19 Февраля 2017

    Комментарии (0)
  5. Perl / Говнокод #22370

    −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
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    #!/usr/bin/perl
    # -*- perl -*-
    
    my $ret = undef;
    
    if (! eval "require LWP::UserAgent;")
    {
    	$ret = "LWP::UserAgent not found";
    }
    
    my $URL = exists $ENV{'url'} ? $ENV{'url'} : "http://127.0.0.1:%d/status";
    my @PORTS = exists $ENV{'ports'} ? split(' ', $ENV{'ports'}) : (80);
    
    if ( defined $ARGV[0] and $ARGV[0] eq "autoconf" )
    {
    	if ($ret)
    	{
    		print "no ($ret)\n";
    		exit 1;
    	}
    
    	my $ua = LWP::UserAgent->new(timeout => 30);
    
    	my @badports;
    	foreach my $port (@PORTS) {
    		my $url = sprintf $URL, $port;
    		my $response = $ua->request(HTTP::Request->new('GET',$url));
    		push @badports, $port unless $response->is_success and $response->content =~ /^accepted conn:/im;
    	}
    	if (@badports) {
    		print "no (phpfpm-status)\n";
    		exit 1;
    	} else {
    		print "yes\n";
    		exit 0;
    	}
    }
    
    if ( defined $ARGV[0] and $ARGV[0] eq "config" )
    {
    	print('graph_title PHP-FPM Status
    graph_args --base 1024 -l 0
    graph_vlabel Connections
    graph_category PHP
    graph_order active idle total
    graph_info Plugin created by TJ Stein
    active.label Active
    active.draw AREA
    idle.label Idle
    idle.draw STACK
    total.label Total
    total.draw LINE1
    ');
    
    	exit 0;
    }
    
    foreach my $port (@PORTS)
    {
        my $ua = LWP::UserAgent->new(timeout => 30);
        my $url = sprintf $URL, $port;
        my $response = $ua->request(HTTP::Request->new('GET',$url));
    	if ($response->content =~ /idle processes:\s+([0-9\.]+)/im) {
            print "idle.value $1\n";
        } else {
            print "idle.value U\n";
        }
    	if ($response->content =~ /active processes:\s+([0-9\.]+)/im) {
            print "active.value $1\n";
        } else {
            print "active.value U\n";
        }
    	if ($response->content =~ /total processes:\s+([0-9\.]+)/im) {
            print "total.value $1\n";
        } else {
            print "total.value U\n";
        }
    }

    munin, 19 Февраля 2017

    Комментарии (0)
  6. bash / Говнокод #22369

    −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
    #!/bin/sh
    # -*- sh -*-
    
    PHP_BIN=${phpbin-"php-fpm"}
    PHP_POOL=${phppool-"www"}
    
    if [ "$1" = "autoconf" ]; then
    echo yes
    exit 0
    fi
    
    if [ "$1" = "config" ]; then
    echo 'graph_title PHP-FPM Processes'
    echo 'graph_args --base 1000 -l 0 '
    echo 'graph_vlabel PHP-FPM Processes'
    echo 'graph_category PHP'
    echo 'graph_info This graph shows the number of PHP-FPM processes in the system.'
    echo 'php_processes.label PHP-FPM Processes'
    echo 'php_processes.draw LINE2'
    echo 'php_processes.info The current number of PHP-FPM processes.'
    exit 0
    fi
    
    echo -n "php_processes.value "
    ps awwwux | grep "$PHP_BIN: pool $PHP_POOL" | grep -v grep | wc -l

    munin, 19 Февраля 2017

    Комментарии (0)
  7. Perl / Говнокод #22368

    −97

    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
    #!/usr/bin/perl
    # -*- perl -*-
    my $PHP_BIN = exists $ENV{'phpbin'} ? $ENV{'phpbin'} : "php-fpm";
    my $PHP_POOL = exists $ENV{'phppool'} ? $ENV{'phppool'} : "www";
    
    if ( defined $ARGV[0] and $ARGV[0] eq "autoconf" )
    {
            print "yes\n";
            exit 0;
    }
    
    if ( exists $ARGV[0] and $ARGV[0] eq "config" ) {
            print "graph_title PHP-FPM Memory Usage\n";
            print "graph_vlabel RAM\n";
            print "graph_category PHP\n";
            print "ram.label ram\n";
                    print "graph_args --base 1024\n";
    } else {
            my $i = Integer;
            @cmd = `ps auwx | grep "$PHP_BIN: pool $PHP_POOL" | grep -v grep | grep -v phpfpm_memory`;
            foreach (@cmd) {
                    @return = split(/ +/, $_);
                    $i += @return[5]*1024;
            }
            print "ram.value ".$i."\n";
    }

    munin, 19 Февраля 2017

    Комментарии (0)
  8. bash / Говнокод #22367

    −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
    #!/bin/sh
    # -*- sh -*-
    
    HP_BIN=${phpbin-"php-fpm"}
    PHP_POOL=${phppool-"www"}
    
    if [ "$1" = "autoconf" ]; then
    echo yes
    exit 0
    fi
    
    if [ "$1" = "config" ]; then
    echo 'graph_title PHP-FPM Average Process Size'
    echo 'graph_args --base 1024 -l 0 '
    echo 'graph_vlabel PHP-FPM Average Process Size'
    echo 'graph_category PHP'
    echo 'graph_info This graph shows the average process size for PHP-FPM'
    echo 'php_average.label PHP-FPM Average Proccess Size'
    echo 'php_average.draw LINE2'
    echo 'php_average.info The average process size for PHP-FPM'
    exit 0
    fi
    
    echo -n "php_average.value "
    tmpfile=/dev/shm/$$
    ps awwwux | grep "${PHP_BIN}: pool $PHP_POOL" | grep -v grep | grep -v master > $tmpfile
    test -s $tmpfile && awk '{total_mem = $6 * 1024 + total_mem; total_proc++} END{printf("%d\n", total_mem / total_proc)}' $tmpfile || echo N
    rm -f $tmpfile

    munin, 19 Февраля 2017

    Комментарии (0)
  9. Perl / Говнокод #22366

    −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
    #!/usr/bin/perl
    # -*- perl -*-
    
    my $ret = undef;
    
    if (! eval "require LWP::UserAgent;")
    {
    	$ret = "LWP::UserAgent not found";
    }
    
    my $URL = exists $ENV{'url'} ? $ENV{'url'} : "http://127.0.0.1:%d/status";
    my @PORTS = exists $ENV{'ports'} ? split(' ', $ENV{'ports'}) : (80);
    
    if ( defined $ARGV[0] and $ARGV[0] eq "autoconf" )
    {
    	if ($ret)
    	{
    		print "no ($ret)\n";
    		exit 1;
    	}
    
    	my $ua = LWP::UserAgent->new(timeout => 30);
    
    	my @badports;
    	foreach my $port (@PORTS) {
    		my $url = sprintf $URL, $port;
    		my $response = $ua->request(HTTP::Request->new('GET',$url));
    		push @badports, $port unless $response->is_success and $response->content =~ /^accepted conn:/im;
    	}
    	if (@badports) {
    		print "no (phpfpm-status)\n";
    		exit 1;
    	} else {
    		print "yes\n";
    		exit 0;
    	}
    }
    
    if ( defined $ARGV[0] and $ARGV[0] eq "config" )
    {
    	print('graph_title PHP-FPM Accepted Connections
    graph_args --base 1024 -l 0
    graph_vlabel Connections
    graph_category PHP
    graph_info Plugin created by TJ Stein
    accepted.label Accepted
    accepted.draw AREA
    accepted.type DERIVE
    accepted.min 0
    ');
    
    	exit 0;
    }
    
    foreach my $port (@PORTS)
    {
        my $ua = LWP::UserAgent->new(timeout => 30);
        my $url = sprintf $URL, $port;
        my $response = $ua->request(HTTP::Request->new('GET',$url));
    	if ($response->content =~ /accepted conn:\s+([0-9\.]+)/im) {
            print "accepted.value $1\n";
        } else {
            print "accepted.value U\n";
        }
    }

    munin, 19 Февраля 2017

    Комментарии (0)
  10. Perl / Говнокод #22363

    −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
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    83. 83
    84. 84
    85. 85
    86. 86
    87. 87
    88. 88
    89. 89
    90. 90
    91. 91
    92. 92
    93. 93
    94. 94
    95. 95
    96. 96
    97. 97
    #!/usr/bin/perl -w
    # vim: sts=4 sw=4 ts=8
    
    # Munin markers:
    #%# family=auto
    #%# capabilities=autoconf suggest
    
    # Author: Michael Renner <[email protected]>
    
    use strict;
    
    use File::Basename;
    use Carp;
    use POSIX;
    
    # We load our own version of save/restore_state if Munin::Plugin is unavailable.
    # Don't try this at home
    eval { require Munin::Plugin; Munin::Plugin->import; };
    
    if ($@) {
        fake_munin_plugin();
    }
    
    # Sanity check to ensure that the script is called the correct name.
    
    if ( basename($0) !~ /^linux_diskstat_/ ) {
        die
            qq(Please ensure that the name of the script and it's symlinks starts with "linux_diskstat_"\n);
    }
    
    ############
    # autoconf #
    ############
    
    if ( defined $ARGV[0] && $ARGV[0] eq 'autoconf' ) {
        my %stats;
    
        # Capture any croaks on the way
        eval { %stats = parse_diskstats() };
    
        if ( !$@ && keys %stats ) {
    
            print "yes\n";
            exit 0;
        }
        else {
            print "no\n";
            exit 1;
        }
    }
    
    ###########
    # suggest #
    ###########
    
    if ( defined $ARGV[0] && $ARGV[0] eq 'suggest' ) {
    
        my %diskstats = parse_diskstats();
    
        my %suggested_devices;
    
    DEVICE:
        for my $devname ( sort keys %diskstats ) {
    
            # Skip devices without traffic
            next
                if ( $diskstats{$devname}->{'rd_ios'} == 0
                && $diskstats{$devname}->{'wr_ios'} == 0 );
    
            for my $existing_device ( @{ $suggested_devices{'iops'} } ) {
    
              # Filter out devices (partitions) which are matched by existing ones
              # e.g. sda1 -> sda, c0d0p1 -> c0d0
                next DEVICE if ( $devname =~ m/$existing_device/ );
            }
    
            push @{ $suggested_devices{'iops'} },       $devname;
            push @{ $suggested_devices{'throughput'} }, $devname;
    
            # Only suggest latency graphs if the device supports it
            if (   $diskstats{$devname}->{'rd_ticks'} > 0
                || $diskstats{$devname}->{'wr_ticks'} > 0 )
            {
                push @{ $suggested_devices{'latency'} }, $devname;
            }
        }
    
        for my $mode ( keys %suggested_devices ) {
            for my $device ( sort @{ $suggested_devices{$mode} } ) {
    
                my $printdev = translate_device_name( $device, 'TO_FS' );
                print "${mode}_$printdev\n";
            }
        }
    
        exit 0;
    }

    munin, 18 Февраля 2017

    Комментарии (0)
  11. Python / Говнокод #22362

    −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
    #!/usr/bin/env python
    # namecoind_ Munin plugin for Namecoin Server Variables
    #
    # by Mike Koss
    # Feb 14, 2012, MIT License
    
    
    import os
    import sys
    import time
    import re
    import urllib2
    import json
    
    
    DEBUG = False
    
    
    def main():
        # getinfo variable is read from command name - probably the sym-link name.
        request_var = sys.argv[0].split('_', 1)[1] or 'balance'
        command = sys.argv[1] if len(sys.argv) > 1 else None
        request_labels = {'balance': ('Wallet Balance', 'BTC'),
                          'connections': ('Peer Connections', 'Connections'),
                          'fees': ("Tip Offered", "BTC"),
                          'transactions': ("Transactions", "Transactions",
                                           ('confirmed', 'waiting')),
                          'block_age': ("Last Block Age", "Seconds"),
                          'difficulty': ("Difficulty", ""),
                          }
        labels = request_labels[request_var]
        if len(labels) < 3:
            line_labels = [request_var]
        else:
            line_labels = labels[2]
    
        if command == 'suggest':
            for var_name in request_labels.keys():
                print var_name
            return
    
        if command == 'config':
            print 'graph_category namecoin'
            print 'graph_title Namecoin %s' % labels[0]
            print 'graph_vlabel %s' % labels[1]
            for label in line_labels:
                print '%s.label %s' % (label, label)
            return
    
        # Munin should send connection options via environment vars
        namecoin_options = get_env_options('rpcconnect', 'rpcport', 'rpcuser', 'rpcpassword')
        namecoin_options.rpcconnect = namecoin_options.get('rpcconnect', '127.0.0.1')
        namecoin_options.rpcport = namecoin_options.get('rpcport', '8335')
    
        if namecoin_options.get('rpcuser') is None:
            conf_file = os.path.join(os.path.expanduser('~/.namecoin'), 'bitcoin.conf')
            namecoin_options = parse_conf(conf_file)
    
        namecoin_options.require('rpcuser', 'rpcpassword')
    
        namecoin = ServiceProxy('http://%s:%s' % (namecoin_options.rpcconnect,
                                                 namecoin_options.rpcport),
                               username=namecoin_options.rpcuser,
                               password=namecoin_options.rpcpassword)
    
        (info, error) = namecoin.getinfo()
    
        if error:
            if command == 'autoconf':
                print 'no'

    munin, 18 Февраля 2017

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