Agenda: exercises-mrtg-rrdtool.txt

File exercises-mrtg-rrdtool.txt, 5.3 KB (added by hervey, 8 years ago)
Line 
1MRTG and RRDTool
2================
3
4Notes:
5------
6* Commands preceded with "$" imply that you should execute the command as
7  a general user - not as root.
8* Commands preceded with "#" imply that you should be working as root.
9* Commands with more specific command lines (e.g. "GW-RTR>" or "mysql>")
10  imply that you are executing commands on remote equipment, or within
11  another program.
12* If a command line ends with "\" this indicates that the command continues
13  on the next line and you should treat this as a single line.
14
15Exercises Part I
16================
17
180. Log in to your PC/VM or open a terminal window as the sysadm user.
19
201. Install MRTG
21---------------
22
23We will install MRTG and graph input/output data for the network interfaces on our classroom
24routers - i.e. how much traffic is flowing across the router.
25
26        $ sudo apt-get install mrtg
27       
28When asked whether the file should be owned and readable only by root choose "<No>" as it
29does need to be readable by RRDTool later on.
30
31
322. Create the /etc/mrtg directory
33---------------------------------
34
35        $ sudo mkdir /etc/mrtg
36
37
383. SNMP RO Community string: "NetManage"
39----------------------------------------
40
41You will need this information later.
42
434. Find the IP and Name of the Device
44-------------------------------------
45
46You will do this exercises against your router. So, name and IP is
47
48        name:   rtrX.ws.nsrc.org
49        IP:     10.10.X.254
50       
51So, for Group 3 the information would be:
52
53        name:   rtr3.ws.nsrc.org
54        IP:     10.10.3.254
55       
56You need this information for step 5 (below).
57
58
595. Run cfgmaker (the command below all on one line!)
60----------------------------------------------------
61
62Let's become the root user at this point:
63
64        $ sudo bash
65       
66You are now root and your prompt should have a "#" at the end to indicate this.
67       
68        # mkdir -p /var/www/mrtg
69
70        # /usr/bin/cfgmaker --output=/etc/mrtg/device.mrtg --global 'workdir: /var/www/mrtg' --global \
71          'options[_]: growright,bits' NetManage@10.10.X.254
72
73
74View the mrtg configuration file created by cfgmaker, you can make changes and see the results,
75if you want (/etc/mrtg/device.mrtg). For now, however, leave the file as it is.
76
77
786. Use indexmaker to create HTML files (all on one line!)
79---------------------------------------------------------
80
81        # /usr/bin/indexmaker --output=/var/www/mrtg/device.html /etc/mrtg/device.mrtg
82
83
847. Run MRTG command. Do this THREE TIMES! Really, THREE TIMES
85-------------------------------------------------------------
86
87        # LANG=C /usr/bin/mrtg /etc/mrtg/device.mrtg
88
89
90NOTE: Ubuntu/Debian will probably complain about LANG at this point. If this is so, just run
91the command above as:
92
93        # "LANG=C /usr/bin/mrtg /etc/mrtg/device.mrtg"
94
95
968. Put the above command in a script
97------------------------------------
98
99        # echo 'LANG=C /usr/bin/mrtg /etc/mrtg/device.mrtg' >/etc/mrtg/mrtgscript
100       
101Make the script executable:
102
103        # chmod +x /etc/mrtg/mrtgscript
104
105
1069. Edit the crontab and insert the command to be run every 5 minutes
107---------------------------------------------------------------------
108
109        # crontab -e
110
111
112add:
113
114        0-59/5 * * * * /etc/mrtg/mrtgscript
115
116Save the file and exit.
117
118
11910. Load the browser through webserver
120---------------------------------------
121
122View the MRTG output in a browers. Point to your PC (pc1 through pc26):
123
124http://pcX.ws.nsrc.org/mrtg/device.html
125
126You will not see any results for a while - up to 10 minutes. At that point your
127graph should be moving.
128
129
130
131
132RRDTool
133--------
134
1351. Install the Required Pieces
136------------------------------
137
138        # apt-get install rrdtool
139        # apt-get install librrdp-perl
140        # apt-get install librrds-perl
141
142Or, you could just type:
143
144        # apt-get install rrdtool librrdp-perl librrds-perl
145
146This may take a while.
147
1482. Add in your MRTG Configuration file
149--------------------------------------
150
151        # vi /etc/mrtg/device.mrtg
152
153
154Look for the following near the top of the file:
155
156        #  for Debian
157        WorkDir: /var/www/mrtg
158
159Add a line just below the "WorkDir" line that reads:
160
161        LogFormat: rrdtool
162
163Exit and save the file.
164
165Force quick, initial creation of the rrd files in /var/www/mrtg:
166
167        # /etc/mrtg/mrtgscript
168       
169Look at /var/www/mrtg and notice that there are now files named *.rrd:
170
171        # ls /var/www/mrtg
172
173
174But what about graphs?
175
176
1773. Install mrtg-rrd
178-------------------
179
180        # apt-get install mrtg-rrd
181        # cd /usr/lib/cgi-bin
182        # ln -s mrtg-rrd.cgi 14all.cgi
183
184
1854. Run indexmaker again
186------------------------
187
188        # /usr/bin/indexmaker --output=/var/www/mrtg/device.html /etc/mrtg/device.mrtg
189
190
1915. Create /etc/mrtg-rrd.conf
192----------------------------
193
194        # echo '/etc/mrtg/device.mrtg' >/etc/mrtg-rrd.conf
195
196
1974. Make /var/www/mrtg writeable for the Web server
198---------------------------------------------------
199
200        # chown www-data /var/www/mrtg
201
202
2035. Remove the old PNG files for the MRTG graphs
204-----------------------------------------------
205
206        # rm /var/www/mrtg/10.10*.png
207
208
2096. Look at the webpage (http://pcX.ws.nsrc.org/mrtg/device.html) again
210----------------------------------------------------------------------
211
212You now have links to the graphs. Click on each one to see the new graphs. They look
213different, but contain the same information.
214
215Graphs are generated dynamically using RRD vs. being stored as separate PNG files every
216five minutes.
217
218You can adjust the look of pages, text on the pages, etc. by hand-editing the various files
219if you wish, but it is rather tedious...
220
221        /etc/mrtg/device.mrtg
222        /var/www/mrtg/device.html
223       
224etc.