Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/services/console/interface/memphis/plugin.py
blob: 5ee8eb7edaf7116f4f6b7df3975dbd459cf849c4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
###############################################
# Memphis Plugin Support
###############################################

import sys, os
from procmem import proc, proc_smaps, analysis

class Plugin:

    # Plugin list
    list = []
    proc = proc.ProcInfo()
    
    internal_plugin = "memphis_init"
    plg_path = os.path.dirname(os.path.abspath(__file__)) + "/plugins"
    
    # Frequency timer, managed by main program
    freq_timer = 0
    
    def __init__(self):
        
        sys.path.insert(0, self.plg_path)
        
        # Including memphis plugin
        self.list.append(__import__(self.internal_plugin))
        
        if os.path.isdir(self.plg_path):
            # around dir entries
            for plg in os.listdir(self.plg_path):
                
                if plg == self.internal_plugin:
                    continue
                
                if os.path.isdir(self.plg_path + "/" + plg):
                    p = __import__(plg)
                    self.list.append(__import__(plg))
            
    # Parse /proc/PID/smaps information
    def proc_get_smaps(self, pid):
        return proc_smaps.ProcSmaps(pid)
    
    # Parse /proc/PID/maps information
    def proc_get_maps(self, pid):
        return proc_smaps.ProcMaps(pid)

    def proc_analysis(self, pid):
        return analysis.Analysis(pid)