Page 2 of 2

Re: server load on bottom of page

Posted: December 11th, 2008, 6:37 pm
by steve51184
i've just updated to 0.4.5 and i need to reapply this but after doing so i get this error when trying to start sabnzbd

Code: Select all

Traceback (most recent call last):
  File "/home/username/sabnzbd/SABnzbd.py", line 44, in <module>
    import sabnzbd
  File "/home/username/sabnzbd/sabnzbd/__init__.py", line 45, in <module>
    from sabnzbd.assembler import Assembler
  File "/home/username/sabnzbd/sabnzbd/assembler.py", line 34, in <module>
    from sabnzbd.interface import CheckFreeSpace
  File "/home/username/sabnzbd/sabnzbd/interface.py", line 2198
    header['uptimesys'] = "%s" % upsys()
                                       ^
IndentationError: unindent does not match any outer indentation level

Re: server load on bottom of page

Posted: December 12th, 2008, 2:48 am
by shypike
Carefully check your indentation and make sure you don't use tabs but spaces.

Re: server load on bottom of page

Posted: December 21st, 2008, 10:52 am
by jordz
xxhds wrote: I just saw this posted and wanted to add it to my server so I did.  I have no python experience, but adding it was a snap.  It currently does not auto-refresh because I didn't dig into the templates and scripts enough to see how that worked, but it gets the job done for me and is very informative.  Took me about 30 minutes to figure out.  I also removed some other stuff from the template I didn't want.  Here's what mine looks like:

Oh and this is for linux only.  I'm running an ubuntu server with 2 4x500gb raid 5 partitions.  Should work with any linux distribution though.
Image

Two files to modify.  interface.py and your main.tmpl in whatever template folder you are using.

In interface.py located in /sabnzbd .4.4/sabnzbd
search for:

Code: Select all

PROVIDER = DictAuthProvider({})

USERNAME = None
PASSWORD = None

#------------------------------------------------------------------------------
after add:

Code: Select all

def upsys():
    """Returns uptime and cpu load"""
    import commands
    a = commands.getoutput("uptime")
    return a
search for:   

Code: Select all

 header['diskspacetotal2'] = "%.2f" % disktotal(sabnzbd.COMPLETE_DIR)
after add:     

Code: Select all

 header['uptimesys'] = "%s" % upsys()
search for:     

Code: Select all

  "diskspace2" : diskfree(sabnzbd.COMPLETE_DIR),
after add:     

Code: Select all

 "uptimesys" : upsys(),
search for and add the same thing again.   There are two places where the above string is found.

Then in main.tmpl in the folder /sabnzbd .4.4/interfaces/smpl/templates
I use the smpl template.  I just quick looked at the default main.tmpl and I wasn't sure where to put it, but this is just the code to output the results, so you can put it anywhere you want in any template.

scroll all the way to the bottom and add  ${uptimesys}


I put it right before "sabnzbd version: $version"


I don't think a restart is even required, but it might be.  Just refresh the page and you should see your uptime and load statistics.  Let me know if you have an questions.
-xxhds
I created a patch for this:

http://aur.archlinux.org/packages/sabnz ... time.patch

Works against the latest r1899.
Thanks xxhds :)

Re: server load on bottom of page

Posted: January 2nd, 2009, 3:52 pm
by sander
@xxhds,

Do you understand the roles of the different parts in interface.py? I especially don't understand the need for

Code: Select all

header['uptimesys'] = "%s" % upsys()
Maybe you can explain it a bit?



xxhds wrote: I just saw this posted and wanted to add it to my server so I did.  I have no python experience, but adding it was a snap.  It currently does not auto-refresh because I didn't dig into the templates and scripts enough to see how that worked, but it gets the job done for me and is very informative.  Took me about 30 minutes to figure out.  I also removed some other stuff from the template I didn't want.  Here's what mine looks like:

Oh and this is for linux only.  I'm running an ubuntu server with 2 4x500gb raid 5 partitions.  Should work with any linux distribution though.
Image

Two files to modify.  interface.py and your main.tmpl in whatever template folder you are using.

In interface.py located in /sabnzbd .4.4/sabnzbd
search for:

Code: Select all

PROVIDER = DictAuthProvider({})

USERNAME = None
PASSWORD = None

#------------------------------------------------------------------------------
after add:

Code: Select all

def upsys():
    """Returns uptime and cpu load"""
    import commands
    a = commands.getoutput("uptime")
    return a
search for:   

Code: Select all

 header['diskspacetotal2'] = "%.2f" % disktotal(sabnzbd.COMPLETE_DIR)
after add:     

Code: Select all

 header['uptimesys'] = "%s" % upsys()
search for:     

Code: Select all

  "diskspace2" : diskfree(sabnzbd.COMPLETE_DIR),
after add:     

Code: Select all

 "uptimesys" : upsys(),
search for and add the same thing again.   There are two places where the above string is found.

Then in main.tmpl in the folder /sabnzbd .4.4/interfaces/smpl/templates
I use the smpl template.  I just quick looked at the default main.tmpl and I wasn't sure where to put it, but this is just the code to output the results, so you can put it anywhere you want in any template.

scroll all the way to the bottom and add  ${uptimesys}


I put it right before "sabnzbd version: $version"


I don't think a restart is even required, but it might be.  Just refresh the page and you should see your uptime and load statistics.  Let me know if you have an questions.
-xxhds

Re: server load on bottom of page

Posted: January 14th, 2009, 7:28 am
by jordz
I saw that the system load is added in trunk :)