linux_stat 2.1.2 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -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
- Time.at(start_time_epoch(pid))
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 an Integer.
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
- times = LinuxStat::ProcFS.ps_stat(pid)
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 = cpu_time(pid)
637
+ v = LinuxStat::ProcFS.ps_times(pid)
634
638
  return {} unless v
635
639
 
636
- hour = v / 3600
637
- min = v % 3600 / 60
638
- sec = v % 60
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
 
@@ -22,6 +22,7 @@ module LinuxStat
22
22
  #
23
23
  # If the info isn't available, it will return an empty Hash.
24
24
  def any?
25
+ return nil unless File.readable?('/proc/swaps'.freeze)
25
26
  !!IO.foreach('/proc/swaps'.freeze).first(2)[1]
26
27
  end
27
28
 
@@ -1,3 +1,3 @@
1
1
  module LinuxStat
2
- VERSION ||= "2.1.2"
2
+ VERSION = "2.3.0"
3
3
  end
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.1.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-02-06 00:00:00.000000000 Z
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.7
90
+ rubygems_version: 3.2.18
89
91
  signing_key:
90
92
  specification_version: 4
91
93
  summary: Efficient linux system reporting gem