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]

Restore of backup database found in /var/lib/staffcop/staffcop_backup

sudo staffcop restore_db [PATH_TO_BACKUP]

Delete all files and screenshots older than DAYS

sudo staffcop cleandata <DAYS>

Delete all files and events older than DAYS then reduces the size of the database

sudo staffcop cleanup <DAYS>

Clickhouse managing

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 problems 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        Delete data by agent, username and event type
--days N     Keep data for N days
--compact     database defragmentation
--keep-files  Keep files
--keep-events Keep events

List of available event types:

DiskDrive | USB-drives FileOperation | Operations with files SystemLog | System log UserActivity | Alert WebcamSnapshot | Webcam snapshot MicRecording | Sound recording DevInventory | Hardware inventory AppInventory | Software inventory WebSearch | Query in search engines DesktopVideo | Desktop video recording FormData | Data filled in web forms WLan | Wireless connection InterceptedFile | Intercepted file Keyboard | Text input with keyboard Run | Application launching Exit | Application closed Screenshot | Screenshot NetworkConnection | Network connection AppInstallation | Software installation Web | Web-site visiting Im | Message in IM Mail | E-mail FTP | FTP PrintDoc | Printed documents UserLogon | Facts of user logon/logoff Clipboard | Clipboard content Device | Device Stat | Activity time


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

Output available commands

sudo staffcop help [command|django]

choose django to output commands from django command line

Restore the tree of filters

sudo staffcop rebuild_mptt

Run this command if you meet any errors when opening web-interface in JS console

Export filters and configurations to FILE_TO_EXPORT.json (specify full path)

sudo staffcop export FILE_TO_EXPORT.json

Import filters and configurations from FILE_TO_IMPORT.json

sudo staffcop import FILE_TO_IMPORT.json

Current filters will be saved

Output information about server and occupied space on the hard disk

sudo staffcop info

Initialize and restore server settings

sudo staffcop init

Install Staffcop agent from StaffCop Server

sudo staffcop install [options] ip-address

--domain=DOMAIN       | Domain
--user=USER           | Username
--password=PASSWORD   | Password
--server=SERVER_HOST  | IP-address of StaffCop Server
--port=SERVER_PORT    | Port of StaffCop Server
--dry-run             | Check installation possibility
--reinstall           | Agent reinstallation
--traceback           | output trace errors
--uninstall           | Uninstall agent
--language=LANGUAGE   | Choose language (en, ru)
--log                 | Show installation log
--version             | Show StaffCop version

Where IP-address is the IP-address of the PC where you want to install agent. Computer’s address can be presented as a name of the workstation, in this case you should have DNS-server correctly configured in the network parameters.

Launch mule with high priority

sudo staffcop mule <MULE_NAME>

Run command for text recognition in images or pdf

sudo staffcop ocr <image or pdf file>

Set up new password for a user

sudo staffcop passwd NEW_PASSWORD

Output current SQL-queries

sudo staffcop prof

Delete users and agents which don’t have any registered 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 we choose “full” parameter, all user’s filters will be deleted as well

Restart StaffCop service

sudo staffcop restart

Create superuser in admin panel

sudo staffcop createsuperuser

Unite events of agents with identical names

sudo staffcop sane

Manage sharding

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

Create shard for current month

sudo staffcop shard init

Enable database sharding

sudo staffcop shard install


Irreversible operation! This command works in PostgreSQL starting from version 11, it requires 50% of disk space.

Output list of current shards

sudo staffcop shard list

Access to SQL-console of StaffCop

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 11)

sudo staffcop upgrade-postgress

Recalculate a filter

sudo staffcop process 'Filter name' 0


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 'Cards' 1000000

Enable\Disable additional features of admin panel

To enable usage Linux-console in admin panel and the ability to delete agent data run the command:

sudo staffcop enable webshell

To disable usage of Linux-console in admin panel and the ability to delete agent data, run the command:

sudo staffcop disable webshell


By default these menus are disabled in the admin panel.