예제 #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
파일: phpfpm.py 프로젝트: tehstone/PyMunin
 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)