1. Python / Говнокод #22361

    −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
    #!/usr/bin/env python
    # litecoind_ Munin plugin for Litecoin 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 litecoin'
            print 'graph_title Litecoin %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
        litecoin_options = get_env_options('rpcconnect', 'rpcport', 'rpcuser', 'rpcpassword')
        litecoin_options.rpcconnect = litecoin_options.get('rpcconnect', '127.0.0.1')
        litecoin_options.rpcport = litecoin_options.get('rpcport', '8332')
    
        if litecoin_options.get('rpcuser') is None:
            conf_file = os.path.join(os.path.expanduser('~/.litecoin'), 'litecoin.conf')
            litecoin_options = parse_conf(conf_file)
    
        litecoin_options.require('rpcuser', 'rpcpassword')
    
        litecoin = ServiceProxy('http://%s:%s' % (litecoin_options.rpcconnect,
                                                 litecoin_options.rpcport),
                               username=litecoin_options.rpcuser,
                               password=litecoin_options.rpcpassword)
    
        (info, error) = litecoin.getinfo()
    
        if error:
            if command == 'autoconf':
                print 'no'

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