Sondes RRD


   Ces sondes sont les évolutions des scripts MRTG adaptés à l'utilisation de RRDtool, et qui remontent des informations sur l'état du système.

   Ces scripts sont à exécuter régulièrement par une CRON, (toute les cinq minutes, par exemple), pour remplir des bases RRD.
   Le graphage des données peut ensuite être réalisé avec MyRRD (le graphage de mysql n'est qu'un exemple).



   Liste des sondes disponibles :


   Charge Processeur

   Cette sonde mesure les activitées processeur (en %) ainsi que la valeur du load-average à partir des infos de /proc. Les états suivants sont mesurés: user, nice, system, iowait, irq et softirq.
Les données temporaires sont stockées dans le fichier /var/lib/rrd-cpu.cache.

   Code source : rrd-cpu.pl   [ md5: ce192f10bc575db61f3275f72fe10cc1 ]

   Définition de la base RRD :
rrdtool create cpu.rrd --step 300 \
	DS:user:GAUGE:600:0:U \
	DS:nice:GAUGE:600:0:U \
	DS:system:GAUGE:600:0:U \
	DS:iowait:GAUGE:600:0:U \
	DS:irq:GAUGE:600:0:U \
	DS:softirq:GAUGE:600:0:U \
	RRA:AVERAGE:0.5:1:106560 \
	RRA:AVERAGE:0.5:72:2960 \
	RRA:AVERAGE:0.5:288:1850 \
	RRA:MIN:0.5:72:2960 \
	RRA:MIN:0.5:288:1850 \
	RRA:MAX:0.5:72:2960 \
	RRA:MAX:0.5:288:1850
   Exemple d'utilisation :
eval `/root/bin/rrd-cpu.pl`
rrdtool update $RRDDIR/cpu.rrd N:$USER:$NICE:$SYSTEM:$IOWAIT:$IRQ:$SOFTIRQ
rrdtool update $RRDDIR/loadavg.rrd N:$LOADAVG
   Exemple de configuration pour MyRRD :
"cpu" => array
(
	"Label"   => "CPU",
	"Title"   => "CPU",
	"Caption" => "",
	"Graph"   => array
	(
		"VLabel"    => "%",
		"HLabel"    => "",
		"Prefix"    => "cpuP3R",
		"Data"      => array
		(
			array
			(
				"DSName"  => "softirq",
				"Stack"   => true,
				"RRDFile" => "$dir/cpu.rrd",
				"Label"   => "SoftIRQ ",
				"Color"   => "#00DDCC",
				"Type"    => "AREA"
			),
			array
			(
				"DSName"  => "irq",
				"Stack"   => true,
				"RRDFile" => "$dir/cpu.rrd",
				"Label"   => "IRQ     ",
				"Color"   => "#FF9966",
				"Type"    => "AREA"
			),
			array
			(
				"DSName"  => "iowait",
				"Stack"   => true,
				"RRDFile" => "$dir/cpu.rrd",
				"Label"   => "Iowait  ",
				"Color"   => "#FFEE00",
				"Type"    => "AREA"
			),
			array
			(
				"DSName"  => "system",
				"Stack"   => true,
				"RRDFile" => "$dir/cpu.rrd",
				"Label"   => "System  ",
				"Color"   => "#FF3311",
				"Type"    => "AREA"
			),
			array
			(
				"DSName"  => "user",
				"Stack"   => true,
				"RRDFile" => "$dir/cpu.rrd",
				"Label"   => "User    ",
				"Color"   => "#22FF33",
				"Type"    => "AREA"
			),
			array
			(
				"DSName"  => "nice",
				"Stack"   => true,
				"RRDFile" => "$dir/cpu.rrd",
				"Label"   => "Nice    ",
				"Color"   => "#DD33FF",
				"Type"    => "AREA"
			),
			array
			(
				"DSName"  => "loadavg",
				"Compute" => "100,*",
				"RRDFile" => "$dir/loadavg.rrd",
				"Label"   => "LoadAVG ",
				"Color"   => "#220099",
				"Type"    => "LINE1"
			)
		)
	)
),


   Utilisation RAM

   Cette sonde mesure le taux d'utilisation de la RAM (en %) à partir des infos de /proc. Elle remonte la RAM réellement utilisée (sans les buffers), l'utilisations des buffers et la SWAP.

   Code source : rrd-ram.pl   [ md5: 43498cc9facf34dba640a6afacffdff2 ]

   Définition de la base RRD :
