source stringclasses 1
value | repo stringlengths 5 63 | repo_url stringlengths 24 82 | path stringlengths 5 167 | language stringclasses 1
value | license stringclasses 5
values | stars int64 10 51.4k | ref stringclasses 23
values | size_bytes int64 200 258k | text stringlengths 137 258k |
|---|---|---|---|---|---|---|---|---|---|
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | osctl/lib/osctl/cli/top/view.rb | Ruby | mit | 185 | staging | 212 | module OsCtl::Cli
class Top::View
attr_reader :model, :rate
def initialize(model, rate)
@model = model
@rate = rate
end
def start
raise NotImplementedError
end
end
end |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | osctl/lib/osctl/cli/top/arcstats.rb | Ruby | mit | 185 | staging | 1,293 | module OsCtl::Cli
class Top::ArcStats
def initialize(file = '/proc/spl/kstat/zfs/arcstats')
parse(file)
end
# @param since [ArcStats, nil]
def hit_rate(since = nil)
hits = since ? @data[:hits] - since.hits : @data[:hits]
misses = since ? @data[:misses] - since.misses : @data[:misses... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | osctl/lib/osctl/cli/top/main.rb | Ruby | mit | 185 | staging | 430 | require 'osctl/cli/command'
module OsCtl::Cli
class Top::Main < Command
def start
model = Top::Model.new(enable_iostat: opts[:iostat])
model.setup
kwargs = {}
if gopts[:json]
klass = Top::JsonExporter
else
klass = Top::Tui
kwargs = { enable_procs: opts[:pr... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | osctl/lib/osctl/cli/top/container.rb | Ruby | mit | 185 | staging | 2,181 | module OsCtl::Cli
class Top::Container
NetIf = Struct.new(:name, :veth, :stats) do
def initialize(netif)
self.name = netif[:name]
self.veth = netif[:veth]
end
end
attr_reader :id, :pool, :ident, :dataset, :group_path
attr_accessor :state, :cpu_package_inuse, :init_pid, :ne... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | osctl/lib/osctl/cli/top/model.rb | Ruby | mit | 185 | staging | 5,788 | require 'libosctl'
module OsCtl::Cli
class Top::Model
MODES = %i[realtime cumulative].freeze
attr_reader :containers
attr_accessor :mode
def initialize(enable_iostat: true)
@mutex = Mutex.new
@monitor = Top::Monitor.new(self)
@iostat = enable_iostat ? OsCtl::Lib::Zfs::IOStat.new :... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | osctl/lib/osctl/cli/top/measurement.rb | Ruby | mit | 185 | staging | 3,131 | require 'libosctl'
require 'osctl/cli/cgroup_params'
module OsCtl::Cli
class Top::Measurement
class Error < StandardError; end
include CGroupParams
attr_reader :time, :data
def initialize(host, subsystems, group_path, dataset, netifs)
@host = host
@subsystems = subsystems
@group_... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | osctl/lib/osctl/cli/top/monitor.rb | Ruby | mit | 185 | staging | 3,362 | module OsCtl::Cli
class Top::Monitor
def initialize(model)
@model = model
@started = false
@buffer = []
end
def subscribe
@client = OsCtl::Client.new
client.open
ret = client.cmd_data!(:event_subscribe)
return if ret != 'subscribed'
@thread = Thread.new d... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | osctl/lib/osctl/cli/top/host.rb | Ruby | mit | 185 | staging | 3,426 | require 'osctl/cli/top/container'
require 'libosctl'
module OsCtl::Cli
class Top::Host < Top::Container
Cpu = Struct.new(
:user,
:nice,
:system,
:idle,
:iowait,
:irq,
:softirq,
:steal,
:guest,
:guest_nice
) do
attr_reader :time
def init... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | osctl/lib/osctl/cli/top/tui/process_thread.rb | Ruby | mit | 185 | staging | 1,342 | require 'libosctl'
module OsCtl::Cli::Top
class Tui::ProcessThread
def initialize(rate)
@rate = rate
@stats = empty_stats
@last_probe = nil
@queue = OsCtl::Lib::Queue.new
@mutex = Mutex.new
end
def start
@stop = false
@thread = Thread.new { work }
end
d... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | osctl/lib/osctl/cli/top/tui/main.rb | Ruby | mit | 185 | staging | 32,331 | require 'curses'
require 'libosctl'
require 'osctl/cli/top/tui/screen'
module OsCtl::Cli::Top
class Tui::Main < Tui::Screen
include OsCtl::Lib::Utils::Humanize
MIN_COLS = 75
MIN_LINES = 12
MIN_STATS_LINES = MIN_LINES + 6
class Module
attr_reader :name, :header_fmts, :header_labels, :row_f... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | osctl/lib/osctl/cli/top/tui/model_thread.rb | Ruby | mit | 185 | staging | 1,491 | require 'libosctl'
module OsCtl::Cli::Top
class Tui::ModelThread
# @return [Time, nil]
attr_reader :last_measurement
# @return [Integer]
attr_reader :generation
# @return [:realtime, :cumulative]
attr_reader :mode
def initialize(model, rate)
@model = model
@rate = rate
... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | osctl/lib/osctl/cli/top/tui/help.rb | Ruby | mit | 185 | staging | 1,544 | require 'curses'
require 'osctl/cli/top/tui/screen'
module OsCtl::Cli::Top
class Tui::Help < Tui::Screen
def initialize(main_screen)
super()
@main_screen = main_screen
end
def open
loop do
render
case Curses.getch
when 'q', '?', Tui::Key::ESCAPE
retur... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | osctl/lib/osctl/cli/ps/columns.rb | Ruby | mit | 185 | staging | 3,519 | require 'libosctl'
module OsCtl::Cli
class Ps::Columns
COLS = %i[
pool
ctid
pid
ctpid
ruid
rgid
euid
egid
ctruid
ctrgid
cteuid
ctegid
vmsize
rss
state
start
time
command
name
].freeze
DEFAUL... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | osctl/lib/osctl/cli/ps/filter.rb | Ruby | mit | 185 | staging | 2,612 | require 'libosctl'
module OsCtl::Cli
class Ps::Filter
OPERANDS = %w[=~ !~ != >= <= = > <].freeze
NUMERIC = %i[
pid
ctpid
ruid
rgid
euid
egid
ctruid
ctrgid
cteuid
ctegid
].freeze
BYTES = %i[
vmsize
rss
].freeze
TIMES = ... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | osctl/lib/osctl/cli/ps/main.rb | Ruby | mit | 185 | staging | 5,450 | require 'libosctl'
require 'tty-spinner'
module OsCtl::Cli
class Ps::Main < Command
SlowOsProcess = Struct.new(:os_process, :duration)
READ_TIMEOUT = 1
def run
param_selector = OsCtl::Lib::Cli::ParameterSelector.new(
all_params: Ps::Columns::COLS
)
if opts[:list]
puts... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | libosctl/libosctl.gemspec | Ruby | mit | 185 | staging | 928 | lib = File.expand_path('lib', __dir__)
$:.unshift(lib) unless $:.include?(lib)
require 'libosctl/version'
Gem::Specification.new do |s|
s.name = 'libosctl'
s.version = if ENV['OS_BUILD_ID']
"#{OsCtl::Lib::VERSION}.build#{ENV['OS_BUILD_ID']}"
else
OsCtl::Lib::VERSION
... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | libosctl/Rakefile | Ruby | mit | 185 | staging | 470 | require 'bundler/gem_tasks'
require 'rake/extensiontask'
require 'yard'
gemspec = Gem::Specification.load('libosctl.gemspec')
Rake::ExtensionTask.new do |ext|
ext.name = 'native'
ext.source_pattern = '*.{c,h}'
ext.ext_dir = 'ext/libosctl'
ext.lib_dir = 'lib/libosctl'
ext.gem_spec = gemspec
end
YARD::Rake::... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | libosctl/lib/libosctl.rb | Ruby | mit | 185 | staging | 232 | require 'require_all'
module OsCtl
module Lib
module Cli
module Completion; end
end
module Exporter; end
module Utils; end
module Zfs; end
end
end
require_rel 'libosctl/utils'
require_rel 'libosctl' |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | libosctl/lib/libosctl/meminfo.rb | Ruby | mit | 185 | staging | 1,009 | module OsCtl::Lib
class MemInfo
def initialize(file = '/proc/meminfo')
@content = File.read(file)
@values = {}
end
def total
read_param('MemTotal')
end
def used(without_cache = true)
total - free(without_cache)
end
def cached
read_param('Cached')
end
... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | libosctl/lib/libosctl/netif_stats.rb | Ruby | mit | 185 | staging | 1,255 | module OsCtl::Lib
class NetifStats
def initialize
@cache = {}
end
def reset
cache.clear
end
# @param netif [String]
def get_stats_for(netif)
@cache[netif] ||= {
tx: {
bytes: read_stat(netif, :tx, :bytes),
packets: read_stat(netif, :tx, :packets)
... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | libosctl/lib/libosctl/system_command_result.rb | Ruby | mit | 185 | staging | 577 | module OsCtl::Lib
class SystemCommandResult
# @return [Integer]
attr_reader :exitstatus
# @return [String]
attr_reader :output
# @param exitstatus [Integer]
# @param output [String]
def initialize(exitstatus, output)
@exitstatus = exitstatus
@output = output
end
def ... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | libosctl/lib/libosctl/index.rb | Ruby | mit | 185 | staging | 882 | module OsCtl::Lib
# Hash-based cache for collection lookups by key
#
# {Index} is not thread-safe.
class Index
# @yieldparam obj [Object] the indexed object
# @yieldreturn [String] key for the indexed object
def initialize(&block)
@block = block
@index = {}
end
# Add object to t... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | libosctl/lib/libosctl/kernel_keyring.rb | Ruby | mit | 185 | staging | 2,849 | module OsCtl::Lib
# Provides access to usage info of the kernel keyring
class KernelKeyring
# @!attribute [r] uid
# @return [Integer] User ID
# @!attribute [r] usage
# @return [Integer] Kernel-internal usage count
# @!attribute [r] nkeys
# @return [Integer] The total number of keys own... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | libosctl/lib/libosctl/logger.rb | Ruby | mit | 185 | staging | 1,179 | module OsCtl::Lib
module Logger
# @param type [Symbol] `:stdout`, `:io`, `:syslog` or `:none`
# @param opts [Hash]
# @option opts [IO] :io
# @option opts [String] :name program name for syslog
# @option opts [String] :facility syslog facility, see man syslog(3), in lower case,
# ... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | libosctl/lib/libosctl/hostname.rb | Ruby | mit | 185 | staging | 279 | module OsCtl::Lib
class Hostname
attr_reader :local, :domain, :fqdn
# @param fqdn [String]
def initialize(fqdn)
names = fqdn.split('.')
@local = names.first
@domain = names[1..].join('.')
@fqdn = fqdn
end
alias to_s fqdn
end
end |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | libosctl/lib/libosctl/cpu_mask.rb | Ruby | mit | 185 | staging | 2,703 | require 'etc'
module OsCtl::Lib
# Interface for CPU masks
class CpuMask
# @param mask [Array<Integer>]
# @return [String]
def self.format(mask)
new(mask).to_s
end
# @param mask [String, Array<Integer>]
def initialize(mask)
@cpu_list =
if mask.is_a?(String)
par... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | libosctl/lib/libosctl/os_process.rb | Ruby | mit | 185 | staging | 6,325 | require_relative 'sys_conf'
module OsCtl::Lib
# Interface to system processes, reading information from `/proc`
class OsProcess
TICS_PER_SECOND = SysConf.tics_per_second
PAGE_SIZE = SysConf.page_size
def self.system_start_time
@system_start_time ||= Time.now - File.read('/proc/uptime').strip.spl... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | libosctl/lib/libosctl/exceptions.rb | Ruby | mit | 185 | staging | 665 | module OsCtl::Lib
module Exceptions
class SystemCommandFailed < StandardError
attr_reader :cmd, :rc, :output
def initialize(cmd, rc, output)
@cmd = cmd
@rc = rc
@output = output
super("command '#{cmd}' exited with code '#{rc}', output: '#{output}'")
end
end
... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | libosctl/lib/libosctl/mutex.rb | Ruby | mit | 185 | staging | 2,503 | module OsCtl::Lib
# Extended mutex with an optional timeout on lock
class Mutex
class Timeout < ::StandardError; end
def initialize
@mutex = ::Mutex.new
@cond = ConditionVariable.new
@thread = nil
@queue = 0
end
# Attempts to grab the lock and waits if it isn't available
... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | libosctl/lib/libosctl/sys_conf.rb | Ruby | mit | 185 | staging | 732 | require 'etc'
require 'singleton'
module OsCtl::Lib
class SysConf
include Singleton
VALUES = %i[page_size tics_per_second].freeze
class << self
VALUES.each do |v|
define_method(v) { instance.send(v) }
end
end
def initialize
@values = {}
end
# @param name [Sym... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | libosctl/lib/libosctl/queue.rb | Ruby | mit | 185 | staging | 1,688 | module OsCtl::Lib
# Replacement for stock Queue
class Queue
def initialize
@mutex = ::Mutex.new
@cond = ConditionVariable.new
@queue = []
end
# Add value into queue
def push(v)
sync do
@queue << v
@cond.signal
end
end
alias << push
# Inser... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | libosctl/lib/libosctl/string_escape.rb | Ruby | mit | 185 | staging | 1,366 | module OsCtl::Lib
module StringEscape
# Escape path so that it can be used as a file name
#
# Alphanumeric characters and ";" ":" are kept as is, while all other
# characters are replaced by C-style escape sequences.
#
# @param path [String]
# @return [String]
def self.escape_path(path... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | libosctl/lib/libosctl/cgroup.rb | Ruby | mit | 185 | staging | 442 | module OsCtl::Lib
module CGroup
FS = '/sys/fs/cgroup'.freeze
# @return [1, 2] cgroup hierarchy version
def self.version
return @version if @version
@version = if File.exist?(File.join(FS, 'cgroup.procs'))
2
else
1
end
... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | libosctl/lib/libosctl/process_list.rb | Ruby | mit | 185 | staging | 994 | module OsCtl::Lib
class ProcessList < Array
# Iterate over all processes
# @param opts [Hash] options passed to {OsProcess}
# @yieldparam [OsProcess] process
def self.each(**opts, &block)
new(**opts) do |p|
block.call(p)
next(false)
end
nil
end
# Create an a... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | libosctl/lib/libosctl/cpu_topology.rb | Ruby | mit | 185 | staging | 1,460 | module OsCtl::Lib
class CpuTopology
# @!attribute [r] id
# @return [Integer] Package ID
# @!attribute [r] cpus
# @return [Hash<Integer, Cpu>]
Package = Struct.new(:id, :cpus, keyword_init: true)
# @!attribute [r] id
# @return [Integer] CPU ID
# @!attribute [r] package_id
# ... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | libosctl/lib/libosctl/uptime.rb | Ruby | mit | 185 | staging | 523 | module OsCtl::Lib
# Read `/proc/uptime`
class Uptime
# @return [Float] uptime in seconds
attr_reader :uptime
# @return [Float] idle time in seconds
attr_reader :idle_time
# @return [Time] time of boot
attr_reader :booted_at
def initialize(path: '/proc/uptime')
parse(path)
en... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | libosctl/lib/libosctl/config_file.rb | Ruby | mit | 185 | staging | 508 | require 'yaml'
module OsCtl::Lib
module ConfigFile
# Safely load YAML file
# @param filename [String]
def self.load_yaml_file(filename)
File.open(filename, 'r:bom|utf-8') do |f|
YAML.safe_load(f, filename:)
end
end
# Safely load YAML from string
# @param string [String]
... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | libosctl/lib/libosctl/id_map.rb | Ruby | mit | 185 | staging | 2,364 | module OsCtl::Lib
# {IdMap} represents ID mappings for user namespaces, be it user or group IDs
class IdMap
Entry = Struct.new(:ns_id, :host_id, :id_count) do
def self.from_string(str, separator: ':')
ns_id, host_id, cnt = str.split(separator)
Entry.new(ns_id.to_i, host_id.to_i, cnt.to_i)
... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | libosctl/lib/libosctl/loadavg.rb | Ruby | mit | 185 | staging | 868 | module OsCtl::Lib
# Read system load average from /proc/loadavg, see man proc(5)
class LoadAvg
# @return [Hash<1, 5, 15>] load averages
attr_reader :avg
# @return [Integer]
attr_reader :runnable
# @return [Integer]
attr_reader :total
# @return [Integer]
attr_reader :last_pid
... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | libosctl/lib/libosctl/loadavg_reader.rb | Ruby | mit | 185 | staging | 2,207 | module OsCtl::Lib
# Returns per-container load averages
class LoadAvgReader
# This file contains a list of load averages from first-level cgroup namespaces
#
# Available only on vpsAdminOS
FILE = '/proc/vpsadminos/loadavg'.freeze
LoadAvg = Struct.new(:pool_name, :ctid, :avg, :runnable, :total) ... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | libosctl/lib/libosctl/sys.rb | Ruby | mit | 185 | staging | 4,752 | require 'fiddle'
require 'fiddle/import'
require 'tempfile'
require 'libosctl/native'
module OsCtl::Lib
class Sys
CLONE_NEWNS = 0x00020000
CLONE_NEWUTS = 0x04000000
CLONE_NEWUSER = 0x10000000
CLONE_NEWPID = 0x20000000
CLONE_NEWNET = 0x40000000
CLONE_NEWIPC = 0x08000000
MS_MGC_VAL = 0xc0e... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | libosctl/lib/libosctl/pid_finder.rb | Ruby | mit | 185 | staging | 511 | module OsCtl::Lib
# Locate containers by process IDs from the host
class PidFinder
Result = Struct.new(:pool, :ctid, :os_process)
# @param pid [Integer] process ID from the host
# @return [Result, nil]
def find(pid)
os_proc = OsProcess.new(pid)
ctid = os_proc.ct_id
if ctid.nil?
... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | libosctl/lib/libosctl/exporter/base.rb | Ruby | mit | 185 | staging | 4,336 | require 'rubygems'
require 'rubygems/package'
require 'zlib'
module OsCtl::Lib
# Handles dumping containers into tar archives
#
# This base class can dump only archive metadata and config files.
# To export the container's rootfs, use either {Exporter::Zfs} or
# {Exporter::Tar}.
class Exporter::Base
BL... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | libosctl/lib/libosctl/exporter/zfs.rb | Ruby | mit | 185 | staging | 4,925 | require 'libosctl/exporter/base'
module OsCtl::Lib
# Handles dumping containers as ZFS streams into tar archives
#
# Usage:
#
# exporter.dump_rootfs do
# # Create a snapshot a dump it
# exporter.dump_base
#
# # Create another snapshot and dump it as an incremental stream
# # from ... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | libosctl/lib/libosctl/exporter/tar.rb | Ruby | mit | 185 | staging | 694 | require 'libosctl/exporter/base'
module OsCtl::Lib
# Handles dumping containers into tar archives
#
# The container's rootfs is stored as a compressed tar archive.
class Exporter::Tar < Exporter::Base
include Utils::Log
include Utils::System
def pack_rootfs
tar.mkdir('rootfs', DIR_MODE)
... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | libosctl/lib/libosctl/utils/exception.rb | Ruby | mit | 185 | staging | 379 | module OsCtl::Lib
module Utils::Exception
# Return a new backtrace with removed `/nix/store/...` prefixes
# @param backtrace [Array<String>]
# @return [Array<String>]
def denixstorify(backtrace)
backtrace.map do |line|
line.sub(
%r{^/nix/store/[^/]+/lib/ruby/gems/\d+\.\d+\.\d+/... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | libosctl/lib/libosctl/utils/migration.rb | Ruby | mit | 185 | staging | 385 | module OsCtl::Lib
module Utils::Send
def send_ssh_cmd(key_chain, m_opts, cmd)
ret = [
'ssh',
'-o', 'StrictHostKeyChecking=no',
'-T',
'-p', m_opts[:port].to_s
]
ret.push('-i', key_chain.private_key_path) if key_chain
ret.push(
'-l', 'osctl-ct-receiv... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | libosctl/lib/libosctl/utils/file.rb | Ruby | mit | 185 | staging | 954 | require 'securerandom'
module OsCtl::Lib
module Utils::File
def regenerate_file(path, mode)
replacement = "#{path}.new-#{SecureRandom.hex(3)}"
File.open(replacement, 'w', mode) do |new|
if File.exist?(path)
File.open(path, 'r') do |old|
yield(new, old)
end
... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | libosctl/lib/libosctl/utils/system.rb | Ruby | mit | 185 | staging | 3,315 | require 'timeout'
module OsCtl::Lib
module Utils::System
include Timeout
# @param cmd [String]
# @param opts [Hash]
# @option opts [Array<Integer>, :all] :valid_rcs valid exit codes
# @option opts [Boolean] :stderr include stderr in output?
# @option opts [Integer] :timeout in seconds
# ... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | libosctl/lib/libosctl/utils/humanize.rb | Ruby | mit | 185 | staging | 2,342 | module OsCtl::Lib
module Utils::Humanize
def humanize_data(v)
bits = 39
units = %i[T G M K]
units.each do |u|
threshold = 2 << bits
if v >= threshold
division = v / threshold.to_f
return "#{division.round}#{u}" if division >= 1000
return "#{divis... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | libosctl/lib/libosctl/utils/log.rb | Ruby | mit | 185 | staging | 1,516 | module OsCtl::Lib
module Utils::Log
module PrivateMethods
LEVELS = %i[debug info warn error fatal unknown].freeze
def self.log(level, type, msg)
Logger.log(
LEVELS.include?(level) ? level : :unknown,
"[#{type}] #{msg}"
)
end
def self.resolve_type(type)... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | libosctl/lib/libosctl/cli/output_formatter.rb | Ruby | mit | 185 | staging | 6,583 | require 'rainbow'
module OsCtl::Lib::Cli
# Format and print data in column or row view
class OutputFormatter
# Format data and return as string
# @return [String]
def self.to_s(*, **)
f = new(*, **)
f.to_s
end
# Format data and print to standard output
def self.print(*, **)
... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | libosctl/lib/libosctl/cli/command.rb | Ruby | mit | 185 | staging | 1,171 | module OsCtl::Lib
# Utilities for command handlers in CLI
class Cli::Command
attr_reader :gopts, :opts, :args
def initialize(global_opts, opts, args)
@gopts = global_opts
@opts = opts
@args = args
end
protected
# @param required [Array] list of required arguments
# @para... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | libosctl/lib/libosctl/cli/presentable.rb | Ruby | mit | 185 | staging | 1,830 | module OsCtl::Lib
# Container for values that should be treated and presented differently
#
# {Cli::Presentable} is used for {Cli::OutputFormatter}, so that values
# are sorted by their precise representation, but presented as a formatted
# string, whose sorting would yield incorrect results.
#
# The form... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | libosctl/lib/libosctl/cli/parameter_selector.rb | Ruby | mit | 185 | staging | 1,896 | module OsCtl::Lib
# Process output parameters for CLI options -o, --output and -L
class Cli::ParameterSelector
# @param all_params [Array<Symbol>] list of all possible parameters
# @param default_params [Array<Symbol>, nil] list of default parameters
# @param allow_user_attributes [Boolean] allow custom... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | libosctl/lib/libosctl/cli/completion/bash.rb | Ruby | mit | 185 | staging | 4,703 | require 'erb'
module OsCtl::Lib
class Cli::Completion::Bash
class OptArg
attr_reader :cmd, :name, :expand
# @param opts [Hash]
# @option opts [:all, Array<Symbol>] :cmd
# @option opts [Symbol] :name
# @option opts [String] :expand
def initialize(opts)
@cmd = if opts[:... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | libosctl/lib/libosctl/cgroup/path_reader.rb | Ruby | mit | 185 | staging | 12,776 | module OsCtl::Lib
# Version-agnostic interface for reading CGroup parameters
class CGroup::PathReader
class Base
include Utils::Humanize
def initialize
@cache = {}
end
def read_stats
@cpu_limit = nil
@memory_limit = nil
@memory_usage = nil
yield
... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | libosctl/lib/libosctl/zfs/stream.rb | Ruby | mit | 185 | staging | 8,532 | require 'shellwords'
module OsCtl::Lib
# Control class for ZFS send invocation.
#
# {Zfs::Stream} uses the `-v` flag of zfs send to monitor how the transfer
# progresses. The following output from zfs send is parsed:
#
# send from <snap1> to <snap2> estimated size is <n><unit>
# send from <snap2> to ... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | libosctl/lib/libosctl/zfs/property_state.rb | Ruby | mit | 185 | staging | 1,230 | module OsCtl::Lib
# Store a set of configured ZFS properties, then apply it to another dataset
class Zfs::PropertyState
include Utils::Log
include Utils::System
# @return [Hash]
attr_reader :properties
# @return [Hash]
attr_reader :options
def initialize
@properties = {}
@... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | libosctl/lib/libosctl/zfs/dataset_tree.rb | Ruby | mit | 185 | staging | 2,050 | module OsCtl::Lib
# Encapsulates a tree of datasets and their properties
class Zfs::DatasetTree
# @return [String, nil] full name
attr_reader :name
# @return [Hash<String, String>]
attr_reader :properties
# @return [Hash<String, Zfs::DatasetTree>]
attr_reader :datasets
# @param name [... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | libosctl/lib/libosctl/zfs/dataset_cache.rb | Ruby | mit | 185 | staging | 414 | module OsCtl::Lib
class Zfs::DatasetCache
# @param datasets [Array<Zfs::Dataset>]
def initialize(datasets)
@index = {}
rebuild_index(datasets)
end
# @param name [String]
# @return [Zfs::Dataset, nil]
def [](name)
@index[name]
end
protected
def rebuild_index(dat... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | libosctl/lib/libosctl/zfs/zpool_transaction_groups.rb | Ruby | mit | 185 | staging | 5,239 | module OsCtl::Lib
# Read interface to /proc/spl/kstat/zfs/<pool>/txgs
class Zfs::ZpoolTransactionGroups
PROC_PATH = '/proc/spl/kstat/zfs'.freeze
STATES = {
'B' => :birth,
'O' => :open,
'Q' => :quiesced,
'W' => :wait_for_sync,
'S' => :synced,
'C' => :committed,
'?' ... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | libosctl/lib/libosctl/zfs/objset_stats.rb | Ruby | mit | 185 | staging | 302 | module OsCtl::Lib
module Zfs::ObjsetStats
def self.read_pools(pools)
tree = Zfs::ObjsetStats::Tree.new
pools.each { |pool| tree << read_pool(pool) }
tree
end
def self.read_pool(pool)
parser = Zfs::ObjsetStats::Parser.new
parser.read(pool)
end
end
end |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | libosctl/lib/libosctl/zfs/zpool_status.rb | Ruby | mit | 185 | staging | 5,462 | module OsCtl::Lib
# Read interface to zpool status
class Zfs::ZpoolStatus
# @!attribute [r] name
# @return [String] pool name
# @!attribute [r] state
# @return [:online, :degraded, :suspended, :faulted] pool state
# @!attribute [r] scan
# @return [:none, :scrub, :resilver] active scan ... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | libosctl/lib/libosctl/zfs/dataset.rb | Ruby | mit | 185 | staging | 7,887 | module OsCtl::Lib
# Class representing a single ZFS dataset
class Zfs::Dataset
include Utils::Log
include Utils::System
# Full dataset name
# @return [String]
attr_reader :name
# Zpool name
# @return [String]
attr_reader :pool
# Dataset properties, only loaded properties are p... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | libosctl/lib/libosctl/zfs/iostat.rb | Ruby | mit | 185 | staging | 3,692 | module OsCtl::Lib
class Zfs::IOStat
PoolStats = Struct.new(
:pool,
:alloc,
:free,
:io_read,
:io_written,
:bytes_read,
:bytes_written
) do
def <<(other)
self.alloc = nil
self.free = nil
self.io_read += other.io_read
self.io_written... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | libosctl/lib/libosctl/zfs/snapshot.rb | Ruby | mit | 185 | staging | 496 | module OsCtl::Lib
# Class representing a single ZFS snapshot
class Zfs::Snapshot
# @return [Zfs::Dataset]
attr_reader :dataset
# @return [Hash]
attr_reader :properties
# @param dataset [Zfs::Dataset]
# @param name [String]
def initialize(dataset, name)
@dataset = dataset
@n... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | libosctl/lib/libosctl/zfs/property_reader.rb | Ruby | mit | 185 | staging | 1,051 | module OsCtl::Lib
# Read selected dataset properties into {Zfs::DatasetTree}
class Zfs::PropertyReader
include Utils::Log
include Utils::System
# @param dataset_names [Array<String>]
# @param properties [Array<String>]
# @param type [String]
# @param recursive [Boolean]
# @param ignore_... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | libosctl/lib/libosctl/zfs/objset_stats/tree.rb | Ruby | mit | 185 | staging | 653 | module OsCtl::Lib
class Zfs::ObjsetStats::Tree
def initialize
@pool_trees = {}
end
# @param pool_tree [Zfs::ObjsetStats::PoolTree]
def <<(pool_tree)
@pool_trees[pool_tree.pool] = pool_tree
end
# @param dataset [String]
def [](dataset)
pool = dataset.split('/').first
... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | libosctl/lib/libosctl/zfs/objset_stats/objset.rb | Ruby | mit | 185 | staging | 1,237 | module OsCtl::Lib
class Zfs::ObjsetStats::Objset
AggregatedStats = Struct.new(
:write_ios,
:write_bytes,
:read_ios,
:read_bytes
)
attr_accessor :dataset_name, :write_ios, :write_bytes, :read_ios, :read_bytes
attr_reader :subdatasets
def initialize
@write_ios = 0
... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | libosctl/lib/libosctl/zfs/objset_stats/parser.rb | Ruby | mit | 185 | staging | 1,256 | module OsCtl::Lib
class Zfs::ObjsetStats::Parser
# @param pool [String]
# @return [Zfs::ObjsetStats::PoolTree]
def read(pool)
tree = Zfs::ObjsetStats::PoolTree.new(pool)
Dir.glob(File.join('/proc/spl/kstat/zfs', pool, 'objset-*')).each do |f|
objset = parse_objset(f)
tree << o... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | libosctl/lib/libosctl/zfs/objset_stats/pool_tree.rb | Ruby | mit | 185 | staging | 1,327 | module OsCtl::Lib
class Zfs::ObjsetStats::PoolTree
attr_reader :pool, :root
# @param pool [String]
def initialize(pool)
@pool = pool
@list = []
@index = {}
@root = nil
end
# @param objset [Zfs::ObjsetStats::Objset]
def <<(objset)
@list << objset
@index[obj... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | libosctl/spec/spec_helper.rb | Ruby | mit | 185 | staging | 757 | # frozen_string_literal: true
require 'rspec'
require 'fileutils'
require 'tmpdir'
require 'stringio'
require 'json'
REPO_ROOT = File.expand_path('../..', __dir__)
$:.unshift(File.join(REPO_ROOT, 'libosctl', 'lib'))
require 'libosctl/version'
require_relative 'support/namespace_bootstrap'
module GLI
class BadComm... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | libosctl/spec/support/archive_helpers.rb | Ruby | mit | 185 | staging | 785 | # frozen_string_literal: true
require 'rubygems/package'
require 'stringio'
require 'zlib'
module ArchiveHelpers
def tar_entries(blob)
io = blob.is_a?(String) ? StringIO.new(blob) : blob
io.rewind if io.respond_to?(:rewind)
entries = {}
Gem::Package::TarReader.new(io) do |tar|
tar.each do |e... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | libosctl/spec/support/fake_sysfs_helpers.rb | Ruby | mit | 185 | staging | 310 | # frozen_string_literal: true
module FakeSysfsHelpers
def write_sysfs_file(root, relative_path, contents)
path = File.join(root, relative_path)
FileUtils.mkdir_p(File.dirname(path))
File.write(path, contents)
path
end
end
RSpec.configure do |config|
config.include FakeSysfsHelpers
end |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | libosctl/spec/support/fake_cli_completion_helpers.rb | Ruby | mit | 185 | staging | 605 | # frozen_string_literal: true
module FakeCliCompletionHelpers
FakeSwitch = Struct.new(:forms) do
def arguments_for_option_parser
forms
end
end
FakeFlag = Struct.new(:forms, :must_match) do
def all_forms(_sep)
forms.join(', ')
end
end
FakeCommand = Struct.new(
:name,
:des... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | libosctl/spec/support/fake_proc_helpers.rb | Ruby | mit | 185 | staging | 434 | # frozen_string_literal: true
module FakeProcHelpers
def proc_dir(root, pid)
path = File.join(root, pid.to_s)
FileUtils.mkdir_p(path)
path
end
def write_proc_file(root, pid, relative_path, contents)
path = File.join(proc_dir(root, pid), relative_path)
FileUtils.mkdir_p(File.dirname(path))
... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | libosctl/spec/support/reset_state_helpers.rb | Ruby | mit | 185 | staging | 286 | # frozen_string_literal: true
module ResetStateHelpers
def reset_module_ivars(mod, *ivars)
ivars.each do |ivar|
mod.remove_instance_variable(ivar) if mod.instance_variable_defined?(ivar)
end
end
end
RSpec.configure do |config|
config.include ResetStateHelpers
end |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | libosctl/spec/support/fake_exporter_helpers.rb | Ruby | mit | 185 | staging | 975 | # frozen_string_literal: true
require 'fileutils'
module FakeExporterHelpers
FakeUser = Struct.new(:name, :config_path, keyword_init: true)
FakeGroup = Struct.new(:name, :config_path, keyword_init: true)
FakeHookScript = Struct.new(:abs_path, :rel_path, keyword_init: true)
FakeContainer = Struct.new(
:id,... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | libosctl/spec/support/command_helpers.rb | Ruby | mit | 185 | staging | 236 | # frozen_string_literal: true
module CommandHelpers
def command_result(exitstatus: 0, output: '')
OsCtl::Lib::SystemCommandResult.new(exitstatus, output)
end
end
RSpec.configure do |config|
config.include CommandHelpers
end |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | libosctl/spec/support/namespace_bootstrap.rb | Ruby | mit | 185 | staging | 264 | # frozen_string_literal: true
module OsCtl
module Lib
module Cli
module Completion; end
end
module Exporter; end
module Utils; end
module Zfs; end
module CGroup; end
end
end
module OsCtl::Lib::Zfs
module ObjsetStats; end
end |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | libosctl/spec/libosctl/string_escape_spec.rb | Ruby | mit | 185 | staging | 680 | # frozen_string_literal: true
require 'spec_helper'
require 'libosctl/string_escape'
RSpec.describe OsCtl::Lib::StringEscape do
it 'escapes the root path' do
expect(described_class.escape_path('/')).to eq('-')
expect(described_class.unescape_path('-')).to eq('/')
end
it 'strips leading slashes and repl... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | libosctl/spec/libosctl/cpu_mask_spec.rb | Ruby | mit | 185 | staging | 975 | # frozen_string_literal: true
require 'spec_helper'
require 'libosctl/cpu_mask'
RSpec.describe OsCtl::Lib::CpuMask do
it 'parses lists and ranges and exposes enumerable helpers' do
mask = described_class.new('0,2-4')
expect(mask).to include(3)
expect(mask).not_to include(1)
expect(mask.size).to eq(... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | libosctl/spec/libosctl/loadavg_spec.rb | Ruby | mit | 185 | staging | 612 | # frozen_string_literal: true
require 'spec_helper'
require 'libosctl/loadavg'
RSpec.describe OsCtl::Lib::LoadAvg do
it 'parses averages, runnable tasks, total tasks, and the last pid' do
with_tmpdir do |dir|
path = File.join(dir, 'loadavg')
File.write(path, "0.10 1.20 2.30 3/99 1234\n")
load... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | libosctl/spec/libosctl/sys_conf_spec.rb | Ruby | mit | 185 | staging | 1,093 | # frozen_string_literal: true
require 'spec_helper'
require 'libosctl/sys_conf'
RSpec.describe OsCtl::Lib::SysConf do
around do |example|
reset_module_ivars(described_class.instance, :@values)
described_class.instance.send(:initialize)
example.run
reset_module_ivars(described_class.instance, :@value... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | libosctl/spec/libosctl/process_list_spec.rb | Ruby | mit | 185 | staging | 1,512 | # frozen_string_literal: true
require 'spec_helper'
require 'libosctl/exceptions'
require 'libosctl/process_list'
RSpec.describe OsCtl::Lib::ProcessList do
let(:host_process) { instance_double(OsCtl::Lib::OsProcess, pid: 100) }
let(:other_process) { instance_double(OsCtl::Lib::OsProcess, pid: 300) }
before do
... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | libosctl/spec/libosctl/exceptions_spec.rb | Ruby | mit | 185 | staging | 1,107 | # frozen_string_literal: true
require 'spec_helper'
require 'libosctl/exceptions'
RSpec.describe OsCtl::Lib::Exceptions do
describe OsCtl::Lib::Exceptions::SystemCommandFailed do
it 'stores the command context in attributes and message' do
error = described_class.new('zfs list', 3, 'boom')
expect(e... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | libosctl/spec/libosctl/queue_spec.rb | Ruby | mit | 185 | staging | 958 | # frozen_string_literal: true
require 'spec_helper'
require 'libosctl/queue'
RSpec.describe OsCtl::Lib::Queue do
it 'pushes, prepends, and exposes queue contents' do
queue = described_class.new
queue.push(1)
queue << 2
queue.insert(0)
expect(queue.to_a).to eq([0, 1, 2])
expect(queue.length... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | libosctl/spec/libosctl/pid_finder_spec.rb | Ruby | mit | 185 | staging | 1,090 | # frozen_string_literal: true
require 'spec_helper'
require 'libosctl/exceptions'
require 'libosctl/pid_finder'
RSpec.describe OsCtl::Lib::PidFinder do
it 'returns host and container results depending on the process cgroup' do
host_process = instance_double(OsCtl::Lib::OsProcess, ct_id: nil)
ct_process = in... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | libosctl/spec/libosctl/logger_spec.rb | Ruby | mit | 185 | staging | 1,563 | # frozen_string_literal: true
require 'spec_helper'
require 'libosctl/logger'
RSpec.describe OsCtl::Lib::Logger do
before do
described_class.instance_variable_set(:@logger, nil)
end
it 'sets up a stdout logger and exposes it with get' do
output = capture_stdout do
described_class.setup(:stdout)
... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | libosctl/spec/libosctl/kernel_keyring_spec.rb | Ruby | mit | 185 | staging | 1,288 | # frozen_string_literal: true
require 'spec_helper'
require 'libosctl/id_map'
require 'libosctl/kernel_keyring'
RSpec.describe OsCtl::Lib::KernelKeyring do
it 'parses key users, filters by uid and id maps, sorts entries, and reads system limits' do
with_tmpdir do |dir|
key_users = File.join(dir, 'key-user... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | libosctl/spec/libosctl/os_process_spec.rb | Ruby | mit | 185 | staging | 4,053 | # frozen_string_literal: true
require 'spec_helper'
require 'libosctl/exceptions'
require 'libosctl/id_map'
require 'libosctl/os_process'
RSpec.describe OsCtl::Lib::OsProcess do
def build_process(root, pid)
process = described_class.new(pid, parse_stat: false, parse_status: false)
process.instance_variable_... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | libosctl/spec/libosctl/id_map_spec.rb | Ruby | mit | 185 | staging | 1,373 | # frozen_string_literal: true
require 'spec_helper'
require 'libosctl/exceptions'
require 'libosctl/id_map'
RSpec.describe OsCtl::Lib::IdMap do
it 'builds mappings from strings and hashes and performs lookups' do
string_map = described_class.from_string_list(['0:100_000:10', '20:200_000:5'])
hash_map = desc... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | libosctl/spec/libosctl/config_file_spec.rb | Ruby | mit | 185 | staging | 1,115 | # frozen_string_literal: true
require 'spec_helper'
require 'libosctl/config_file'
RSpec.describe OsCtl::Lib::ConfigFile do
describe '.load_yaml' do
it 'loads YAML from a string' do
expect(described_class.load_yaml("---\nfoo: bar\nnested:\n baz: 1\n")).to eq(
'foo' => 'bar',
'nested' => {... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | libosctl/spec/libosctl/system_command_result_spec.rb | Ruby | mit | 185 | staging | 759 | # frozen_string_literal: true
require 'spec_helper'
require 'libosctl/system_command_result'
RSpec.describe OsCtl::Lib::SystemCommandResult do
it 'reports success and exposes exit status and output' do
result = described_class.new(0, 'ok')
expect(result).to be_success
expect(result).not_to be_error
... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | libosctl/spec/libosctl/sys_spec.rb | Ruby | mit | 185 | staging | 7,410 | # frozen_string_literal: true
require 'spec_helper'
require 'libosctl/sys'
RSpec.describe OsCtl::Lib::Sys do
subject(:sys) { described_class.new }
def invoke(method_name, positional_args, keyword_args)
if keyword_args.empty?
sys.public_send(method_name, *positional_args)
else
sys.public_send(... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | libosctl/spec/libosctl/uptime_spec.rb | Ruby | mit | 185 | staging | 589 | # frozen_string_literal: true
require 'spec_helper'
require 'libosctl/uptime'
RSpec.describe OsCtl::Lib::Uptime do
it 'parses uptime and derives the boot time from Time.now' do
with_tmpdir do |dir|
path = File.join(dir, 'uptime')
File.write(path, "120.5 456.75\n")
now = Time.at(1_000)
a... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | libosctl/spec/libosctl/bootstrap_spec.rb | Ruby | mit | 185 | staging | 652 | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe OsCtl::Lib do
it 'loads the full library and remaining entrypoints' do
expect { require 'libosctl' }.not_to raise_error
expect(OsCtl::Lib::VERSION).to be_a(String)
expect(OsCtl::Lib::Sys).to be_a(Class)
expect(OsCtl::Lib::Exporter::B... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | libosctl/spec/libosctl/meminfo_spec.rb | Ruby | mit | 185 | staging | 1,219 | # frozen_string_literal: true
require 'spec_helper'
require 'libosctl/meminfo'
RSpec.describe OsCtl::Lib::MemInfo do
it 'parses memory and swap values and caches parsed entries' do
with_tmpdir do |dir|
path = File.join(dir, 'meminfo')
File.write(path, <<~MEMINFO)
MemTotal: 4096 kB
... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | libosctl/spec/libosctl/mutex_spec.rb | Ruby | mit | 185 | staging | 1,810 | # frozen_string_literal: true
require 'spec_helper'
require 'libosctl/mutex'
RSpec.describe OsCtl::Lib::Mutex do
it 'locks, unlocks, and reports ownership' do
mutex = described_class.new
mutex.lock
expect(mutex).to be_locked
expect(mutex).to be_owned
mutex.unlock
expect(mutex).not_to be_l... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.