Example #1
0
def error404(error):
    ip = request.environ.get('REMOTE_ADDR')
    url = request.url
    #maybe logged due to favico GET
    logpyle.logger(ip, url, "error 404")
    a = header + 'Shop is closed, sorry' + foot
    return a
Example #2
0
def error404(error):
    ip = request.environ.get('REMOTE_ADDR')
    url = request.url
    #maybe logged due to favico GET
    logpyle.logger(ip,url,"error 404") 
    a = header + 'Shop is closed, sorry' + foot
    return a
Example #3
0
def disk_usage():
    import df
    ip = request.environ.get('REMOTE_ADDR')
    logpyle.logger(ip, " requested disk usage info") 
    a = df.fsinfo() 
    b = header + "<div class='container'>" + a.replace('\n','</br>').replace('\t','&emsp;')+ "</div>" + foot
    return b
Example #4
0
def show_ip():
    ip = request.environ.get('REMOTE_ADDR')
    # or ip = request.get('REMOTE_ADDR')
    # or ip = request['REMOTE_ADDR']
    logpyle.logger(ip, " resquested its IP")
    a = "<div class='container'> Your IP is: %s </div>" % ip
    a = header + a + foot
    return a
Example #5
0
def show_ip():
    ip = request.environ.get('REMOTE_ADDR')
    # or ip = request.get('REMOTE_ADDR')
    # or ip = request['REMOTE_ADDR']
    logpyle.logger(ip, " resquested its IP") 
    a = "<div class='container'> Your IP is: %s </div>" % ip
    a = header + a + foot
    return a
Example #6
0
def disk_usage():
    import df
    ip = request.environ.get('REMOTE_ADDR')
    logpyle.logger(ip, " requested disk usage info")
    a = df.fsinfo()
    b = header + "<div class='container'>" + a.replace('\n', '</br>').replace(
        '\t', '&emsp;') + "</div>" + foot
    return b
Example #7
0
def index():
    ip = request.environ.get('REMOTE_ADDR')
    logpyle.logger(ip, " requested index.{php,html}")
    a = header + "<div class='container'><p>Welcome to raspberry pi monitor!</p></div>" + foot
    return a
Example #8
0
def testplot():
    ip = request.environ.get('REMOTE_ADDR')
    logpyle.logger(ip, " requested plot.jpeg")
    return static_file('plot.jpeg', root='/home/pi/raspberry_juice/')
Example #9
0
def favicon():
    ip = request.environ.get('REMOTE_ADDR')
    logpyle.logger(ip, " requested favicon")
    return static_file('favicon.ico', root='/home/pi/raspberry_juice/')
Example #10
0
def plottedgraph(name):
    ip = request.environ.get('REMOTE_ADDR')
    logpyle.logger(ip, " cpu usage plotfile requested")
    sfile = "%s.jpg" % name
    return static_file(sfile, root='/home/pi/raspberry_juice/')
Example #11
0
#!/usr/bin/env python
# stupid test script

import logpyle
import time,os,sys,random

A=sys.platform
B="string, sexy string"
counter=1
while counter<10:
  print counter
  logpyle.logger("some other useless action", A)
  logpyle.logger("CRITICAL ERROR", B)
  logpyle.logger()
  counter += 1
  time.sleep(random.randrange(1,10))
Example #12
0
def index():
    ip = request.environ.get('REMOTE_ADDR')
    logpyle.logger(ip, " requested index.{php,html}")
    a = header + "<div class='container'><p>Welcome to raspberry pi monitor!</p></div>" + foot
    return a
Example #13
0
def testplot():
    ip = request.environ.get('REMOTE_ADDR')
    logpyle.logger(ip, " requested plot.jpeg") 
    return static_file('plot.jpeg', root='/home/pi/raspberry_juice/')
Example #14
0
def favicon():
    ip = request.environ.get('REMOTE_ADDR')
    logpyle.logger(ip, " requested favicon") 
    return static_file('favicon.ico', root='/home/pi/raspberry_juice/')
Example #15
0
def plottedgraph(name):
    ip = request.environ.get('REMOTE_ADDR')
    logpyle.logger(ip, " cpu usage plotfile requested") 
    sfile = "%s.jpg"%name
    return static_file(sfile, root='/home/pi/raspberry_juice/')
Example #16
0
  def cpu_usage(self):
      datafiles = []
      plotlinks = []

      ip = request.environ.get('REMOTE_ADDR')
      logpyle.logger(ip, " requested cpu_usage") 
      cpu = open('/proc/loadavg','r')
      data = cpu.read()
      cpu.close()
      logpyle.logger(ip, " requested cpu usage info") 
      a = str(data[0:4]) 
      if float(a) > 1:
        a = 1
      width = 300 # 100%
      cpuu = (float(a) * 100) * 3 # 100% = 300 p
      r1w=(cpuu/2)
      r1w_round = round(r1w)
      r2w = 300 - r1w 
      #print(r1w, r1w_round, r2w, cpuu)
      
      # name variables like this:
      # self.r2w = r2w  
      # and so on

      # 8< --- cut here ----
      
      
      js = """
      <script src="http://code.jquery.com/jquery-latest.js"></script>
      <script>
        var url = "http://"+window.location.host+'/cpu_usage#cpu';
        var rellenar = function() {
          $.get(
            url,
            function(text) {
                $('#cpu').html(text);
            }
          );
        };

        setTimeout(rellenar, 5000);
      </script>
      """
      svg = """
      <div id="cpu" class="container">
      <svg xmlns="http://www.w3.org/2000/svg" version="1.1">
      <defs>
          <filter id="f1" x="0" y="0" width="100%%" height="20">
            <feOffset result="offOut" in="SourceAlpha" dx="5" dy="5" />
            <feGaussianBlur result="blurOut" in="offOut" stdDeviation="5" />
            <feBlend in="SourceGraphic" in2="blurOut" mode="normal" />
          </filter>
      </defs>
      <rect id="rect1" x="0" y="0" width="%d" height="20" style="fill:rgb(254,0,0);stroke-width:1;stroke:rgb(0,0,0);opacity:0.5" filter="url(#f1)"/>
      <rect id="rect2" x="%d" y="0" width="%d" height="20" style="fill:rgb(0,255,0);stroke-width:1;stroke:rgb(0,0,0);opacity:0.7" filter="url(#f1)" />
      </svg>
      </div>
      </br></br> """ %(r1w,r1w_round,r2w)
      #for i in os.listdir('/home/pi/raspberry_juice/'):
      #  if fnmatch.fnmatch(i, "*.data"):
      #    datafiles.append(i)    
      #for each in datafiles:
      #  plotlink = "<a href=\"%s\"> %s </a>" %(each,each)
      #  print(plotlink)
      #  plotlinks.append(plotlink)
      
      #b = header + "<div class='container'>" + a.replace('\n','</br>').replace('\t','&emsp;')+ "</br>"+ str(plotlinks) + svg + "</div>" + foot
      b = header +  svg  + js + foot
      return b
Example #17
0
    def cpu_usage(self):
        datafiles = []
        plotlinks = []

        ip = request.environ.get('REMOTE_ADDR')
        logpyle.logger(ip, " requested cpu_usage")
        cpu = open('/proc/loadavg', 'r')
        data = cpu.read()
        cpu.close()
        logpyle.logger(ip, " requested cpu usage info")
        a = str(data[0:4])
        if float(a) > 1:
            a = 1
        width = 300  # 100%
        cpuu = (float(a) * 100) * 3  # 100% = 300 p
        r1w = (cpuu / 2)
        r1w_round = round(r1w)
        r2w = 300 - r1w
        #print(r1w, r1w_round, r2w, cpuu)

        # name variables like this:
        # self.r2w = r2w
        # and so on

        # 8< --- cut here ----

        js = """
      <script src="http://code.jquery.com/jquery-latest.js"></script>
      <script>
        var url = "http://"+window.location.host+'/cpu_usage#cpu';
        var rellenar = function() {
          $.get(
            url,
            function(text) {
                $('#cpu').html(text);
            }
          );
        };

        setTimeout(rellenar, 5000);
      </script>
      """
        svg = """
      <div id="cpu" class="container">
      <svg xmlns="http://www.w3.org/2000/svg" version="1.1">
      <defs>
          <filter id="f1" x="0" y="0" width="100%%" height="20">
            <feOffset result="offOut" in="SourceAlpha" dx="5" dy="5" />
            <feGaussianBlur result="blurOut" in="offOut" stdDeviation="5" />
            <feBlend in="SourceGraphic" in2="blurOut" mode="normal" />
          </filter>
      </defs>
      <rect id="rect1" x="0" y="0" width="%d" height="20" style="fill:rgb(254,0,0);stroke-width:1;stroke:rgb(0,0,0);opacity:0.5" filter="url(#f1)"/>
      <rect id="rect2" x="%d" y="0" width="%d" height="20" style="fill:rgb(0,255,0);stroke-width:1;stroke:rgb(0,0,0);opacity:0.7" filter="url(#f1)" />
      </svg>
      </div>
      </br></br> """ % (r1w, r1w_round, r2w)
        #for i in os.listdir('/home/pi/raspberry_juice/'):
        #  if fnmatch.fnmatch(i, "*.data"):
        #    datafiles.append(i)
        #for each in datafiles:
        #  plotlink = "<a href=\"%s\"> %s </a>" %(each,each)
        #  print(plotlink)
        #  plotlinks.append(plotlink)

        #b = header + "<div class='container'>" + a.replace('\n','</br>').replace('\t','&emsp;')+ "</br>"+ str(plotlinks) + svg + "</div>" + foot
        b = header + svg + js + foot
        return b
Example #18
0
#!/usr/bin/env python
# stupid test script

import logpyle
import time, os, sys, random

A = sys.platform
B = "string, sexy string"
counter = 1
while counter < 10:
    print counter
    logpyle.logger("some other useless action", A)
    logpyle.logger("CRITICAL ERROR", B)
    logpyle.logger()
    counter += 1
    time.sleep(random.randrange(1, 10))