# \[résolu\]MRTG

**URL:** <https://forum.geekzone.fr/t/resolu-mrtg/31527>\
**Category:** Softs & Apps\
**Created:** [Octobre 28, 2006, 9:56 UTC](https://forum.geekzone.fr/t/resolu-mrtg/31527 "2006-10-28T09:56:56Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![v\_a\_n\_e\_s](https://forum.geekzone.fr/letter_avatar_proxy/v4/letter/v/71c47a/32.png) [@v\_a\_n\_e\_s](https://forum.geekzone.fr/u/v_a_n_e_s)\
**Post date:** [Octobre 28, 2006, 9:56 UTC](https://forum.geekzone.fr/t/resolu-mrtg/31527/1 "2006-10-28T09:56:56Z")

</div>

J’en bave.

Je cherche à monitorer certaines valeurs de différentes machines.

Comme ces valeurs ne sont pas toutes accessibles au travers de snmp, j’ai fait des petits scripts qui sortent des trucs au format attendu par mrtg.

[code]#!/bin/bash  
LANG=C  
DISK=$1

TEMP=`/usr/sbin/smartctl -a -d ata -i $DISK | /bin/grep ^194 | /usr/bin/awk -F' ' '{print $10}'`  
UPTIME=`/usr/bin/uptime | /usr/bin/awk -F" " '{print $3 " " $4 " " $5}' | /bin/sed s/","//g`  
SERVER=`/bin/uname -n`

echo $TEMP  
echo $TEMP  
echo $UPTIME  
echo $SERVER[/code]  
et

[code]#!/bin/bash  
LANG=C

DISK=$1

USED=`/bin/df -B1 | /bin/grep $DISK | /usr/bin/awk -F" " '{print $3}'`  
FREE=`/bin/df -B1 | /bin/grep $DISK | /usr/bin/awk -F" " '{print $4}'`  
UPTIME=`/usr/bin/uptime | /usr/bin/awk -F" " '{print $3 " " $4 " " $5}' | /bin/sed s/","//g`  
SERVER=`/bin/uname -n`

echo $USED  
echo $FREE  
echo $UPTIME  
echo $SERVER[/code]

ces scripts sont appelés au travers d’une crontab sur chaque machine, et leur sortie standard est écrite dans un fichier stocké dans un repertoire nfs

le contenu d’un fichier généré par le premier script (qui récupère la température depuis le SMART) :

`34
34
199 days 3:25
mail`

et le deuxieme, qui donne l’espace utilisé et l’espace libre (et l’uptime et le nom du serveur, mais c’est les specs de mrtg qui veulent ça)

`678883328
13338320896
199 days 3:25
mail`

mon mrtg.cfg, histoire d’avoir fait le tour du background du bazar :

[code]WorkDir: /var/www/mrtg  
EnableIPv6: no  
LoadMIBs: /usr/share/snmp/mibs/UCD-SNMP-MIB.txt

### eth0@fw1

Target[192.168.1.254\_2]: [2:public@192.168.1.254](mailto:2:public@192.168.1.254):  
SetEnv[192.168.1.254\_2]: MRTG\_INT\_IP=“195.146.226.242” MRTG\_INT\_DESCR="eth0"  
MaxBytes[192.168.1.254\_2]: 2000000  
Title[192.168.1.254\_2]: [TRAFIC][FW1]: eth0  
PageTop[192.168.1.254\_2]:

# [TRAFIC][FW1]: eth0

| System: | Fw1 |
| Maintainer: | mathieu@mairie-leers.fr |
| Description: | eth0 |
| ifType: | Ethernet |
| ifName: | eth0 |
| Max Speed: | 2Mbits/s |
| Ip: | 195.146.226.242 (MAIRIELEERS-DSL7.turboadsl.nordnet.fr) |

### eth1@fw1

Target[192.168.1.254\_3]: [3:public@192.168.1.254](mailto:3:public@192.168.1.254):  
SetEnv[192.168.1.254\_3]: MRTG\_INT\_IP=“192.168.1.254” MRTG\_INT\_DESCR="eth1"  
MaxBytes[192.168.1.254\_3]: 100000000  
Title[192.168.1.254\_3]: [TRAFIC][FW1]: eth1  
PageTop[192.168.1.254\_3]:

# [TRAFIC][FW1]: eth1

| System: | Fw1 |
| Maintainer: | mathieu@mairie-leers.fr |
| Description: | eth1 |
| ifType: | Ethernet |
| ifName: | eth1 |
| Max Speed: | 100Mbits/s |
| Ip: | 192.168.1.254 (fw1.mairie-leers.fr.1.168.192.in-addr.arpa) |

### eth1@mail

Target[192.168.1.2\_3]: [3:public@192.168.1.2](mailto:3:public@192.168.1.2):  
SetEnv[192.168.1.2\_3]: MRTG\_INT\_IP=“192.168.1.2” MRTG\_INT\_DESCR="eth1"  
MaxBytes[192.168.1.2\_3]: 1250000  
Title[192.168.1.2\_3]: [TRAFIC][MAIL]: eth1  
PageTop[192.168.1.2\_3]:

# [TRAFIC][MAIL]: eth1

| System: | Mail |
| Maintainer: | mathieu@mairie-leers.fr |
| Description: | eth1 |
| ifType: | ethernet |
| ifName: | eth1 |
| Max Speed: | 100Mbits/s |
| Ip: | 192.168.1.2(mail.mairie-leers.fr.1.168.192.in-addr.arpa) |

### md0\_espace\_disque@mail

Target[mail\_md0]: `/bin/cat /home/mrtg_data/mail_disk_md0.txt 2>>/var/log/mrtg.err`  
MaxBytes[mail\_md0]: 15000000000  
Title[mail\_md0]: [Espace disque][mail]: md0  
PageTop[mail\_md0]:

# [Espace disque][mail]: /
  
Options[mail\_md0]: gauge,nopercent  
Kilo[mail\_md0]: 1024  
ShortLegend[mail\_md0]: b  
YLegend[mail\_md0]: Espace Disque md0  
Legend1[mail\_md0]: Used  
Legend2[mail\_md0]: Free  
LegendI[mail\_md0]: Used  
LegendO[mail\_md0]: Free
### md1\_espace\_disque@mail

Target[mail\_md1]: `/bin/cat /home/mrtg_data/mail_disk_md1.txt 2>>/var/log/mrtg.err`  
MaxBytes[mail\_md1]: 15000000  
Title[mail\_md1]: [Espace disque][mail]: md1  
PageTop[mail\_md1]:

# [Espace disque][mail]: /var
  
Options[mail\_md1]: gauge,nopercent  
Kilo[mail\_md1]: 1024  
ShortLegend[mail\_md1]: b  
YLegend[mail\_md1]: Espace Disque md1  
Legend1[mail\_md1]: Used  
Legend2[mail\_md1]: Free  
LegendI[mail\_md1]: Used  
LegendO[mail\_md1]: Free
### md2\_espace\_disque@mail

Target[mail\_md2]: `/bin/cat /home/mrtg_data/mail_disk_md2.txt 2>>/var/log/mrtg.err`  
MaxBytes[mail\_md2]: 15000000  
Title[mail\_md2]: [Espace disque][mail]: md2  
PageTop[mail\_md2]:

# [Espace disque][mail]: /home
  
Options[mail\_md2]: gauge,nopercent  
Kilo[mail\_md2]: 1024  
ShortLegend[mail\_md2]: b  
YLegend[mail\_md2]: Espace Disque md2  
Legend1[mail\_md2]: Used  
Legend2[mail\_md2]: Free  
LegendI[mail\_md2]: Used  
LegendO[mail\_md2]: Free
### cpu\_load@mail

Target[mail.cpuload]: [ssCpuRawUser.0&ssCpuRawUser.0:public@192.168.1.2](mailto:ssCpuRawUser.0&ssCpuRawUser.0:public@192.168.1.2) + [ssCpuRawSystem.0&ssCpuRawSystem.0:public@192.168.1.2](mailto:ssCpuRawSystem.0&ssCpuRawSystem.0:public@192.168.1.2) + [ssCpuRawNice.0&ssCpuRawNice.0:public@192.168.1.2](mailto:ssCpuRawNice.0&ssCpuRawNice.0:public@192.168.1.2)  
MaxBytes[mail.cpuload]: 100  
Title[mail.cpuload]: [Charge CPU][Mail]  
PageTop[mail.cpuload]:

# [Charge CPU][Mail]
  
Unscaled[mail.cpuload]: ymwd  
ShortLegend[mail.cpuload]: %  
YLegend[mail.cpuload]: Utilisation CPU  
Legend1[mail.cpuload]: Charge CPU en %  
Legend2[mail.cpuload]:  
Legend3[mail.cpuload]:  
Legend4[mail.cpuload]:  
LegendI[mail.cpuload]: Actif  
LegendO[mail.cpuload]:  
Options[mail.cpuload]: nopercent
### sda\_temp@mail

Target[mail\_sda]: `/bin/cat /home/mrtg_data/mail_temp_sda.txt 2>>/var/log/mrtg.err`  
MaxBytes[mail\_sda]: 100  
Title[mail\_sda]: [T° Disque][Mail] /dev/sda  
PageTop[mail\_sda]:

# [T° Disque][Mail] /dev/sda
  
Options[mail\_sda]: nopercent  
Unscaled[mail\_sda]: ymwd  
ShortLegend[mail\_sda]: °  
YLegend[mail\_sda]: Temperature disque /dev/sda  
Legend1[mail\_sda]: T°  
Legend2[mail\_sda]:  
LegendI[mail\_sda]: T°  
LegendO[mail\_sda]:[/code]

Bon, après vous avoir abreuvé d’infos bien rébarbatives, voici mon problème :

alors que les fichiers générés par mes scripts sont remplis de valeurs valides, qu’ils sont pris en compte (récupération des valeurs d’uptime et des noms de machine), certains graphes (md1, md2, charge cpu et temp hd) restent désespérément plats. B)

L’un d’entre vous verrait-il un problème qui m’échappe ? (ça fait 2 jours que je planche sur le sujet B) )

Marchi

– edit

En fait, j’ai découvert Munin ( [http://munin.projects.linpro.no/](http://munin.projects.linpro.no/) ), qui remplace avec brio mrtg, qui graphe une brochette impressionnantes de données “out of the box”, et qui fait même le café.

thx, vns
