Project

General

Profile

ClientPgGraph2Install » History » Version 3

Aurynn Shaw, 03/19/2008 01:46 PM

1 1 Aurynn Shaw
README -- Mar 13, 2008 -- Aurynn Shaw -- ashaw@commandprompt.com
2
3
== At A Glance Installation ==
4
5
 * Use /var/www/python/_main/install.py. Consult this document for specifics.
6
 * symlink busy_dml_report.py into your new install dir.
7
 * Run the forwarder, /var/www/python/_main/forward.py /path/to/your/new/install
8
 * Check if you need to set up a bastion install
9
   * If you do, ssh to the bastion and run
10
     * screen
11
     * inside screen: ssh -L7750:localhost:5432 cmd@the_actual_db_server
12
     * ctrl-a ctrl-d, detach from screen. It keeps on truckin'.
13
 * Run python /var/www/pggraph/_main/bridge.py /path/to/your/new/install/config.ini
14
 * Wait until it returns. Now run it again.
15
 * check http://www.cmdalert.com/pggraph/your_install/
16
 * Make sure there's graphs.
17
 * Go edit the Apache config, copy and paste the existing format for PG-backed password auth.
18
   * The file is 001-something in /etc/apache2/sites-enabled
19
 * Using the existing format, dump and add the database users from the client 
20
   Trac to serve as the auth for pggraph.
21
 * Reload apache.
22
 * Add the cronjob, based on the other cronjobs for pggraph.
23
 * Fini.
24
     
25
== Introduction ==
26
27
If youre reading this document, congratulations! Youve managed to 
28
successfully install the server software for PGGraph! Youve done an amazing
29
thing, and you ought to be proud of yourself.
30
31
This document will be discussing the next step, setting up client systems for
32
pggraph, the configuration weirdness and gotchas that you need to know.
33
34
The specific sections in this document are as follows:
35
36
 * The Installer
37
 * Server preparation
38
 * Running it the first time
39
 * Cronjob
40
 * Cursing
41
 
42
== The Installer ==
43
44
Step one, setting up a client instance.
45
Given PGGraphs curious evolutionary path, the process of installing a client
46
was once much more difficult than it is now, and thus, I created the 
47
Installer.
48
49
The installer is run from the source directory of all PGGGraph scripts - in
50
the case of cmdalert.com, /var/www/pggraph/_main/
51
52
The software is executed thusly:
53 3 Aurynn Shaw
{{{
54
  $ python ./install.py
55
}}}
56 1 Aurynn Shaw
It will then ask you a number of questions specifically relating to the 
57
install process.
58
For clarity, the installer is reproduced here to give you a basic walkthrough
59
on what values are expected and a basic concept of how PGGraph works.
60
61
{{{
62
    
63
    Installation directory?  || Requires absolute path: This is the exact path to the install. /var/www/pggraph/some_dir. || 
64
    Relative WWW path?  || Usually pggraph/prefix: pggraph/some_dir. Controls HTML generation. || 
65
    Full text title?  || Usually customer name: Page title, in the databse || 
66
    Now for some database configuration..
67
68
    Local pggraph database name? [pggraph]  || Don't change this, unless you're putting their data in a new DB || 
69
    Table prefix?  || some prefix, like aweber or vltlgx or something. To keep tables from colliding. || 
70
    Local database port? [5432]  || It's on 5432. || 
71
    Local pggraph host? usually localhost [localhost]  || It's always localhost. Except when it isn't. || 
72
    
73
    Local username? usually pggraph [pggraph]  || It's pggraph. || 
74
    Password? Can be blank [8sm4LA2]  || It's this password. || 
75
76
    Remote DB username?  || Username we connect to the remote DB with. cmd, postgres, or other. || 
77
    Remote DB password?  || As described || 
78
    Remote DB host? [localhost]  || Almost always localhost. || 
79
    Local port to bind to remote PG port? [7555]  || Always a non-5432 local port. || 
80
81
    Some pggraph settings..
82
83
    Shortest display interval, in minutes? [10]  || How frequently we're updating the database. || 
84
    Maximum number of images per page? [10]  || Suffers from an off-by-one error, so enter 1 more than you want to display. || 
85
    Delay before continuing PGGraph startup [7]  || Number of seconds after initializing a new tunnel via forward, that the script waits before attempting to connect. || 
86
87
    So far, so good. Now for the SSH configuration for the PG tunnel.
88
89
    SSH User?  || SSH user name. almost always cmd || 
90
    SSH Password?  || Deprecated in favour of || 
91
    Authentication keyfile? [/home/pggraph/.ssh/id_dsa]  || the default admin ssh key. Good almost everywhere. || 
92
    Remote server?  || remote server IP || 
93
    Port to SSH to? [22]  || Remote port to SSH to || 
94
    Bind to what port? [5432]  || Remote port to bind to - not always 5432, in cases of bastions. || 
95
    Bind to which remote address? [localhost]  || Again, not always, in case of bastions. || 
96
    Use a twin tunnel mechanism? Leave blank if you dont know currently buggy:  || Don't use this. It was a prior attempt at making bastions work. || 
97
        Address for 2nd server?  || Only shows up if you select twin tunnel. So don't. :) || 
98
    
99
}}}
100
101
Any question with a [] following it indicates that pressing enter will give 
102
you the default value.
103
104
Once you've answered all the installer's questions, it will go off and create
105
the appropriate directories, create symlinks for all the necessary scripts and
106
libraries, as well as write out the configuration data.
107
108
At this point, you're about halfway done.
109
110
The first step (as of Mar 17, 2008), is to symlink busy_dml_report.py into the
111
freshly created directory. It's a recent addition and is not yet supported by
112
the installer script.
113
114
== Server Preparation ==
115
116
=== No Bastion ===
117
The next step is, the remote server information needs to be verified. This is 
118
always going to be in the customers' Trac wiki, and easily found.
119
120
To test the tunneling setup:
121
122
{{{
123
    
124
   $ python /var/www/pggraph/forward.py /var/www/new_server
125
   Initializing tunnel..
126
   $ psql -d template1 -U cmd -h localhost -p <the port you gave it>
127
}}}
128
129
If you connect, success! You can move on to the next phase in the installation.
130
131
If you don't, you can use the error message you got in helping you track down
132
why. The most common errors I've had are specific to pg_hba settings being
133
incorrect, and the cmd user not existing.
134
135
136
=== Bastions ===
137
138
A fact of life, some of our customers don't trust people on the internet. It's
139
hard to not blame them for that, but it does make our life a lot harder when
140
it comes to running pggraph for them.
141
142
To set up a bastion host for pggraph, you're going to need to do a little bit
143
of trickery.
144
145
The specific process I've followed is:
146
 * Set up forward.py as normal on cmdalert.
