This repository has been archived by the owner on Jun 21, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Titan::System, Titan::Thread#used_cpu and Titan::Thread#used_me…
…mory
- Loading branch information
1 parent
702d487
commit 21d4ab6
Showing
7 changed files
with
118 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,5 +2,6 @@ | |
|
||
module Titan | ||
autoload :CLI, "titan/cli" | ||
autoload :System, "titan/system" | ||
autoload :Thread, "titan/thread" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
module Titan | ||
class System | ||
class << self | ||
# | ||
# Calls the ps function of the OS with a given command and process | ||
# id | ||
# | ||
# E.g., if you want to get the used memory of a given process | ||
# (pid=10), you can do this by: | ||
# | ||
# Titan::System.ps('rss', 10).to_i | ||
# | ||
def ps(command, pid) | ||
if pid > 0 | ||
`ps -o #{command}= -p #{pid}` | ||
else | ||
nil | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module Titan | ||
VERSION = "0.3.0" | ||
VERSION = "0.4.0.dev" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
require 'spec_helper' | ||
|
||
describe Titan::System do | ||
describe ".ps" do | ||
context "given a pid that is greater than 0" do | ||
it "should return a String" do | ||
Titan::System.ps('rss', 1).should be_a(String) | ||
end | ||
end | ||
|
||
context "given a pid that is equal 0" do | ||
it "should return nil" do | ||
Titan::System.ps('rss', 0).should be_nil | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters