linux_stat 2.1.2 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +54 -1052
- data/exe/linuxstat.rb +148 -98
- data/ext/fs_stat/disk_stat.h +25 -0
- data/ext/fs_stat/extconf.rb +2 -1
- data/ext/fs_stat/fs_stat.c +10 -1
- data/ext/fs_stat/sector_size.h +13 -0
- data/ext/nproc/nproc.c +1 -1
- data/ext/procfs/loadavg_pid.h +1 -1
- data/ext/procfs/procfs.c +1 -0
- data/ext/procfs/stat.h +23 -2
- data/ext/procfs/statm.h +5 -5
- data/ext/procfs/uptime.h +1 -1
- data/ext/sysconf/sysconf.c +17 -17
- data/ext/sysinfo/sysinfo.c +11 -11
- data/ext/utsname/utsname.c +5 -5
- data/lib/linux_stat/battery.rb +32 -6
- data/lib/linux_stat/filesystem.rb +45 -0
- data/lib/linux_stat/os.rb +11 -5
- data/lib/linux_stat/prettify_bytes.rb +130 -31
- data/lib/linux_stat/process_info.rb +21 -13
- data/lib/linux_stat/swap.rb +1 -0
- data/lib/linux_stat/version.rb +1 -1
- metadata +5 -3
@@ -521,7 +521,9 @@ module LinuxStat
|
|
521
521
|
def start_time(pid = $$)
|
522
522
|
# Getting two Time objects and dealing with floating point numbers
|
523
523
|
# Just to make sure the time goes monotonically
|
524
|
-
|
524
|
+
_ste = start_time_epoch(pid)
|
525
|
+
return nil unless _ste
|
526
|
+
Time.at(_ste)
|
525
527
|
end
|
526
528
|
|
527
529
|
##
|
@@ -614,13 +616,10 @@ module LinuxStat
|
|
614
616
|
#
|
615
617
|
# Shows the CPU time used by the process.
|
616
618
|
#
|
617
|
-
# The return value is
|
619
|
+
# The return value is a Float.
|
620
|
+
# But if the info isn't available, it will return nil.
|
618
621
|
def cpu_time(pid = $$)
|
619
|
-
|
620
|
-
utime, stime, cutime, cstime = times[10], times[11], times[12], times[13]
|
621
|
-
return nil unless utime && stime && cutime && cstime
|
622
|
-
|
623
|
-
utime.+(stime).+(cutime).+(cstime) / get_ticks
|
622
|
+
LinuxStat::ProcFS.ps_times(pid)
|
624
623
|
end
|
625
624
|
|
626
625
|
##
|
@@ -628,19 +627,28 @@ module LinuxStat
|
|
628
627
|
#
|
629
628
|
# Shows the CPU time used by the process.
|
630
629
|
#
|
631
|
-
# The return value is a Hash
|
630
|
+
# The return value is a Hash formatted like this:
|
631
|
+
# LS::ProcessInfo.cpu_times($$)
|
632
|
+
#
|
633
|
+
# => {:hour=>0, :minute=>39, :second=>12, :jiffy=>0.42}
|
634
|
+
#
|
635
|
+
# But if the info isn't available, it will return an empty Hash..
|
632
636
|
def cpu_times(pid = $$)
|
633
|
-
v =
|
637
|
+
v = LinuxStat::ProcFS.ps_times(pid)
|
634
638
|
return {} unless v
|
635
639
|
|
636
|
-
|
637
|
-
|
638
|
-
|
640
|
+
v_i = v.to_i
|
641
|
+
|
642
|
+
hour = v_i / 3600
|
643
|
+
min = v_i % 3600 / 60
|
644
|
+
sec = v_i % 60
|
645
|
+
jiffy = v.-(v_i) * 100
|
639
646
|
|
640
647
|
{
|
641
648
|
hour: hour,
|
642
649
|
minute: min,
|
643
|
-
second: sec
|
650
|
+
second: sec,
|
651
|
+
jiffy: jiffy.to_i
|
644
652
|
}
|
645
653
|
end
|
646
654
|
|
data/lib/linux_stat/swap.rb
CHANGED
data/lib/linux_stat/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: linux_stat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sourav Goswami
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-06-07 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Linux only, efficient linux system utilization reporting and system monitoring
|
14
14
|
gem
|
@@ -31,8 +31,10 @@ files:
|
|
31
31
|
- bin/console
|
32
32
|
- bin/setup
|
33
33
|
- exe/linuxstat.rb
|
34
|
+
- ext/fs_stat/disk_stat.h
|
34
35
|
- ext/fs_stat/extconf.rb
|
35
36
|
- ext/fs_stat/fs_stat.c
|
37
|
+
- ext/fs_stat/sector_size.h
|
36
38
|
- ext/nproc/extconf.rb
|
37
39
|
- ext/nproc/nproc.c
|
38
40
|
- ext/procfs/extconf.rb
|
@@ -85,7 +87,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
85
87
|
- !ruby/object:Gem::Version
|
86
88
|
version: '0'
|
87
89
|
requirements: []
|
88
|
-
rubygems_version: 3.2.
|
90
|
+
rubygems_version: 3.2.18
|
89
91
|
signing_key:
|
90
92
|
specification_version: 4
|
91
93
|
summary: Efficient linux system reporting gem
|