Skip to content

Database

jdeananderson edited this page Dec 5, 2018 · 17 revisions

Database tables, usernames and permissions

The wall-ink-server contains two database tables; devices, and monitoring. The devices table contains information about all of the wall-ink devices that have been added to the wall-ink-server. The monitoring table is used for Nagios monitoring of the wall-ink-server. The deviceDatabaseUsername specified in settings.cfg requires read and write access to the devices table. After creating the monitoring table in the sql_setup.sh script, the deviceDatabaseUsername account does not need to read or write access to the monitoring table. The user used for Nagios monitoring requires readonly access to the devices table, and read and write access to the monitoring table. There are two tables with two separate users to ensure that the Nagios script does no damage to the devices table. Sometimes in enterprise situations, monitoring is handled by a separate group and should not be able to damage production data.

For exact definitions of the tables, including field lenghts, etc, see the sql_setup.sh script in the Github repository.

Devices table

device_id

A simple autoincremented integer associated with each device in the devices table. Used by the view_devices.php and edit_device.php pages as a unique ID.

resource_id

The resource_id is an identifier that tells a plugin which resource a particular device is tied to. For instance, if a device is using the Google calendar plugin, the resource_id would be the identifier for a particular Google calendar. If the static_images plugin is selected, the resource_id would identify which folder of images to display. If the Booked plugin is selected, the resource_id identifies which Booked resource to display a schedule for.

device_type (or layout)

device_type, sometimes referred to as "layout" lets a plugin know which layout or formatting to use for an image displayed on a device. The plugin may use the layout for screen sizing, how to organize text on the screen, which fonts to use, and how long to display an image for. A plugin can display any image it wants, for any period of time, given the resource_id and the device_type, or layout. Layouts for a particular plugin and resource are selected in the device manager.

mac_address

This is the MAC address a the wall-ink device. The wall-ink devices pass their MAC address to the wall-ink-server when they check in and ask for an image. The wall-ink server queries the devices table and finds which plugin, resource_id and layout to use to build a Wink file to return.

voltage

This is the voltage of the wall-ink device as reported when the device last checked in. The voltage may be stored using the voltage monitoring tool.

orientation

The case for the 7.5" wall-ink device was designed to operate the Waveshare 7.5" screen upside-down. Because of this, all images are flipped up-side down before sending them to the device. This field in the database keeps track of whether or not to flip the image.

last_checked_in

last_checked_in is a Unix time stamp of the last time a particular wall-ink device asked for an image from the wall-ink-server.

batteries_replaced_date

This field is updated with the current Unix time stamp when a significantly higher voltage is recorded compared with the previous entry in the database. This number is used so systems administrators can see how long batteries are lasting in various devices to help diagnose hardware problems.

firmware_version

firmware_version keeps track of the last reported firmware version of each device. This helps systems administrators keep track of firmware versions of all their devices in the device manager.

plugin

The plugin field keeps track of which plugin is used for a particular device. In older versions of the code, this field was labeled "scheduling_system". This field was updated to "plugin" when other types of plugins were created that were not scheduling systems like Google Calendar or Booked.

Notes

The notes field is used in the device manager for systems administrators to keep notes on a particular wall-ink device. It may include location information, like "West Entrance". In some cases it may contain information about hardware issues, or who currently owns or has possession of the device.

height

Screen height of a wall-ink device in pixels. This field is updated by a wall-ink device when it checks in.

width

Screen width of a wall-ink device in pixels. This field is updated by a wall-ink device when it checks in.

is_production

This field allows Nagios monitoring to know if a device is to be monitored or not. This allows systems administrators to choose if they want to be notified if a particular wall-ink device is not checking in on time.

Monitoring table

mac_address

Used in conjunction with device_id to identify a unique device between the monitoring table and the devices table

next_check_in

next_check_in contains the Unix time stamp of when a particular wall-ink device is supposed to check back in with the server for an update. This field is not populated when a wall-ink device checks in, but instead when the Nagios checkin script pretends to be that device. See the Nagios monitoring documentation for more details.

missed_count

missed_count is the number of times a particular wall-ink device has missed a checkin. Usually Nagios keeps this in it's own database and handles this type of scenario, but allowing the wall-ink-server to monitor the missed count for each device allows for there to only be one monitored wall-ink device object in Nagios. Instead of there being dozens or hundreds of wall-ink devices in Nagios, there is just one. You can't monitor wall-ink devices the same way you monitor regular servers, since you can't ping them, and can't run service checks against them. All you can do is see if they have checked in when they are supposed to. It makes more sense for one Nagios script to monitor the database and pass on warnings about multiple devices.