Menu

YfiTechHeartbeat

Anonymous

Setting Up a heartbeat system


Consider the diagram above

  • The IP of the Access Point is never known to the server running YFi Hotspot Manager and FreeRADIUS.
  • The incoming IP Address to the YFi Hotspot Manager will be the outside public address of the NAT firewall.
  • There is now way (taking the defaults) for the YFi Hotspot Manager to directly contact the Access Point.

The work around

  • Create a program on the Access Point to send a heartbeat signaling to the YFi Hotspot Manager server that it is alive.(We'll use the MAC address on which the CoovaChilli daemon runs as a unique signature).
  • Set up a cron job on th Access Point to send this heartbeat to the YFi Hotspot Manager every X seconds.
  • The YFi Hotspot Manager can then in reply to the heartbeat signal identify the device and return commands that the device should execute.
  • In this way we can terminate active connections indirectly without contacting the Access Point directly.

Configure YFi for this

  • Ensure you have the version of YFi Hotspot manager that support this feature. To check, ensure that a NAS type can be defined as CoovaChilli-NAT.
  • Set up dynamic clients for FreeRADIUS as described in this URL. (You have to recompile FreeRADIUS with a patch) https://sourceforge.net/apps/trac/hotcakes/wiki/YfiTechDynamicClients
  • To define a NATed NAS device it has to have the following:

Item
Detail

Type
Set it to CoovaChilli-NAT

Active Monitor
Check this option so we can know when the device is down

Community
Set this to the value of the Called-Station-Id (This is the MAC address of the interface on which CoovaChilli runs e.g. 08-00-27-56-22-0B) Check the incoming request to FreeRADIUS in debug mode for detail

Everything on the YFi side is now configured. Next is the Access Point where you have to set up the heartbeat script.


Configure the Access Point's Heartbeat

  • Attached to this page is a tar file containing a heartbeat script that can be used (still under development)
  • Configure the script to read the correct interface of the Access Point it is on.
  • Also supply the correct URL so that it points to your YFi server.
  • Configure cron to run this script at regular intervals.

Manually test things

It is always nice to know how things work in order to troubleshoot when they don't work as they are suppose to do.

Faking a heartbeat

  • To fake a heartbeat on the YFi server go to this URL. Substitute the IP with your YFi server's and add the MAC of the NAS as unique identifier (the one specified in the Community of the NAS):

http://10.1.0.1/c2/yfi_cake/heartbeats/json_hello/08-00-27-56-22-0B

  • If the MAC is not identified among those defined in the NAS Devices the following reply will be given.

    ERROR: MAC not defined correct -OR- NAS type not correct
    
  • If there was no reply command lined up for this NAS there will be just a blank screen in the reply.

  • If there was a reply lined up it will be reflected in the feedback.

Adding commands to execute

  • You can manually add commands to execute in reply to a heartbeat.
  • Select the NAS Device and edit it. Select the Actions sub-tab.
  • This will list all the actions (fetched and awaiting) for the NAS Device.

  • Click on the plus icon to add a new action which will then be returned to the heartbeat script

  • The new action will now wait for the next heartbeat. After it is returned in reply to the heartbeat the status will change to Fetched.

Kicking off Users

  • One can manually terminate a user's connection on CoovaChilli connection with the following command:

    chilli_query logout <MAC Address>
    
  • If a NAS device is marked as Type CoovaChilli-NAT we will use the heartbeat mechanism to line up a command for the NAS to terminate the user's connection.

  • This is done in two places.
  • Manually selecting a listed active connection and kicking the user off (Using the YFi interface)
  • When a permanent user's account is disabled or the data / time cap is depleted. (Done by the code inside the FreeRADIUS Perl module.)
  • Then you will find entries as listed in the Actions sub-tab.

Marking a device dead or alive

  • Depending on how regular a heartbeat is send to the YFi server and how regular the nasmonitor cron script runs you will see if a device is marked up or down. In /etc/cron.d/yfi.

    */5 * * * * www-data /var/www/c2/cake/console/cake -app /var/www/c2/yfi_cake nasmonitor >> /dev/null 2>&1
    
  • You should also configure the time with no heartbeat a once live device will be marked as dead. In the /var/www/c2/yfi_cake/config/yfi.php file

    //Consider a heartbeat device dead after so many seconds
    $config['heartbeat']['dead_after']                  = 660; //Eleven minutes
    

Related

Wiki: YfiTechBeta6VM
Wiki: YfiTechOpenMeshHeartbeat