rrdtool create ram.rrd --step 300 \
	DS:used:GAUGE:600:0:100 \
	DS:buffer:GAUGE:600:0:100 \
	DS:swap:GAUGE:600:0:100 \
	RRA:AVERAGE:0.5:1:106560 \
	RRA:AVERAGE:0.5:72:2960 \
	RRA:AVERAGE:0.5:288:1850 \
	RRA:MIN:0.5:72:2960 \
	RRA:MIN:0.5:288:1850 \
	RRA:MAX:0.5:72:2960 \
	RRA:MAX:0.5:288:1850
   Exemple d'utilisation :
eval `/root/bin/rrd-ram.pl`
rrdtool update $RRDDIR/ram.rrd N:$RAM_USED:$BUFFER:$SWAP_USED
   Exemple de configuration pour MyRRD :
"ram" => array
(
	"Label"   => "Mémoires",
	"Title"   => "Mémoires",
	"Caption" => "",
	"Graph"   => array
	(
		"VLabel"    => "%",
		"HLabel"    => "",
		"Prefix"    => "ram",
		"LowerLimit" => 0,
		"UpperLimit" => 100,
		"Data"      => array
		(
			array
			(
				"DSName"  => "used",
				"Stack"   => true,
				"RRDFile" => "$dir/ram.rrd",
				"Label"   => "Used    ",
				"Color"   => "#FFEE00",
				"Type"    => "AREA"
			),
			array
			(
				"DSName"  => "buffer",
				"Stack"   => true,
				"RRDFile" => "$dir/ram.rrd",
				"Label"   => "Buffered",
				"Color"   => "#00DDCC",
				"Type"    => "AREA"
			),
			array
			(
				"DSName"  => "swap",
				"RRDFile" => "$dir/ram.rrd",
				"Label"   => "Swap    ",
				"Color"   => "#FF3311",
				"Type"    => "LINE2"
			)
		)
	)
),

   Activités réseaux

   Cette sonde mesure l'activité du réseaux, c.a.d. le nombre de connections TCP et UDP dans chaques états : TIME_WAIT, ESTABLISHED, CLOSE, CLOSE_WAIT, FIN_WAIT, LAST_ACK, SYN_RECV, SYN_SENT pour TCP et ASSURED, UNREPLIED pour UDP.
Ce script nécéssite le chargement du module noyau nf_conntrack.

   Code source : rrd-netstat.pl   [ md5: ffb00cc9f36a96d81b863bdbb787c3d1 ]

   Définition de la base RRD :
rrdtool create netstat-tcp.rrd --step 300 \
	DS:CLOSE:GAUGE:600:0:U \
	DS:CLOSE_WAIT:GAUGE:600:0:U \
	DS:ESTABLISHED:GAUGE:600:0:U \
	DS:FIN_WAIT:GAUGE:600:0:U \
	DS:LAST_ACK:GAUGE:600:0:U \
	DS:SYN_RECV:GAUGE:600:0:U \
	DS:SYN_SENT:GAUGE:600:0:U \
	DS:TIME_WAIT:GAUGE:600:0:U \
	RRA:AVERAGE:0.5:1:106560 \
	RRA:AVERAGE:0.5:72:2960 \
	RRA:AVERAGE:0.5:288:1850 \
	RRA:MIN:0.5:72:2960 \
	RRA:MIN:0.5:288:1850 \
	RRA:MAX:0.5:72:2960 \
	RRA:MAX:0.5:288:1850

rrdtool create netstat-udp.rrd --step 300 \
	DS:ASSURED:GAUGE:600:0:U \
	DS:UNREPLIED:GAUGE:600:0:U \
	RRA:AVERAGE:0.5:1:106560 \
	RRA:AVERAGE:0.5:72:2960 \
	RRA:AVERAGE:0.5:288:1850 \
	RRA:MIN:0.5:72:2960 \
	RRA:MIN:0.5:288:1850 \
	RRA:MAX:0.5:72:2960 \
	RRA:MAX:0.5:288:1850
   Exemple d'utilisation :
eval `/root/bin/rrd-netstat.pl`
rrdtool update $RRDDIR/netstat-tcp.rrd N:$CLOSE:$CLOSE_WAIT:$ESTABLISHED:$FIN_WAIT:$LAST_ACK:$SYN_RECV:$SYN_SENT:$TIME_WAIT
rrdtool update $RRDDIR/netstat-udp.rrd N:$ASSURED:$UNREPLIED
   Exemple de configuration pour MyRRD :
