PHP code example of mrtazz / yagd

1. Go to this page and download the library: Download mrtazz/yagd library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

mrtazz / yagd example snippets




de_once("../config.php");

use Yagd\CollectdHost;
use Yagd\Page;

$page = new Page($CONFIG);
echo $page->getHeader($CONFIG["title"],
    $CONFIG["navitems"]);

foreach($CONFIG["hosts"] as $host => $data) {

    $fss = empty($data["filesystems"]) ? [] : $data["filesystems"];

    $server = new CollectdHost($host, $data["cpus"], $fss,
                               $data["interfaces"]);
    $server->setGraphiteConfiguration($CONFIG["graphite"]["host"]);
    echo "<h2> {$host} </h2>";
    $server->render();
}

echo $page->getFooter();




$selectbox = "";
$selectbox .= "<form method='get' action='hosts.php' style='margin-top: 15px'class='pull-right'>";
$selectbox .= "   <select name='hostname' onchange='this.form.submit()'>";
    foreach ($CONFIG["hosts"] as $host => $data) {
        $selected = ($_GET["hostname"] == $host) ? "selected" : "";
        $selectbox .= "<option value='{$host}' {$selected}>{$host}</option>";
}
$selectbox .= "</select>";
$selectbox .= "</form>";

$page = new Page($CONFIG);
echo $page->getHeader($CONFIG["title"],
    $CONFIG["navitems"],
    $selectbox);

if (empty($_GET["hostname"])) {
    $hosts = $CONFIG["hosts"];
} else {
    $hosts = [ $_GET["hostname"] => $CONFIG["hosts"][$_GET["hostname"]] ];
}