OAS: Cheat Sheet: File / Directories

Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

OAS: Cheat Sheet

File / Directories

Configuration

# Standard configuration
/opt/guardvant/db
/opt/guardvant/configs

# Client configuration
/opt/guardvant/clients/<minesite>/db

# Local configuration
/opt/guardvant/db/gvos.conf

# Profile Configuration
Attached to operator/location profile, example:
/opt/guardvant/db/oper-eye.json

Logs

# logs directory
/opt/guardvant/logs

# log for gvos service


/opt/guardvant/logs/<minename>.log

# log for mail service


/var/logs/mail.log

# log for gvuploads service


/opt/guardvant/logs/gvupload.log

GVOS Commands

List available components

objects all

List a component's properties


-- on server

web

replicator

-- on equipment

face_yaw_scaler

face_tensor

fatigue

gps

audio

eyes

Get component properties

fatigue.seat_enabled

gps.fake_speed

Set component properties (when gvos restarted, it will back to original value)

-- on server

web.query_limit=100000

-- equipment
gps.fake_speed=30

eyes.tracking_sensitivity=0.8

eyes.closure_sensitivity=0.8

face_tensor.microsleep_percent=25

face_tensor.microsleep_percent_high=25

Show component methods

-- server

web methods

manager methods

replicator devices

mail_notifier get_mail_lists

-- equipment

GvSensor sensors

Accessing component methods


# Device parent
-
GvDevice.this_device

GvDevice.this_device.properties

GvDevice.this_device.all_groups

Create a copy of db from equipment to server and inspect what inside

replicator database_for_device T52006

mv /tmp/gvxxx ~/T52006.db
sqlite3 /-csv ~/T52006.db

Enable logging to a component

-- server
listen replicator
listen mail_notifier

-- equipment

listen sensor_face_yaw

listen face_tensor

list sensor_gps

listen sensor_adc_illum

listen fatigue

list sensor_gps_speed

Stop logging a component

unlisten replicator
unlisten mail_notifier

unlisten face_tensor

# Adding timestamp
-
self.timestamps=true

Force event generation

fatigue event <type> <timestamp> <duration_msec> <value>

example:
fatigue event microsleep now 4000 50

Force play sound

audio play_sound fatigue_1


Activate vibrator

gpout <type> <gpio_pin> <msec_interval> <duration>


example:
gpout blink ena_4 250 1000

Misc Commands

Cleanup old files

# Look for Guardvant's large old file(s)


cd /opt/guardvant/clients/<minename>/
find snapshots/*/ \( -type f -a -mtime +180 \) -print 'removing file %p \n'

# delete it
find snapshots/*/ \( -type f -a -mtime +180 \) -print 'removing file %p \n' -delete

File location

df
/data/dvr/<equipment_name>

/backup/dvr/<equipment_name>

# transfer file from equipment


rsync -av HA477:/backup/dvr/HA477/cabin-20200604-0350* .

gv_admin

/opt/guardvant/scripts/gv_admin

env --> list of environment variable

init --> only when server initialiaze

clean --> listed suggestion of configuration that no longer used anymore / might not be needed

diff --> giving difference between json file (/opt/guardvant/clients/<minesite>/db) and database

load --> load data dictionary

Using gv_admin diff


[1] Keep json file
-
cd /opt/guardvant/clients/<minesite>/db
mkdir save
mv enum_tables.json equipment.json fatigue_levels.json languages.json phrases.json rotation.json sensor_alarms.
json users.json access_points.json devices.json save/.
[2] Leave Files that only have configurations
-
configurations.json
proximity.json
opweb.json
illuminator_config.json
gpsprox.json

[3] Run the gv_admin diff


/opt/guardvant/scripts/gv_admin diff

--> It will dump client configuration into different json files (grouped by device) under /opt/guardvant/clients
/<minesite>/db

Use gv_model to load changes from a specific json file to db

cd /opt/guardvant/clients/<minesite>/db
gv_model load -v -D postgres://localhost/cananea,user=gv_admin,password=guard4640 server.json

gv_model load -v -D postgres://localhost/cananea,user=gv_admin,password=guard4640 cananea_diff.json

# To add new equipment (new_devices.json)


-
gv_model load -v -D postgres://localhost /cananea,user=gv_admin,password=guard4640 new_devices.json

A way to get 'netconfig.json' file

curl http://localhost/gvos/manager/download_software,config,null,null
curl http://localhost/gvos/manager/download_software,config,null,null > netconfig.json

Database Commands

Copy SQLite database onboard

guardvant@HT02:~$ /etc/init.d/gvos stop


stopping /etc/init.d/gvos
guardvant@HT02:~$ cd /data/db/
guardvant@HT02:/data/db$ cp opguard.db opguard.db.save
guardvant@HT02:/data/db$ /etc/init.d/gvos start
starting /etc/init.d/gvos
guardvant@HT02:/data/db$

