Posting RAM usage ingame. (Should be easy to do)

Discussion in 'Archived: Plugin Requests' started by QRS%, Dec 28, 2012.

  1. Offline

    QRS%

    Hey!

    Is there a possibilty to make a plugin that says "The server is now using 34% of it's RAM" ingame as a broadcast?

    /Fred
     
  2. Offline

    Jentagh

    You could use something like Skript or VariableTriggers in conjunction with LagMeter, which is my preferred method.
     
  3. Offline

    kg9dh

    I think you can get it by:

    Code:
    Runntime run = Runntime.getRuntime();
     
    ....
     
    long totalmemory = runtime.totalMemory();
    long freememory = runtime.freeMemory();
     
  4. Offline

    Darkhand81

    NoLagg provides a graphical memory display:

    [​IMG]
     
  5. Offline

    Zoroark173

    I am pretty sure that Essentials has this!
     
    frash23 likes this.
  6. Offline

    frash23

    Essentials' /lag command provides a lot of informative stuff on ram usage, even your TPS
     
  7. Offline

    xMakerx

    Here is example code that you add right underneath a command if statement:

    Code:
    Runntime run = Runntime.getRuntime();
     
    Player player = (Player)sender;
     
    long totalmemory = runtime.totalMemory();
    long freememory = runtime.freeMemory();
    long usedmemory = totalmemory =- freememory;
     
    player.sendMessage(ChatColor.GOLD + "Memory " + usedmemory + "/ " + totalmemory);
    return true;
    
    That should work, I haven't tested it yet though xD.
     
  8. Offline

    QRS%

    I'm not looking for the ram usage as an individual player, I want it to broadcast it.
    I already know that there are functions that does that.

    xMakerx, are you able to make me a plugin that does that, I don't know how to compile and etc.
     
  9. Offline

    kg9dh

  10. Offline

    QRS%

  11. Offline

    kg9dh

  12. Offline

    QRS%

    I'll have a look at it,
    + could you change the code to "The server is using 34% of it's RAM"
     
  13. Offline

    kg9dh

    yeah sure, do you still want the graphics? I could just add it on the right side of it.
     
  14. Offline

    QRS%

    Thanks for the offer, but I just want the simple text :) + perhaps you could add this infront of it? so it's "[Baconia] The server is using 34% of it's RAM." and have the "[Baconia]" as dark red and the rest of the text green (&a).

    It's the name of the server :p
     
  15. Offline

    kg9dh

  16. Offline

    QRS%

  17. Offline

    QRS%

  18. Offline

    kg9dh

    Transactions per second?
     
  19. Offline

    1mpre55

    Ticks per second.

    I think this code will get it
    Code:
    final int ticks = 100; // should be 5 seconds
    final long time = System.currentTimeMillis();
    Bukkit.getScheduler().runTaskLater(plugin, new Runnable() {
        @Override
        public void run() {
            int tpsResult = (int)(ticks / ((System.currentTimeMillis() - time) / 1000));
            // do something
        }
    }, ticks);
     
  20. Offline

    QRS%

    Yes on both, could you compile it for me? I want it to broadcast the same way as the other RAM usage plugin did.

    Nope, ticks per second!

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 30, 2016
  21. Offline

    kg9dh

    Last edited by a moderator: May 30, 2016
  22. Offline

    QRS%

  23. Offline

    mrhelton

    I like this idea. Is it possible to also upload a version that doesn't say [Baconia]? Just says how much RAM is being used and nothing more? Much appreciated!
     
  24. Offline

    kg9dh

    sure

    /tps prints out [Baconia] The servers TPS is 20
    (or whatever it is)

    and /ram same as before

    First version with config:
    https://www.dropbox.com/s/2woi4rh85g16ymc/RamUsage.jar

    Code:
    #RamUsage / BroadCastRam by kg9dh
     
    #If it's sent to the player(sender). If this is set to true it will override 'server-output'
    player-output: false
     
    #If it's sent to everyone (Broadcast)
    server-output: true
     
    #If it should output 'Total RAM', 'Used RAM', 'Free RAM'
    usage-output: false
     
    #If it should output the graphics
    graphics-output: false
     
    #If it should output how many percent of RAM are used.
    percent-output: true
     
    #The broadcasts name (label)
    label: Server
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 30, 2016
  25. Offline

    mrhelton

    Excellent, thank you!
     

Share This Page