Comment créer son propre monitoring. (Version simple PHP) TUTORIELS Louis Foraux DROID CENTER HTTP://DROID CENTER.TK
Table des matières Présentation du projet... 2 Crédits... 2 Utilisation... 2 Infos Utiles... 2 Réalisation... 3 Page index.php... 3 Page list.php... 4 LOUIS FORAUX 1
Présentation du projet Crédits CSS : Bootstrap 3 (Version thème dark) Serveur Web : Windows XAMPP avec Apache Connexion internet : Inexistante (Développement hors connexion) / Existante lors des tests. JS : Jquery pour la fonction refresh AJAX Utilisation En Localhost, pour un monitoring plus précis (Etat des connexions internet (si il y en a plusieurs)) En Ligne, sur les serveurs de Nextwab.com par exemple. Sans mesure des connexions Internet. Ce fichier est compatible avec tous les hébergeurs internets. Infos Utiles Ce tutoriel est rédigé, publié et non re partageable sans l accord du présent auteur. Le tutoriel est disponible sur les plateformes suivantes : Nextwab PDF (PC, MAC, Linux, Android, ios, ) Version vidéo sur Youtube, Dailymotion (Chaîne de gigalouismdr) MyNetwork (http://mynetwork.forumactif.org) Un grand merci à Stephen de chez Nextwab, pour l hébergement de ce présent document sur ses serveurs et qui est relié sur sa plateforme. Temps de réalisation de ce tutoriel : 30 minutes max. LOUIS FORAUX 2
Réalisation Page index.php Pour commencer, c est très simple, on créer une page qui va venir rechercher la page «list.php» toutes les 100 millisecondes. (Attention si votre hébergeur vous alloue une bande passante, cette dernière va très vite être utilisé, préférez plutôt un temps plus long (par exemple : 10000 millisecondes) pour éviter de tout utiliser.) Alors, oui là j avoue de mon code n est pas professionnel, mais vous êtes grands, vous pouvez le modifier! <! Latest compiled and minified CSS > <link rel="stylesheet" href="./css/bootstrap.min.css"> <! Optional theme > <link rel="stylesheet" href="theme/bootstrap.min.css"> <! Latest compiled and minified JavaScript > <script src="./js/bootstrap.min.js"></script> <script type="text/javascript" src="./jquery.min.js"></script> <script type="text/javascript"> var auto_refresh = setinterval( function () { $('#mods').load('list.php').fadein("slow");, 100); // refresh every 10000 milliseconds </script> <div id="mods"><marquee>chargement du monitoring en cours</marquee> <title>chargement en cours</title> LOUIS FORAUX 3
Après dans la page list, ça se complique! Page list.php Là, nous n avons pas besoin de venir remettre le CSS, vu que l on appelle la page dans la page index, on fait une sorte d «include» à intervalle régulier par un AJAX. Pour réaliser la page comme je l ai fait, il vous faut ce code : Ce qui ne vous fait pas loin de 239 lignes. Rassurez vous, ce n est que a copier coller, quoi que j aurais plus vous mettre une image du code et a vous de recopier <title>monitoring</title> <div class="pageheader"><h1>monitoring <small>datacentre : LocalHost</small></h1> <?php $internet = "http://google.fr"; $nextwabfr = "http://nextwab.fr"; $nextwabcom = "http://nextwab.fr"; $nextwabsql = "http://mysql.nextwab.com"; $nextwabftp = "http://ftp.nextwab.com"; $localhost = "localhost"; $portint = "80"; $portftp = "21"; $portsql = "3306"; $portssl = "443"; $timeout = "30"; if ($internet and $portint and $timeout) { $internet = @fsockopen("$internet", $portint, $errno, $errstr, $timeout); $nextwabfr = @fsockopen("$nextwabfr", $portint, $errno, $errstr, $timeout); $nextwabcom = @fsockopen("$nextwabcom", $portint, $errno, $errstr, $timeout); $nextwabsql = @fsockopen("$nextwabsql", $portsql, $errno, $errstr, $timeout); $localsql = @fsockopen("$localhost", $portsql, $errno, $errstr, $timeout); $localftp = @fsockopen("$localhost", $portftp, $errno, $errstr, $timeout); $nextwabftp = @fsockopen("$nextwabftp", $portftp, $errno, $errstr, $timeout); $localssl = @fsockopen("$localhost", $portssl, $errno, $errstr, $timeout); LOUIS FORAUX 4
<div class="gird"> <?php if($internet) { <div class="panel title">internet <div class="panel body">fonctionnel '; echo '<div class="panel panel warning"> <div class="panel title">internet <div class="panel body">hors connexion '; <?php if($localsql) { <div class="panel title">localhost SQL <div class="panel body">fonctionnel '; LOUIS FORAUX 5
<div class="panel title">localhost SQL <div class="panel body">en Panne '; <?php if($localftp) { <div class="panel title">localhost FTP <div class="panel body">fonctionnel '; <div class="panel title">localhost FTP <div class="panel body">en Panne '; LOUIS FORAUX 6
<?php if($localssl) { <div class="panel title">localhost SSL <div class="panel body">fonctionnel '; <div class="panel title">localhost SSL <div class="panel body">en Panne '; <div class="pageheader"><h1>monitoring <small>datacentre : Nextwab</small></h1> <?php $internet = "http://google.fr"; $nextwabfr = "http://nextwab.fr"; $nextwabcom = "http://nextwab.fr"; $nextwabsql = "http://mysql.nextwab.com"; $nextwabftp = "http://ftp.nextwab.com"; $localhost = "localhost"; $portint = "80"; LOUIS FORAUX 7
$portftp = "21"; $portsql = "3306"; $timeout = "30"; if ($internet and $portint and $timeout) { $internet = @fsockopen("$internet", $portint, $errno, $errstr, $timeout); $nextwabfr = @fsockopen("$nextwabfr", $portint, $errno, $errstr, $timeout); $nextwabcom = @fsockopen("$nextwabcom", $portint, $errno, $errstr, $timeout); $nextwabsql = @fsockopen("$nextwabsql", $portsql, $errno, $errstr, $timeout); $localsql = @fsockopen("$localhost", $portsql, $errno, $errstr, $timeout); $localftp = @fsockopen("$localhost", $portftp, $errno, $errstr, $timeout); $nextwabftp = @fsockopen("$nextwabftp", $portftp, $errno, $errstr, $timeout); <div class="gird"> <?php if($internet) { <div class="panel title">internet <div class="panel body">fonctionnel '; echo '<div class="panel panel warning"> <div class="panel title">internet <div class="panel body">hors connexion '; LOUIS FORAUX 8
<?php if($nextwabfr) { <div class="panel title">nextwab.fr <div class="panel body">fonctionnel '; <div class="panel title">nextwab.fr <div class="panel body">en Panne '; <?php if($nextwabcom) { <div class="panel title">nextwab.com <div class="panel body">fonctionnel '; LOUIS FORAUX 9
<div class="panel title">nextwab.com <div class="panel body">en Panne '; <?php if($nextwabsql) { <div class="panel title">nextwab SQL <div class="panel body">fonctionnel '; <div class="panel title">nextwab SQL <div class="panel body">en Panne '; LOUIS FORAUX 10
<?php if($nextwabftp) { <div class="panel title">nextwab FTP <div class="panel body">fonctionnel '; <div class="panel title">nextwab FTP <div class="panel body">en Panne '; Ensuite il vous suffit de modifier les lignes «<?php $internet = "http://google.fr"; $nextwabfr = "http://nextwab.fr"; $nextwabcom = "http://nextwab.fr"; $nextwabsql = "http://mysql.nextwab.com"; $nextwabftp = "http://ftp.nextwab.com"; $localhost = "localhost"; $portint = "80"; LOUIS FORAUX 11
$portftp = "21"; $portsql = "3306"; $portssl = "443"; $timeout = "30"; if ($internet and $portint and $timeout) { $internet = @fsockopen("$internet", $portint, $errno, $errstr, $timeout); $nextwabfr = @fsockopen("$nextwabfr", $portint, $errno, $errstr, $timeout); $nextwabcom = @fsockopen("$nextwabcom", $portint, $errno, $errstr, $timeout); $nextwabsql = @fsockopen("$nextwabsql", $portsql, $errno, $errstr, $timeout); $localsql = @fsockopen("$localhost", $portsql, $errno, $errstr, $timeout); $localftp = @fsockopen("$localhost", $portftp, $errno, $errstr, $timeout); $nextwabftp = @fsockopen("$nextwabftp", $portftp, $errno, $errstr, $timeout); $localssl = @fsockopen("$localhost", $portssl, $errno, $errstr, $timeout);» À votre guise, si vous avez besoin, vous n avez qu à demander. C est donc tout pour ce tutoriel, on se dit à la prochaine! LOUIS FORAUX 12