utilinfo 0.1.3
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 +7 -0
- data/lib/linux_utilinfo.rb +11 -0
- data/lib/linux_utilinfo/environment_methods.rb +11 -0
- data/lib/linux_utilinfo/general_methods.rb +13 -0
- data/lib/linux_utilinfo/hardware_methods.rb +29 -0
- data/lib/linux_utilinfo/memory_methods.rb +10 -0
- data/lib/linux_utilinfo/operating_system_methods.rb +20 -0
- data/lib/mac_utilinfo.rb +10 -0
- data/lib/utilinfo.rb +25 -0
- data/lib/utilinfo/version.rb +3 -0
- data/lib/win_utilinfo.rb +9 -0
- metadata +82 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: bf389f86e666ed91bb12cad3dbdad16300440976
|
4
|
+
data.tar.gz: fddf4490986e354fac5b626a257c450de6b11f86
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a2667d5873f88453337b50b1601adc9b7e095c05eac961e9841c7d8d854d3a6a3078f601cfe668b704682438e22a31af1792df218e36eb5c6fdef3ea8328117e
|
7
|
+
data.tar.gz: d6f945c971d99498bf6c56058e30a2f2f45483a7bad09ceb8566fd697d77e5132654e8e33313c4bd07684c80c31a61c3b60ea45e3dd4c4efdd78cc408dd42c37
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'linux_utilinfo/hardware_methods'
|
2
|
+
require 'linux_utilinfo/memory_methods'
|
3
|
+
require 'linux_utilinfo/operating_system_methods'
|
4
|
+
require 'linux_utilinfo/environment_methods'
|
5
|
+
|
6
|
+
module LinuxUtilinfo
|
7
|
+
include HardwareMethods
|
8
|
+
include MemoryMethods
|
9
|
+
include OperatingSystemMethods
|
10
|
+
include EnvironmentMethods
|
11
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module LinuxUtilinfo
|
2
|
+
module GeneralMethods
|
3
|
+
def get_uptime
|
4
|
+
uptime = `uptime | tr "," " " | cut -d " " -f5-6`
|
5
|
+
return uptime
|
6
|
+
end
|
7
|
+
|
8
|
+
def get_timezone
|
9
|
+
timezone = `timedatectl | grep -i 'Time zone' | cut -d ':' -f2`
|
10
|
+
return timezone
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module LinuxUtilinfo
|
2
|
+
module HardwareMethods
|
3
|
+
def get_processor
|
4
|
+
processor_name = `cat /proc/cpuinfo | grep -m 1 -i 'model name' | cut -d ':' -f2`
|
5
|
+
processor_name.strip!
|
6
|
+
return processor_name
|
7
|
+
end
|
8
|
+
|
9
|
+
def get_bios_vendor
|
10
|
+
bios_vendor = `cat /sys/devices/virtual/dmi/id/bios_vendor`
|
11
|
+
return bios_vendor
|
12
|
+
end
|
13
|
+
|
14
|
+
def get_model
|
15
|
+
product_model = `cat /sys/devices/virtual/dmi/id/product_name`
|
16
|
+
return product_model
|
17
|
+
end
|
18
|
+
|
19
|
+
def get_number_of_cores
|
20
|
+
core_number = `grep -c '^processor' /proc/cpuinfo`
|
21
|
+
return core_number
|
22
|
+
end
|
23
|
+
|
24
|
+
def get_dimensions
|
25
|
+
dimensions = `xdpyinfo | grep 'dimensions:' | cut -d ':' -f2`
|
26
|
+
return dimensions
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
module LinuxUtilinfo
|
2
|
+
module MemoryMethods
|
3
|
+
def get_total_memory
|
4
|
+
memory_total_in_kb = `cat /proc/meminfo | grep -i 'MemTotal' | awk '{print $2}'`.to_i
|
5
|
+
memory_total_in_kb /= (1000**2)
|
6
|
+
memory_total_in_gb = "#{memory_total_in_kb}GB"
|
7
|
+
return memory_total_in_gb
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module LinuxUtilinfo
|
2
|
+
module OperatingSystemMethods
|
3
|
+
def get_distro
|
4
|
+
distro_name = `cat /etc/os-release | grep -i '^ID=' | cut -d '=' -f2`
|
5
|
+
distro_name.strip!
|
6
|
+
printf(distro_name)
|
7
|
+
end
|
8
|
+
|
9
|
+
def get_platform
|
10
|
+
platform = `uname`
|
11
|
+
return platform
|
12
|
+
end
|
13
|
+
|
14
|
+
def get_distro_release
|
15
|
+
distro_release = `cat /etc/os-release | grep -i '^VERSION_ID=' | cut -d '=' -f 2`
|
16
|
+
distro_release.gsub!(/^\"|\"?$/, '')
|
17
|
+
return distro_release
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/mac_utilinfo.rb
ADDED
data/lib/utilinfo.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "linux_utilinfo"
|
4
|
+
require "utilinfo/version"
|
5
|
+
|
6
|
+
class Utilinfo
|
7
|
+
def self.load_os_module
|
8
|
+
nix_name = `uname -a`
|
9
|
+
if Gem.win_platform?
|
10
|
+
include WinUtilinfo
|
11
|
+
elsif nix_name && $?.success?
|
12
|
+
if nix_name.to_s.downcase.include?('linux')
|
13
|
+
include LinuxUtilinfo
|
14
|
+
elsif nix_nameto_s..downcase.include?('darwin')
|
15
|
+
include MacUtilinfo
|
16
|
+
end
|
17
|
+
else
|
18
|
+
printf("Could not detect your OS.\n")
|
19
|
+
return
|
20
|
+
end
|
21
|
+
end
|
22
|
+
def initialize
|
23
|
+
Utilinfo.load_os_module
|
24
|
+
end
|
25
|
+
end
|
data/lib/win_utilinfo.rb
ADDED
metadata
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: utilinfo
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.3
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Arun Sahadeo
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-05-07 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.16'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.16'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
description:
|
42
|
+
email:
|
43
|
+
- arunjamessahadeo@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- lib/linux_utilinfo.rb
|
49
|
+
- lib/linux_utilinfo/environment_methods.rb
|
50
|
+
- lib/linux_utilinfo/general_methods.rb
|
51
|
+
- lib/linux_utilinfo/hardware_methods.rb
|
52
|
+
- lib/linux_utilinfo/memory_methods.rb
|
53
|
+
- lib/linux_utilinfo/operating_system_methods.rb
|
54
|
+
- lib/mac_utilinfo.rb
|
55
|
+
- lib/utilinfo.rb
|
56
|
+
- lib/utilinfo/version.rb
|
57
|
+
- lib/win_utilinfo.rb
|
58
|
+
homepage: https://github.com/ArunSahadeo/utilinfo
|
59
|
+
licenses:
|
60
|
+
- GPL
|
61
|
+
metadata: {}
|
62
|
+
post_install_message:
|
63
|
+
rdoc_options: []
|
64
|
+
require_paths:
|
65
|
+
- lib
|
66
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
71
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
requirements: []
|
77
|
+
rubyforge_project:
|
78
|
+
rubygems_version: 2.6.11
|
79
|
+
signing_key:
|
80
|
+
specification_version: 4
|
81
|
+
summary: Fetch system information from your machine.
|
82
|
+
test_files: []
|