|
System | : | Linux MiraNet 3.0.0-14-generic-pae #23-Ubuntu SMP Mon Nov 21 22:07:10 UTC 2011 i686 |
Software | : | Apache. PHP/5.3.6-13ubuntu3.10 |
ID | : | uid=65534(nobody) gid=65534(nogroup) groups=65534(nogroup)
|
|
Safe Mode | : | OFF |
Open_Basedir | : | OFF |
Freespace | : | 23.97 GB of 70.42 GB (34.03%) |
|
MySQL: ON MSSQL: OFF Oracle: OFF PostgreSQL: OFF Curl: OFF Sockets: ON Fetch: OFF Wget: ON Perl: ON |
Disabled Functions: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,
|
[ System Info ]
[ Processes ]
[ SQL Manager ]
[ Eval ]
[ Encoder ]
[ Mailer ]
[ Back Connection ]
[ Backdoor Server ]
[ Kernel Exploit Search ]
[ MD5 Decrypter ]
[ Reverse IP ]
[ Kill Shell ]
[ FTP Brute-Force ]
|
|
/
usr/
share/
pyshared/
landscape/
monitor/
- drwxr-xr-x
|
Viewing file: computerinfo.py (3.51 KB) -rw-r--r--Select action/file-type:  ( +) |  ( +) |  ( +) | Code ( +) | Session ( +) |  ( +) | SDB ( +) |  ( +) |  ( +) |  ( +) |  ( +) |  ( +) |
import logging
from landscape.lib.lsb_release import LSB_RELEASE_FILENAME, parse_lsb_release from landscape.lib.network import get_fqdn from landscape.monitor.plugin import MonitorPlugin
class DistributionInfoError(Exception): pass
class ComputerInfo(MonitorPlugin): """Plugin captures and reports basic computer information."""
persist_name = "computer-info"
def __init__(self, get_fqdn=get_fqdn, meminfo_file="/proc/meminfo", lsb_release_filename=LSB_RELEASE_FILENAME, root_path="/"): self._get_fqdn = get_fqdn self._meminfo_file = meminfo_file self._lsb_release_filename = lsb_release_filename self._root_path = root_path
def register(self, registry): super(ComputerInfo, self).register(registry) self.call_on_accepted("computer-info", self.send_computer_message, True) self.call_on_accepted("distribution-info", self.send_distribution_message, True)
def send_computer_message(self, urgent=False): message = self._create_computer_info_message() if message: message["type"] = "computer-info" logging.info("Queueing message with updated computer info.") self.registry.broker.send_message(message, urgent=urgent)
def send_distribution_message(self, urgent=False): message = self._create_distribution_info_message() if message: message["type"] = "distribution-info" logging.info("Queueing message with updated distribution info.") self.registry.broker.send_message(message, urgent=urgent)
def exchange(self, urgent=False): broker = self.registry.broker broker.call_if_accepted("computer-info", self.send_computer_message, urgent) broker.call_if_accepted("distribution-info", self.send_distribution_message, urgent)
def _create_computer_info_message(self): message = {} self._add_if_new(message, "hostname", self._get_fqdn()) total_memory, total_swap = self._get_memory_info() self._add_if_new(message, "total-memory", total_memory) self._add_if_new(message, "total-swap", total_swap) return message
def _add_if_new(self, message, key, value): if value != self._persist.get(key): self._persist.set(key, value) message[key] = value
def _create_distribution_info_message(self): message = self._get_distribution_info() if message != self._persist.get("distribution-info"): self._persist.set("distribution-info", message) return message return None
def _get_memory_info(self): """Get details in megabytes and return a C{(memory, swap)} tuple.""" message = {} file = open(self._meminfo_file) for line in file: if line != '\n': parts = line.split(":") key = parts[0] if key in ["MemTotal", "SwapTotal"]: value = int(parts[1].strip().split(" ")[0]) message[key] = value file.close() return (message["MemTotal"] // 1024, message["SwapTotal"] // 1024)
def _get_distribution_info(self): """Get details about the distribution.""" message = {} message.update(parse_lsb_release(self._lsb_release_filename)) return message
|