Eric
vendredi août 14, 2009
mrtg sous Solaris avec mrtg pme
J'ai installé les packages de coolstack avant.
# cd /opt # wget http://oss.oetiker.ch/mrtg/pub/mrtg-2.16.2.tar.gz # gzip -dc mrtg-2.16.2.tar.gz | tar xvf - # cd mrtg-2.16.2 # ./configure --prefix=/opt/mrtg-2 --with-gd-inc=/opt/coolstack/include --with-gd-lib=/opt/coolstack/lib # make # make install
# cd /opt/mrtg-2 # wget http://prdownloads.sourceforge.net/mrtg-pme/mrtgpme-1.0.2.tar.gz # gunzip mrtgpme-1.0.2.tar.gz # tar xvf mrtgpme-1.0.2.tar
# cd /opt/mrtg-2/mrtgpme-1.0.2/solaris/ # vi *-solaris.pl il faut virer dans le path local #!/usr/local/bin/perl #!/usr/bin/perl `/usr/local/bin/ssh `/usr/bin/ssh
# vi solaris-*.cfg WorkDir: /export/home1/daemons/apache/mrtg #IconDir: /usr/local/mrtg/images changer les HOST par le bon hostname sur toutes les lignes. :%s/HOST/hostname/g Target[HOST-*]: `/opt/mrtg-2/mrtgpme-1.0.2/solaris/*-solaris.pl HOST`
# vi /opt/mrtg-2/mrtg.ksh
----
#!/bin/ksh
#
# cants.org
# Eric Cantin
# version 20090814
# ce script lance mrtg
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/opt/coolstack/lib
export LD_LIBRARY_PATH
/opt/mrtg-2/bin/mrtg /opt/mrtg-2/mrtgpme-1.0.2/solaris/solaris-cpu.cfg
/opt/mrtg-2/bin/mrtg /opt/mrtg-2/mrtgpme-1.0.2/solaris/solaris-mem.cfg
/opt/mrtg-2/bin/mrtg /opt/mrtg-2/mrtgpme-1.0.2/solaris/solaris-root.cfg
----
# chmod +x /opt/mrtg-2/mrtg.ksh
# vi index.php
----
<?php
function DirTri($rep,$tri)
{
$Array = array(); $dir = opendir($rep);
$i=0;
while ($File = readdir($dir)){
// liste des fichiers qui ne sont pas affich?
if($File != "." && $File != ".." && substr(strtolower($File), -3) != "log" && substr(strtolower($File), -3) != "png" && subst
r(strtolower($File), -3) != "old" && $File != "index.php" && $File != "index.html")
{
$Array[] = "$File";
}
$i++;
}
// message du top
echo "<html>";
echo "<head>";
echo "<title>Stats mrtg - Cants.org</title>";
echo "</head>";
echo 'Les stats sont produites avec <a href="http://mrtg-pme.sourceforge.net">MRTG Performance Monitoring Extensions</a>.<br>';
echo 'Et <a href="http://oss.oetiker.ch/mrtg/">MRTG</a>.<br>';
echo "<body TEXT=#000000 BGCOLOR=#CACADE LINK=#0000EF VLINK=#55188A ALINK=#FF0000>";
echo "<b>Liste des serveurs mrtg :</b><br><br>";
closedir($dir);
if($tri == 'DESC'){
rsort($Array);
}else{
sort($Array);
}
$Max = count($Array);
for($i = 0; $i != $Max; $i++){
echo "<a href=\"$Array[$i]\">$Array[$i]</a><br>";
}
// affiche le nombre de fichiers dans le répertoire
// echo "<br><br>".$Max." fichier(s)" ;
}
// utilisation de la fonction
// param.1 : chemin du répertoire ("." si il s'agit du rép. courant)
// param.2 : ASC ou DESC (A-Z ou Z-A)
DirTri(".","ASC");
// message en bas
echo '<FONT face="Cosmic" size="-3">';
echo "<!-- Champ de Copyright -->";
echo '<center>Copyright © 2004-2005, Eric Cantin (www.cants.org), tous droits réservés.<br>';
echo 'Protégé par les lois du copyright des États-Unis et du Canada et par des traités internationaux
.<br>';
echo 'Cants, Lévis, Québec 12 novembre 2005.<br></center>';
echo "<!-- Copyright -->";
echo "</FONT>";
echo "</body>";
echo "</html>";
?>
Posted at 02:33PM août 14, 2009 by Éric in Solaris |
Comments:





