示例#1
0
文件: rpc.py 项目: gawhelan/jsonrpc
    def handle(self):
        data = socket_read(self.request)
        request = result = error = None
        try:
            request, method, args, kwargs = \
                                self.server.protocol.unmarshall_request(data)
            result = self.server.dispatcher.dispatch(method, *args, **kwargs)
        except Error as e:
            error = e

        response = self.server.protocol.marshall_response(request,
                                                          result,
                                                          error)

        if response:
            self.request.send(response)
示例#2
0
 def _retrieve(self):
     """Query Apache Tomcat Server Status Page in XML format and return 
     the result as an ElementTree object.
     
     @return: ElementTree object of Status Page XML.
     
     """
     if self._user is not None and self._password is not None:
         url = "%s://%s:%s@%s:%d/manager/status?XML=true" % (
             self._proto, urllib.quote(self._user),
             urllib.quote(self._password), self._host, self._port)
     else:
         url = "%s://%s:%d/manager/status?XML=true" % (
             self._proto, self._host, self._port)
     fp = urllib.urlopen(url)
     response = util.socket_read(fp)
     fp.close()
     tree = ElementTree.XML(response)
     return tree
示例#3
0
文件: tomcat.py 项目: mlavin/PyMunin
 def _retrieve(self):
     """Query Apache Tomcat Server Status Page in XML format and return 
     the result as an ElementTree object.
     
     @return: ElementTree object of Status Page XML.
     
     """
     if self._user is not None and self._password is not None:
         url = "%s://%s:%s@%s:%d/manager/status?XML=true" % (self._proto,
             urllib.quote(self._user), urllib.quote(self._password), 
             self._host, self._port)
     else:
         url = "%s://%s:%d/manager/status?XML=true" % (self._proto,
              self._host, self._port)
     fp = urllib.urlopen(url)
     response = util.socket_read(fp)
     fp.close()
     tree = ElementTree.XML(response)
     return tree
示例#4
0
文件: apache.py 项目: mlavin/PyMunin
 def initStats(self):
     """Query and parse Apache Web Server Status Page."""
     if self._user is not None and self._password is not None:
         url = "%s://%s:%s@%s:%d/%s?auto" % (self._proto, 
                   urllib.quote(self._user), urllib.quote(self._password), 
                   self._host, self._port, self._statuspath)
     else:
         url = "%s://%s:%d/%s?auto"  % (self._proto, self._host, self._port, 
                                        self._statuspath)
     fp = urllib.urlopen(url)
     response = util.socket_read(fp)
     fp.close()
     self._statusDict = {}
     for line in response.splitlines():
         mobj = re.match('(\S.*\S)\s*:\s*(\S+)\s*$', line)
         if mobj:
             self._statusDict[mobj.group(1)] = util.parse_value(mobj.group(2))
     if self._statusDict.has_key('Scoreboard'):
         self._statusDict['MaxWorkers'] = len(self._statusDict['Scoreboard'])
示例#5
0
文件: phpapc.py 项目: mlavin/PyMunin
 def initStats(self):
     """Query and parse Web Server Status Page.
     
     """
     if self._user is not None and self._password is not None:
         url = "%s://%s:%s@%s:%d/%s" % (self._proto,
             urllib.quote(self._user), urllib.quote(self._password), 
             self._host, self._port, self._monpath)
     else:
         url = "%s://%s:%d/%s" % (self._proto, self._host, self._port, 
                                  self._monpath)
     fp = urllib.urlopen(url)
     response = util.socket_read(fp)
     fp.close()
     self._statusDict = {}
     for line in response.splitlines():
         cols = line.split(':')
         if not self._statusDict.has_key(cols[0]):
             self._statusDict[cols[0]] = {}
         self._statusDict[cols[0]][cols[1]] = util.parse_value(cols[2])
示例#6
0
 def initStats(self):
     """Query and parse Web Server Status Page.
     
     """
     if self._user is not None and self._password is not None:
         url = "%s://%s:%s@%s:%d/%s" % (self._proto, urllib.quote(
             self._user), urllib.quote(
                 self._password), self._host, self._port, self._monpath)
     else:
         url = "%s://%s:%d/%s" % (self._proto, self._host, self._port,
                                  self._monpath)
     fp = urllib.urlopen(url)
     response = util.socket_read(fp)
     fp.close()
     self._statusDict = {}
     for line in response.splitlines():
         cols = line.split(':')
         if not self._statusDict.has_key(cols[0]):
             self._statusDict[cols[0]] = {}
         self._statusDict[cols[0]][cols[1]] = util.parse_value(cols[2])
示例#7
0
 def getStats(self):
     """Query and parse Web Server Status Page.
     
     """
     if self._user is not None and self._password is not None:
         url = "%s://%s:%s@%s:%d/%s" % (self._proto,
             urllib.quote(self._user), urllib.quote(self._password), 
             self._host, self._port, self._monpath)
     else:
         url = "%s://%s:%d/%s" % (self._proto, self._host, self._port, 
                                  self._monpath)
     fp = urllib.urlopen(url)
     response = util.socket_read(fp)
     fp.close()
     stats = {}
     for line in response.splitlines():
         mobj = re.match('([\w\s]+):\s+(\w+)$', line)
         if mobj:
             stats[mobj.group(1)] = util.parse_value(mobj.group(2))
     return stats
示例#8
0
 def getStats(self):
     """Query and parse Web Server Status Page.
     
     """
     if self._user is not None and self._password is not None:
         url = "%s://%s:%s@%s:%d/%s" % (self._proto, urllib.quote(
             self._user), urllib.quote(
                 self._password), self._host, self._port, self._monpath)
     else:
         url = "%s://%s:%d/%s" % (self._proto, self._host, self._port,
                                  self._monpath)
     fp = urllib.urlopen(url)
     response = util.socket_read(fp)
     fp.close()
     stats = {}
     for line in response.splitlines():
         mobj = re.match('([\w\s]+):\s+(\w+)$', line)
         if mobj:
             stats[mobj.group(1)] = util.parse_value(mobj.group(2))
     return stats
示例#9
0
 def initStats(self):
     """Query and parse Apache Web Server Status Page."""
     if self._user is not None and self._password is not None:
         url = "%s://%s:%s@%s:%d/%s?auto" % (
             self._proto, urllib.quote(self._user),
             urllib.quote(
                 self._password), self._host, self._port, self._statuspath)
     else:
         url = "%s://%s:%d/%s?auto" % (self._proto, self._host, self._port,
                                       self._statuspath)
     fp = urllib.urlopen(url)
     response = util.socket_read(fp)
     fp.close()
     self._statusDict = {}
     for line in response.splitlines():
         mobj = re.match('(\S.*\S)\s*:\s*(\S+)\s*$', line)
         if mobj:
             self._statusDict[mobj.group(1)] = util.parse_value(
                 mobj.group(2))
     if self._statusDict.has_key('Scoreboard'):
         self._statusDict['MaxWorkers'] = len(
             self._statusDict['Scoreboard'])
示例#10
0
文件: nginx.py 项目: mlavin/PyMunin
 def initStats(self):
     """Query and parse Nginx Web Server Status Page."""
     if self._user is not None and self._password is not None:
         url = "%s://%s:%s@%s:%d/%s" % (self._proto,
             urllib.quote(self._user), urllib.quote(self._password), 
             self._host, self._port, self._statuspath)
     else:
         url = "%s://%s:%d/%s" % (self._proto, self._host, self._port, 
                                  self._statuspath)
     fp = urllib.urlopen(url)
     response = util.socket_read(fp)
     fp.close()
     self._statusDict = {}
     for line in response.splitlines():
         mobj = re.match('\s*(\d+)\s+(\d+)\s+(\d+)\s*$', line)
         if mobj:
             idx = 0
             for key in ('accepts','handled','requests'):
                 idx += 1
                 self._statusDict[key] = util.parse_value(mobj.group(idx))
         else:
             for (key,val) in re.findall('(\w+):\s*(\d+)', line):
                 self._statusDict[key.lower()] = util.parse_value(val)
示例#11
0
文件: rpc.py 项目: gawhelan/jsonrpc
 def send_request(self, data):
     with open_socket(self.address) as sock:
         sock.send(data)
         return socket_read(sock)