StaffCop command line

A lot of administrative operations have a convenient and concise system of commands that can be run in the command line.

To add a rule to the global configuration run the following command:

sudo staffcop acl <RULE> <VALUE>

Detailed list of rules can be found here

Backup of database and settings. Saves backup by default in /var/lib/staffcop/staffcop_backup

sudo staffcop backup_db [PATH_TO_BACKUP]

Delete all files and screenshots older than DAYS

sudo staffcop cleandata <DAYS>

Delete all files and events older than DAYS

sudo staffcop cleanup <DAYS>

Manage Clickhouse database

sudo staffcop clickhouse [install|init|reinit|pump|test|start|stop|restart]

Install and activate Clickhouse database

sudo staffcop clickhouse install

Upgrade Clickhouse to the latest stable version

staffcop upgrade clickhouse

Install the latest stable version of Clickhouse. Sometimes it helps you to get rid of promlems associated with unstable Clickhouse versions, which as a rule are newer ones.

Export data from postgresql to clickhouse

sudo staffcop clickhouse pump

Testing of data export from postgresql to clickhouse is required for diagnostic

sudo staffcop clickhouse test

Overwrite all the data of Clickhouse Database

sudo staffcop clickhouse reinit

Restart clickhouse-server

sudo staffcop clickhouse restart

Start clickhouse-server

sudo staffcop clickhouse start

Stop clickhouse-server

sudo staffcop clickhouse stop

Test of sending data from client to server and output of server configuration.

sudo staffcop client [SERVER]

Copy postgresql database and files from remote server to the local one

sudo staffcop clone <SSH-USER>@<REMOTE-HOST> [ssh options]

Clear free space and database defragmentation

sudo staffcop compact

Output database paths

sudo staffcop db_path

Deletes all the data on the selected dimension

sudo staffcop delete [--type agent|account|event] [--days N] [--keep-files] [--keep-events] [--compact] <NAME>

--type        Удаление данных по агенту, имени пользователя или типу событий
--days N      Оставить данные за N дней
--compact     Дефрагментация базы данных
--keep-files  Оставить файлы
--keep-events Оставить события

Доступный список event для команды:

DiskDrive         | Внешние диски
FileOperation     | Операции с файлами
SystemLog         | Системный лог
UserActivity      | Алерт
WebcamSnapshot    | Снимок с веб-камеры
MicRecording      | Запись звука
DevInventory      | Реестр оборудования
AppInventory      | Реестр софта
WebSearch         | Поисковый запрос
DesktopVideo      | Видео рабочего стола
FormData          | Данные формы
WLan              | Беспроводное подключение
InterceptedFile   | Перехваченный файл
Keyboard          | Ввод с клавиатуры
Run               | Запуск приложения
Exit              | Завершение приложения
Screenshot        | Снимок экрана
NetworkConnection | Сеть
AppInstallation   | Установка ПО
Web               | Посещение сайтов
Im                | Интернет-пейджер
Mail              | Почта
FTP               | FTP
PrintDoc          | Печать документов
UserLogon         | Вход/выход из системы
Clipboard         | Буфер обмена
Device            | Устройства
Stat              | Время активности

Note

This command is sensitive to the computer name, please be careful!

Export filters and configurations to FILE_TO_EXPORT.json (full path must be stated)

sudo staffcop export FILE_TO_EXPORT.json

Output available commands

sudo staffcop help [command|django]

choose django to output django commands

Import filters and configurations from FILE_TO_IMPORT.json.

sudo staffcop import FILE_TO_IMPORT.json

Current filters will be saved.

Output information about the server and free disk space.

sudo staffcop info

Initialize or restore server settings.

sudo staffcop init

Start mule with high priority

sudo staffcop mule <MULE_NAME>

Run command for OCR in PDF files

sudo staffcop ocr <image or pdf file>

Set new user password

sudo staffcop passwd NEW_PASSWORD

Output current sql-queries and overview

sudo staffcop prof

Delete users and computers with no events

sudo staffcop prune

Output staffcop processes

sudo staffcop ps

Rebuild reports for N months

sudo staffcop rebuild_sessions MONTHS

Reset server settings to default

sudo staffcop reinit [full]

If “full” parameter is chosen all user filters will also be deleted

Restart staffcop service

sudo staffcop restart

Your backup will be placed in the /var/lib/staffcop/staffcop_backup folder

sudo staffcop restore_db [PATH_TO_BACKUP]

Merge events of computers with identical names

sudo staffcop sane

Manage sharding

sudo staffcop shard [init|install|list|ddl|index|copy]

Create shard fro the current month

sudo staffcop shard init

Enable database sharding

sudo staffcop shard install

Warning

Irreversible operation! Command works in PostgreSQL 11 and over, requires 50% of disk space.

Output the list of current shards

sudo staffcop shard list

Access to staffcop sql-console

sudo staffcop sql

Start staffcop service

sudo staffcop start

Stop staffcop service

sudo staffcop stop

Output top staffcop processes

sudo staffcop top

Delete all data

sudo staffcop truncate

Upgrade to the latest version

sudo staffcop upgrade

Upgrade postgresql (to version 10)

sudo staffcop upgrade-postgress

Recalculate a filter

sudo staffcop process 'Имя фильтра' 0

Note

You can recalculate a filter starting from a certain ID or specify (instead of “0”) the number of event to start recalculation with.

For example, you want to recalculate filter named “Cards” starting with ID=1000000, then you should run the command:

sudo staffcop process 'Карты' 1000000