Beispiel #1
0
    def get_status(self):
        status = super().get_status()

        # Usage
        page = self._browser.open(status.clientarea.url)
        matches = re.findall(
            r'([\d.]+) (KB|MB|GB|TB) of ([\d.]+) (KB|MB|GB|TB) Used',
            page.text)
        usage = (
            self._convert_gigabyte(matches[1][0],
                                   matches[1][1]),  # Memory used
            self._convert_gigabyte(matches[1][2],
                                   matches[1][3]),  # Memory total
            self._convert_gigabyte(matches[0][0],
                                   matches[0][1]),  # Storage used
            self._convert_gigabyte(matches[0][2],
                                   matches[0][3]),  # Storage total
            self._convert_gigabyte(matches[2][0],
                                   matches[2][1]),  # Bandwidth used
            self._convert_gigabyte(matches[2][2],
                                   matches[2][3])  # Bandwidth total
        )

        memory = VpsStatusResource(usage[0], usage[1])
        storage = VpsStatusResource(usage[2], usage[3])
        bandwidth = VpsStatusResource(usage[4], usage[5])

        # return status
        return VpsStatus(memory, storage, bandwidth, status.online,
                         status.expiration, status.clientarea)
Beispiel #2
0
    def get_status(self):
        status = super().get_status()

        # Get server stats
        page = self._browser.open('{}&api=json&act=vpsmanage&stats=1'.format(
            status.clientarea.url))
        data = page.json()

        memory = VpsStatusResource(
            self._convert_mb_to_gb(data['info']['ram']['used']),
            self._convert_mb_to_gb(data['info']['ram']['limit']))
        storage = VpsStatusResource(data['info']['disk']['used_gb'],
                                    data['info']['disk']['limit_gb'])
        bandwidth = VpsStatusResource(data['info']['bandwidth']['used_gb'],
                                      data['info']['bandwidth']['limit_gb'])

        return VpsStatus(memory, storage, bandwidth, status.online,
                         status.expiration, status.clientarea)
Beispiel #3
0
    def get_status(self):
        status = super().get_status()

        # Retrieve the vserverid
        page = self._browser.open(status.clientarea.url)
        match = re.search(r'vserverid = (\d+)', page.text)
        identifier = match.group(1)

        millis = int(round(time.time() * 1000))  # Needed for some reason
        page = self._browser.open('{}?vserverid={}&_={}'.format(self.CLIENT_DATA_URL, identifier, millis))
        data = page.json()

        memory = VpsStatusResource(self._convert_gigabyte(data['memoryused']),
                                   self._convert_gigabyte(data['memorytotal']))
        storage = VpsStatusResource(self._convert_gigabyte(data['hddused']), self._convert_gigabyte(data['hddtotal']))
        bandwidth = VpsStatusResource(self._convert_gigabyte(data['bandwidthused']),
                                      self._convert_gigabyte(data['bandwidthtotal']))

        return VpsStatus(memory, storage, bandwidth, status.online, status.expiration, status.clientarea)
Beispiel #4
0
    def get_status(self):
        status = super().get_status()

        service_id = status.clientarea.url.split('=')[-1]
        data = self._browser.post(
            url=
            'https://ua.2sync.org/modules/servers/tProxmox/monitorProxmox.php',
            data={
                'serviceid': service_id,
                'typeVm': 'qemu'
            }).json()

        memory = VpsStatusResource(
            self._convert_bytes_to_gbytes(data['mem']),
            self._convert_bytes_to_gbytes(data['maxmem']))
        storage = VpsStatusResource(
            self._convert_bytes_to_gbytes(data['freemem']),
            self._convert_bytes_to_gbytes(data['maxdisk']))
        bandwidth = VpsStatusResource(float('inf'), float('inf'))

        return VpsStatus(memory, storage, bandwidth, status.online,
                         status.expiration, status.clientarea)