Citizen Sense data analysis toolkit
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


The Airsift PM2.5 and Airsift Frackbox Data Analysis Toolkits have been developed by Citizen Sense for use with citizen-generated air quality data collected as part of the “Pollution Sensing” project area. For more information see The toolkit is Free and Open Source.


The research leading to these results has received funding from the European Research Council under the European Union's Seventh Framework Programme (FP/2007-2013) / ERC Grant Agreement n. 313347, “Citizen Sensing and Environmental Practice: Assessing Participatory Engagements with Environments through Sensor Technologies.” For more information on the project and contributors, see

License and Charter of Use

The source code for Airsift, Airsift PM2.5 and Airsift frackbox, Copyright (C) <2016> Citizen Sense is distributed under the terms of the GNU GPL.

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. See "License" file of Airsift for full details.

All users of Airsift, or of any derivative software containing all or parts of Airsift's code, must agree to a Charter of Use and License of the tool.

This is clearly indicated in the "License" file of Airsift, which contains the actual charter of use.


  1. R -v 3.2.0
  2. Shiny -v latest

Package Dependencies

  1. plyr
  2. RSQLite
  3. openair
  4. reshape2

RStudio (Local Machine)

Openair Installation

Go to,

Type these lines below in R or RStudio console:


In case you can't install devtools, run these lines below in your terminal, then run the lines above again in your R's:

$ sudo apt-get -y build-dep libcurl4-gnutls-dev
$ sudo apt-get -y install libcurl4-gnutls-dev



Ubuntu Linux (Developer Server)

Install Shiny Server

Paste these below on your terminal:

$ sudo apt-get install r-base

$ sudo su - \
-c "R -e \"install.packages('shiny', repos='')\""

$ sudo apt-get install gdebi-core
$ wget
$ sudo gdebi shiny-server-

Grant Permissions

Now we have the directory structure for our files, but they are owned by our root user. If we want our regular user to be able to modify files in our web directories, we can change the ownership by doing this:

$ sudo chown lau.users /srv/shiny-server/

Upstart (Ubuntu 12.04 through 14.10, RedHat 6)

$ sudo start shiny-server
$ sudo stop shiny-server
$ sudo restart shiny-server

Install packages

$ sudo su - -c "R -e \"install.packages('plyr', repos='')\""
$ sudo su - -c "R -e \"install.packages('RSQLite', repos='')\""
$ sudo su - -c "R -e \"devtools::install_github('davidcarslaw/openair')\""
$ sudo su - -c "R -e \"install.packages('reshape2', repos='')\""
$ sudo su - -c "R -e \"install.packages('memoise', repos='')\""
$ sudo su - -c "R -e \"install.packages('maps', repos='')\""

The config file for Shiny Server is at /etc/shiny-server/shiny-server.conf.



System Performance Monitoring

Using command top, we can get the Process ID (PID), CPU/Memory usage for each shiny app.

$ top -u shiny

netstat is a command-line tool that displays all network connections. It can list all connections to a shiny app by specifing its Process ID (PID) using command:

$ sudo netstat -p | grep <PID>

Now, we have known the CPU/Memory performance and connections number for each shiny app, however, we still don’t know the name of each shiny app, which can be get using command lsof:

$ sudo lsof -p <PID> | grep DIR



Cron Task

  1. Create shiny-system folder via terminal:

    $ mkdir /srv/shiny-system/

  2. Create cron folder and keep cpu.R in this folder.

  3. Start the crontab editor from a terminal window,

    $ crontab -e

  4. Add entries to your own user's crontab file,

    $ * * * * * Rscript /srv/shiny-system/cron/specks/cpu.R
    $ * * * * * Rscript /srv/shiny-system/cron/fracks/cpu.R

Arch Linux (Production Server)

Check release

To check what Linux release you are running on your server:

$ cat /etc/*-release

NAME="Arch Linux"
PRETTY_NAME="Arch Linux"

Install net-tools for netstat

You should Arch package manager - pacman to install net-tools:

$ sudo pacman -S net-tools

Install cronie

Install cronie for running cron tasks:

$ sudo pacman -Syu cronie

Then enable it:

$ sudo systemctl enable --now cronie.service

Check its status:

$ systemctl status cronie

Start it:

$ sudo systemctl start crond

[citizensense@localhost ~]$ sudo systemctl enable --now cronie.service
Created symlink from /etc/systemd/system/ to /usr/lib/systemd/system/cronie.service.


  2. status crond

Set editor

Set editor to your editor:

$ sudo export EDITOR=vim

Add cront tasks (as a user)

Note that adding cron tasks as a user does not work on the production/ live server:

$ crontab -e

* * * * * Rscript /srv/shiny-system/cron/specks/cpu.R
* * * * * Rscript /srv/shiny-system/cron/fracks/cpu.R
"/tmp/crontab.8VZ7vq" 1 line, 47 characters

Add cront tasks (as a root)

On the production server, you should add the cron task as a root or the tasks won't not be executed:

$ sudo crontab -e

* * * * * Rscript /srv/shiny-system/cron/specks/cpu.R
* * * * * Rscript /srv/shiny-system/cron/fracks/cpu.R
"/tmp/crontab.8VZ7vq" 1 line, 47 characters

Add vim to your crontab editor env that makes it easy to edit the cron tasks:

$ sudo EDITOR=vim crontab -e

You can run the cpu.R manually by type this in your terminal,

$ Rscript /srv/shiny-system/cron/specks/cpu.R
$ Rscript /srv/shiny-system/cron/fracks/cpu.R



List cron tasks

Check what tasks are running:

$ sudo crontab -l

Final notes

  1. Make sure /srv/shiny-system/cron/specks/ folder is set to 777, and cpu.R is set to be executable.
  2. Make sure /srv/shiny-server/specks/speck<1-4>/ folders are set to 777, and log.txt in each of them is set to to 777.