Private GIT

Skip to content
Snippets Groups Projects
Commit ca72a077 authored by Christophe K.'s avatar Christophe K.
Browse files

Version 4.0c entièrement repensé sur la base de df -h <location>

pour être en phase avec le system d'exploitation debian

attention risque de ne pas fonctionner sur d'autre system autre que linux
parent 373e79a3
No related branches found
No related tags found
No related merge requests found
...@@ -12,73 +12,60 @@ ...@@ -12,73 +12,60 @@
/* /*
* @version 3.0b * @version 4.0c
*/ */
// DD 1 // DD 1
// 4 YOYO FILM // 1 YOYO SERIES
$yoyolocation = "/home/data"; $yoyolocation = "/home/data";
$totheformatyoyo = createarrayinfdata($yoyolocation);
//hard disk for percentages //hard disk for percentages
$dptotalyoyo = round_up(@disk_total_space($yoyolocation),0); //Total $dptotalyoyo = formatarrygetdf($totheformatyoyo["total"]); //Total
$dptotalyoyosized = cksize2($dptotalyoyo); $dpfreeyoyo = formatarrygetdf($totheformatyoyo["free"]); //Available
$dpfreeyoyo = round_up(@disk_free_space($yoyolocation)); //Available $dpusedyoyo = formatarrygetdf($totheformatyoyo["used"]); //used
$dpusedyoyo = cksize2($dptotalyoyo-$dpfreeyoyo); //used $barWidthyoyo = str_ireplace("%", "", $totheformatyoyo["PUsed"]); // %P used;
$dpfreesizedyoyo = cksize2($dpfreeyoyo); // Available human read
$barWidthyoyo = round_up((($dptotalyoyo-$dpfreeyoyo) / $dptotalyoyo ) * 100) ;
$linknetdatayoyo = '<embed src="https://www.nailis.fr/netdata/api/v1/badge.svg?chart=disk_space._home_data&alarm=disk_fill_rate&refresh=auto" type="image/svg+xml" height="20"/>'; $linknetdatayoyo = '<embed src="https://www.nailis.fr/netdata/api/v1/badge.svg?chart=disk_space._home_data&alarm=disk_fill_rate&refresh=auto" type="image/svg+xml" height="20"/>';
echo CreateTemplateDD("DD YOYO SERIES",$yoyolocation,$dptotalyoyo,$dptotalyoyosized,$dpfreeyoyo,$dpusedyoyo,$dpfreesizedyoyo,$barWidthyoyo,$linknetdatayoyo); echo CreateTemplateDD("DD YOYO SERIES",$yoyolocation,$dptotalyoyo,$dpfreeyoyo,$dpusedyoyo,$barWidthyoyo,$linknetdatayoyo);
// DD 3 // DD 4
// 4 YOYO FILM // 4 YOYO FILMS
$yoyolocation4 = "/home/data4"; $yoyolocation4 = "/home/data4";
$totheformatyoyo4 = createarrayinfdata($yoyolocation4);
//hard disk for percentages //hard disk for percentages
$dptotalyoyo4 = round_up(@disk_total_space($yoyolocation4),0); //Total $dptotalyoyo4 = formatarrygetdf($totheformatyoyo4["total"]); //Total
$dptotalyoyosized4 = cksize2($dptotalyoyo4); $dpfreeyoyo4 = formatarrygetdf($totheformatyoyo4["free"]); //Available
$dpfreeyoyo4 = round_up(@disk_free_space($yoyolocation4)); //Available $dpusedyoyo4 = formatarrygetdf($totheformatyoyo4["used"]); //used
$dpusedyoyo4 = cksize2($dptotalyoyo4 - $dpfreeyoyo4); //used $barWidthyoyo4 = str_ireplace("%", "", $totheformatyoyo4["PUsed"]); // %P used;
$dpfreesizedyoyo4 = cksize2($dpfreeyoyo4); // Available human read
$barWidthyoyo4 = round_up((($dptotalyoyo4-$dpfreeyoyo4) / $dptotalyoyo4 ) * 100) ;
//echo cksize2(system("du -s ".$yoyolocation4));
// cksize2(system("du -s ".$yoyolocation4));
$linknetdatayoyo4 = '<embed src="https://www.nailis.fr/netdata/api/v1/badge.svg?chart=disk_space._home_data4&alarm=disk_fill_rate&refresh=auto" type="image/svg+xml" height="20"/>'; $linknetdatayoyo4 = '<embed src="https://www.nailis.fr/netdata/api/v1/badge.svg?chart=disk_space._home_data4&alarm=disk_fill_rate&refresh=auto" type="image/svg+xml" height="20"/>';
echo CreateTemplateDD("DD YOYO FILMS",$yoyolocation4,$dptotalyoyo4,$dptotalyoyosized4,$dpfreeyoyo4,$dpusedyoyo4,$dpfreesizedyoyo4,$barWidthyoyo4,$linknetdatayoyo4); echo CreateTemplateDD("DD YOYO FILMS",$yoyolocation4,$dptotalyoyo4,$dpfreeyoyo4,$dpusedyoyo4,$barWidthyoyo4,$linknetdatayoyo4);
// DD 2 // DD 2
// 4 CK // 2 CK FILMS/SERIES
$cklocation ="/home/data2"; $yoyolocation2 = "/home/data2";
$totheformatyoyo2 = createarrayinfdata($yoyolocation2);
//hard disk for percentages //hard disk for percentages
$dptotalck = round_up(@disk_total_space($cklocation),0); //Total unformated $dptotalyoyo2 = formatarrygetdf($totheformatyoyo2["total"]); //Total
$dptotalcksized = cksize2($dptotalck); $dpfreeyoyo2 = formatarrygetdf($totheformatyoyo2["free"]); //Available
$dpfreeck = round_up(@disk_free_space($cklocation)); //Available $dpusedyoyo2 = formatarrygetdf($totheformatyoyo2["used"]); //used
$dpusedck = cksize2(round_up($dptotalck-$dpfreeck)); //used $barWidthyoyo2 = str_ireplace("%", "", $totheformatyoyo2["PUsed"]); // %P used;
$dpfreesizedck = cksize2($dpfreeck); // Available human read $linknetdatayoyo2 = '<embed src="https://www.nailis.fr/netdata/api/v1/badge.svg?chart=disk_space._home_data2&alarm=disk_fill_rate&refresh=auto" type="image/svg+xml" height="20"/>';
$barWidthck = round_up((($dptotalck-$dpfreeck) / $dptotalck ) * 100) ; echo CreateTemplateDD("DD CK FILMS/SERIES",$yoyolocation2,$dptotalyoyo2,$dpfreeyoyo2,$dpusedyoyo2,$barWidthyoyo2,$linknetdatayoyo2);
$linknetdatack = '<embed src="https://www.nailis.fr/netdata/api/v1/badge.svg?chart=disk_space._home_data2&alarm=disk_fill_rate&refresh=auto" type="image/svg+xml" height="20"/>';
echo CreateTemplateDD("DD CK SERIES",$cklocation,$dptotalck,$dptotalcksized,$dpfreeck,$dpusedck,$dpfreesizedck,$barWidthck,$linknetdatack);
// DD 3 // DD 3
// 4 JK // 2 JK FILMS/SERIES
$jklocation ="/home/data3"; $yoyolocation3 = "/home/data3";
$totheformatyoyo3 = createarrayinfdata($yoyolocation3);
//hard disk for percentages //hard disk for percentages
$dptotaljk = round_up(@disk_total_space($jklocation),0); //Total unformated $dptotalyoyo3 = formatarrygetdf($totheformatyoyo3["total"]); //Total
$dptotaljksized = cksize2($dptotaljk); $dpfreeyoyo3 = formatarrygetdf($totheformatyoyo3["free"]); //Available
$dpfreejk = round_up(@disk_free_space($jklocation)); //Available $dpusedyoyo3 = formatarrygetdf($totheformatyoyo3["used"]); //used
$dpusedjk = cksize2(round_up($dptotaljk-$dpfreejk)); //used $barWidthyoyo3 = str_ireplace("%", "", $totheformatyoyo3["PUsed"]); // %P used;
$dpfreesizedjk = cksize2($dpfreejk); // Available human read $linknetdatayoyo3 = '<embed src="https://www.nailis.fr/netdata/api/v1/badge.svg?chart=disk_space._home_data3&alarm=disk_fill_rate&refresh=auto" type="image/svg+xml" height="20"/>';
$barWidthjk = round_up((($dptotaljk-$dpfreejk) / $dptotaljk ) * 100) ; echo CreateTemplateDD("DD JK FILMS/SERIES",$yoyolocation3,$dptotalyoyo3,$dpfreeyoyo3,$dpusedyoyo3,$barWidthyoyo3,$linknetdatayoyo3);
$linknetdatajk = '<embed src="https://www.nailis.fr/netdata/api/v1/badge.svg?chart=disk_space._home_data3&alarm=disk_fill_rate&refresh=auto" type="image/svg+xml" height="20"/>';
echo CreateTemplateDD("DD JK FILMS+SERIES",$jklocation,$dptotaljk,$dptotaljksized,$dpfreejk,$dpusedjk,$dpfreesizedjk,$barWidthjk,$linknetdatajk);
...@@ -94,37 +81,63 @@ ...@@ -94,37 +81,63 @@
*************************** ***************************
*/ */
function cksize2($Bytes) // pour formatage des chiffre obtenus !
{ function formatarrygetdf($vartoconvert) {
$Type=array("O", "KO", "MO", "GO", "TO", "PO", "EO", "ZO", "YO"); $bytes = $vartoconvert;
$Index=0; $s = array('B', 'Kb', 'MB', 'GB', 'TB', 'PB');
while($Bytes>=1024) $e = floor(log($bytes)/log(1024));
{ return sprintf('%.2f '.$s[$e], ($bytes/pow(1024, floor($e))));
$Bytes/=1024;
$Index++;
}
return( "". round_up($Bytes) ." ".$Type[$Index]."" );
} }
/*
************************** /* ************
* ARRONDI A LA DECIMALE * Fonction to extract
* PRECISION X * df value from debian sys
************************* * may not compatible with
* other system
*/ */
function createarrayinfdata($location) {
// 1 = TOTAL
// 2 = USED
// 3 = DISPO
// 4 = Pourcent Used
// 5 = path
$getdf = exec("df ".$location,$returnval);
$arrey_getdf = explode(' ', $getdf) ;
$compt =0;
foreach ($arrey_getdf as &$value) {
function round_up($value, $decimals) if ($value > "")
{ {
$decimals > "" ? $decimals : $decimals = 2; $arrey_getdf2[$compt] = $value;
$compt++;
}
}
//var_dump($arrey_getdf2);
//exit;
// return floor($value*pow(10,$decimals)+0.5)/pow(10,$decimals); $thebase = 1024;
// attention la constante PHP_ROUND_HALF_UP peut ne pas fonctionner avec php < 5.3 $toreturn4 = array(
return sprintf ("%01.2f", round ($value , $decimals , PHP_ROUND_HALF_UP )) ; "total" => $arrey_getdf2[1] * $thebase,
"used" => $arrey_getdf2[2] * $thebase,
"free" => $arrey_getdf2[3] * $thebase,
"PUsed" => $arrey_getdf2[4],
"path" => $location
);
return $toreturn4;
} }
/* ************ /* ************
* Fonction to generate * Fonction to generate
* the html code from the * the html code from the
...@@ -132,13 +145,12 @@ return sprintf ("%01.2f", round ($value , $decimals , PHP_ROUND_HALF_UP )) ; ...@@ -132,13 +145,12 @@ return sprintf ("%01.2f", round ($value , $decimals , PHP_ROUND_HALF_UP )) ;
* *
*/ */
function CreateTemplateDD ($namedd, /*DDNAME*/ function CreateTemplateDD ($namedd, /*DDNAME*/
$location, /*Target to get information, ex hard drive or folder*/ $location, /*Target to get information, ex hard drive or folder*/
$dptotal="", /*Total space of HD*/ $dptotal="", /*Total space of HD*/
$dptotalsized="", /*Total space of HD formatted*/
$dpfree="", /*Free space*/ $dpfree="", /*Free space*/
$dpused="", /*Used space*/ $dpused="", /*Used space*/
$dpfreesized="", /*Human size */
$barwidth_fonc, /*Barsized width */ $barwidth_fonc, /*Barsized width */
$netdatalink="") /*Netdata Link */ $netdatalink="") /*Netdata Link */
...@@ -165,9 +177,9 @@ $STP = T('DISK_SPACE'); ...@@ -165,9 +177,9 @@ $STP = T('DISK_SPACE');
$tocompile = <<<LECODE $tocompile = <<<LECODE
<!-- ADDON CK - {$namedd} --> <!-- ADDON CK - {$namedd} -->
<p class="nomargin">{$namedd} {$location} {$barWidth}</p> <p class="nomargin">{$namedd} {$location} {$barWidth}</p>
<p class="nomargin">{$STF}: <span style="color:yellow; font-weight: 700; position: absolute; left: 100px;">{$dpfreesized}</span></p> <p class="nomargin">{$STF}: <span style="color:yellow; font-weight: 700; position: absolute; left: 100px;">{$dpfree}</span></p>
<p class="nomargin">{$STU}: <span style="font-weight: 700; position: absolute; left: 100px;">{$dpused}</span></p> <p class="nomargin">{$STU}: <span style="font-weight: 700; position: absolute; left: 100px;">{$dpused}</span></p>
<p class="nomargin">{$STS}: <span style="font-weight: 700; position: absolute; left: 100px;">{$dptotalsized}</span></p> <p class="nomargin">{$STS}: <span style="font-weight: 700; position: absolute; left: 100px;">{$dptotal}</span></p>
<div class="row"> <div class="row">
<div class="col-sm-8"> <div class="col-sm-8">
<h3>{$STP}</h3> <h3>{$STP}</h3>
...@@ -186,10 +198,10 @@ LECODE; ...@@ -186,10 +198,10 @@ LECODE;
return $tocompile; return $tocompile;
} // END function CreateTemplateDD } // END function CreateTemplateDD
//<!-- version git add on -->
$versionAPP = exec('git rev-parse --short HEAD');
?> ?>
<!-- version git add on -->
<span style="font-size:8px">version de l'add on ck : < <span style="color:yellow"><?=$versionAPP;?></span> ></span>
<h3>LOCAL /HOME </h3> <h3>LOCAL /HOME </h3>
<!--FIN ADDON CK --> <!--FIN ADDON CK -->
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment