jah 0.0.3 → 0.0.5

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.
Files changed (69) hide show
  1. data/README.md +62 -13
  2. data/Rakefile +4 -3
  3. data/VERSION +1 -1
  4. data/bin/jah +4 -2
  5. data/jah.gemspec +73 -21
  6. data/lib/jah/act_pkg/apt.rb +13 -0
  7. data/lib/jah/act_pkg/base.rb +17 -0
  8. data/lib/jah/act_pkg/emerge.rb +4 -0
  9. data/lib/jah/act_pkg/pacman.rb +59 -0
  10. data/lib/jah/act_pkg/pkg.rb +52 -0
  11. data/lib/jah/act_pkg/ports.rb +9 -0
  12. data/lib/jah/act_pkg/slack.rb +8 -0
  13. data/lib/jah/act_pkg/urpm.rb +7 -0
  14. data/lib/jah/act_pkg/yum.rb +31 -0
  15. data/lib/jah/act_pkg/zypp.rb +12 -0
  16. data/lib/jah/act_pkg.rb +41 -0
  17. data/lib/jah/agent.rb +14 -6
  18. data/lib/jah/agents/xmpp.rb +164 -23
  19. data/lib/jah/cli.rb +15 -46
  20. data/lib/jah/command.rb +10 -5
  21. data/lib/jah/commands/cpu.rb +38 -0
  22. data/lib/jah/commands/disk.rb +35 -0
  23. data/lib/jah/commands/mem.rb +49 -0
  24. data/lib/jah/{collectors/net.rb → commands/netstat.rb} +11 -9
  25. data/lib/jah/commands/packages.rb +25 -0
  26. data/lib/jah/commands/prok.rb +97 -0
  27. data/lib/jah/commands/services.rb +14 -0
  28. data/lib/jah/commands/status.rb +1 -41
  29. data/lib/jah/commands/who.rb +27 -0
  30. data/lib/jah/history.rb +25 -0
  31. data/lib/jah/install.rb +12 -18
  32. data/lib/jah/opt.rb +87 -0
  33. data/lib/jah/prayer.rb +75 -0
  34. data/lib/jah.rb +21 -13
  35. data/lib/locales/en_us.yml +9 -1
  36. data/lib/locales/pt_br.yml +9 -1
  37. data/spec/jah/act_pkg/apt_spec.rb +40 -0
  38. data/spec/jah/act_pkg/pacman_spec.rb +141 -0
  39. data/spec/jah/act_pkg/pkg_spec.rb +51 -0
  40. data/spec/jah/act_pkg/ports_spec.rb +36 -0
  41. data/spec/jah/act_pkg/yum_spec.rb +55 -0
  42. data/spec/jah/act_pkg_spec.rb +41 -0
  43. data/spec/jah/agent_spec.rb +8 -0
  44. data/spec/jah/agents/xmpp_spec.rb +8 -0
  45. data/spec/jah/cli_spec.rb +47 -0
  46. data/spec/jah/command_spec.rb +5 -0
  47. data/spec/jah/commands/cpu_spec.rb +51 -0
  48. data/spec/jah/commands/disk_spec.rb +49 -0
  49. data/spec/jah/commands/mem_spec.rb +60 -0
  50. data/spec/jah/commands/netstat_spec.rb +13 -0
  51. data/spec/jah/commands/prok_spec.rb +248 -0
  52. data/spec/jah/commands/who_spec.rb +25 -0
  53. data/spec/jah/history_spec.rb +35 -0
  54. data/spec/jah/install_spec.rb +15 -0
  55. data/spec/jah/opt_spec.rb +37 -0
  56. data/spec/jah/prayer_spec.rb +8 -0
  57. data/spec/jah_spec.rb +4 -2
  58. data/spec/spec_helper.rb +3 -1
  59. metadata +67 -16
  60. data/lib/jah/collector.rb +0 -12
  61. data/lib/jah/collectors/cpu.rb +0 -35
  62. data/lib/jah/collectors/disk.rb +0 -14
  63. data/lib/jah/collectors/mem.rb +0 -51
  64. data/lib/jah/collectors/prok.rb +0 -88
  65. data/lib/jah/collectors/services.rb +0 -13
  66. data/lib/jah/collectors/who.rb +0 -20
  67. data/lib/jah/commands/pub.rb +0 -34
  68. data/lib/jah/god.rb +0 -24
  69. data/lib/jah.yaml.template +0 -26
