PDA

View Full Version : [ubuntu] Monitor multiple devices with MRTG



majestiknl
March 10th, 2010, 08:25 AM
Hello,

At the moment I'm taking my first steps into Ubuntu since I work at a IT department.

They asked me if I could find out how to monitor multiple devices (routers and switches) with MRTG. The program is up and running on Ubuntu Server but the next job is to monitor more devices.

I searched google and many people came up with another <devicename>.cfg file. I tried this but it won't work.

Here (http://www.iceflatline.com/?s=mrtg) is a tutorial I used to get MRTG to work on my Ubuntu Server.

My question: could someone please tell me how to add another device to MRTG?

Thanks for the support!

Tristan

ps, sorry for bad English ;)

majestiknl
March 10th, 2010, 09:37 AM
Additional information:

The first <device name>.cfg will start to monitor, the second cfg file I try to start wont work.

I use the command
sudo env LANG=C /usr/bin/mrtg /etc/<folder>/<dev name>.cfg to start the cfg files. I think it has to be something with the command.

I also get an error: I Quit, mrtg is already running.

However, sometimes it will run and saying: Daemonizing.

Thanks!

Grenage
March 10th, 2010, 09:46 AM
If you're running as a daemon then it will always be running in the background. I personally don't have that, I just have a load of config files and a crontab entry for the scheduling. For example, in my crontab -e:


*/5 * * * * env LANG=C mrtg /var/lib/mrtg/router1.cfg
*/5 * * * * env LANG=C mrtg /var/lib/mrtg/router2.cfg

I don't know if this is the best way to go about it, but it's easy to manage.

majestiknl
March 10th, 2010, 09:54 AM
Thnx Grenage for your reply.

Im going to ty your advice.

I tried your given command (crontab -e) and it says I don't have one yet. Is this normal?

Edit:
Created the crontab file... what name should I give it and in what folder should the file be?

Grenage
March 10th, 2010, 10:04 AM
It's normal if you haven't used it before. It might be worth stopping MRTG from running as a daemon when the machine boots up, otherwise you'll probably run into the same problem.

majestiknl
March 10th, 2010, 10:10 AM
Thanks for your reply, ill keep you updated :)

Grenage
March 10th, 2010, 10:13 AM
You shouldn't need to manually create it yourself! By typing "crontab -e" (as the user who will be running the commands) it should create it for you:


grenage@ubqd:~$ crontab -e
no crontab for grenage - using an empty one

Select an editor. To change later, run 'select-editor'.
1. /bin/ed
2. /bin/nano <---- easiest
3. /usr/bin/vim.basic
4. /usr/bin/vim.tiny

majestiknl
March 10th, 2010, 10:40 AM
Hey Grenage,

I did what you said and I get the same message as you. I choose nano and then i get the following screen:


GNU nano 2.0.9 file: /tmp/crontab.uRqFMC/crontab

# m h dom mon dow command

Then I typ the same as you but with my path to the cfg files and ofcourse their filename.

Then I say Write out and it askes for a file name to write to. So I choose the same folder as suggested by nano and I reboot.

But it won't start MRTG :(.

I think it's a really small thing I'm doing wrong...

Grenage
March 10th, 2010, 10:48 AM
I think the crontab files are kept in /var/spool/cron/crontabs/, so mine would be /var/spool/cron/crontabs/grenage.

I've never used Nano (I'm a vim man), but it should work just as well! Does the command (env LANG=C mrtg /var/lib/mrtg/xxxxx.cfg) work in the command line, now that MRTG is not running as a daemon?

majestiknl
March 10th, 2010, 10:57 AM
Does the command (env LANG=C mrtg /var/lib/mrtg/xxxxx.cfg) work in the command line, now that MRTG is not running as a daemon?

My command looks like this:


sudo env LANG=C /usr/bin/mrtg /etc/mrtg-dev-1/router1.cfg

And yes, it works for only one device.

I'm going to try to find that folder/file and see if my crontab is there.

Grenage
March 10th, 2010, 11:11 AM
If the command needs to be run as root, then you'll want to modify the crontab of root:


sudo -s
crontab -e
exit

majestiknl
March 10th, 2010, 11:23 AM
Right now my crontab is created. After a reboot (and login) it wont start.

My crontab looks like this:


*/5 * * * * env LANG=C /usr/bin/mrtg /etc/mrtg-dev-1/router1.cfg

After the edit it said that the crontab was written and it is in the correct dir.

Thanks in advance

Edit:

Going to try your suggested sudo ;) seems i dont have some permissions.

Grenage
March 10th, 2010, 11:27 AM
so crontab -e (as root) displays correctly but does not run, and the command works from the command line correctly?


Going to try your suggested sudo seems i dont have some permissions.

Ok!

majestiknl
March 10th, 2010, 11:31 AM
Grenage, your the best. It works for one device, now I'm going to generate the next device and see if I van get it to work.

[-o<

Grenage
March 10th, 2010, 11:36 AM
Glad to hear it's working! :)

majestiknl
March 10th, 2010, 12:01 PM
Consider this topic is solved!

I really appreciate your help Grenage ;) both graphs are updating and I will add more to see how it works.

Was easier then I was thinking :P

Again, thanks for your help! :D