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

    Всего: 55

  2. Python / Говнокод #22404

    −103

    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
    #!/usr/bin/env python
    import requests
    import json
    import sys
    import os
    
    config = False
    if len(sys.argv) > 1:
        if sys.argv[1] == "config":
            config = True
            
    if config:
        print """graph_title Wireless Clients
    graph_info This graph shows the number of wireless clients on the DD-WRT router
    graph_category wireless
    active_wireless.label Clients
    graph_vlabel Clients"""
    else:
        ip = "192.168.1.1"
        if os.getenv("HOST") is not None:
            if os.getenv("HOST") != "":
                ip = os.getenv("HOST")
        info = requests.get("http://" + ip + "/Info.live.htm").content.split("\n")
        
        for line in info:
            if "::" in line:
                key = line.split("::")[0].replace("{", "")
                data = line.split("::")[1].replace("}", "")
                
                if key == "active_wireless":
                    data = json.loads("[" + data.replace("'", "\"") + "]")
                    
                    print "active_wireless.value %i" % (len(data)/9)

    munin, 19 Февраля 2017

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

    −102

    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
    #!/bin/bash
    network=$(echo $0 | cut -d'_' -f3)
    channel=$(echo $0 | cut -d'_' -f4)
    if [ "$1" = "config" ]; then
        echo "graph_title $channel on $network"
        echo "graph_info This graph shows the amount of activity on $channel."
        echo "graph_category irc"
        echo "graph_vlabel lines"
        echo "lines.label lines"
        echo "lines.type COUNTER"
    fi
    export linecount=$(cat $HOME/.weechat/logs/irc.$network.*$channel.weechatlog | wc -l)
    echo "lines.value $linecount"

    munin, 19 Февраля 2017

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

    −102

    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/env python
    import requests
    import os,sys
    
    try:
        subs = os.getenv("subs").split(",")
    except:
        sys.exit(1)
    
    config = False
    
    if len(sys.argv) > 1:
        if sys.argv[1] == "config":
            config = True
            
    if config:
        print "graph_title Subreddit Users Online"
        print "graph_vlabel users"
        print "graph_category reddit"
    
    for sub in subs:
        if config:
            print sub + ".label Users on /r/" + sub
        else:
            data = requests.get("http://www.reddit.com/r/" + sub + "/about.json")
            print sub + ".value " + str(data.json()['data']['accounts_active'])

    munin, 19 Февраля 2017

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

    −102

    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
    #!/usr/bin/env python
    import sys
    import os
     
    config = False
    if len(sys.argv) > 1:
        if sys.argv[1] == "config":
            config = True
    
    user = os.getenv("username")
    
    if config:
        print "graph_title Reddit Karma"
        print "graph_info This graph shows the amount of karma that " + user + " has."
        print "graph_category reddit"
        print "link.label Link Karma"
        print "comment.label Comment Karma"
    else:
        import requests
        import json
     
        domain = os.getenv("domain", "www.reddit.com")
    
        url = "http://" + domain + "/user/" + user + "/about.json"
        response = requests.get(url).content
        about = json.loads(response)
        
        print "link.value " + str(about['data']['link_karma'])
        print "comment.value " + str(about['data']['comment_karma'])

    munin, 19 Февраля 2017

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

    −101

    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/env python
    import requests
    import os,sys
    
    try:
        subs = os.getenv("subs").split(",")
    except:
        sys.exit(1)
    
    config = False
    
    if len(sys.argv) > 1:
        if sys.argv[1] == "config":
            config = True
            
    if config:
        print "graph_title Subreddit subscriber count"
        print "graph_vlabel subscribers"
        print "graph_category reddit"
    
    for sub in subs:
        if config:
            print sub + ".label Subscribers on /r/" + sub
        else:
            data = requests.get("http://www.reddit.com/r/" + sub + "/about.json")
            print sub + ".value " + str(data.json()['data']['subscribers'])

    munin, 19 Февраля 2017

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

    −101

    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
    #!/usr/bin/env python3
    import requests
    import sys
    import os
    
    nodes = os.getenv("fingerprints").split(" ")
    addresses = os.getenv("addresses").split(" ")
    
    request = requests.get("https://oniontip.com/result.json")
    if isinstance(request.json, dict):
        results = request.json
    else:
        results = request.json()
    
    config = False
    if len(sys.argv) > 1:
        if sys.argv[1] == "config":
            config = True
    if config:
        print("""graph_title Oniontip Position
    graph_info Shows the position in the oniontip list
    graph_category tor
    graph_vlabel Position
    """)
        for node in results['results']:
            if node['fp'] in nodes or node['bitcoin_address'] in addresses:
                print("%s.label %s" % (node['fp'], node['nick']))
    else:
        for node in results['results']:
            if node['fp'] in nodes or node['bitcoin_address'] in addresses:
                print("%s.value %s" % (node['fp'], node['index']))

    munin, 19 Февраля 2017

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

    −102

    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
    #!/usr/bin/env python
    import sys
    import os
    
    config = False
    if len(sys.argv) > 1:
        if sys.argv[1] == "config":
            config = True
    
    if config:
        print """graph_title Clear Bars
    graph_info This graph shows the number or bars on the clear modem.
    graph_category wireless
    bars.label Bars
    bars.draw AREASTACK
    bars.color 00FF00
    graph_vlabel Bars"""
    else:
        import requests
        modem = "192.168.15.1"
        if os.getenv("MODEM") != "" and os.getenv("MODEM") != None:
            modem = os.getenv("MODEM")
        status = requests.get("http://" + modem + "/cgi-bin/webcm?getpage=/usr/www/wimax_status.html").content.strip().split(":")
        bars = status[3]
        if bars == "":
            bars = "0"
        print "bars.value " + bars

    munin, 19 Февраля 2017

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

    −101

    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
    #!/bin/bash
    if [ "$1" = "config" ]; then
        echo "graph_title Visible Bluetooth Devices"
        echo "graph_info This graph shows the number of bluetooth devices visible"
        echo "graph_category misc"
        echo "graph_vlabel devices"
        echo "devices.label devices"
        echo "devices.type GAUGE"
        echo "devices.draw LINE2"
        exit 0
    fi
    
    echo devices.value $(hcitool scan | grep -v "Scanning ..." | wc -l)

    munin, 19 Февраля 2017

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

    −101

    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
    #!/bin/bash
    
    if test -z "$1"
    then
    	#
    	# the following command should output something along the following
    	#
    	# 145 upgraded, 0 newly installed, 0 to remove and 3 not upgraded
    
    	apt-get upgrade -squ | grep "upgraded," | awk '{ print "UPGRADE.value", $1,  "\nINSTALL.value", $3, "\nREMOVE.value", $6, "\nNO_UPGRADE.value", $10 }'
    else
    	if [[ "$1" = "config" ]]
    	then
    		# time for the munin configuration items
    		echo "graph_title APT get Status"
    		echo "graph_vlabel Availability Number of Packages"
    		echo "graph_category system"
    
    		# in green
    		echo "UPGRADE.label Upgrades"
    		echo "UPGRADE.draw LINE"
    
    		echo "INSTALL.label New installs"
    		echo "INSTALL.draw LINE"
    
    		echo "REMOVE.label Removals"
    		echo "REMOVE.draw LINE"
    
    		echo "NO_UPGRADE.label Not upgradeable"
    		echo "NO_UPGRADE.draw LINE"
    
    		echo "graph_args -l 0 "
    	fi
    fi

    munin, 19 Февраля 2017

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

    −99

    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
    #!/usr/bin/python
    
    import string, os, sys
    
    LOG_DIRECTORY = os.environ.get("NEWZNAB_LOG_FILE")
    
    group_left_count = {}
    
    def get_remaining_parts():
    	with open(LOG_DIRECTORY) as input_file:
    		for line in input_file:
    			if line.rfind("new parts.") != -1:
    				line = string.strip(line)
    				splits = line.split(" ")
    				group_left_count[splits[1]] = splits[3].replace(",", "")
    
    def get_stats():
    	keys = group_left_count.keys()
    	keys.sort()
    
    	for key in keys:
    		print(replaceDot(key) + ".value " + group_left_count[key])
    
    def replaceDot(key):
    	return(key.replace(".", "_"))
    
    if __name__ == "__main__":
    	# are we doing config/autoconfig?
    	get_remaining_parts()
    
    	if(len(sys.argv) > 1):
    		if (sys.argv[1]=="config"):
    			print "graph_title Newznab Parts Left"
    			print "graph_vlabel Number of parts"
    			print "graph_category newznab"
    
    			keys = group_left_count.keys()
    			keys.sort()
    
    			for key in keys:
    
    				print replaceDot(key) + ".label " + key
    				print replaceDot(key) + ".draw LINE1"
    
    			print "graph_args --base 1000 "
    			sys.exit()
    
    	get_stats()

    munin, 19 Февраля 2017

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