Module: Processwatch_setup

Defined in:
lib/processwatch/pw_setup.rb

Overview

License: (MIT), Copyright © 2013 Process Watch Author Phil Chen.

Instance Method Summary collapse

Instance Method Details

#setupObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/processwatch/pw_setup.rb', line 5

def setup
  if File.directory?("/usr/local/processwatch")

  puts "Process Watch Is Already Been Installed In /usr/local/processwatch"

  else

  `mkdir -p /usr/local/processwatch/conf`
  general_restart_contact = "/usr/local/processwatch/conf/general_restart_contact"
  restart_ssh = "/usr/local/processwatch/conf/restart_ssh"
  runaway = "/usr/local/processwatch/conf/runaway"
  processwatch = "/usr/local/processwatch/processwatch.rb"

grc = "#CONFIGURATION KEY\n#\#$restart_smtp_host = SMTP Server To Send Email From\n#\#$restart_smtp_port = SMTP Server Port To Send Email From\n#\#$restart_from = Name of the Email From Field\n#\#$restart_to = Name of the Email To Field\n#\#$restart_from_email = Email Address the Notification Comes From\n#\#$restart_to_email = Email Address the Notification Goes To\n#\n$restart_smtp_host = \"127.0.0.1\"\n$restart_smtp_port = \"25\"\n$restart_from = \"FromName\"\n$restart_to = \"ToName\"\n$restart_from_email = \"[email protected]\"\n$restart_to_email = \"[email protected]\"\n\n"

rs = "#CONFIGURATION KEY\n#\#$restart_mail = yes or no send email notifying of dead process\n#\#$restart_start = yes or no start the dead process\n#\#$restart_process = name of process try to be unique, you can find the names of processes by running: ps h -eo cm\n#\#$restart_action = command to start the process try to use full paths for everything\n#\n$restart_mail = \"no\"\n$restart_start = \"no\"\n$restart_process = '/usr/sbin/sshd'\n$restart_action = '/etc/init.d/sshd start'\n\n"

r = "#CONFIGURATION KEY\n#\#$runaway_max_time = Maximum CPU Time in Seconds That Defines a Run Away Process\n#\#$runaway_smtp_host = SMTP Server To Send Email From\n#\#$runaway_smtp_port = SMTP Server Port To Send Email From\n#\#$runaway_from = Name of the Email From Field\n#\#$runaway_to = Name of the Email To Field\n#\#$runaway_from_email = Email Address the Notification Comes From\n#\#$runaway_to_email = Email Address the Notification Goes To\n#\#$runaway_mail = yes or no send email notifying the runaway process\n#\#$runaway_kill = yes or no kill the runaway process **NOTE BE CAREFUL THIS WILL KILL THE PROCESS\n#\n$runaway_max_time = \"6000\"\n$runaway_smtp_host = \"127.0.0.1\"\n$runaway_smtp_port = \"25\"\n$runaway_from = \"FromName\"\n$runaway_to = \"ToName\"\n$runaway_from_email = \"[email protected]\"\n$runaway_to_email = \"[email protected]\"\n$runaway_mail = \"no\"\n$runaway_kill = \"no\"\n\n"

pw = "#!/usr/bin/ruby\n\nrequire 'processwatch'\n\ninclude Processwatch\n\n  restart\n  runaway\n\n"

  output = File.open(general_restart_contact, 'w')
  output.puts grc
  output.close

  output = File.open(restart_ssh, 'w')
  output.puts rs
  output.close

  output = File.open(runaway, 'w')
  output.puts r
  output.close

  output = File.open(processwatch, 'w')
  output.puts pw
  output.close

  puts ""
  puts "Installation of Directory Structure and Configuration Files Successful!"
  puts ""
  puts "Go to /usr/local/processwatch/conf to edit configuration files"
  puts ""
  end
end