Skip to content
Snippets Groups Projects
Commit c624e0bf authored by Tibo's avatar Tibo
Browse files

Add agent to check installed client version

parent 54f2a129
No related branches found
No related tags found
No related merge requests found
<?php
namespace App\Sensor;
/**
* Description of Reboot
*
* @author tibo
*/
class ClientVersion extends \App\AbstractSensor {
public function latestVersion() {
return json_decode(file_get_contents("https://gitlab.cylab.be/cylab/monitoring/raw/master/php-client/release/manifest.json"))[0]->version;
}
//put your code here
public function report() {
return "<p>Installed version: " . $this->getServer()->clientVersion() . "</p>"
. "<p>Latest client version: " . $this->latestVersion() . "</p>";
}
public function status() {
return self::STATUS_OK;
}
}
......@@ -15,7 +15,8 @@ class Server extends Model
\App\Sensor\Updates::class,
\App\Sensor\Disks::class,
\App\Sensor\Inodes::class,
\App\Sensor\Date::class
\App\Sensor\Date::class,
\App\Sensor\ClientVersion::class
];
public function __construct(array $attributes = array()) {
......
......@@ -72,7 +72,12 @@ tmpfs 2451716 0 2451716 0% /run/user/1000";
$cpuinfo = $server->parseCpuinfo($string);
$this->assertEquals(8, $cpuinfo["threads"]);
$this->assertEquals("Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz", $cpuinfo["cpu"]);
}
public function testClientVersion() {
$server = new \App\Server();
$client_version = new \App\Sensor\ClientVersion($server);
$this->assertStringMatchesFormat('%f', $client_version->latestVersion());
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment