code couleur ping
This commit is contained in:
parent
042dca8a9c
commit
1db332b8e5
@ -363,16 +363,36 @@ function DateDiff($date1, $date2){
|
||||
// Fonction FormateDelta(&delta)
|
||||
// Retourne une chaîne de caractère du delta entre deux dates arrondi à la seconde, à la minute, à l'heure ou au jour
|
||||
function FormateDelta(&$delta) {
|
||||
if ($delta['day'] != 0) {
|
||||
return (string)$delta['day']." jours";
|
||||
$days = $delta['day'];
|
||||
if ($days != 0) {
|
||||
$unit = " jours";
|
||||
if ($days == 1) {
|
||||
$unit = " jour";
|
||||
}
|
||||
if ($delta['hour'] != 0) {
|
||||
return (string)$delta['hour']." heures";
|
||||
return (string)$days.$unit;
|
||||
}
|
||||
if ($delta['minute'] != 0) {
|
||||
return (string)$delta['minute']." minutes";
|
||||
$hours = $delta['hour'];
|
||||
if ($hours != 0) {
|
||||
$unit = " heures";
|
||||
if ($hours == 1) {
|
||||
$unit = " heure";
|
||||
}
|
||||
return (string)$delta['second']." secondes";
|
||||
return (string)$hours.$unit;
|
||||
}
|
||||
$mins = $delta['minute'];
|
||||
if ($mins != 0) {
|
||||
$unit = " minutes";
|
||||
if ($hours == 1) {
|
||||
$unit = " minute";
|
||||
}
|
||||
return (string)$mins.$unit;
|
||||
}
|
||||
$secs = $delta['second'];
|
||||
$unit = " secondes";
|
||||
if ($secs == 1) {
|
||||
$unit = " seconde";
|
||||
}
|
||||
return (string)$secs.$unit;
|
||||
}
|
||||
|
||||
?>
|
||||
|
@ -186,3 +186,7 @@ a.anchor {
|
||||
height: 230px;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.noping {
|
||||
background-color: Gainsboro;
|
||||
}
|
@ -31,7 +31,7 @@ fi;
|
||||
# Une fois le fichier rempli, on exécute admin/get_ping.php qui va récupérer le contenu du fichier dans la base Winlog
|
||||
while :
|
||||
do
|
||||
actives=`fping -t$timeout -f$fichierIN | grep alive | cut -d ' ' -f1`
|
||||
actives=`fping -a -t$timeout -f$fichierIN`
|
||||
timestamp=$(date +"%Y-%m-%d %H:%M:%S")
|
||||
>$fichierOUT
|
||||
i=0
|
||||
|
@ -107,17 +107,21 @@ while ($mdc = current($machines_de_salle)) {
|
||||
}
|
||||
|
||||
$ping_info = "";
|
||||
$class_noping = " noping";
|
||||
if ($mode_ping) {
|
||||
$ping_delta = "indisponible";
|
||||
if (array_key_exists($mac, $ping_timestamps)) {
|
||||
$ping_ts = strtotime($ping_timestamps[$mac]);
|
||||
$ping_delta = "il y a ".FormateDelta(DateDiff($ping_ts, $now));
|
||||
if ($now - $ping_ts <= $seuil_couleur_ping) {
|
||||
$class_noping = "";
|
||||
}
|
||||
}
|
||||
$ping_info = "ping : ".$ping_delta;
|
||||
}
|
||||
|
||||
echo "<tr class=\"connexion\" id=\"".str_replace('.','-',$connexion_machine[$mac]["ip"])."\">";
|
||||
echo "<td><a href=\"machine.php?id=".$mac."\" target=\"blank\" title=\"$ping_info\">".$style.$mac.$fin_style."</a></td>";
|
||||
echo "<td><a href=\"machine.php?id=".$mac."\" target=\"blank\" class=\"$class_noping\" title=\"$ping_info\">".$style.$mac.$fin_style."</a></td>";
|
||||
echo "<td>".$style.date("H:i:s",$connexion_machine[$mac]["stamp"]).$fin_style."</td>";
|
||||
echo "<td>".$style.$connexion_machine[$mac]["ip"].$fin_style."</td>";
|
||||
echo "<td>".$div_trombi.$style.$username.$fin_style.$fin_div."</td>";
|
||||
|
@ -51,6 +51,7 @@ $xy_portes = $porte_coord[$salle];
|
||||
// Styles globaux
|
||||
$coul_libre = "#E0E0E0";
|
||||
$coul_occupe = "#b1d7e8";
|
||||
$coul_ping = "#7ff0d4";
|
||||
$coul_hs10 = "#f3e575";
|
||||
$coul_hs20 = "#e17b17";
|
||||
$coul_hs30 = "#d5382c";
|
||||
@ -62,6 +63,7 @@ echo ".j10 {background-color:".$coul_hs10."; }\n";
|
||||
echo ".j20 {background-color:".$coul_hs20."; }\n";
|
||||
echo ".j30 {background-color:".$coul_hs30."; }\n";
|
||||
echo ".ip {font-size: 80%; }\n";
|
||||
echo ".ping {background-color:".$coul_ping."; }\n";
|
||||
|
||||
// Calcul et placement des div
|
||||
|
||||
|
@ -53,6 +53,7 @@ function Affiche_plan_salle(&$machines_de_la_salle, &$portes) {
|
||||
global $trombino_defaut_url;
|
||||
global $trombino_extension_fichier;
|
||||
global $mode_ping;
|
||||
global $seuil_couleur_ping;
|
||||
|
||||
// Timestamps du ping
|
||||
if ($mode_ping) {
|
||||
@ -82,11 +83,15 @@ function Affiche_plan_salle(&$machines_de_la_salle, &$portes) {
|
||||
|
||||
|
||||
$ping_info = "";
|
||||
$class_ping = "";
|
||||
if ($mode_ping) {
|
||||
$ping_delta = "indisponible";
|
||||
if (array_key_exists($machine, $ping_timestamps)) {
|
||||
$ping_ts = strtotime($ping_timestamps[$machine]);
|
||||
$ping_delta = "il y a ".FormateDelta(DateDiff($ping_ts, $date_now));
|
||||
if ($date_now - $ping_ts <= $seuil_couleur_ping) {
|
||||
$class_ping = " ping";
|
||||
}
|
||||
}
|
||||
$ping_info = "ping : ".$ping_delta;
|
||||
}
|
||||
@ -98,9 +103,11 @@ function Affiche_plan_salle(&$machines_de_la_salle, &$portes) {
|
||||
// s'il existe une connexion sur la machine
|
||||
if (array_key_exists($machine, $machines_connectees)) {
|
||||
$class_connexion = ' conn';
|
||||
$class_ping = '';
|
||||
$username = $machines_connectees[$machine]["username"];
|
||||
$ip = $machines_connectees[$machine]["ip"];
|
||||
}
|
||||
|
||||
$cpt = Compte($username); // récupère les informations sur l'utilisateur courant
|
||||
$style = "";
|
||||
$fin_style = "";
|
||||
@ -117,8 +124,10 @@ function Affiche_plan_salle(&$machines_de_la_salle, &$portes) {
|
||||
$url_photo = $trombino_url."/".$username.$trombino_extension_fichier;
|
||||
$img_trombi = "<img src='".$url_photo."' onerror=\"this.error=null;this.src='".$trombino_defaut_url."';\">";
|
||||
}
|
||||
|
||||
|
||||
//$user_affich = $username;
|
||||
$div = "<div id='".$machine."' class='pc".$class_connexion.$class_jour.$class_trombi."'>".$link.$machine."</a><br/>".$style.$username.$fin_style.$img_trombi."<br/><span class='ip'>".$ip."</span></div>";
|
||||
$div = "<div id='".$machine."' class='pc".$class_ping.$class_connexion.$class_jour.$class_trombi."'>".$link.$machine."</a><br/>".$style.$username.$fin_style.$img_trombi."<br/><span class='ip'>".$ip."</span></div>";
|
||||
echo $div;
|
||||
}
|
||||
|
||||
@ -166,7 +175,7 @@ if ($profil > 0) {
|
||||
$form = $form.'</form>';
|
||||
echo $form;
|
||||
}
|
||||
echo("<p><span class='conn'>bleu</span> : connecté <span class='pc'>gris</span> : inactif <span class='j10'>jaune</span> : inactif 10j <span class='j20'>orange</span> : inactif 20j <span class='j30'>rouge</span> : inactif 30j</p>");
|
||||
echo("<p><span class='conn'>bleu</span> : connecté <span class='pc'>gris</span> : inactif <span class='j10'>jaune</span> : inactif 10j <span class='j20'>orange</span> : inactif 20j <span class='j30'>rouge</span> : inactif 30j <span class='ping'>vert</span> : ping depuis moins de $seuil_couleur_ping s");
|
||||
Affiche_plan_salle($machines_du_plan, $portes, $trombino);
|
||||
}
|
||||
else {
|
||||
|
@ -163,4 +163,6 @@ $winlog_ping_debug = false;
|
||||
$php_path = "/usr/bin/php5";
|
||||
// chemin vers le script winlog de collecte des résultats du ping
|
||||
$winlog_get_ping = "/var/www/html/admin/get_ping.php";
|
||||
// seuil de temps en secondes avant changement de couleur du statut "pinguée" d'une machine
|
||||
$seuil_couleur_ping = 120;
|
||||
?>
|
||||
|
Loading…
x
Reference in New Issue
Block a user