Project

General

Profile

ClientPgGraph2Install » History » Version 4

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