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:

..code:

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

..code:

sudo staffcop backup_db [PATH_TO_BACKUP]

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

..code:

sudo staffcop restore_db [PATH_TO_BACKUP]

Delete all files and screenshots older than DAYS

..code:

sudo staffcop cleandata <DAYS>

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

..code:

sudo staffcop cleanup <DAYS>

Note

To reach the maximum performance of the database cleanup mechanism, provide the free space according to the formula: free space = database size / 8.

Clickhouse managing

..code:

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

Install and activate Clickhouse database

..code:

sudo staffcop clickhouse install

Upgrade Clickhouse to the latest stable version

..code:

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

..code:

sudo staffcop clickhouse pump

Note

Run this command only if you are completely aware of the consequences!

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

..code:

sudo staffcop clickhouse test

Overwrite all the data of Clickhouse Database

..code:

sudo staffcop clickhouse reinit

Restart clickhouse-server

..code:

sudo staffcop clickhouse restart

Start clickhouse-server

..code:

sudo staffcop clickhouse start

Stop clickhouse-server

..code:

sudo staffcop clickhouse stop

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

..code:

sudo staffcop client [SERVER]

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

..code:

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

Clear free space and database defragmentation

..code:

sudo staffcop compact

Output database paths

..code:

sudo staffcop db_path

Deletes all the data on the selected dimension

..code:

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:

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

DiskDrive         | External disks
FileOperation     | Operations with files
SystemLog         | System log
UserActivity      | Alert
WebcamSnapshot    | Webcam snapshot
MicRecording      | Sound recording
DevInventory      | Hardware inventory
AppInventory      | Software inventory
WebSearch         | Search query
DesktopVideo      | Desktop video record
FormData          | Web data form
WLan              | Wireless connection
InterceptedFile   | Intercepted file
Keyboard          | Keyboard input
Run               | Application launching
Exit              | Application closing
Screenshot        | Screenshot
NetworkConnection | Network connection
AppInstallation   | Software installation
Web               | Web-site visiting
Im                | Instant messaging
Mail              | E-mail
FTP               | FTP
PrintDoc          | Document printing
UserLogon         | User logon/logoff
Clipboard         | Clipboard content
Device            | Hardware
Stat              | Activity time
File              | File scanner

Note

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

Output available commands

..code:

sudo staffcop help [command|django]

choose django to output commands from django command line

Restore the tree of filters

..code:

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)

..code:

sudo staffcop export FILE_TO_EXPORT.json

Import filters and configurations from FILE_TO_IMPORT.json

..code:

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

..code:

sudo staffcop init

Install Staffcop agent from StaffCop Server

..code:

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 used by 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

..code:

sudo staffcop mule <MULE_NAME>

Run command for text recognition in images or pdf

..code:

sudo staffcop ocr <image or pdf file>

Set up new password for a user

..code:

sudo staffcop passwd NEW_PASSWORD

Output current SQL-queries

..code:

sudo staffcop prof

Delete users and agents which don’t have any registered events

..code:

sudo staffcop prune

Output StaffCop processes

..code:

sudo staffcop ps

Rebuild reports for N months

..code:

sudo staffcop rebuild_sessions MONTHS

Reset server settings to default

..code:

sudo staffcop reinit [full]

If we choose “full” parameter, all user’s filters will be deleted as well

Restart StaffCop service

..code:

sudo staffcop restart

Create superuser in admin panel

..code:

sudo staffcop createsuperuser

Unite events of agents with identical names

..code:

staffcop sane          | unites agents and accounts
staffcop sane agents   | unites only agents
staffcop sane accounts | unites only accounts

Manage sharding

..code:

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

Create shard for current month

..code:

sudo staffcop shard init

Enable database sharding

..code:

sudo staffcop shard install

Note

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

Output list of current shards

..code:

sudo staffcop shard list

Delete a part of sharded database

..code:

sudo staffcop shard drop agent_event_2021_01_01

Deletes the part of the database collected since January 2021

Access to SQL-console of StaffCop

..code:

sudo staffcop sql

Add, delete and display dynamic fields in the cube model

..code:

staffcop dynamic [options]

Note

To output a short manual on this command, just run staffcop dynamic

Create or update user accounts from AD

..code:

staffcop ad_sync - synchronization of all accounts
staffcop ad_sync --exists - synchronization of the existing account only
staffcop ad_sync --user USER_NAME - synchronization of a particular user

Note

Takes AD settings from the web interface

Assign configuration to a user or agent

..code:

staffcop config --[user|agent] <AgentName|UserName> <ComputerConfigurationName|UserConfigurationName>

Note

If the name of the configuration consists of several words, you should use quotation marks: «Computer Config».

Start staffcop service

..code:

sudo staffcop start

Stop staffcop service

..code:

sudo staffcop stop

Output top StaffCop processes

..code:

sudo staffcop top

Delete all data

..code:

sudo staffcop truncate

Upgrade to the latest version

..code:

sudo staffcop upgrade

Upgrade postgresql (to version 11)

..code:

sudo staffcop upgrade-postgress

Recalculate a single filter

..code:

sudo staffcop process 'Filter name' 0

Note

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

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

..code:

sudo staffcop process 'Cards' 1000000

EnableDisable additional features of admin panel

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

..code:

sudo staffcop enable webshell

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

..code:

sudo staffcop disable webshell

Note

By default these menus are disabled in the admin panel.