User Tools

Site Tools


informatique:logiciels:nagios

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
informatique:logiciels:nagios [2015/09/14 10:05] – check_snmp --rate pteuinformatique:logiciels:nagios [2016/04/01 07:34] – [Exemple 3] pteu
Line 1281: Line 1281:
 $def[1] .= "GPRINT:var2:AVERAGE:\"%7.2lf %SB/s avg\" " ; $def[1] .= "GPRINT:var2:AVERAGE:\"%7.2lf %SB/s avg\" " ;
 $def[1] .= "GPRINT:var2:MAX:\"%7.2lf %SB/s max\\n\" " $def[1] .= "GPRINT:var2:MAX:\"%7.2lf %SB/s max\\n\" "
 +
 +# pour afficher le dernier check sur le graphe
 +if($this->MACRO['TIMET'] != ""){
 +    $def[1] .= "VRULE:".$this->MACRO['TIMET']."#000000:\"Last Service Check \\n\" ";
 +}
 ?> ?>
 </code> </code>
Line 1288: Line 1293:
 {{ :informatique:logiciels:trafic_internet.png?direct |}} {{ :informatique:logiciels:trafic_internet.png?direct |}}
  
 +Le même, un peu plus perfectionné :
 +<code php>
 +<?php
 +# Copyright (c) 2006-2010 Joerg Linge (http://www.pnp4nagios.org)
 +# Plugin: check_snmp_int.pl (COUNTER)
 +# modif traffic reseau in/out
 +
 +$unit = "bps";
 +
 +$ds_name[1] = "$hostname In/Out $unit";
 +$opt[1] = " --vertical-label $unit -b 1000 --title \"$hostname : $servicedesc\" ";
 +$def[1] = rrd::def("var1",$RRDFILE[1],$DS[1],"AVERAGE");
 +$def[1] .= rrd::def("var2",$RRDFILE[2],$DS[2],"AVERAGE");
 +
 +#$def[1] .= "AREA:var1#99ff99:\"$NAME[1]  \" " ;
 +$def[1] .= rrd::gradient('var1','ebffeb','99ff99',sprintf("%-16s",$NAME[1]),20);
 +$def[1] .= rrd::gprint('var1',array("LAST","AVERAGE","MAX"),"%3.2lf %s$unit");
 +
 +$def[1] .= "LINE1:var2#0099ff:\"".sprintf("%-15s",$NAME[2])." \" " ;
 +$def[1] .= rrd::gprint('var2',array("LAST","AVERAGE","MAX"),"%3.2lf %s$unit");
 +
 +if($this->MACRO['TIMET'] != ""){
 +    $def[1] .= "VRULE:".$this->MACRO['TIMET']."#000000:\"Last Service Check \\n\" ";
 +}
 +?>
 +
 +</code>
 ====Exemple 2 : courbe CPU==== ====Exemple 2 : courbe CPU====
  
Line 1415: Line 1447:
 {{ :informatique:logiciels:cpu_forti.png?direct |}} {{ :informatique:logiciels:cpu_forti.png?direct |}}
  
 +====Exemple 3 : graphique adaptatif====
 +
 +Ce template va détecter automatiquement le nombre d'enregistrement dans la base RRD et s'adapter pour tracer le bon nombre de courbe (inconnue à l'avance).
 +<code bash>
 +<?php
 +$unit = "pc";
 +
 +# max : 7 entrées
 +$TAB_COLORS = array('#ff0000','#ff8000','#cccc00','#0066ff','#9933ff','#00ff55','#ff80ff');
 +$CPT=1;
 +
 +$ds_name[$CPT] = "$hostname %CPU x10";
 +$opt[$CPT] = " --vertical-label $unit -b 1000 --title \"$hostname : $servicedesc (% x10)\" ";
 +
 +foreach ($this->DS as $CHAMP_RRD=>$VAL) {
 +
 +        if ($CPT == "1") {
 +                $def[1] = rrd::def("var".$CPT,$VAL['RRDFILE'],$VAL['DS'],"AVERAGE");
 +        }
 +        else {
 +                $def[1] .= rrd::def("var".$CPT,$VAL['RRDFILE'],$VAL['DS'],"AVERAGE");
 +        }
 +
 +        $def[1] .= "LINE1:var".$CPT.$TAB_COLORS[$CHAMP_RRD].":\"".sprintf("%-15s",$VAL['NAME'])." \" " ;
 +        $def[1] .= rrd::gprint('var'.$CPT,array("LAST","AVERAGE","MAX"),"%3.2lf %s$unit");
 +
 +        $CPT++;
 +}
 +
 +if($this->MACRO['TIMET'] != ""){
 +    $def[1] .= "VRULE:".$this->MACRO['TIMET']."#000000:\"Last Service Check \\n\" ";
 +}
 +?>
 +
 +</code>
  
 ======Tips====== ======Tips======
informatique/logiciels/nagios.txt · Last modified: 2021/01/15 15:47 by pteu