__  __    __   __  _____      _            _          _____ _          _ _ 
 |  \/  |   \ \ / / |  __ \    (_)          | |        / ____| |        | | |
 | \  / |_ __\ V /  | |__) | __ ___   ____ _| |_ ___  | (___ | |__   ___| | |
 | |\/| | '__|> <   |  ___/ '__| \ \ / / _` | __/ _ \  \___ \| '_ \ / _ \ | |
 | |  | | |_ / . \  | |   | |  | |\ V / (_| | ||  __/  ____) | | | |  __/ | |
 |_|  |_|_(_)_/ \_\ |_|   |_|  |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1
 if you need WebShell for Seo everyday contact me on Telegram
 Telegram Address : @jackleet
        
        
For_More_Tools: Telegram: @jackleet | Bulk Smtp support mail sender | Business Mail Collector | Mail Bouncer All Mail | Bulk Office Mail Validator | Html Letter private



Upload:

Command:

www-data@216.73.216.10: ~ $
import logging
import os
from datetime import datetime
from datetime import timedelta

from landscape.lib import sysstats
from landscape.lib.jiffies import detect_jiffies
from landscape.lib.timestamp import to_timestamp


class ProcessInformation:
    """
    @param proc_dir: The directory to use for process information.
    @param jiffies: The value to use for jiffies per second.
    @param boot_time: An alternate value to use for the last boot time.  If
        None, the system last boot time will be used.
    @param uptime: The uptime value to use (for unit tests only).
    """

    def __init__(
        self,
        proc_dir="/proc",
        jiffies=None,
        boot_time=None,
        uptime=None,
    ):
        if boot_time is None:
            boot_time = sysstats.BootTimes().get_last_boot_time()
        if boot_time is not None:
            boot_time = datetime.utcfromtimestamp(boot_time)
        self._boot_time = boot_time
        self._proc_dir = proc_dir
        self._jiffies_per_sec = jiffies or detect_jiffies()
        self._uptime = uptime

    def get_all_process_info(self):
        """Get process information for all processes on the system."""
        for filename in os.listdir(self._proc_dir):
            try:
                process_id = int(filename)
            except ValueError:
                continue
            process_info = self.get_process_info(process_id)
            if process_info:
                yield process_info

    def get_process_info(self, process_id):
        """
        Parse the /proc/<pid>/cmdline and /proc/<pid>/status files for
        information about the running process with process_id.

        The /proc filesystem doesn't behave like ext2, open files can disappear
        during the read process.
        """
        cmd_line_name = ""
        process_dir = os.path.join(self._proc_dir, str(process_id))
        process_info = {"pid": process_id}

        try:
            file = open(os.path.join(process_dir, "cmdline"), "r")
            try:
                # cmdline is a \0 separated list of strings
                # We take the first, and then strip off the path, leaving
                # us with the basename.
                cmd_line = file.readline()
                cmd_line_name = os.path.basename(cmd_line.split("\0")[0])
            finally:
                file.close()

            file = open(os.path.join(process_dir, "status"), "r")
            try:
                for line in file:
                    parts = line.split(":", 1)
                    if parts[0] == "Name":
                        process_info["name"] = (
                            cmd_line_name.strip() or parts[1].strip()
                        )
                    elif parts[0] == "State":
                        state = parts[1].strip()
                        # In Lucid, capital T is used for both tracing stop
                        # and stopped. Starting with Natty, lowercase t is
                        # used for tracing stop.
                        if state == "T (tracing stop)":
                            state = state.lower()
                        process_info["state"] = state[0].encode("ascii")
                    elif parts[0] == "Uid":
                        value_parts = parts[1].split()
                        process_info["uid"] = int(value_parts[0])
                    elif parts[0] == "Gid":
                        value_parts = parts[1].split()
                        process_info["gid"] = int(value_parts[0])
                    elif parts[0] == "VmSize":
                        value_parts = parts[1].split()
                        process_info["vm-size"] = int(value_parts[0])
                        break
            finally:
                file.close()

            file = open(os.path.join(process_dir, "stat"), "r")
            try:
                # These variable names are lifted directly from proc(5)
                # utime: The number of jiffies that this process has been
                #        scheduled in user mode.
                # stime: The number of jiffies that this process has been
                #        scheduled in kernel mode.
                # cutime: The number of jiffies that this process's waited-for
                #         children have been scheduled in user mode.
                # cstime: The number of jiffies that this process's waited-for
                #         children have been scheduled in kernel mode.
                parts = file.read().split()
                start_time = int(parts[21])
                utime = int(parts[13])
                stime = int(parts[14])
                uptime = self._uptime or sysstats.get_uptime()
                pcpu = calculate_pcpu(
                    utime,
                    stime,
                    uptime,
                    start_time,
                    self._jiffies_per_sec,
                )
                process_info["percent-cpu"] = pcpu
                delta = timedelta(0, start_time // self._jiffies_per_sec)
                if self._boot_time is None:
                    logging.warning(
                        "Skipping process (PID %s) without boot time.",
                        process_id,
                    )
                    return None
                process_info["start-time"] = to_timestamp(
                    self._boot_time + delta,
                )
            finally:
                file.close()

        except OSError:
            # Handle the race that happens when we find a process
            # which terminates before we open the stat file.
            return None

        assert (
            "pid" in process_info
            and "state" in process_info
            and "name" in process_info
            and "uid" in process_info
            and "gid" in process_info
            and "start-time" in process_info
        )
        return process_info


def calculate_pcpu(utime, stime, uptime, start_time, hertz):
    """
    Implement ps' algorithm to calculate the percentage cpu utilisation for a
    process.::

    unsigned long long total_time;   /* jiffies used by this process */
    unsigned pcpu = 0;               /* scaled %cpu, 99 means 99% */
    unsigned long long seconds;      /* seconds of process life */
    total_time = pp->utime + pp->stime;
    if(include_dead_children) total_time += (pp->cutime + pp->cstime);
    seconds = seconds_since_boot - pp->start_time / hertz;
    if(seconds) pcpu = (total_time * 100ULL / hertz) / seconds;
    if (pcpu > 99U) pcpu = 99U;
    return snprintf(outbuf, COLWID, "%2u", pcpu);
    """
    pcpu = 0
    total_time = utime + stime
    seconds = uptime - (start_time / hertz)
    if seconds:
        pcpu = total_time * 100 / hertz / seconds
    return round(max(min(pcpu, 99.0), 0), 1)

Filemanager

Name Type Size Permission Actions
__pycache__ Folder 0755
apt Folder 0755
__init__.py File 198 B 0644
amp.py File 21.87 KB 0644
backoff.py File 1.65 KB 0644
base64.py File 156 B 0644
bootstrap.py File 1.36 KB 0644
bpickle.py File 6.68 KB 0644
cli.py File 457 B 0644
cloud.py File 1.69 KB 0644
compat.py File 621 B 0644
config.py File 12.36 KB 0644
disk.py File 5.09 KB 0644
encoding.py File 545 B 0644
fd.py File 750 B 0644
fetch.py File 6.65 KB 0644
format.py File 1.96 KB 0644
fs.py File 3.8 KB 0644
gpg.py File 1.88 KB 0644
hashlib.py File 264 B 0644
jiffies.py File 1.59 KB 0644
juju.py File 828 B 0644
lock.py File 705 B 0644
log.py File 444 B 0644
logging.py File 2.94 KB 0644
machine_id.py File 1.02 KB 0644
message.py File 2.57 KB 0644
monitor.py File 6.19 KB 0644
network.py File 9.74 KB 0644
os_release.py File 1.78 KB 0644
persist.py File 20.57 KB 0644
plugin.py File 1.69 KB 0644
process.py File 6.66 KB 0644
reactor.py File 8.65 KB 0644
schema.py File 6.61 KB 0644
scriptcontent.py File 519 B 0644
sequenceranges.py File 5.58 KB 0644
store.py File 1.42 KB 0644
sysstats.py File 7.71 KB 0644
tag.py File 506 B 0644
testing.py File 24.48 KB 0644
timestamp.py File 233 B 0644
twisted_util.py File 4.54 KB 0644
user.py File 1.44 KB 0644
versioning.py File 1.25 KB 0644
vm_info.py File 3.12 KB 0644
warning.py File 393 B 0644
Filemanager