"netstat" => array
(
	"Label"   => "Netstat",
	"Title"   => "Netstat",
	"Caption" => "",
	"Graph"   => array
	(
		"VLabel"    => "Cnx",
		"HLabel"    => "",
		"Prefix"    => "netstat",
		"Data"      => array
		(
			array
			(
				"DSName"  => "CLOSE",
				"RRDFile" => "$dir/netstat-tcp.rrd",
				"Label"   => "CLOSE      ",
				"Color"   => "#EEAF00",
				"Type"    => "LINE1"
			),
			array
			(
				"DSName"  => "CLOSE_WAIT",
				"RRDFile" => "$dir/netstat-tcp.rrd",
				"Label"   => "CLOSE_WAIT ",
				"Color"   => "#EE0000",
				"Type"    => "LINE1"
			),
			array
			(
				"DSName"  => "ESTABLISHED",
				"RRDFile" => "$dir/netstat-tcp.rrd",
				"Label"   => "ESTABLISHED",
				"Color"   => "#00DD22",
				"Type"    => "LINE1"
			),
			array
			(
				"DSName"  => "FIN_WAIT",
				"RRDFile" => "$dir/netstat-tcp.rrd",
				"Label"   => "FIN_WAIT   ",
				"Color"   => "#EE20FF",
				"Type"    => "LINE1"
			),
			array
			(
				"DSName"  => "LAST_ACK",
				"RRDFile" => "$dir/netstat-tcp.rrd",
				"Label"   => "LAST_ACK   ",
				"Color"   => "#009977",
				"Type"    => "LINE1"
			),
			array
			(
				"DSName"  => "SYN_RECV",
				"RRDFile" => "$dir/netstat-tcp.rrd",
				"Label"   => "SYN_RECV   ",
				"Color"   => "#FFAEB9",
				"Type"    => "LINE1"
			),
			array
			(
				"DSName"  => "SYN_SENT",
				"RRDFile" => "$dir/netstat-tcp.rrd",
				"Label"   => "SYN_SENT   ",
				"Color"   => "#FF7F00",
				"Type"    => "LINE1"
			),
			array
			(
				"DSName"  => "TIME_WAIT",
				"RRDFile" => "$dir/netstat-tcp.rrd",
				"Label"   => "TIME_WAIT  ",
				"Color"   => "#CDCD00",
				"Type"    => "LINE1"
			),
			array
			(
				"DSName"  => "ASSURED",
				"RRDFile" => "$dir/netstat-udp.rrd",
				"Label"   => "ASSURED    ",
				"Color"   => "#698B22",
				"Type"    => "LINE1"
			),
			array
			(
				"DSName"  => "UNREPLIED",
				"RRDFile" => "$dir/netstat-udp.rrd",
				"Label"   => "UNREPLIED  ",
				"Color"   => "#00E5EE",
				"Type"    => "LINE1"
			),
		)
	)
),

   Indicateurs SMART

   Cette sonde informe sur l'état des disques durs. Elle remonte les informations SMART Reallocated_Sector_Ct, Spin_Retry_Count, Raw_Read_Error_Rate, Seek_Error_Rate et Temperature_Celsius.
Ce script nécéssite les outils smartmontools.

   Code source : rrd-smart.pl   [ md5: fccdb1839f36e0718995b082777ebf78 ]

   Définition de la base RRD :
rrdtool create smart-sda.rrd --step 300 \
	DS:ReallocatedSectorCt:GAUGE:600:0:U \
	DS:SpinRetryCount:GAUGE:600:0:U \
	DS:RawReadErrorRate:GAUGE:600:0:255 \
	DS:SeekErrorRate:GAUGE:600:0:255 \
	DS:TemperatureCelsius:GAUGE:600:0:100 \
	RRA:AVERAGE:0.5:1:106560 \
	RRA:AVERAGE:0.5:72:2960 \
	RRA:AVERAGE:0.5:288:1850 \
	RRA:MIN:0.5:72:2960 \
	RRA:MIN:0.5:288:1850 \
	RRA:MAX:0.5:72:2960 \
	RRA:MAX:0.5:288:1850
   Exemple d'utilisation :
REALLOCATED_SECTOR_CT="U"
SPIN_RETRY_COUNT="U"
RAW_READ_ERROR_RATE="U"
SEEK_ERROR_RATE="U"
TEMPERATURE_CELSIUS="U"
eval `ssh $HOST /root/bin/rrd-smart.pl /dev/sda`
rrdtool update $RRDDIR/smart-sda.rrd N:$REALLOCATED_SECTOR_CT:$SPIN_RETRY_COUNT:$RAW_READ_ERROR_RATE:$SEEK_ERROR_RATE:$TEMPERATURE_CELSIUS
   Exemple de configuration pour MyRRD :
