dstat Node Profiler
Crystal Setup
Install dependencies, which will be resolved into lib from shard.yml:
crystal deps
Database Setup
Creating the Roles and Tables
sudo su - postgres
psql
CREATE DATABASE stats;
CREATE USER capstone3 WITH PASSWORD 'password';
Then, run psql/schema.psql to initialize the tables, enumerated types, and indices. The database must also be externally reachable:
- In
pg_hba.conf, an entryhost all all 0.0.0.0/0 md5must be added - In
postgresql.conf,listen_addressesmust be set to'*'to bind to0.0.0.0rather than localhost - The following modification must be made to
iptables:
iptables -A INPUT -s 0/0 -p tcp --dport 5432 -j ACCEPT
telnet (instead of a psql client) can be used to trivially verify the port is open on the host machine.
Configure Cron
crontab -e
Should be configured to run benchmarking (dstat -r) every minute:
* * * * * /usr/local/dstat/dstat -r
SystemD Configuration
Move the service unit file, dstat.service into /etc/systemd/system (altering the user option as appropriate). Then the web service can be interacted with using the expected service commands:
sudo service dstat status
If the unit file is changed on disk, run: systemctl daemon-reload as root.