Giter VIP home page Giter VIP logo

akita.py's Introduction

akita.py

A simple, lightweight event-driven network device drop-off and reconnection tool for hacking home network devices.

For example, you can program your network connected lighting to come on if:

  • Your phone disconnects from the local network for more than fifteen minutes
  • When it reconnects, it's currently dark outside

You can also capture disconnection events. For example, send yourself an email if your home server is offline for more than one minute.

Installing

Pre-requisites:

  • Python 2.7
  • fping

Ubuntu / Debian / Raspbian

cd ~/
git clone https://github.com/isdampe/akita.git
cd akita
./install.sh

Configuring your network events

The akita jobs configuration is stored in ~/.config/akita/jobs.json.

See "jobs.json manifest format" below.

jobs.json manifest format

The jobs.json manifest format is a JSON document, containing an array of objects, each of which is loaded into akita.py for monitoring.

[
	{
		"name": "My mobile phone",
		"ip": "192.168.0.150",
		"reconnectTimer": 120,
		"disconnectTimer": 60,
		"reconnectAction": "/opt/phone-reconnect.sh",
		"disconnectAction": "/opt/phone-disconnect.sh"
	},
	{
		"name": "My raspberry pi",
		"ip": "192.168.0.160"
	}
]

In the example above, if device 192.168.0.150 does not respond to ICMP ping requests for more than 60 seconds, /opt/phone-disconnect.sh will be executed.

Likewise, once the phone reconnects, if it has been offline for more than 120 seconds, /opt/phone-reconnect.sh will be triggered.

Object description

{
	"name": "Your device name",
	"ip": "Your IP address to ping",
	"reconnectTimer": 120, //If left blank, defaults to 120
	"reconnectAction": "/path/to/reconnect.sh",
	"disconnectTimer": 120, //If left blank, defaults to 120
	"disconnectAction: "/path/to/disconnect.py
}

Some notes about reconnectAction, and disconnectAction

If no reconnectAction or disconnectAction is supplied, akita.py will look for and try to execute a script located in ~/.config/akita/proc.d as per below.


Upon reconnection:
~/.config/akita/proc.d/[ip-address]-reconnect.sh

Upon disconnection:
~/.config/akita/proc.d/[ip-address]-disconnect.sh

All actions executed will receive one command line argument, which represents the numbers of seconds the device has been offline for.

The argument is supplied with a -t prefix. For example.

~/.config/akita/proc.d/192.168.0.150-reconnect.sh -t 320

Implying 192.168.0.150 was down for 320 seconds.

Running akita.py

Simply run in user mode with ./akita.py. If you're looking for a headless, safer way, try creating a sytemd or init service.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.