"smart-sda" => array
(
	"Label"   => "SMART sda",
	"Title"   => "Indicateurs SMART",
	"Caption" => "",
	"Graph"   => array
	(
		"VLabel"    => "Indicateur",
		"HLabel"    => "",
		"Prefix"    => "ssda",
		"Data"      => array
		(
			array
			(
				"DSName"  => "ReallocatedSectorCt",
				"RRDFile" => "$dir/smart-sda.rrd",
				"Label"   => "ReallocatedSectorCt",
				"Color"   => "#EEAF00",
				"Type"    => "LINE2"
			),
			array
			(
				"DSName"  => "SpinRetryCount",
				"RRDFile" => "$dir/smart-sda.rrd",
				"Label"   => "SpinRetryCount     ",
				"Color"   => "#EE0000",
				"Type"    => "LINE2"
			),
			array
			(
				"DSName"  => "RawReadErrorRate",
				"RRDFile" => "$dir/smart-sda.rrd",
				"Label"   => "RawReadErrorRate   ",
				"Color"   => "#00DD22",
				"Type"    => "LINE1"
			),
			array
			(
				"DSName"  => "SeekErrorRate",
				"RRDFile" => "$dir/smart-sda.rrd",
				"Label"   => "SeekErrorRate      ",
				"Color"   => "#0022DD",
				"Type"    => "LINE1"
			)
		)
	)
),

   Monitoring de machines virtuelles Xen

   Cette sonde permet de grapher la consommation CPU (en % relatif à 1 CPU) de chaque VM et leurs utilisations en ram (utile en cas d'utilisation du ballooning).
Contrairement aux autres sondes, celle-ci doit être utilisée en daemon, et lancée obligatoirement sur le Dom0.

Ce script utilise l'API cxm pour se connecter à Xen. Evidemment, Xen doit être fonctionnel.

   Code source : xenmonitor.py   [ md5: 35f9788bce74d49c7af2d48ba1ec6c1e ]

   Définition de la base RRD :
rrdtool create cpuxen.rrd --step 300 \
	DS:Dom0:GAUGE:600:0:400 \
	DS:VM1:GAUGE:600:0:400 \
	DS:VM2:GAUGE:600:0:400 \
	DS:VM3:GAUGE:600:0:400 \
	RRA:AVERAGE:0.5:1:106560 \
	RRA:AVERAGE:0.5:72:2960 \
	RRA:AVERAGE:0.5:288:1850 \
	RRA:MIN:0.5:72:2960 \
	RRA:MIN:0.5:288:1850 \
	RRA:MAX:0.5:72:2960 \
	RRA:MAX:0.5:288:1850

rrdtool create ramxen.rrd --step 300 \
	DS:Dom0:GAUGE:600:0:U \
	DS:VM1:GAUGE:600:0:U \
	DS:VM2:GAUGE:600:0:U \
	DS:VM3:GAUGE:600:0:U \
	RRA:AVERAGE:0.5:1:106560 \
	RRA:AVERAGE:0.5:72:2960 \
	RRA:AVERAGE:0.5:288:1850 \
	RRA:MIN:0.5:72:2960 \
	RRA:MIN:0.5:288:1850 \
	RRA:MAX:0.5:72:2960 \
	RRA:MAX:0.5:288:1850
   Exemple d'utilisation :
nohup /usr/local/sbin/xenmonitor.py >/dev/null 2>/dev/null &
eval `nc localhost 9999`
rrdtool update $RRDDIR/cpuxen.rrd N:$CPU_Domain_0:$CPU_VM1:$CPU_VM2:$CPU_VM3
rrdtool update $RRDDIR/ramxen.rrd N:$RAM_Domain_0:$RAM_VM1:$RAM_VM2:$RAM_VM3
   Exemple de configuration pour MyRRD :
"cpuxen" => array
(
	"Label"   => "Utilisation CPU",
	"Title"   => "Utilisation CPU",
	"Caption" => "",
	"Graph"   => array
	(
		"VLabel"    => "%",
		"HLabel"    => "",
		"Prefix"    => "cpuxen",
		"Data"      => array
		(
			array
			(
				"DSName"  => "Dom0",
				"Stack"   => true,
				"RRDFile" => "$dir/cpuxen.rrd",
				"Label"   => "Dom0",
				"Color"   => "#EEAF00",
				"Type"    => "AREA"
			),
			array
			(
				"DSName"  => "VM1",
				"Stack"   => true,
				"RRDFile" => "$dir/cpuxen.rrd",
				"Label"   => "VM 1",
				"Color"   => "#4477EE",
				"Type"    => "AREA"
			),
			array
			(
				"DSName"  => "VM2",
				"Stack"   => true,
				"RRDFile" => "$dir/cpuxen.rrd",
				"Label"   => "VM 2",
				"Color"   => "#EE0000",
				"Type"    => "AREA"
			),
			array
			(
				"DSName"  => "VM3",
				"Stack"   => true,
				"RRDFile" => "$dir/cpuxen.rrd",
				"Label"   => "VM 3",
				"Color"   => "#00DD22",
				"Type"    => "AREA"
			)
		)
	)
),
"ramxen" => array
(
	"Label"   => "Repartition RAM",
	"Title"   => "Repartiton RAM",
	"Caption" => "",
	"Graph"   => array
	(
		"VLabel"    => "Mo",
		"HLabel"    => "",
		"Prefix"    => "ramxen",
		"LowerLimit" => 0,
		"Data"      => array
		(
			array
			(
				"DSName"  => "Dom0",
				"Stack"   => true,
				"RRDFile" => "$dir/ramxen.rrd",
				"Label"   => "Dom0",
				"Color"   => "#EEAF00",
				"Type"    => "AREA"
			),
			array
			(
				"DSName"  => "VM1",
				"Stack"   => true,
				"RRDFile" => "$dir/ramxen.rrd",
				"Label"   => "VM 1",
				"Color"   => "#4477EE",
				"Type"    => "AREA"
			),
			array
			(
				"DSName"  => "VM2",
				"Stack"   => true,
				"RRDFile" => "$dir/ramxen.rrd",
				"Label"   => "VM 2",
				"Color"   => "#EE0000",
				"Type"    => "AREA"
			),
			array
			(
				"DSName"  => "VM3",
				"Stack"   => true,
				"RRDFile" => "$dir/ramxen.rrd",
				"Label"   => "VM 3",
				"Color"   => "#00DD22",
				"Type"    => "AREA"
			)
		)
	)
),

   Fréquences des CPU Xen

   Cette sonde mesure la fréquence moyenne des CPU lorsque la gestion d'économie d'énergie de XEN est activée.
Celle sonde doit être lancée obligatoirement sur le Dom0. Elle utilise la commande xenpm.

   Code source : rrd-xenpm.pl   [ md5: 8f0cee98c7dd5a820b77b0f2b9bfd37c ]

   Définition de la base RRD :
rrdtool create cpufreq.rrd --step 300 \
	DS:cpu0:GAUGE:600:0:U \
	DS:cpu1:GAUGE:600:0:U \
	DS:cpu2:GAUGE:600:0:U \
	DS:cpu3:GAUGE:600:0:U \
	RRA:AVERAGE:0.5:1:106560 \
	RRA:AVERAGE:0.5:72:2960 \
	RRA:AVERAGE:0.5:288:1850 \
	RRA:MIN:0.5:72:2960 \
	RRA:MIN:0.5:288:1850 \
	RRA:MAX:0.5:72:2960 \
	RRA:MAX:0.5:288:1850
   Exemple d'utilisation :
eval `ssh $HOST /root/bin/rrd-xenpm.pl`
rrdtool update $RRDDIR/cpufreq.rrd N:$CPU0:$CPU1:$CPU2:$CPU3
   Exemple de configuration pour MyRRD :
"cpufreq" => array
(
	"Label"   => "Fréquences CPU",
	"Title"   => "Fréquences CPU",
	"Caption" => "",
	"Graph"   => array
	(
		"VLabel"    => "Hz",
		"HLabel"    => "",
		"Prefix"    => "cpufreq",
		"Data"      => array
		(
			array
			(
				"DSName"  => "cpu0",
				"RRDFile" => "$dir/cpufreq.rrd",
				"Label"   => "CPU 0",
				"Color"   => "#EEAF00",
				"Type"    => "LINE1"
			),
			array
			(
				"DSName"  => "cpu1",
				"RRDFile" => "$dir/cpufreq.rrd",
				"Label"   => "CPU 1",
				"Color"   => "#EE0000",
				"Type"    => "LINE1"
			),
			array
			(
				"DSName"  => "cpu2",
				"RRDFile" => "$dir/cpufreq.rrd",
				"Label"   => "CPU 2",
				"Color"   => "#00DD22",
				"Type"    => "LINE1"
			),
			array
			(
				"DSName"  => "cpu3",
				"RRDFile" => "$dir/cpufreq.rrd",
				"Label"   => "CPU 3",
				"Color"   => "#00E5EE",
				"Type"    => "LINE1"
			)
		)
	)
),
Copyleft 2010 - Nicolas AGIUS