Showing Last Check-in Time
-
Is there a way to show when a client last communicated (checked in) with the fog server? I’d like to compile a list of all my clients showing their check-in times and see if any clients are no longer communicating.
-
@FlareImp While I don’t have a simple answer to approach, we do track the last time the security token was updated. Which I believe is set at 15-30 minute increments.
You could write a hook to expose that on the UI. Right now there isn’t a component that updates the last checkin time in the database though, so not quite sure if this will fit the needs.
I will try to mock up what a sample of the hook might look like that you could at least glean that last status time.
-
@Tom-Elliott This is completely untested and I’m sorry for that, but should give a potential way forward:
<?php /** * Displays the sec token time on hosts. * * PHP version 5 * * @category HostSecTime * @package FOGProject * @author Tom Elliott <tommygunsster@gmail.com> * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link https://fogproject.org */ /** * Displays the sec token time on hosts. * * @category HostSecTime * @package FOGProject * @author Tom Elliott <tommygunsster@gmail.com> * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link https://fogproject.org */ class HostSecTime extends Hook { /** * The name of this hook. * * @var string */ public $name = 'HostSecTime'; /** * The description of this hook. * * @var string */ public $description = 'Adds the host security time to the Host Lists'; /** * Is this hook active? * * @var bool */ public $active = true; /** * Iniatializes object. * * @return void */ public function __construct() { parent::__construct(); self::$HookManager ->register( 'HOST_DATA', array( $this, 'hostData' ) ) ->register( 'HOST_HEADER_DATA', array( $this, 'hostTableHeader' ) ); } /** * The data to alter. * * @param mixed $arguments The items to alter. * * @return void */ public function hostData($arguments) { global $node; if ($node != 'host') { return; } $arguments['templates'][] = '${host_sec_time}'; $arguments['attributes'][] = array('class' => 'c'); foreach ((array)$arguments['data'] as $i => &$data) { $arguments['data'][$i]['host_sec_time'] = $data['host_sec_time']; unset($data); } } /** * The table header to alter * * @param mixed $arguments The items to alter. * * @return void */ public function hostTableHeader($arguments) { global $node; if ($node != 'host') { return; } $arguments['headerData'][] = _('Security Token Expires Time'); } }
-
@Tom-Elliott Awesome, thank you very much! I’ll start playing around with this.
-
I gave your script a try and it crashes with web UI when set from active=false to active=true.
-
@FlareImp What’s the error log show?
It’s likely a call that I overlooked.
I just gave a quick baseline, not a tested instance as it’s been a while since I built a hook, and I don’t have my normal environment since years now.
-
@Tom-Elliott dumb question but where would I find the log file for hooks?
-
@FlareImp It wouldn’t be the hook specifically, but the general php/http logs.
-
@FlareImp said in Showing Last Check-in Time:
dumb question but where would I find the log file for hooks?
See my signature.