Example #1
0
 def device_content_system(name):
     agentsystem = WebData.web_code_device_system(name)
     html = """<table style="width:100%"><tr>
     <td><b>Name:</b> """ + agentsystem['name'] + """</td>
     <td><b>IP Address:</b> """ + agentsystem['ipaddress'] + """</td>
     <td><b>Domain:</b> """ + agentsystem['domain'].lower() + """</td>
     <td><b>Platform:</b> """ + agentsystem[
         'platform'] + " (" + agentsystem['architecture'] + """)</td>
     <td><b>Build:</b> """ + str(agentsystem['buildnumber']) + """</td>
     <td><b>Processors:</b> """ + str(agentsystem['processors']) + """</td>
     <td><b>Memory:</b> """ + str(agentsystem['memory'])[:-3] + """ MB</td>
     </tr></table>"""
     return html
Example #2
0
    def index_block_3():
        name = socket.gethostname().lower()
        uptime_check = 300
        currenttime = time.time()
        agent_platform = ""
        agent_architecture = ""
        agent_timestamp = 0
        agent_processors = 0
        agent_memory = 0
        cpu_perc = 0
        mem_perc = 0
        try:
            agentsystem = WebData.web_code_device_system(name)
            agent_platform = agentsystem['platform']
            agent_architecture = agentsystem['architecture']
            agent_timestamp = agentsystem['timestamp']
            agent_processors = agentsystem['processors']
            agent_memory = agentsystem['memory']
        except:
            pass
        try:
            agent_perf = WebData.web_code_device_data_latest(name)
            cpu_perc = 0
            mem_perc = 0
            for i in agent_perf:
                if i['monitor'] == 'perf.processor.percent.used':
                    cpu_perc = float(i['value'])
                if i['monitor'] == 'perf.memory.percent.used':
                    mem_perc = float(i['value'])
        except:
            pass
        html = """<table style="width:100%;height:105px"><tr><td style="width:50%;padding-left:25px;vertical-align:top;padding-top:10px">
        Name: """ + name + """<br />
        Processors: """ + str(agent_processors) + """<br />
        Memory: """ + str(agent_memory)[:-3] + """ MB <br />
        Platform: """ + agent_platform + """ (""" + agent_architecture + """) <br />
        </td><td style="width:50%;padding-left:10px;vertical-align:top;padding-top:10px">"""

        if (agent_timestamp + uptime_check) >= currenttime:
            cpu_color = "93C54B"
            mem_color = "93C54B"
            if cpu_perc >= 90: cpu_color = "D9534F"
            html = html + """<svg width="10" height="10"><rect width="10" height="10" style="fill:#""" + cpu_color + """" /></svg> """ + str(
                cpu_perc)[:-2] + """% CPU<br />"""
            if mem_perc >= 90: mem_color = "D9534F"
            html = html + """<svg width="10" height="10"><rect width="10" height="10" style="fill:#""" + mem_color + """" /></svg> """ + str(
                mem_perc)[:-3] + """% Memory<br />"""
        else:
            html = html + "Agent Not Reporting"
        html = html + "</td></tr></table>"
        return html
Example #3
0
    def device_content_data(name):
        agentsystem = WebData.web_code_device_system(name)
        agent_query = WebData.web_code_device_data_latest(name)
        cpu_perc = 0
        mem_perc = 0
        pagefile_perc = 0
        uptime_days = 0
        net_br = 0
        net_bs = 0
        fs_list = []
        for i in agent_query:
            if i['monitor'] == 'perf.processor.percent.used':
                cpu_perc = round(float(i['value']), 0)
            if i['monitor'] == 'perf.memory.percent.used':
                mem_perc = round(float(i['value']), 0)
            if i['monitor'] == 'perf.pagefile.percent.used':
                pagefile_perc = round(float(i['value']), 0)
            if i['monitor'] == 'perf.system.uptime.seconds':
                uptime_days = round(float(i['value']) / 86400, 0)
            if i['monitor'] == 'perf.network.bytes.received':
                net_br = round(float(i['value']), 0)
            if i['monitor'] == 'perf.network.bytes.sent':
                net_bs = round(float(i['value']), 0)
            if 'filesystem' in i['monitor'] and 'active' in i['monitor']:
                fs_name = i['monitor'].replace('perf.filesystem.', '').replace(
                    '.percent.active', '')
                fs_list.append(fs_name)

        html_fs = """<tr><td  style="padding-bottom:4px;text-align:left">
                  <div class="card-div">
                  <div class="card-header">Filesystem Monitors</div>
                  <div style="padding-left: 10px">"""
        for i in fs_list:
            try:
                fs_query_free = WebData.web_code_device_filesystem(
                    name, 'perf.filesystem.' + i + '.percent.free')
                fs_query_active = WebData.web_code_device_filesystem(
                    name, 'perf.filesystem.' + i + '.percent.active')
                fs_free = str(round(float(fs_query_free['value']), 0))
                fs_active = str(round(float(fs_query_active['value']), 0))
                fs_name = ""
                if agentsystem['platform'] == 'Windows':
                    fs_name = "Windows " + i + " drive"
                elif agentsystem['platform'] == 'Linux':
                    fs_name = "Linux Filesystem: " + i
                html_fs += """<table style="width:100%"><tr>
                        <td style="width:33%">""" + fs_name + """ drive</td>
                        <td style="width:33%"><a href="/devices/""" + name + """/perf.filesystem.""" + i + """.percent.free">Free Space: """ + fs_free + """</a></td>
                        <td style="width:33%"><a href="/devices/""" + name + """/perf.filesystem.""" + i + """.percent.active">Filesystem Activity: """ + fs_active + """</a></td>
                        </tr></table>"""
            except:
                pass
        html_fs += """</div></div></td></tr>"""
        html = """<tr><td style="padding-right:4px;text-align:center">
            <div class="card-div" style="height:70px">
            <div class="card-header">Processor (% used)</div>
            <div  class="device-stats"><a class="device-stats" href="/devices/""" + name + """/perf.processor.percent.used">""" + str(
            cpu_perc) + """</a></div>
            </div></td>
            <td style="padding-left:4px;padding-right:4px;text-align:center">
            <div class="card-div" style="height:70px">
            <div class="card-header">Memory (% used)</div>
            <span class="device-stats"><a class="device-stats" href="/devices/""" + name + """/perf.memory.percent.used">""" + str(
                mem_perc) + """</a></span>
            </div></td>
            <td style="padding-left:4px;padding-right:4px;text-align:center">
            <div class="card-div" style="height:70px">
            <div class="card-header">Pagefile (% used)</div>
            <span class="device-stats"><a class="device-stats" href="/devices/""" + name + """/perf.pagefile.percent.used">""" + str(
                    pagefile_perc) + """</a></span>
            </div></td>
            <td style="padding-left:4px;text-align:center">
            <div class="card-div" style="height:70px">
            <div class="card-header">Uptime (days)</div>
            <span class="device-stats"><a class="device-stats" href="/devices/""" + name + """/perf.system.uptime.seconds">""" + str(
                        uptime_days) + """</a></span>
            </div></td></tr></table>
            <table style="width:100%">  
            <tr><td style="padding-bottom:4px;text-align:left">
            <div class="card-div">
            <div class="card-header">Network Monitors</div>
            <div style="padding-left: 10px">
            <table style="width:100%"><tr>
            <td style="width:33%">Network Total Traffic</td>
            <td style="width:33%"><a href="/devices/""" + name + """/graph/perf.network.bytes.sent">Bytes Sent: """ + str(
                            net_bs) + """</a></td>
            <td style="width:33%"><a href="/devices/""" + name + """/graph/perf.network.bytes.received">Bytes Received: """ + str(
                                net_br) + """</a></td>
            </tr></table></div></div></td></tr>"""
        html += html_fs

        return html