147
 * ssh into the bastion server
148
 * Using screen, run
149
   {{{
150
       ssh -L7750:localhost:5432 cmd@the_actual_db_server
151
   }}}
152
 * Detach from screen, leaving the ssh tunnel open.
153
 * Now that you're back on the bastion server, see if you can telnet to port 
154
   7750. 
155
 * If you can, disconnect and attempt to connect via psql from cmdalert.
156
   * Retrace your steps in the event that you can't connect.
157
   * Most error messages are going to be caused by incorrect settings in
158
     pg_hba.conf.
159
     
160
You will need to check on your bastion-side tunnel from time to time, as 
161
they are significantly more fragile than the standard pggraph installation,
162
and require manual intervention to recreate.
163
164
165
== Running PGGraph ==
166
167
At this point, you're close to finished the PGGraph installation. The next 
168
step is to run the data-collecting script and test for proper graph 
169
generation.
170
171
This is fairly easily done, simply
172
{{{
173
python ../_main/bridge.py ./config.ini
174
}}}
175
from the newly installed PGGraph client path.
176
177
This will attempt to connect across the tunnel and collect the data that is
178
used to build the graphs.
179
180
At this point, you should open a browser window to the newly created path (as
181
mentioned in the installer), usually http://cmdalert.com/pggraph/your_client/
182
The first graph is a good indicator whether or not data is being correctly
183
collected, and its presence shows that you can move on to the next step.
184
185
If it fails to display, first you should re-run the data collector, and test 
186
the graph again. A lot of the architecture of PGGraph is based around deltas
187
of dataset - (dataset - 1 time unit), so only a single database entry may 
188
cause unintended failure.
189
190
If that fails, verify that your connection chain is intact. Failing that, feel
191
free to email me and ask for help.
192
193
194
== Cron ==
195
196
In order for PGGraph to continue to collect data about its client systems, the
197
data collector needs to be run on a regular basis. Thus, comes the cronjob.
198
199
Adding the cronjob is simple: as the pggraph user, add a line similar to the 
200
following to your crontab, and you're done.
201
202
{{{
203
    */10 * * * * /usr/bin/python /var/www/pggraph/_main/bridge.py /var/www/pggraph/your_install_dir/config.ini
204
    or
205
    5,15,25,35,45,55 * * * * /usr/bin/python /var/www/pggraph/_main/bridge.py /var/www/pggraph/your_install_dir/config.ini
206
}}}
207
208
Write out the crontab, and pggraph is now collecting data on a regular cycle.
209
210
211
== Apache ==
212
213 2 Aurynn Shaw
As pggraph contains a lot of very detailed information on the structure
214 1 Aurynn Shaw
of the clients' database, it's generally a bad idea for anyone who can type in
215
a URL to be able to access it.
216
217
From that, we come to require an authentication system to keep fingers and 
218
eyeballs from where they don't belong.
219
220
As we're using a Pg-backed authentication system in Apache, and as it's 
221 2 Aurynn Shaw
already fully set up, I won't go into any detail regarding installation or
222
configuration issues.
223
224
To set up the directory-specific authentication, you should copy and paste
225
the following configuration and modify it as needed to fit the new PGGraph
226
installation.
227
228
The file that needs to be altered is /etc/apache2/sites-enabled/default-ssl
229
Please back up this file prior to modification.
230
231
{{{
232
<Location /pggraph/your_install>
233
234
        AuthName "Pggraph authentication for: Your Installation"
235
        AuthType Basic
236
        Auth_PG_host localhost
237
        Auth_PG_port 5432
238
        Auth_PG_user pggraph
239
        Auth_PG_pwd 8sm4LA2
240
        Auth_PG_authoritative on
241
        Auth_PG_database pggraph_users
242
        Auth_PG_pwd_table client_users
243
        Auth_PG_hash_type MD5
244
        Auth_PG_uid_field user_name
245
        Auth_PG_pwd_field user_passwd
246
        Auth_PG_log_table client_access_log
247
        Auth_PG_log_uname_field login
248
        Auth_PG_log_date_field date
249
        Auth_PG_log_uri_field   request
250
        Auth_PG_log_addrs_field  ip_address
251
        AuthBasicAuthoritative Off
252
        Require valid-user
253
</Location>
254
}}}
255
256
Reload Apache via /etc/init.d/apache2 reload, and your new 
257
pggraph installation is now completed.