Agenda: exercises-mrtg-rrdtool.txt

File exercises-mrtg-rrdtool.txt, 5.2 KB (added by admin, 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
414. Find the IP and Name of the Device
42-------------------------------------
43
44You will do this exercises against your router. So, name and IP is
45
46        name:   rtrX.ws.nsrc.org
47        IP:     10.10.X.254
48       
49So, for Group 3 the information would be:
50
51        name:   rtr3.ws.nsrc.org
52        IP:     10.10.3.254
53       
54You need this information for step 5 (below).
55
56
575. Run cfgmaker (the command below all on one line!)
58----------------------------------------------------
59
60Let's become the root user at this point:
61
62        $ sudo bash
63       
64You are now root and your prompt should have a "#" at the end to indicate this.
65       
66        # mkdir -p /var/www/mrtg
67
68        # /usr/bin/cfgmaker --output=/etc/mrtg/device.mrtg --global 'workdir: /var/www/mrtg' --global
69          'options[_]: growright,bits' NetManage@10.10.X.254
70
71
72View the mrtg configuration file created by cfgmaker, you can make changes and see the results,
73if you want (/etc/mrtg/device.mrtg). For now, however, leave the file as it is.
74
75
766. Use indexmaker to create HTML files (all on one line!)
77---------------------------------------------------------
78
79        # /usr/bin/indexmaker --output=/var/www/mrtg/device.html /etc/mrtg/device.mrtg
80
81
827. Run MRTG command. Do this THREE TIMES! Really, THREE TIMES
83-------------------------------------------------------------
84
85        # LANG=C /usr/bin/mrtg /etc/mrtg/device.mrtg
86
87
88NOTE: Ubuntu/Debian will probably complain about LANG at this point. If this is so, just run
89the command above as “LANG=C /usr/bin/mrtg /etc/mrtg/device.mrtg”
90
91
928. Put the above command in a script
93------------------------------------
94
95        # echo 'LANG=C /usr/bin/mrtg /etc/mrtg/device.mrtg' >/etc/mrtg/mrtgscript
96       
97Make the script executable:
98
99        # chmod +x /etc/mrtg/mrtgscript
100
101
1029. Edit the crontab and insert the command to be run every 5 minutes
103---------------------------------------------------------------------
104
105        # crontab -e
106
107
108add:
109
110        0-59/5 * * * * /etc/mrtg/mrtgscript
111
112Save the file and exit.
113
114
11510. Load the browser through webserver
116---------------------------------------
117
118View the MRTG output in a browers. Point to your PC (pc1 through pc26):
119
120http://pcX.ws.nsrc.org/mrtg/device.html
121
122Go for Tea /come back and see if your graph is moving (wait at LEAST 10 minutes!)
123
124
125
126
127RRDTool
128--------
129
1301. Install the Required Pieces
131------------------------------
132
133        # apt-get install rrdtool
134        # apt-get install librrdp-perl
135        # apt-get install librrds-perl
136
137Or, you could just type:
138
139        # apt-get install rrdtool librrdp-perl librrds-perl
140
141This may take a while.
142
1432. Add in your MRTG Configuration file
144--------------------------------------
145
146        # vi /etc/mrtg/device.mrtg
147
148
149Look for the following near the top of the file:
150
151        #  for Debian
152        WorkDir: /var/www/mrtg
153
154Add a line just below the "WorkDir" line that reads:
155
156        LogFormat: rrdtool
157
158Exit and save the file.
159
160Force quick, initial creation of the rrd files in /var/www/mrtg:
161
162        # /etc/mrtg/mrtgscript
163       
164Look at /var/www/mrtg and notice that there are now files named *.rrd:
165
166        # ls /var/www/mrtg
167
168
169But what about graphs?
170
171
1723. Install mrtg-rrd
173-------------------
174
175        # apt-get install mrtg-rrd
176        # cd /usr/lib/cgi-bin
177        # ln -s mrtg-rrd.cgi 14all.cgi
178
179
1804. Run indexmaker again
181------------------------
182
183        # /usr/bin/indexmaker --output=/var/www/mrtg/device.html /etc/mrtg/device.mrtg
184
185
1865. Create /etc/mrtg-rrd.conf
187----------------------------
188
189        # echo '/etc/mrtg/device.mrtg' >/etc/mrtg-rrd.conf
190
191
1924. Make /var/www/mrtg writeable for the Web server
193---------------------------------------------------
194
195        # chown www-data /var/www/mrtg
196
197
1985. Remove the old PNG files for the MRTG graphs
199-----------------------------------------------
200
201        # rm /var/www/mrtg/10.10*.png
202
203
2046. Look at the webpage (http://pcX.ws.nsrc.org/mrtg/device.html) again
205----------------------------------------------------------------------
206
207You now have links to the graphs. Click on each one to see the new graphs. They look
208different, but contain the same information.
209
210Graphs are generated dynamically using RRD vs. being stored as separate PNG files every
211five minutes.
212
213You can adjust the look of pages, text on the pages, etc. by hand-editing the various files
214if you wish, but it is rather tedious...
215
216        /etc/mrtg/device.mrtg
217        /var/www/mrtg/device.html
218       
219etc.