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