@@ -0,0 +1,36 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
+ require "jah/act_pkg/ports"
3
+
4
+ describe Ports do
5
+
6
+
7
+
8
+
9
+
10
+ LI = <<LI
11
+ autoconf @2.64 devel/autoconf
12
+ automake @1.11 devel/automake
13
+ bzip2 @1.0.5 archivers/bzip2
14
+ cairo @1.8.8 graphics/cairo
15
+ cmake @2.6.4 devel/cmake
16
+ curl @7.19.6 net/curl
17
+ db46 @4.6.21 databases/db46
18
+ expat @2.0.1 textproc/expat
19
+ libid3tag @0.15.1b audio/libid3tag
20
+ openssl @0.9.8k devel/openssl
21
+ p5-error @0.17015 perl/p5-error
22
+ LI
23
+
24
+ SEARCH = <<SEARCH
25
+ awesome @3.3.4 (x11, x11-wm)
26
+ awesome is a tiling window manager
27
+
28
+ rancid @2.3.2a9 (net)
29
+ Really Awesome New Cisco confIg Differ
30
+
31
+ Found 2 ports.
32
+
33
+ SEARCH
34
+
35
+ end
36
+
@@ -0,0 +1,55 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
+ require "jah/act_pkg/yum"
3
+
4
+ describe Yum do
5
+
6
+ before do
7
+ @yum ||= Yum.new
8
+ end
9
+
10
+ describe "All" do
11
+ before do
12
+ @yum.stub!(:"`").and_return(YUMLIST)
13
+ @pkgs ||= @yum.all
14
+ end
15
+
16
+ it "should fetch name" do
17
+ @pkgs[0].name.should eql("db4")
18
+ end
19
+
20
+ it "should fetch version" do
21
+ @pkgs[0].version.should eql("4.3.29-9.fc6")
22
+ end
23
+
24
+ end
25
+
26
+
27
+
28
+
29
+
30
+ YUMLIST = <<YUMLIST
31
+ Installed Packages
32
+ db4.i386 4.3.29-9.fc6 installed
33
+ dbus.i386 1.0.0-7.el5 installed
34
+ dbus-devel.i386 1.0.0-7.el5 installed
35
+ desktop-file-utils.i386 0.10-7 installed
36
+ YUMLIST
37
+
38
+ YUMINFO = <<YUMINFO
39
+ Available Packages
40
+ Name : ruby
41
+ Arch : i386
42
+ Version: 1.8.5
43
+ Release: 5.el5_3.7
44
+ Size : 274 k
45
+ Repo : updates
46
+ Summary: An interpreter of object-oriented scripting language
47
+ Description:
48
+ Ruby is the interpreted scripting language for quick and easy
49
+ object-oriented programming. It has many features to process text
50
+ files and to do system management tasks (as in Perl). It is simple,
51
+ straight-forward, and extensible.
52
+
53
+ YUMINFO
54
+
55
+ end
@@ -0,0 +1,41 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+
4
+ describe ActPkg do
5
+
6
+ it "should detect archlinux" do
7
+ File.stub!(:read).and_return(" Arch Linux \r (\n) (\l)")
8
+ ActPkg.detect.should eql(:pacman)
9
+ end
10
+
11
+ it "should detect debian like" do
12
+ File.stub!(:read).and_return(" Ubuntu karmic (development branch) \n \l")
13
+ ActPkg.detect.should eql(:apt)
14
+ end
15
+
16
+ it "should detect slack" do
17
+ File.stub!(:read).and_return(" Welcome to \s \r (\l)")
18
+ ActPkg.detect.should eql(:slack)
19
+ end
20
+
21
+ it "should detect gentoo" do
22
+ File.stub!(:read).and_return(" This is \n.\O (\s \m \r) \t")
23
+ ActPkg.detect.should eql(:emerge) # sparta
24
+ end
25
+
26
+ it "should detect centos" do
27
+ File.stub!(:read).and_return(" CentOS release 5.2 (Final)\n Kernel \r on an \m")
28
+ ActPkg.detect.should eql(:yum)
29
+ end
30
+
31
+ it "should return an instance of the correct adapter (arch)" do
32
+ ActPkg.stub!(:detect).and_return(:pacman)
33
+ ActPkg.manager.should be_instance_of Pacman
34
+ end
35
+
36
+ it "should delegate to the manager" do
37
+ ActPkg.manager.should_receive(:install).with("foo")
38
+ ActPkg.install("foo")
39
+ end
40
+ end
41
+
@@ -0,0 +1,8 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+
4
+ describe Agent do
5
+
6
+
7
+
8
+ end
@@ -0,0 +1,8 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
+ require "jah/agents/xmpp"
3
+
4
+ describe XmppAgent do
5
+
6
+
7
+
8
+ end
@@ -0,0 +1,47 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+ describe Jah::Cli do
4
+
5
+ before do
6
+ Cli.stub!(:puts)
7
+ Opt.stub!(:puts)
8
+ File.stub!(:exists?).and_return(false)
9
+ Jah::Cli.stub!(:parse_options).and_return({})
10
+ Opt.stub!(:autoload_config)
11
+ end
12
+
13
+ it "should start with install/config" do
14
+ Opt.should_receive(:mode).and_return(nil)
15
+ Jah::Install.should_receive(:new)
16
+ Jah::Cli.work([])
17
+ end
18
+
19
+ it "should work install" do
20
+ Jah::Install.should_receive(:new)
21
+ Jah::Cli.work(["install"])
22
+ end
23
+
24
+ it "should start if mode" do
25
+ Opt.should_receive(:mode).and_return(:xmpp)
26
+ Jah::Agent.should_receive(:start).and_return(true)
27
+ Jah::Cli.work([])
28
+ end
29
+
30
+
31
+ it "should not write if it wasnt" do
32
+ EM.should_receive(:stop)
33
+ File.should_not_receive(:open)
34
+ Jah::Cli.stop!
35
+ end
36
+
37
+ it "should write config down if changed" do
38
+ Opt.mode = "xre"
39
+ EM.should_receive(:stop)
40
+ File.should_receive(:open).with(Opt[:config], "w+").and_yield(@mf = mock(File))
41
+ @mf.should_receive(:write).exactly(2).times
42
+ Jah::Cli.stop!
43
+ end
44
+
45
+
46
+
47
+ end
@@ -0,0 +1,5 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+ describe Command do
4
+
5
+ end
@@ -0,0 +1,51 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
+
3
+
4
+ describe Cpu do
5
+
6
+ describe "Read All" do
7
+ before do
8
+ Cpu.should_receive(:"`").with("uptime").and_return(" 20:10:57 up 12 days, 15:33, 8 users, load average: 0.02, 0.08, 0.08\n")
9
+ end
10
+
11
+ it "should read one" do
12
+ if RUBY_PLATFORM =~ /darwin/
13
+ Cpu.should_receive(:"`").with("hwprefs cpu_count").and_return("2\n")
14
+ else
15
+ Cpu.should_receive(:"`").with("cat /proc/cpuinfo | grep 'model name' | wc -l").and_return("2\n")
16
+ end
17
+ Cpu.read[:one].should be_close(0.02, 0.01)
18
+ end
19
+
20
+ it "should read five minutes" do
21
+ Cpu.read[:five].should be_close(0.08, 0.01)
22
+ end
23
+
24
+
25
+ it "should read five minutes" do
26
+ Cpu.read[:ten].should be_close(0.08, 0.01)
27
+ end
28
+
29
+ it "should find the number of cores" do
30
+ Cpu.read[:cores].should eql(2)
31
+ end
32
+
33
+ it "should calc the med" do
34
+ Cpu.read[:med].should be_close(0.04, 0.01)
35
+ end
36
+
37
+ it "should have a method missing" do
38
+ Cpu.one.should be_close(0.02, 0.01)
39
+ end
40
+
41
+ end
42
+
43
+ describe "Direct" do
44
+
45
+ it "should print load average" do
46
+ Cpu.cores.should eql(2)
47
+ end
48
+
49
+
50
+ end
51
+ end
@@ -0,0 +1,49 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
+
3
+
4
+ describe Disk do
5
+
6
+ before do
7
+ Disk.should_receive(:"`").with("df").and_return(DISK)
8
+ end
9
+
10
+ it "should read" do
11
+ Disk.all[0].should be_instance_of(Disk) #eql({:free=>"25191840", :used=>"7033476", :total=>"32225316", :percent=>"22%", :path=>"/dev/sda5"})
12
+ end
13
+
14
+ describe "A Partition" do
15
+ before do
16
+ @disk = Disk.all.first
17
+ end
18
+
19
+ it "should find free" do
20
+ @disk.free.should eql(25191840)
21
+ end
22
+
23
+ it "should find percent used" do
24
+ @disk.percent.should eql(22)
25
+ end
26
+
27
+ it "should find dev" do
28
+ @disk.path.should eql("/dev/sda5")
29
+ end
30
+
31
+ it "should find mountpoint" do
32
+ @disk.mount.should eql("/")
33
+ end
34
+
35
+ end
36
+
37
+
38
+
39
+ DISK = <<DFLH
40
+ Filesystem 1K-blocks Used Available Use% Mounted on
41
+ /dev/sda5 32225316 7033476 25191840 22% /
42
+ none 1037004 192 1036812 1% /dev
43
+ none 1037004 0 1037004 0% /dev/shm
44
+ /dev/sda1 242216196 210412036 19597172 92% /mnt/disk
45
+ /dev/sda3 78121640 17208224 60913416 23% /home
46
+ DFLH
47
+
48
+
49
+ end
@@ -0,0 +1,60 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
+
3
+
4
+ describe Mem do
5
+
6
+ describe "Read All" do
7
+ before do
8
+ Mem.should_receive(:`).with("cat /proc/meminfo").and_return(MEMINFO) #`
9
+ end
10
+
11
+ it "should get free mem" do
12
+ Mem.free.should eql(4194)
13
+ end
14
+
15
+ it "should get free mem" do
16
+ Mem.used.should eql(3790)
17
+ end
18
+
19
+ it "should get free percentage" do
20
+ Mem.percent.should eql(52)
21
+ end
22
+ end
23
+
24
+ MEMINFO = <<MEMINFO
25
+ MemTotal: 8175844 kB
26
+ MemFree: 201264 kB
27
+ Buffers: 126684 kB
28
+ Cached: 3967476 kB
29
+ SwapCached: 7704 kB
30
+ Active: 5993204 kB
31
+ Inactive: 1731788 kB
32
+ Active(anon): 3077496 kB
33
+ Inactive(anon): 579456 kB
34
+ Active(file): 2915708 kB
35
+ Inactive(file): 1152332 kB
36
+ Unevictable: 0 kB
37
+ Mlocked: 0 kB
38
+ SwapTotal: 7815580 kB
39
+ SwapFree: 7766252 kB
40
+ Dirty: 640 kB
41
+ Writeback: 0 kB
42
+ AnonPages: 3623964 kB
43
+ Mapped: 39020 kB
44
+ Slab: 208776 kB
45
+ SReclaimable: 195744 kB
46
+ SUnreclaim: 13032 kB
47
+ PageTables: 17348 kB
48
+ NFS_Unstable: 0 kB
49
+ Bounce: 0 kB
50
+ WritebackTmp: 0 kB
51
+ CommitLimit: 11903500 kB
52
+ Committed_AS: 4057620 kB
53
+ VmallocTotal: 34348367 kB
54
+ VmallocUsed: 269584 kB
55
+ VmallocChunk: 34357495 kB
56
+ DirectMap4k: 3584 kB
57
+ DirectMap2M: 8384512 kB
58
+ MEMINFO
59
+
60
+ end
@@ -0,0 +1,13 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
+
3
+
4
+ describe Netstat do
5
+
6
+ it "should count connections" do
7
+ Netstat.should_receive(:"`").with("netstat -n | grep -i established | wc -l").and_return("9")
8
+ Netstat.count.should eql(9)
9
+ end
10
+
11
+
12
+
13
+ end
@@ -0,0 +1,248 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
+
3
+
4
+ describe Prok do
5
+
6
+ before do
7
+ Prok.stub!("`".to_sym).and_return(PSAUX) #```
8
+ end
9
+
10
+ it "should find all" do
11
+ Prok.all.should be_instance_of Array
12
+ end
13
+
14
+ it "should be a intance of Prok" do
15
+ Prok.all[0].should be_instance_of Prok
16
+ end
17
+
18
+ it "should a proc by pid" do
19
+ Prok.find("3537").first.comm.should eql("ruby bin/jah")
20
+ end
21
+
22
+ it "should return [] if no proc found" do
23
+ Prok.find("8888").should be_empty
24
+ end
25
+
26
+ it "should find by name" do
27
+ Prok.find("jah")[0].pid.should eql 3537
28
+ end
29
+
30
+ it "should return [] if no comm found" do
31
+ Prok.find("nothere").should be_empty
32
+ end
33
+
34
+ describe "A Prok" do
35
+ before do
36
+ @prok ||= Prok.all[0]
37
+ end
38
+
39
+ it "should get the command name" do
40
+ @prok.comm.should eql("ini")
41
+ end
42
+
43
+ it "should set the user" do
44
+ @prok.user.should eql("root")
45
+ end
46
+
47
+ it "should set the PID as integer" do
48
+ @prok.pid.should eql(1)
49
+ end
50
+
51
+ it "should get cpu percentage" do
52
+ @prok.cpu.should be_close(0.0, 0.01)
53
+ end
54
+
55
+ it "should get mem percentage" do
56
+ @prok.mem.should be_close(0.0, 0.01)
57
+ end
58
+
59
+ it "should get the v size" do
60
+ @prok.vsz.should eql(1684)
61
+ end
62
+
63
+ it "should get the rss size" do
64
+ @prok.rss.should eql(480)
65
+ end
66
+
67
+ it "should get the TTY" do
68
+ @prok.tty.should eql("?")
69
+ end
70
+
71
+ it "should get STAT" do
72
+ @prok.stat.should eql("Ss")
73
+ end
74
+
75
+ it "should get TIME" do
76
+ @prok.time.should eql("0:05")
77
+ end
78
+
79
+ it "should send a HUP" do
80
+ @prok.should_receive(:exec).with("kill -1 1")
81
+ @prok.hup!
82
+ end
83
+
84
+ it "should send a SIGTERM" do
85
+ @prok.should_receive(:exec).with("kill 1")
86
+ @prok.kill!
87
+ end
88
+
89
+ it "should send a KILL -9" do
90
+ @prok.should_receive(:exec).with("kill -9 1")
91
+ @prok.move_to_acre!
92
+ end
93
+
94
+ it "should have a to_s method" do
95
+ @prok.to_s.should eql("1 - root - ini (0.0, 0.0)")
96
+ end
97
+
98
+ end
99
+
100
+ it "should genocide!" do
101
+ Prok.stub!(:new).and_return(@prok = mock(Prok))
102
+ @prok.should_receive(:comm).and_return("bin/jah")
103
+ @prok.stub!(:comm)
104
+ @prok.should_receive(:kill!)
105
+ Prok.genocide!("jah")
106
+ end
107
+
108
+
109
+ PSAUX = <<PSAUX
110
+ USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
111
+ root 1 0.0 0.0 1684 480 ? Ss Sep20 0:05 ini
112
+ root 2 0.0 0.0 0 0 ? S< Sep20 0:00 [kthreadd]
113
+ root 3 0.0 0.0 0 0 ? S< Sep20 0:00 [migration/0]
114
+ root 4 0.0 0.0 0 0 ? S< Sep20 0:08 [ksoftirqd/0]
115
+ root 5 0.0 0.0 0 0 ? S< Sep20 0:00 [watchdog/0]
116
+ root 6 0.0 0.0 0 0 ? S< Sep20 0:00 [migration/1]
117
+ root 7 0.0 0.0 0 0 ? S< Sep20 5:39 [ksoftirqd/1]
118
+ root 8 0.0 0.0 0 0 ? S< Sep20 0:00 [watchdog/1]
119
+ root 9 0.0 0.0 0 0 ? S< Sep20 0:16 [events/0]
120
+ root 10 0.0 0.0 0 0 ? S< Sep20 0:16 [events/1]
121
+ root 11 0.0 0.0 0 0 ? S< Sep20 0:00 [khelper]
122
+ root 12 0.0 0.0 0 0 ? S< Sep20 0:00 [async/mgr]
123
+ root 13 0.0 0.0 0 0 ? S< Sep20 0:00 [kblockd/0]
124
+ root 14 0.0 0.0 0 0 ? S< Sep20 0:05 [kblockd/1]
125
+ root 15 0.0 0.0 0 0 ? S< Sep20 0:00 [kacpid]
126
+ root 16 0.0 0.0 0 0 ? S< Sep20 0:00 [kacpi_notify]
127
+ root 17 0.0 0.0 0 0 ? S< Sep20 0:00 [kseriod]
128
+ root 18 0.0 0.0 0 0 ? S Sep20 0:03 [khungtaskd]
129
+ root 19 0.0 0.0 0 0 ? S Sep20 0:12 [pdflush]
130
+ root 21 0.0 0.0 0 0 ? S< Sep20 0:09 [kswapd0]
131
+ root 22 0.0 0.0 0 0 ? S< Sep20 0:00 [aio/0]
132
+ root 23 0.0 0.0 0 0 ? S< Sep20 0:00 [aio/1]
133
+ root 24 0.0 0.0 0 0 ? S< Sep20 0:00 [crypto/0]
134
+ root 25 0.0 0.0 0 0 ? S< Sep20 0:00 [crypto/1]
135
+ root 446 0.0 0.0 0 0 ? S< Sep20 0:00 [ata/0]
136
+ root 448 0.0 0.0 0 0 ? S< Sep20 0:00 [ata/1]
137
+ root 449 0.0 0.0 0 0 ? S< Sep20 0:00 [ata_aux]
138
+ root 450 0.0 0.0 0 0 ? S< Sep20 0:00 [scsi_eh_0]
139
+ root 451 0.0 0.0 0 0 ? S< Sep20 0:04 [scsi_eh_1]
140
+ root 452 0.0 0.0 0 0 ? S< Sep20 0:00 [scsi_eh_2]
141
+ root 455 0.0 0.0 0 0 ? S< Sep20 0:00 [scsi_eh_3]
142
+ root 456 0.0 0.0 0 0 ? S< Sep20 0:00 [scsi_eh_4]
143
+ root 457 0.0 0.0 0 0 ? S< Sep20 0:00 [scsi_eh_5]
144
+ root 458 0.0 0.0 0 0 ? S< Sep20 0:00 [scsi_eh_6]
145
+ root 461 0.0 0.0 0 0 ? S< Sep20 0:00 [scsi_eh_7]
146
+ root 469 0.0 0.0 0 0 ? S< Sep20 0:00 [scsi_eh_8]
147
+ root 470 0.0 0.0 0 0 ? S< Sep20 0:00 [scsi_eh_9]
148
+ root 562 0.0 0.0 0 0 ? S< Sep20 0:00 [reiserfs/0]
149
+ root 563 0.0 0.0 0 0 ? S< Sep20 0:00 [reiserfs/1]
150
+ root 588 0.0 0.0 1956 376 ? S<s Sep20 0:00 /sbin/udevd --daemon
151
+ root 836 0.0 0.0 0 0 ? S< Sep20 0:00 [kpsmoused]
152
+ root 842 0.0 0.0 0 0 ? S< Sep20 0:00 [ksuspend_usbd]
153
+ root 843 0.0 0.0 0 0 ? S< Sep20 0:00 [khubd]
154
+ root 913 0.0 0.0 0 0 ? S< Sep20 0:00 [hd-audio0]
155
+ root 951 0.0 0.0 0 0 ? S< Sep20 0:00 [usbhid_resumer]
156
+ root 1129 0.0 0.0 0 0 ? S< Sep20 0:00 [kjournald]
157
+ root 1265 0.0 0.0 4700 192 ? S Sep20 0:00 supervising syslog-ng
158
+ root 1266 0.0 0.0 4880 868 ? Ss Sep20 0:00 /usr/sbin/syslog-ng
159
+ root 1276 0.0 0.0 2380 544 tty1 Ss Sep20 0:00 /bin/login --
160
+ root 1277 0.0 0.0 1684 440 tty2 Ss+ Sep20 0:00 /sbin/agetty -8 38400 tty2 linux
161
+ root 1278 0.0 0.0 1684 440 tty3 Ss+ Sep20 0:00 /sbin/agetty -8 38400 tty3 linux
162
+ root 1279 0.0 0.0 1684 440 tty4 Ss+ Sep20 0:00 /sbin/agetty -8 38400 tty4 linux
163
+ root 1280 0.0 0.0 1684 440 tty5 Ss+ Sep20 0:00 /sbin/agetty -8 38400 tty5 linux
164
+ root 1281 0.0 0.0 1684 440 tty6 Ss+ Sep20 0:00 /sbin/agetty -8 38400 tty6 linux
165
+ nofxx 1292 0.0 1.9 95628 40664 ? S Sep28 3:32 terminal
166
+ nofxx 1293 0.0 0.0 1728 560 ? S Sep28 0:00 gnome-pty-helper
167
+ root 1313 0.0 0.0 1720 548 ? S Sep20 0:00 /usr/sbin/crond
168
+ root 1342 0.0 0.0 1864 244 ? S Sep20 0:03 /usr/lib/erlang/erts-5.7.1/bin/epmd -daemon
169
+ root 1344 0.0 0.0 2052 420 ? Ss Sep20 0:00 /usr/bin/rpcbind
170
+ nofxx 1348 0.0 0.0 4176 1456 ? Ss Sep20 4:52 /usr/sbin/famd -T 0 -c /etc/fam/fam.conf
171
+ dbus 1351 0.0 0.0 2384 868 ? Ss Sep20 0:00 /usr/bin/dbus-daemon --system
172
+ hal 1364 0.0 0.0 6028 1472 ? Ss Sep20 0:04 /usr/sbin/hald
173
+ root 1404 0.0 0.0 7856 852 ? Sl Sep20 0:00 PassengerNginxHelperServer /usr/lib/ruby/gems/1.8/gems/passenger-2.2.4 /usr/bin/ruby 3 4 0 6 0 300 1 nobody 1000 100 /tmp/passenger.1385
174
+ root 1413 0.0 0.1 23616 3032 ? Sl Sep20 3:11 Passenger spawn server
175
+ root 1416 0.0 0.0 4160 172 ? Ss Sep20 0:00 nginx: master process /opt/nginx/sbin/nginx -c /opt/nginx/conf/nginx.conf
176
+ nofxx 1417 0.0 0.0 4648 744 ? S Sep20 0:00 nginx: worker process
177
+ root 1443 0.0 0.0 9028 980 ? Ssl Sep20 0:00 /usr/sbin/console-kit-daemon
178
+ root 1444 0.0 0.0 3296 556 ? S Sep20 0:00 hald-runner
179
+ root 1540 0.0 0.0 3228 588 ? S Sep20 1:19 hald-addon-input: Listening on /dev/input/event7 /dev/input/event2 /dev/input/event1 /dev/input/event8
180
+ nofxx 1583 0.0 0.0 9452 1072 pts/2 Ss Sep28 0:00 bash
181
+ hal 1584 0.0 0.0 2924 460 ? S Sep20 0:00 hald-addon-acpi: listening on acpi kernel interface /proc/acpi/event
182
+ root 1585 0.0 0.0 3232 556 ? S Sep20 0:06 hald-addon-storage: polling /dev/sr0 (every 16 sec)
183
+ root 1657 0.0 0.0 1872 248 ? Ss Sep20 0:00 /sbin/dhcpcd -q eth0
184
+ nofxx 1660 0.0 0.0 9420 732 tty1 S Sep20 0:00 -bash
185
+ nofxx 2468 0.0 0.0 6228 708 tty1 S+ Sep20 0:00 /bin/sh /usr/bin/startx
186
+ nofxx 2484 0.0 0.0 2956 492 tty1 S+ Sep20 0:00 xinit /home/nofxx/.xinitrc -- /etc/X11/xinit/xserverrc :0 -auth /home/nofxx/.serverauth.2468
187
+ root 2485 0.6 15.2 872568 316392 tty7 S<s+ Sep20 120:31 /usr/bin/X -nolisten tcp
188
+ nofxx 2492 0.0 0.0 5980 708 tty1 S Sep20 0:00 /bin/sh /etc/xdg/xfce4/xinitrc -- /etc/X11/xinit/xserverrc
189
+ nofxx 2501 0.0 0.0 5752 336 ? Ss Sep20 0:00 /usr/bin/ssh-agent -s
190
+ nofxx 2506 0.0 0.0 3156 348 tty1 S Sep20 0:02 /usr/bin/dbus-launch --sh-syntax --exit-with-session
191
+ nofxx 2507 0.0 0.0 2272 900 ? Ss Sep20 0:30 /usr/bin/dbus-daemon --fork --print-pid 5 --print-address 7 --session
192
+ nofxx 2509 0.0 0.1 18864 3060 tty1 S Sep20 0:39 /usr/bin/xfce4-session
193
+ nofxx 2511 0.0 0.0 3312 820 ? S Sep20 0:00 /usr/lib/xfconfd
194
+ nofxx 2515 0.0 0.0 15444 1364 tty1 S Sep20 0:00 xfsettingsd
195
+ nofxx 2516 0.0 0.7 69088 15192 tty1 Sl Sep20 0:26 xfdesktop --sm-client-id 2fe03b273-585f-4a64-8b6e-a2d8b82b094f --display :0.0
196
+ nofxx 2518 0.0 0.1 20064 2752 tty1 S Sep20 0:36 xfce4-settings-helper --display :0.0 --sm-client-id 2720f3d6c-875a-4bf8-b46b-c4afdc31650a
197
+ nofxx 2519 0.0 0.0 15888 1976 tty1 S Sep20 0:00 xfce4-panel
198
+ nofxx 2532 0.0 0.8 85832 16816 ? Sl Sep20 1:13 /usr/bin/Thunar --daemon
199
+ nofxx 2556 1.0 4.7 178944 97604 tty1 Sl Sep20 199:51 skype -session 2d64394f0-cf8b-4e9f-8ab5-f1755485c_4299_196609
200
+ nofxx 2559 0.0 0.5 47116 11928 tty1 Sl Sep20 0:02 /usr/lib/xfce4/panel-plugins/xfce4-mixer-plugin socket_id 16777248 name xfce4-mixer-plugin id 12476125132 display_name Mixer size 16 screen_position 7
201
+ nofxx 2575 0.2 0.3 21104 7900 ? Ss Sep20 44:53 awesome
202
+ nofxx 2787 0.0 0.6 14404 13076 pts/7 S 13:18 0:00 ruby /usr/bin/autospec
203
+ nofxx 2794 0.2 0.6 15480 14096 pts/7 S 13:18 0:00 /usr/bin/ruby -ws /usr/bin/autotest
204
+ nofxx 2912 0.0 0.0 7304 1264 pts/2 S+ Sep29 0:05 ssh naomi
205
+ nofxx 3226 0.0 0.0 5296 1040 pts/12 R+ 13:25 0:00 ps auxww
206
+ nofxx 3285 0.0 0.0 9620 1072 pts/3 Ss Sep28 0:00 bash
207
+ nofxx 3389 0.0 0.0 6728 904 pts/3 S+ Sep30 0:03 ssh naomi
208
+ nofxx 3537 0.9 1.0 25828 21532 pts/7 S+ 13:30 0:00 ruby bin/jah
209
+ nofxx 3932 0.0 0.2 9836 4304 pts/9 Ss+ Sep30 0:00 bash
210
+ nofxx 4108 0.0 0.0 46732 1908 ? Sl Sep20 0:09 /usr/lib/erlang/erts-5.7.1/bin/beam.smp -- -root /usr/lib/erlang -progname erl -- -home /home/nofxx -W -pa spec -sname spec -s spec_server
211
+ nofxx 4403 4.0 13.4 392108 278704 ? SLl Sep29 241:50 python /usr/lib/exaile/exaile.py --datadir=/usr/share/exaile/data --startgui
212
+ nofxx 5426 0.0 0.2 9640 4616 pts/7 Ss+ Sep28 0:01 bash
213
+ couchdb 10908 0.0 0.0 6232 708 ? S Sep26 0:00 /bin/sh -e /usr/bin/couchdb -a \"/etc/couchdb/default.ini\" -a \"/etc/couchdb/local.ini\" -b -r 5 -p /var/run/couchdb/couchdb.pid -o /dev/null -e /dev/null -R
214
+ couchdb 10931 0.0 0.0 6232 148 ? S Sep26 0:00 /bin/sh -e /usr/bin/couchdb -a \"/etc/couchdb/default.ini\" -a \"/etc/couchdb/local.ini\" -b -r 5 -p /var/run/couchdb/couchdb.pid -o /dev/null -e /dev/null -R
215
+ couchdb 10932 0.0 0.1 67548 2484 ? Sl Sep26 6:14 /usr/lib/erlang/erts-5.7.1/bin/beam.smp -Bd -K true -- -root /usr/lib/erlang -progname erl -- -home /var/lib/couchdb -noshell -noinput -smp auto -sasl errlog_type error -pa /usr/lib/couchdb/erlang/lib/couch-0.10.0a784601/ebin /usr/lib/couchdb/erlang/lib/mochiweb-r97/ebin /usr/lib/couchdb/erlang/lib/ibrowse-1.4.1/ebin -eval application:load(ibrowse) -eval application:load(crypto) -eval application:load(couch) -eval crypto:start() -eval ibrowse:start() -eval couch_server:start([ "/etc/couchdb/default.ini", "/etc/couchdb/local.ini", "/etc/couchdb/default.ini", "/etc/couchdb/local.ini"]), receive done -> done end. -pidfile /var/run/couchdb/couchdb.pid -heart
216
+ couchdb 10941 0.0 0.0 1532 380 ? Ss Sep26 0:00 heart -pid 10932 -ht 11
217
+ nofxx 12033 0.0 0.0 9452 1072 pts/8 Ss Sep28 0:00 bash
218
+ nofxx 12091 0.0 0.0 6180 840 pts/8 S+ Sep28 0:05 ssh naomi
219
+ root 12913 0.1 0.1 47768 3972 ? Ssl Sep22 19:38 /usr/lib/erlang/erts-5.7.1/bin/beam.smp -W w -K true -A30 -- -root /usr/lib/erlang -progname erl -- -home /home/nofxx -pa /usr/bin/../ebin -noshell -noinput -s rabbit -sname rabbit -boot start_sasl -kernel inet_default_listen_options [{nodelay,true},{sndbuf,16384},{recbuf,4096}] -kernel inet_default_connect_options [{nodelay,true}] -rabbit tcp_listeners [{"0.0.0.0", 5672}] -sasl errlog_type error -kernel error_logger {file,"/var/log/rabbitmq/rabbit.log"} -sasl sasl_error_logger {file,"/var/log/rabbitmq/rabbit-sasl.log"} -os_mon start_cpu_sup true -os_mon start_disksup false -os_mon start_memsup false -os_mon start_os_sup false -os_mon memsup_system_only true -os_mon system_memory_high_watermark 0.95 -mnesia dir "/var/lib/rabbitmq/mnesia/rabbit" -noshell -noinput
220
+ root 12962 0.0 0.0 1660 284 ? Ss Sep22 0:00 /usr/lib/erlang/lib/os_mon-2.2.1/priv/bin/cpu_sup
221
+ root 12963 0.0 0.0 1860 320 ? Ss Sep22 0:00 inet_gethost 4
222
+ root 12964 0.0 0.0 1908 352 ? S Sep22 0:00 inet_gethost 4
223
+ nofxx 14054 0.1 1.7 73168 35972 ? S Sep30 6:19 pidgin
224
+ root 15009 0.0 0.0 6192 404 ? Ss Sep30 0:00 /usr/sbin/sshd
225
+ nofxx 16716 0.0 0.0 9452 1072 pts/1 Ss Sep28 0:00 bash
226
+ nofxx 16730 0.0 0.0 6536 828 pts/1 S+ Sep28 0:00 ssh naomi
227
+ nofxx 20500 0.0 0.2 57484 4712 ? S Sep26 1:09 /usr/bin/ruby /usr/bin/gembox
228
+ nofxx 23756 3.8 15.8 841728 329360 ? Sl Oct02 35:45 firefox
229
+ nofxx 23758 0.0 0.1 7556 2716 ? S Oct02 0:01 /usr/lib/GConf/gconfd-2
230
+ root 25145 0.0 0.0 0 0 ? S Oct02 0:00 [pdflush]
231
+ nofxx 25594 0.0 0.2 9456 4860 pts/6 Ss Oct02 0:00 bash
232
+ nofxx 25597 0.0 0.2 9456 5036 pts/10 Ss+ Oct02 0:00 bash
233
+ nofxx 25631 0.0 0.0 6152 1480 pts/6 S+ Oct02 0:00 ssh tor
234
+ nofxx 26342 0.0 0.2 9456 4600 pts/11 Ss Oct01 0:00 bash
235
+ postgres 31170 0.0 0.0 44096 1308 ? S Oct01 0:01 /usr/bin/postgres -D /var/lib/postgres/data
236
+ postgres 31179 0.0 0.2 44504 5336 ? Ss Oct01 0:06 postgres: writer process
237
+ postgres 31180 0.0 0.0 44096 592 ? Ss Oct01 0:03 postgres: wal writer process
238
+ postgres 31181 0.0 0.0 44452 852 ? Ss Oct01 0:03 postgres: autovacuum launcher process
239
+ postgres 31182 0.0 0.0 12532 684 ? Ss Oct01 0:06 postgres: stats collector process
240
+ nofxx 31873 0.0 0.2 9456 5096 pts/12 Ss 12:00 0:00 bash
241
+ nofxx 32343 0.1 2.7 88540 58032 ? S Oct02 2:14 emacs
242
+ nofxx 32402 0.0 0.0 5972 1452 ? S 12:11 0:00 /bin/sh /usr/bin/thunderbird
243
+ nofxx 32406 0.0 0.0 5972 1456 ? S 12:11 0:00 /bin/sh /usr/lib/thunderbird-2.0/run-mozilla.sh /usr/lib/thunderbird-2.0/thunderbird-bin
244
+ nofxx 32411 0.0 2.3 129828 49672 ? Sl 12:11 0:02 /usr/lib/thunderbird-2.0/thunderbird-bin
245
+ nofxx 32725 0.0 0.7 19432 14924 pts/11 S+ 12:19 0:00 irb
246
+ PSAUX
247
+
248
+ end
@@ -0,0 +1,25 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
+
3
+
4
+ describe Who do
5
+
6
+
7
+ before do
8
+ Who.should_receive(:"`").with("who").and_return(WHO)
9
+ end
10
+
11
+ it "should return users" do
12
+ Who.all[0][:who].should eql("nofxx")
13
+ end
14
+
15
+
16
+
17
+
18
+ WHO = <<WHO
19
+ nofxx tty1 2009-10-03 17:17
20
+ nofxx pts/0 2009-10-03 17:17 (:0.0)
21
+ nofxx pts/1 2009-10-03 18:58 (:0.0)
22
+ nofxx pts/2 2009-10-03 18:21 (:0.0)
23
+ WHO
24
+
25
+ end