Class: Commandline

Inherits:
Thor
  • Object
show all
Defined in:
lib/barrage/commandline.rb

Constant Summary collapse

@@dstat_pid =
0
@@unique_id =
""
@@dstat_file =
""
@@image_file =
""

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.dstat_fileObject



18
19
20
# File 'lib/barrage/commandline.rb', line 18

def self.dstat_file
  @@dstat_file
end

.dstat_pidObject



8
9
10
# File 'lib/barrage/commandline.rb', line 8

def self.dstat_pid
  @@dstat_pid
end

.image_fileObject



23
24
25
# File 'lib/barrage/commandline.rb', line 23

def self.image_file
  @@image_file
end

.plot(filename) ⇒ Object



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/barrage/commandline.rb', line 57

def self.plot(filename)
  Gnuplot.open do |gp|
    Gnuplot::Plot.new(gp) do |plot|
      plot.term "png truecolor enhanced fontscale 1.0 size 1920, 1080 font 'Arial,16'"
      plot.output @@image_file
      plot.multiplot "layout 4,2"
      plot.origin "0.0,0.5"
      plot.size "0.5,0.5"

      self.template(plot)
      CPU.perform(filename, plot)
    end

    Gnuplot::Plot.new(gp) do |plot|
      plot.origin "0.5,0.5"
      plot.size "0.5,0.5"

      self.template(plot)
      Memory.perform(filename, plot)
    end

    Gnuplot::Plot.new(gp) do |plot|
      plot.origin "0.0,0.0"
      plot.size "0.5,0.5"

      self.template(plot)
      Network.perform(filename, plot)
    end
  end
end

.template(plot) ⇒ Object



45
46
47
48
49
50
51
52
53
54
55
# File 'lib/barrage/commandline.rb', line 45

def self.template(plot)
  plot.key "font 'Verdana,24'"
  plot.object '1 rectangle from screen 0,0 to screen 3,3 fillcolor rgb"black" behind'
  plot.object '1 rect from graph 0, 0, 0 to graph 1, 1, 0'
  plot.object '1 behind lw 1.0 fc rgb "#000000" fillstyle solid 1.00 border lt -1'
  plot.key 'textcolor rgb "#FFFFFF"'
  plot.key 'inside top center horizontal Right noreverse enhanced autotitles nobox'
  plot.key 'samplen 1 spacing 1.0 font "Arial,16"'
  plot.style "fill transparent solid 0.2"
  plot.grid
end

.unique_idObject



13
14
15
# File 'lib/barrage/commandline.rb', line 13

def self.unique_id
  @@unique_id
end

.uploadObject



88
89
90
91
92
# File 'lib/barrage/commandline.rb', line 88

def self.upload
  puts "Uploading to imgur..."
  output = `imgurr upload #{@@image_file}`
  puts "#{output.split(" ")[1]}"
end

Instance Method Details

#captureObject



28
29
30
# File 'lib/barrage/commandline.rb', line 28

def capture
  dstat
end