Backup SQLite database (alternate method)


# Create database on server

server=# telnet localhost 4640


server=# 6.1-1> replicator.database_for_device HT02
/tmp/gvZzLnNl
Server=# 6.1-1> exit
Connection closed by foreign host.
Server=-# scp /tmp/gvZzLnNl ht02:opguard.db

# Copy database to client

guardvant@HT02:~$ cd /data/db/
guardvant@HT02:/data/db$ /etc/init.d/gvos stop
stopping /etc/init.d/gvos
guardvant@HT02:/data/db$ rm opguard.*
guardvant@HT02:/data/db$ cp ~/opguard.db .
guardvant@HT02:/data/db$ /etc/init.d/gvos start

Backup PostgreSQL database

# Using “pg_dump” (creates 1 file for the database)

server=# pg_dump -U gv_admin my_database > my_filename

# Using “gv_sql” (creates 1 csv file for each table)

server=# gv_sql dump -i postgres://localhost/my_database,user=gv_admin,password=guard4640 -d ./my_dump all

Restore PostgreSQL database

# Restore the previously created file using “psql”

server=# createdb -U gv_admin my_database


server=# psql -U gv_admin my_database < my_filename

# Using “gv_sql”
server=# gv_sql load -d my_dump -o postgres://localhost/my_database,user=guardvant,password=guard4640

Backup/Restore Table
# Using “pg_dump” to dump the table
server=# pg_dump -t configurations my_database2 > configurations.sql

# Using “psql” to load the table onto another database


server=# psql -U gv_admin my_database < configurations.sql
SET
SET
SET
SET
SET
set_config
------------
(1 row)

SET
SET
CREATE TABLE
ALTER TABLE
CREATE SEQUENCE
ALTER TABLE
COPY 1183
setval
--------
1221
(1 row)

ALTER TABLE
server=#

# Using “gv_sql” to dump the table

server=# gv_sql dump -i postgres://localhost/my_database2,user=gv_admin,password=guard4640 -d ./my_dump


configurations

# Using “gv_sql” to load the table onto another database

server=# gv_sql load -d my_dump -o postgres://localhost/my_database,user=guardvant,password=guard4640

Dump Partial Data

# Using “gv_sql dump –h” to dump database with historical data up to X number of hours

server=# gv_sql dump -i postgres://localhost/my_database,user=gv_admin,password=guard4640 -hours 24 -d .


/my_dump all

# Using “pg_dump -T” to exclude a table

server=# pg_dump -U gv_admin my_database –T shift_gps –T shift_sensors > backup.sql

Replicate Database
sudo /opt/guardvant/scripts/gvbackup install -n <name of the process/script that will be appear on etc init d>
<source_database> <destination_database>

Example:
postgres to postgres
-
sudo /opt/guardvant/scripts/gvbackup install -n mymine_backup postgres://localhost/mymine,user=gv_admin,
password=guard4640 postgres://localhost/mymine_backup,user=gv_admin,password=guard4640

postgres to sqlserver
-
sudo /opt/guardvant/scripts/gvbackup install -n mymine_backup postgres://localhost/mymine,user=gv_admin,
password=guard4640 freetds://sqlserverhost/mymine,user=myuser,password=mypassword

Check OS Version onboard

$ cat /etc/owrt-arch
OWRT_arch=gvpc-imx6
OWRT_version=6.1-8
OWRT_major=6
OWRT_topology=fixed

$ cat /etc/os-release
NAME="OpenWrt"
VERSION="6.1"
ID="openwrt"
ID_LIKE="lede openwrt"
PRETTY_NAME="OpenWrt 6.1"
VERSION_ID="6.1"
HOME_URL="http://opkg.guardvant.com"
BUG_URL="http://bugs.openwrt.org/"
SUPPORT_URL="http://forum.lede-project.org/"
BUILD_ID="r9334-43af42a9f9"
LEDE_BOARD="imx6/generic-glibc"
LEDE_ARCH="armv7_neon"
LEDE_TAINTS="no-all glibc busybox"
LEDE_DEVICE_MANUFACTURER="Hexagon"
LEDE_DEVICE_MANUFACTURER_URL="http://openwrt.org/"
LEDE_DEVICE_PRODUCT="OpGuard"
LEDE_DEVICE_REVISION="v0"
LEDE_RELEASE="OpenWrt 6.1 r9334-43af42a9f9"

Related articles
OAS: GVOS Configuration Reference
OP Pro: Identify old shift records that has been updated recently
OAS: Post Installation Configuration
OAS: OpWeb Configuration Reference
OP Pro: Improving security on Linux Server

You might also like