miranda 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.DS_Store +0 -0
- data/.idea/.rakeTasks +7 -0
- data/.idea/encodings.xml +5 -0
- data/.idea/misc.xml +5 -0
- data/.idea/modules.xml +9 -0
- data/.idea/vcs.xml +7 -0
- data/app.rb +83 -0
- data/bin/miranda +29 -0
- data/helpers/link.rb +9 -0
- data/lib/.DS_Store +0 -0
- data/lib/miranda/.DS_Store +0 -0
- data/lib/miranda/system/linux/application.rb +23 -0
- data/lib/miranda/system/linux/cpu.rb +50 -0
- data/lib/miranda/system/linux/disk.rb +30 -0
- data/lib/miranda/system/linux/os.rb +36 -0
- data/lib/miranda/system/linux/ps.rb +31 -0
- data/lib/miranda/system/linux/users.rb +28 -0
- data/lib/miranda/system/load.rb +9 -0
- data/lib/miranda/version.rb +1 -1
- data/miranda.gemspec +1 -1
- data/public/.DS_Store +0 -0
- data/public/coffeescript/dashboard.coffee +81 -0
- data/public/coffeescript/home.coffee +19 -0
- data/public/coffeescript/labels.coffee +7 -0
- data/public/css/app.css +43 -0
- data/public/css/bootstrap-theme.css +347 -0
- data/public/css/bootstrap-theme.css.map +1 -0
- data/public/css/bootstrap-theme.min.css +7 -0
- data/public/css/bootstrap.css +5831 -0
- data/public/css/bootstrap.css.map +1 -0
- data/public/css/bootstrap.min.css +7 -0
- data/public/fonts/.DS_Store +0 -0
- data/public/fonts/glyphicons-halflings-regular.eot +0 -0
- data/public/fonts/glyphicons-halflings-regular.svg +229 -0
- data/public/fonts/glyphicons-halflings-regular.ttf +0 -0
- data/public/fonts/glyphicons-halflings-regular.woff +0 -0
- data/public/js/.DS_Store +0 -0
- data/public/js/bootstrap.js +1951 -0
- data/public/js/bootstrap.min.js +6 -0
- data/public/sass/app.sass +15 -0
- data/views/.DS_Store +0 -0
- data/views/index.slim +38 -0
- data/views/layout.slim +21 -0
- data/views/memory.slim +1 -0
- metadata +45 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 32816bf328c3a90c6c0b515d8f7066d98beb2b05
|
4
|
+
data.tar.gz: d60a1bbd3fd404e412d936cb4bcd9f804db5247c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8f293d1ef21e9a0433d7f68094d15eac78ad89b6868d9207f75d3ecc154373702df1f7af65d136e5c746fdf0cabeaf137e17d8e5865a5189bc162353cb2e3b7c
|
7
|
+
data.tar.gz: ec9b8ae37beb20295e4e37920d1cd66b29f91789095614ba0fc8c291c240243565b668aa242850fe58adcb8f5ed024f77f773679f878a584c2deb925f1284ace
|
data/.DS_Store
ADDED
Binary file
|
data/.idea/.rakeTasks
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<Settings><!--This file was automatically generated by Ruby plugin.
|
3
|
+
You are allowed to:
|
4
|
+
1. Remove rake task
|
5
|
+
2. Add existing rake tasks
|
6
|
+
To add existing rake tasks automatically delete this file and reload the project.
|
7
|
+
--><RakeGroup description="" fullCmd="" taksId="rake"><RakeTask description="Build miranda-0.0.1.gem into the pkg directory" fullCmd="build" taksId="build" /><RakeTask description="Build and install miranda-0.0.1.gem into system gems" fullCmd="install" taksId="install" /><RakeTask description="Create tag v0.0.1 and build and push miranda-0.0.1.gem to Rubygems" fullCmd="release" taksId="release" /></RakeGroup></Settings>
|
data/.idea/encodings.xml
ADDED
data/.idea/misc.xml
ADDED
data/.idea/modules.xml
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<project version="4">
|
3
|
+
<component name="ProjectModuleManager">
|
4
|
+
<modules>
|
5
|
+
<module fileurl="file://$PROJECT_DIR$/.idea/miranda.iml" filepath="$PROJECT_DIR$/.idea/miranda.iml" />
|
6
|
+
</modules>
|
7
|
+
</component>
|
8
|
+
</project>
|
9
|
+
|
data/.idea/vcs.xml
ADDED
data/app.rb
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'sinatra/base'
|
3
|
+
require 'json'
|
4
|
+
require 'coffee-script'
|
5
|
+
require 'slim'
|
6
|
+
require 'sass'
|
7
|
+
|
8
|
+
|
9
|
+
module Miranda
|
10
|
+
class CoffeeEngine < Sinatra::Base
|
11
|
+
set :views, File.dirname(__FILE__) + '/public/coffeescript'
|
12
|
+
get "/javascripts/*.js" do
|
13
|
+
filename = params[:splat].first
|
14
|
+
coffee filename.to_sym
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
class SassEngine < Sinatra::Base
|
19
|
+
set :views, File.dirname(__FILE__) + '/public/sass'
|
20
|
+
get '/sass/*.css' do
|
21
|
+
filename = params[:splat].first
|
22
|
+
sass filename.to_sym
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
class System < Sinatra::Base
|
28
|
+
use CoffeeEngine
|
29
|
+
use SassEngine
|
30
|
+
|
31
|
+
|
32
|
+
enable :sessions
|
33
|
+
set :dump_errors, false
|
34
|
+
set :views, Proc.new { File.join(root, "views") }
|
35
|
+
|
36
|
+
get '/' do
|
37
|
+
slim :index
|
38
|
+
end
|
39
|
+
|
40
|
+
|
41
|
+
get '/users' do
|
42
|
+
@users = Users.new
|
43
|
+
$return_users = @users.parse
|
44
|
+
content_type :json
|
45
|
+
$return_users.to_json
|
46
|
+
end
|
47
|
+
|
48
|
+
get '/disk' do
|
49
|
+
@disk = Disk.new
|
50
|
+
content_type :json
|
51
|
+
@disk.parse.to_json
|
52
|
+
end
|
53
|
+
|
54
|
+
get '/applications' do
|
55
|
+
@applications = Application.new
|
56
|
+
content_type :json
|
57
|
+
@applications.parse.to_json
|
58
|
+
end
|
59
|
+
|
60
|
+
|
61
|
+
get '/ps' do
|
62
|
+
@ps = Ps_Aux.new
|
63
|
+
content_type :json
|
64
|
+
@ps.parse.to_json
|
65
|
+
end
|
66
|
+
|
67
|
+
get '/cpu' do
|
68
|
+
@cpu = Cpu.new
|
69
|
+
content_type :json
|
70
|
+
@cpu.parse.to_json
|
71
|
+
end
|
72
|
+
|
73
|
+
get '/os' do
|
74
|
+
@os = Os.new
|
75
|
+
content_type :json
|
76
|
+
@os.parse.to_json
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
|
83
|
+
|
data/bin/miranda
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require "optparse"
|
3
|
+
require "../lib/miranda/system/load"
|
4
|
+
system = RUBY_PLATFORM
|
5
|
+
|
6
|
+
if system.include? "darwin"
|
7
|
+
platform = "linux"
|
8
|
+
elsif system.include? "linux"
|
9
|
+
platform = "linux"
|
10
|
+
else
|
11
|
+
puts "Miranda supported is only mac and linux platforms !"
|
12
|
+
end
|
13
|
+
|
14
|
+
MirandaLoad::Load.new(platform)
|
15
|
+
|
16
|
+
port = 4000
|
17
|
+
|
18
|
+
opt = OptionParser.new
|
19
|
+
|
20
|
+
opt.on('-p VAL') do |p|
|
21
|
+
port = p
|
22
|
+
end
|
23
|
+
|
24
|
+
opt.parse!
|
25
|
+
|
26
|
+
puts "Miranda Started !"
|
27
|
+
|
28
|
+
require "../app.rb"
|
29
|
+
Miranda::System.run! :port => port
|
data/helpers/link.rb
ADDED
data/lib/.DS_Store
ADDED
Binary file
|
Binary file
|
@@ -0,0 +1,23 @@
|
|
1
|
+
class Application
|
2
|
+
@@applications
|
3
|
+
def initialize
|
4
|
+
@@applications = `/usr/bin/whereis php node mysql vim python ruby java apache2 nginx openssl vsftpd make'.'| /usr/bin/awk '{ split($1, a, ":");if (length($2)==0) print a[1]",not"; else print a[1]","$2;}'`
|
5
|
+
end
|
6
|
+
|
7
|
+
def parse
|
8
|
+
@@applications = @@applications.split("\n")
|
9
|
+
$return_data = {}
|
10
|
+
$i = 0
|
11
|
+
@@applications.each do |line|
|
12
|
+
line = line.split(",")
|
13
|
+
$i += 1
|
14
|
+
$return_data[$i] = {
|
15
|
+
'application' => line[0],
|
16
|
+
'status' => line[1]
|
17
|
+
}
|
18
|
+
end
|
19
|
+
|
20
|
+
$return_data
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
class Cpu
|
2
|
+
|
3
|
+
@@number_of_core
|
4
|
+
@@vendor_id
|
5
|
+
@@cpu_count
|
6
|
+
@@kernel_version
|
7
|
+
@@model_name
|
8
|
+
|
9
|
+
def initialize
|
10
|
+
self.total_core
|
11
|
+
self.cpu_information
|
12
|
+
self.model_name
|
13
|
+
self.cpu_count
|
14
|
+
self.kernel_version
|
15
|
+
end
|
16
|
+
|
17
|
+
def total_core
|
18
|
+
@@number_of_core = `/bin/grep -c ^processor /proc/cpuinfo`
|
19
|
+
end
|
20
|
+
|
21
|
+
def cpu_information
|
22
|
+
@@vendor_id = `/bin/grep -a ^vendor /proc/cpuinfo`
|
23
|
+
@@vendor_id.split("\n")[0].split("vendor_id")[1].split(":")[1]
|
24
|
+
end
|
25
|
+
|
26
|
+
def model_name
|
27
|
+
@@model_name = `/bin/grep model\ name /proc/cpuinfo|sort -u|awk '{print $5" "$7 $8 $9}'`
|
28
|
+
end
|
29
|
+
|
30
|
+
def cpu_count
|
31
|
+
@@cpu_count = `grep physical\ id /proc/cpuinfo |sort -u|wc -l`
|
32
|
+
end
|
33
|
+
|
34
|
+
def kernel_version
|
35
|
+
@@kernel_version = `uname -rsv`
|
36
|
+
end
|
37
|
+
|
38
|
+
|
39
|
+
def parse
|
40
|
+
$return_data = {
|
41
|
+
'number_of_core' => @@number_of_core,
|
42
|
+
'model_name' => @@model_name,
|
43
|
+
'vendor_id' => @@vendor_id,
|
44
|
+
'cpu_count' => @@cpu_count,
|
45
|
+
'kernel_version' => @@kernel_version
|
46
|
+
}
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# Worked on osx
|
2
|
+
class Disk
|
3
|
+
@@disk_usage
|
4
|
+
def initialize
|
5
|
+
@@disk_usage = `/bin/df -h|awk '{print $1","$2","$3","$4","$5","$6}'`
|
6
|
+
end
|
7
|
+
|
8
|
+
def parse
|
9
|
+
@@disk_usage = @@disk_usage.split("\n")
|
10
|
+
$return_data = {}
|
11
|
+
$i = 0
|
12
|
+
@@disk_usage.each do |disk|
|
13
|
+
disk = disk.split(",")
|
14
|
+
if disk[0] != "Filesystem" and disk[0] != "map"
|
15
|
+
$i += 1
|
16
|
+
$return_data[$i] = {
|
17
|
+
'Filesystem' => disk[0],
|
18
|
+
'Size' => disk[1],
|
19
|
+
'Used' => disk[2],
|
20
|
+
'Avail' => disk[3],
|
21
|
+
'Capacity' => disk[4],
|
22
|
+
'iused' => disk[5]
|
23
|
+
}
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
$return_data
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
class Os
|
2
|
+
|
3
|
+
@@os_bit
|
4
|
+
@@m_os
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
self.m_os
|
8
|
+
self.os_bit
|
9
|
+
end
|
10
|
+
|
11
|
+
def m_os
|
12
|
+
@@m_os = `egrep -i 'red\ hat|suse|centos|ubuntu|debian' /etc/issue`
|
13
|
+
@@m_os
|
14
|
+
end
|
15
|
+
|
16
|
+
def os_bit
|
17
|
+
@@os_bit = `uname -m`
|
18
|
+
if @@os_bit == "x86_64"
|
19
|
+
@@os_bit = "64bit"
|
20
|
+
else
|
21
|
+
@@os_bit == "32bit"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
|
26
|
+
def parse
|
27
|
+
$return_data = {
|
28
|
+
'os_bit' => @@os_bit,
|
29
|
+
'm_os' => @@m_os
|
30
|
+
}
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
a = Os.new
|
36
|
+
puts a.m_os
|
@@ -0,0 +1,31 @@
|
|
1
|
+
class Ps_Aux
|
2
|
+
@@ps_aux
|
3
|
+
|
4
|
+
def initialize
|
5
|
+
@@ps_aux = `/bin/ps aux | /usr/bin/awk -F: '{ print $1,$2,$3 }'`
|
6
|
+
end
|
7
|
+
|
8
|
+
def parse
|
9
|
+
@@ps_aux = @@ps_aux.split("\n")
|
10
|
+
$return = {}
|
11
|
+
$i = 0
|
12
|
+
@@ps_aux.each do |ps|
|
13
|
+
ps = ps.split(" ")
|
14
|
+
if ps[0] != "USER"
|
15
|
+
$i += 1
|
16
|
+
$return[$i] = {
|
17
|
+
'user' => ps[0],
|
18
|
+
'pid' => ps[1],
|
19
|
+
'cpu' => ps[2],
|
20
|
+
'mem' => ps[3],
|
21
|
+
'started' => ps[9],
|
22
|
+
'time' => ps[11]
|
23
|
+
}
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
$return
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
## Worked on osx
|
2
|
+
|
3
|
+
class Users
|
4
|
+
|
5
|
+
@@users
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
@@users = `/usr/bin/awk -F: '{ if ($3<=499) print "system,"$1","$6; else print "user,"$1","$6; }' < /etc/passwd`
|
9
|
+
end
|
10
|
+
|
11
|
+
def parse
|
12
|
+
$users = @@users.split("\n")
|
13
|
+
$i = 0
|
14
|
+
$return_users = {}
|
15
|
+
$users.each do |user_block|
|
16
|
+
$i += 1
|
17
|
+
user_block = user_block.split(",")
|
18
|
+
$return_users[$i] = {
|
19
|
+
'platform' => user_block[0],
|
20
|
+
'user' => user_block[1],
|
21
|
+
'directory' => user_block[2]
|
22
|
+
}
|
23
|
+
end
|
24
|
+
$return_users
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
end
|
data/lib/miranda/version.rb
CHANGED
data/miranda.gemspec
CHANGED
@@ -14,7 +14,7 @@ Gem::Specification.new do |spec|
|
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
16
16
|
spec.files = `git ls-files`.split($/)
|
17
|
-
spec.executables
|
17
|
+
spec.executables << "miranda"
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
data/public/.DS_Store
ADDED
Binary file
|
@@ -0,0 +1,81 @@
|
|
1
|
+
class Labels
|
2
|
+
getLabels: (keyword) ->
|
3
|
+
labels =
|
4
|
+
m_os: 'Operating System'
|
5
|
+
os_bit: 'System Bit'
|
6
|
+
return labels[keyword]
|
7
|
+
|
8
|
+
class Dashboard extends Labels
|
9
|
+
constructor: () ->
|
10
|
+
|
11
|
+
getGeneralInformation: () ->
|
12
|
+
html = ""
|
13
|
+
that = this
|
14
|
+
$.get "/os", (data) ->
|
15
|
+
$.each data, (key, value) ->
|
16
|
+
html += "<li> "+that.getLabels(key)+": "+(if value isnt "" then value else " No Result ")+"</li>"
|
17
|
+
return
|
18
|
+
$('#general-information').html html
|
19
|
+
|
20
|
+
getCpuInformation: () ->
|
21
|
+
html = ""
|
22
|
+
that = this
|
23
|
+
$.get "/cpu", (data) ->
|
24
|
+
$.each data, (key,result) ->
|
25
|
+
html += "<tr>"
|
26
|
+
html += "<td>#{result.number_of_core}</td>"
|
27
|
+
html += "<td>#{result.model_name}</td>"
|
28
|
+
html += "<td>#{result.vendor_id}</td>"
|
29
|
+
html += "<td>#{result.cpu_count}</td>"
|
30
|
+
html += "<td>#{result.kernel_version}</td>"
|
31
|
+
html += "</tr>"
|
32
|
+
return
|
33
|
+
$('#cpu_info').html html
|
34
|
+
|
35
|
+
getUsers: () ->
|
36
|
+
html = ""
|
37
|
+
that = this
|
38
|
+
$.get "/users", (data) ->
|
39
|
+
$.each data, (key ,result) ->
|
40
|
+
html += "<tr>"
|
41
|
+
html += "<td>#{result.platform}</td>"
|
42
|
+
html += "<td>#{result.user}</td>"
|
43
|
+
html += "<td>#{result.directory}</td>"
|
44
|
+
html += "</tr>"
|
45
|
+
return
|
46
|
+
$('#users').html html
|
47
|
+
|
48
|
+
getPs: () ->
|
49
|
+
html = ""
|
50
|
+
that = this
|
51
|
+
$.get "/disk", (data) ->
|
52
|
+
$('#disk').html "<tr><td colspan='7'>Loading...</td></tr>"
|
53
|
+
$.each data, (key,result) ->
|
54
|
+
html += "<tr>"
|
55
|
+
html += "<td>#{result.Filesystem}</td>"
|
56
|
+
html += "<td>#{result.Size}</td>"
|
57
|
+
html += "<td>#{result.Used}</td>"
|
58
|
+
html += "<td>#{result.Avail}</td>"
|
59
|
+
html += "<td>#{result.Capacity}</td>"
|
60
|
+
html += "</tr>"
|
61
|
+
return
|
62
|
+
$('#disk').html html
|
63
|
+
|
64
|
+
getCpuProc: () ->
|
65
|
+
$.get "/top_cpu", (data) ->
|
66
|
+
total = data.length
|
67
|
+
return_data = ''
|
68
|
+
i = 0
|
69
|
+
|
70
|
+
while i <= total
|
71
|
+
return_data += "<li>" + data[i] + "</li>" unless typeof data[i] is "undefined"
|
72
|
+
i++
|
73
|
+
$('#cpu_list').html return_data
|
74
|
+
return
|
75
|
+
|
76
|
+
|
77
|
+
|
78
|
+
dashboard = new Dashboard
|
79
|
+
dashboard.getGeneralInformation()
|
80
|
+
dashboard.getPs()
|
81
|
+
dashboard.getUsers()
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class Dashboard
|
2
|
+
constructor: () ->
|
3
|
+
|
4
|
+
getCpuProc: () ->
|
5
|
+
$.get "/top_cpu", (data) ->
|
6
|
+
total = data.length
|
7
|
+
return_data = ''
|
8
|
+
i = 0
|
9
|
+
|
10
|
+
while i <= total
|
11
|
+
return_data += "<li>" + data[i] + "</li>" unless typeof data[i] is "undefined"
|
12
|
+
i++
|
13
|
+
$('#cpu_list').html return_data
|
14
|
+
return
|
15
|
+
|
16
|
+
|
17
|
+
|
18
|
+
dashboard = new Dashboard
|
19
|
+
dashboard.getCpuProc()
|
data/public/css/app.css
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
body {
|
2
|
+
font-family: 'Quattrocento Sans', sans-serif;
|
3
|
+
}
|
4
|
+
|
5
|
+
.wrapper {
|
6
|
+
margin-top:100px;
|
7
|
+
}
|
8
|
+
|
9
|
+
.navbar .nav a {
|
10
|
+
font-size: 11px;
|
11
|
+
}
|
12
|
+
.navbar .nav>li>a { color:#fff !important;}
|
13
|
+
.navbar .brand {
|
14
|
+
font-weight: 600;
|
15
|
+
position: relative;
|
16
|
+
top: 8px;
|
17
|
+
font-size:15px;
|
18
|
+
}
|
19
|
+
|
20
|
+
.navbar {
|
21
|
+
background-color:#c0392b;
|
22
|
+
color: #999999;
|
23
|
+
}
|
24
|
+
|
25
|
+
.navbar .brand:hover {
|
26
|
+
text-decoration: none;
|
27
|
+
}
|
28
|
+
|
29
|
+
.navbar .brand {
|
30
|
+
float: left;
|
31
|
+
display: block;
|
32
|
+
padding: 8px 20px 12px;
|
33
|
+
margin-left: -20px;
|
34
|
+
font-size: 20px;
|
35
|
+
font-weight: 200;
|
36
|
+
line-height: 1;
|
37
|
+
color: #ffffff;
|
38
|
+
}
|
39
|
+
|
40
|
+
.navbar .navbar-text {
|
41
|
+
margin-bottom: 0;
|
42
|
+
line-height: 40px;
|
43
|
+
}
|