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

    Всего: 55

  2. Perl / Говнокод #22429

    −16

    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
    #!/usr/bin/perl -w
    # ESXi host CPU/memory plugin for Munin by Niels Engelen
    # http://www.foonet.be
     
    use strict;
    use warnings;
    use VMware::VIRuntime;
    use VMware::VILib;
     
    $ENV{PERL_LWP_SSL_VERIFY_HOSTNAME} = 0;
     
    my $esxihost = basename($0);
    $esxihost =~ s/esxi\_cpu\_mem\_//;
    my $username = Opts::set_option ('username', $ENV{'username'});
    my $password = Opts::set_option ('password', $ENV{'password'});
    my $url = Opts::set_option ('url', "https://$esxihost/sdk/webService");
    my ($host_info);
     
    if ( exists $ARGV[0] and $ARGV[0] eq "config" ) {
      print "graph_title ESXi CPU/Memory ".$esxihost." \n";
      print "graph_args --base 1000 -r --lower-limit 0 --upper-limit 100 \n";
      print "graph_vlabel % \n";
      print "graph_category ESXi CPU/Memory\n";
      print "graph_scale no\n";
      print "mem.label MEM used\n";
      print "mem.draw AREA\n";
      print "cpu.label CPU used\n";
      exit 0;
    } else {
      Opts::parse();
      Opts::validate();
      Util::connect();
      $host_info = Vim::find_entity_view(view_type => 'HostSystem', properties => ['summary.hardware', 'summary.quickStats'], filter => {'summary.runtime.connectionState' => 'connected'});
      &get_host_mem_info($host_info);
      &get_host_cpu_info($host_info);
      Util::disconnect();
      exit 0;
    }
      
    sub get_host_mem_info {
            if ($host_info) {
            my $percentMemoryUsed = ($host_info->{'summary.quickStats'}->overallMemoryUsage * 1024 * 1024 / $host_info->{'summary.hardware'}->memorySize) * 100;
            printf "mem.value %.2f\n",$percentMemoryUsed;
        }
    }
      
    sub get_host_cpu_info {
        if ($host_info) {
            my $percentCpuUsed = ($host_info->{'summary.quickStats'}->overallCpuUsage / ($host_info->{'summary.hardware'}->cpuMhz * $host_info->{'summary.hardware'}->numCpuCores)) * 100;
            printf "cpu.value %.2f\n",$percentCpuUsed;
            }
    }

    munin, 22 Февраля 2017

    Комментарии (14)
  3. PHP / Говнокод #22413

    −104

    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/php
    <?php
    /**
     * Bukkit player online Munin plugin
     * ---------------------------------
     *
     * Shows the current online players
     * (parsed via JSONAPI)
     *
     * Read more about my plugins on my blog:
     * http://s.frd.mn/XJsryR
     *
     * Author: Jonas Friedmann (http://frd.mn)
     *
     */
    /**
     * JSONAPI configuration
     */
    $hostname = 'your-hostname';
    $username = 'your-username';
    $password = 'your-password';
    $salt     = 'your-salt';
    $port     = 20059;
    /**
     * !!! DO NOT EDIT THIS PART BELOW !!!
     */
    if ((count($argv) > 1) && ($argv[1] == 'config'))
    {
    print("graph_title Bukkit / JSONAPI - players online
    graph_category bukkit
    graph_vlabel players
    graph_args --base 1000 -l 0
    players.type GAUGE
    players.label players
    ");
    exit();
    }
    // Include JSONAPI.php SDK (get this file here: https://github.com/alecgorge/jsonapi/raw/master/sdk/php/JSONAPI.php)
    require('/var/cache/munin/JSONAPI.php');
    // Prepare API call
    $api = new JSONAPI($hostname, $port, $username, $password, $salt);
    $result = $api->call("getPlayerCount");
    // Check for success
    if ($result['result'] == 'success'){
      // Print values
      print('players.value ' . $result['success'] . "\n");
    }
    ?>

    munin, 19 Февраля 2017

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

    −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
    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
    #!/usr/bin/env python
    
    ## GENERATED FILE - DO NOT EDIT
    
    import urllib2
    import sys
    import os  
    import pymongo
    
    def getServerStatus():
        if 'MONGO_DB_URI' in os.environ:
          c = pymongo.MongoClient(os.environ['MONGO_DB_URI'])
        else:
          c = pymongo.MongoClient()
    
        return c.admin.command('serverStatus', workingSet=True)
    
    def get():
        return getServerStatus()["indexCounters"]
    
    def doData():
        for k,v in get().iteritems():
            print( str(k) + ".value " + str(int(v)) )
    
    def doConfig():
    
        print "graph_title MongoDB btree stats"
        print "graph_args --base 1000 -l 0"
        print "graph_vlabel mb ${graph_period}"
        print "graph_category MongoDB"
    
        for k in get():
            print k + ".label " + k
            print k + ".min 0"
            print k + ".type COUNTER"
            print k + ".max 500000"
            print k + ".draw LINE1"
    
    
    
    
    
    
    if __name__ == "__main__":          
    	
        from os import environ
        if 'HOST' in environ:
            host = environ['HOST']
        if 'PORT' in environ:
            port = environ['PORT']
        if 'USER' in environ:
            user = environ['USER']
        if 'PASSWORD' in environ:
            password = environ['PASSWORD']
        
    if len(sys.argv) > 1 and sys.argv[1] == "config":
        doConfig()
    else:
        doData()

    munin, 19 Февраля 2017

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

    −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
    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
    #!/usr/bin/env python
    
    ## GENERATED FILE - DO NOT EDIT
    
    import urllib2
    import sys
    import os  
    import pymongo
    
    def getServerStatus():
        if 'MONGO_DB_URI' in os.environ:
          c = pymongo.MongoClient(os.environ['MONGO_DB_URI'])
        else:
          c = pymongo.MongoClient()
    
        return c.admin.command('serverStatus', workingSet=True)
    
    name = "connections"
    
    
    def doData():
        print name + ".value " + str( getServerStatus()["connections"]["current"] )
    
    def doConfig():
    
        print "graph_title MongoDB current connections"
        print "graph_args --base 1000 -l 0"
        print "graph_vlabel connections"
        print "graph_category MongoDB"
    
        print name + ".label " + name
    
    
    
    
    
    
    if __name__ == "__main__":          
    	
        from os import environ
        if 'HOST' in environ:
            host = environ['HOST']
        if 'PORT' in environ:
            port = environ['PORT']
        if 'USER' in environ:
            user = environ['USER']
        if 'PASSWORD' in environ:
            password = environ['PASSWORD']
        
    if len(sys.argv) > 1 and sys.argv[1] == "config":
        doConfig()
    else:
        doData()

    munin, 19 Февраля 2017

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

    −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
    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
    #!/usr/bin/env python
    
    ## GENERATED FILE - DO NOT EDIT
    
    import urllib2
    import sys
    import os
    import pymongo
    
    def getServerStatus():
        host = "127.0.0.1"
        port = 27017
        c = pymongo.MongoClient(host, port)
        return c.admin.command('serverStatus', workingSet=True)
    
    name = "documents"
    
    
    def doData():
        ss = getServerStatus()
        for k,v in ss["metrics"]["document"].iteritems():
            print( str(k) + ".value " + str(v) )
    
    def doConfig():
    
        print "graph_title MongoDB documents"
        print "graph_args --base 1000 -l 0"
        print "graph_vlabel documents"
        print "graph_category MongoDB"
    
        for k in getServerStatus()["metrics"]["document"]:
            print k + ".label " + k
            print k + ".min 0"
            print k + ".type COUNTER"
            print k + ".max 500000"
            print k + ".draw LINE1"
    
    if __name__ == "__main__":
    
        from os import environ
        if 'HOST' in environ:
            host = environ['HOST']
        if 'PORT' in environ:
            port = environ['PORT']
        if 'USER' in environ:
            user = environ['USER']
        if 'PASSWORD' in environ:
            password = environ['PASSWORD']
    
    if len(sys.argv) > 1 and sys.argv[1] == "config":
        doConfig()
    else:
        doData()

    munin, 19 Февраля 2017

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

    −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
    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
    #!/usr/bin/env python
    
    ## GENERATED FILE - DO NOT EDIT
    
    import urllib2
    import sys
    import os  
    import pymongo
    
    def getServerStatus():
        if 'MONGO_DB_URI' in os.environ:
          c = pymongo.MongoClient(os.environ['MONGO_DB_URI'])
        else:
          c = pymongo.MongoClient()
    
        return c.admin.command('serverStatus', workingSet=True)
    
    name = "locked"
    
    def doData():
        print name + ".value " + str( 100 * (getServerStatus()["globalLock"]["lockTime"]/getServerStatus()["globalLock"]["totalTime"]) )
    
    def doConfig():
    
        print "graph_title MongoDB global write lock percentage"
        print "graph_args --base 1000 -l 0 "
        print "graph_vlabel percentage"
        print "graph_category MongoDB"
    
        print name + ".label " + name
    
    
    
    
    
    
    if __name__ == "__main__":          
    	
        from os import environ
        if 'HOST' in environ:
            host = environ['HOST']
        if 'PORT' in environ:
            port = environ['PORT']
        if 'USER' in environ:
            user = environ['USER']
        if 'PASSWORD' in environ:
            password = environ['PASSWORD']
        
    if len(sys.argv) > 1 and sys.argv[1] == "config":
        doConfig()
    else:
        doData()

    munin, 19 Февраля 2017

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

    −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
    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/env python
    
    ## GENERATED FILE - DO NOT EDIT
    
    import urllib2
    import sys
    import os  
    import pymongo
    
    def getServerStatus():
        if 'MONGO_DB_URI' in os.environ:
          c = pymongo.MongoClient(os.environ['MONGO_DB_URI'])
        else:
          c = pymongo.MongoClient()
    
        return c.admin.command('serverStatus', workingSet=True)
    
    def ok(s):
        return s == "resident" or s == "virtual" or s == "mapped"
    
    def doData():
        for k,v in getServerStatus()["mem"].iteritems():
            if ok(k):
                print( str(k) + ".value " + str(v * 1024 * 1024) )
    
    def doConfig():
    
        print "graph_title MongoDB memory usage"
        print "graph_args --base 1024 -l 0 --vertical-label Bytes"
        print "graph_category MongoDB"
    
        for k in getServerStatus()["mem"]:
            if ok( k ):
                print k + ".label " + k
                print k + ".draw LINE1"
    
    
    
    
    
    
    
    if __name__ == "__main__":          
    	
        from os import environ
        if 'HOST' in environ:
            host = environ['HOST']
        if 'PORT' in environ:
            port = environ['PORT']
        if 'USER' in environ:
            user = environ['USER']
        if 'PASSWORD' in environ:
            password = environ['PASSWORD']
        
    if len(sys.argv) > 1 and sys.argv[1] == "config":
        doConfig()
    else:
        doData()

    munin, 19 Февраля 2017

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

    −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
    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
    #!/usr/bin/env python
    
    ## GENERATED FILE - DO NOT EDIT
    
    import urllib2
    import sys
    import os  
    import pymongo
    
    def getServerStatus():
        if 'MONGO_DB_URI' in os.environ:
          c = pymongo.MongoClient(os.environ['MONGO_DB_URI'])
        else:
          c = pymongo.MongoClient()
    
        return c.admin.command('serverStatus', workingSet=True)
    
    
    def doData():
        ss = getServerStatus()
        for k,v in ss["opcounters"].iteritems():
            print( str(k) + ".value " + str(v) )
    
    def doConfig():
    
        print "graph_title MongoDB ops"
        print "graph_args --base 1000 -l 0"
        print "graph_vlabel ops / ${graph_period}"
        print "graph_category MongoDB"
        print "graph_total total"
    
        for k in getServerStatus()["opcounters"]:
            print k + ".label " + k
            print k + ".min 0"
            print k + ".type COUNTER"
            print k + ".max 500000"
            print k + ".draw LINE1"
    
    if __name__ == "__main__":          
    	
        from os import environ
        if 'HOST' in environ:
            host = environ['HOST']
        if 'PORT' in environ:
            port = environ['PORT']
        if 'USER' in environ:
            user = environ['USER']
        if 'PASSWORD' in environ:
            password = environ['PASSWORD']
        
    if len(sys.argv) > 1 and sys.argv[1] == "config":
        doConfig()
    else:
        doData()

    munin, 19 Февраля 2017

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

    −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
    30. 30
    31. 31
    32. 32
    #!/usr/bin/env python
    """Creates a graph of IPFS's bandwidth usage."""
    import requests
    import os
    import sys
    
    api_base = os.getenv("IPFS_API", "http://localhost:5001/api/v0")
    
    if "config" in sys.argv:
        print("""graph_title IPFS bandwidth
    graph_info This graph shows the amount of bandwidth used by IPFS on this machine
    graph_category ipfs
    graph_order in out
    graph_args --base 1000
    graph_vlabel bits in (-) / out (+) per ${graph_period}
    in.label received
    in.type DERIVE
    in.graph no
    in.cdef in,8,*
    in.min 0
    out.label bps
    out.type DERIVE
    out.negative in
    out.cdef out,8,*
    out.min 0
    out.max 100000000
    out.info Traffic used by IPFS
    in.max 100000000""")
    else:
        data = requests.get("%s/stats/bw" % api_base).json()
        print("in.value %s" % data['TotalIn'])
        print("out.value %s" % data['TotalOut'])

    munin, 19 Февраля 2017

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

    −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
    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
    #!/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 Packets
    graph_info This graph shows the volume of wireless packets
    graph_category wireless
    SWRXgoodPacket.label Packets Transmitted
    SWRXgoodPacket.type DERIVE
    SWRXgoodPacket.graph no
    SWRXgoodPacket.min 0
    SWTXgoodPacket.label Packets Received
    SWTXgoodPacket.type DERIVE
    SWTXgoodPacket.negative SWRXgoodPacket
    SWTXerrorPacket.min 0
    SWRXerrorPacket.label TX error
    SWRXerrorPacket.type DERIVE
    SWRXerrorPacket.graph no
    SWRXerrorPacket.min 0
    SWTXerrorPacket.label RX error
    SWTXerrorPacket.type DERIVE
    SWTXerrorPacket.negative SWRXerrorPacket
    SWTXerrorPacket.min 0
    graph_vlabel Packets"""
    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 == "packet_info":
                    for line2 in data.split(";"):
                        if "=" in line2:
                            key2, value2 = line2.split("=")
                            print "%s.value %s" % (key2, value2)

    munin, 19 Февраля 2017

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