server load on bottom of page

Want something added? Ask for it here.
steve51184

Re: server load on bottom of page

Post 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
User avatar
shypike
Administrator
Administrator
Posts: 19774
Joined: January 18th, 2008, 12:49 pm

Re: server load on bottom of page

Post by shypike »

Carefully check your indentation and make sure you don't use tabs but spaces.
jordz
Newbie
Newbie
Posts: 19
Joined: December 21st, 2008, 10:49 am

Re: server load on bottom of page

Post 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 :)
Arch Linux sabnbzd-svn package: http://aur.archlinux.org/packages.php?ID=21941
User avatar
sander
Release Testers
Release Testers
Posts: 9062
Joined: January 22nd, 2008, 2:22 pm

Re: server load on bottom of page

Post 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
If you like our support, check our special newsserver deal or donate at: https://sabnzbd.org/donate
jordz
Newbie
Newbie
Posts: 19
Joined: December 21st, 2008, 10:49 am

Re: server load on bottom of page

Post by jordz »

I saw that the system load is added in trunk :)
Arch Linux sabnbzd-svn package: http://aur.archlinux.org/packages.php?ID=21941
Post Reply