Skip to content

Monitoring & Maintenance

Proper monitoring and maintenance ensure your Cloud Service node runs smoothly and efficiently.

Monitoring Tools

Built-in Commands

bash
# Blockchain status
cs-cli getblockchaininfo

# Network status
cs-cli getnetworkinfo

# Mining status
cs-cli getmininginfo

# Wallet status
cs-cli getwalletinfo

# Peer connections
cs-cli getpeerinfo

# Memory pool
cs-cli getmempoolinfo

Real-time Monitoring

bash
# Watch blockchain info
watch -n 5 'cs-cli getblockchaininfo | grep -E "blocks|headers|verificationprogress"'

# Monitor connections
watch -n 10 'cs-cli getnetworkinfo | grep -E "connections|networks"'

# Track mining progress
watch -n 30 'cs-cli getmininginfo'

System Monitoring

Resource Usage

bash
# CPU and Memory
top -p $(pgrep csd)
htop -p $(pgrep csd)

# Disk I/O
iotop -p $(pgrep csd)

# Network usage
iftop
nethogs

Disk Space

bash
# Check data directory size
du -sh ~/.cs/
du -sh ~/.cs/blocks/
du -sh ~/.cs/chainstate/

# Monitor available space
df -h

Log Management

Debug Log

bash
# View recent entries
tail -f ~/.cs/debug.log

# Search for specific entries
grep "ERROR" ~/.cs/debug.log
grep "ConnectBlock" ~/.cs/debug.log

# Count log entries by category
grep -oP '^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z \[\w+\]' ~/.cs/debug.log | sort | uniq -c | sort -rn

Log Rotation

Create /etc/logrotate.d/cscoin:

/home/cscoin/.cs/debug.log {
    weekly
    rotate 4
    compress
    delaycompress
    missingok
    notifempty
    create 0640 cscoin cscoin
    postrotate
        systemctl reload csd > /dev/null 2>&1 || true
    endscript
}

Alerting

Simple Monitoring Script

Create monitor_cs.sh:

bash
#!/bin/bash

# Configuration
EMAIL="admin@example.com"
THRESHOLD_CONNECTIONS=5
THRESHOLD_DISK=90
THRESHOLD_MEMPOOL=500

# Check node is running
if ! cs-cli getblockchaininfo > /dev/null 2>&1; then
    echo "Cloud Service node is not responding!" | mail -s "Cloud Service Alert" $EMAIL
    exit 1
fi

# Check connections
CONNECTIONS=$(cs-cli getnetworkinfo | grep '"connections"' | grep -o '[0-9]*')
if [ "$CONNECTIONS" -lt "$THRESHOLD_CONNECTIONS" ]; then
    echo "Low connections: $CONNECTIONS" | mail -s "Cloud Service Alert" $EMAIL
fi

# Check disk space
DISK_USAGE=$(df -h ~/.cs | tail -1 | awk '{print $5}' | tr -d '%')
if [ "$DISK_USAGE" -gt "$THRESHOLD_DISK" ]; then
    echo "High disk usage: ${DISK_USAGE}%" | mail -s "Cloud Service Alert" $EMAIL
fi

# Check mempool
MEMPOOL=$(cs-cli getmempoolinfo | grep '"bytes"' | grep -o '[0-9]*')
MEMPOOL_MB=$((MEMPOOL / 1024 / 1024))
if [ "$MEMPOOL_MB" -gt "$THRESHOLD_MEMPOOL" ]; then
    echo "Large mempool: ${MEMPOOL_MB}MB" | mail -s "Cloud Service Alert" $EMAIL
fi

echo "All checks passed"

Make executable and add to crontab:

bash
chmod +x monitor_cs.sh
crontab -e
# Add: */5 * * * * /path/to/monitor_cs.sh

Maintenance Tasks

Regular Updates

bash
# Check for new releases
curl -s https://api.github.com/repos/MauricioSpagnol/cloudservice/releases/latest | grep tag_name

# Update from source
cd ~/cscoin
git pull
./autogen.sh
./configure
make -j$(nproc)
sudo make install
sudo systemctl restart csd

Database Maintenance

bash
# Reindex blockchain (if needed)
csd -reindex -daemon

# Rescan wallet
cs-cli rescanblockchain

# Compact database (LevelDB)
# Automatic on startup

Backup Procedures

bash
# Backup wallet
cs-cli backupwallet /path/to/backup/wallet.dat

# Backup configuration
cp ~/.cs/cs.conf /path/to/backup/

# Backup entire data directory
tar -czf cs-backup-$(date +%Y%m%d).tar.gz ~/.cs/

# Automate with cron
0 2 * * * tar -czf /backup/cs-$(date +\%Y\%m\%d).tar.gz ~/.cs/cs.conf ~/.cs/wallet.dat

Cleanup

bash
# Remove old log files
find ~/.cs/ -name "debug.log.*" -mtime +30 -delete

# Clear orphan transactions
# Automatic - controlled by maxorphantx

# Restart to clear mempool
cs-cli stop
sleep 10
csd -daemon

Troubleshooting Guide

Common Issues

IssueSolution
Node won't startCheck logs, verify config, ensure ports available
No connectionsCheck firewall, verify network, add nodes manually
High memory usageReduce dbcache, limit mempool
Slow syncUse SSD, increase dbcache, check bandwidth
Wallet not foundVerify datadir, check wallet.dat exists

Diagnostic Commands

bash
# Full diagnostic output
cs-cli getblockchaininfo && \
cs-cli getnetworkinfo && \
cs-cli getmininginfo && \
cs-cli getmempoolinfo

# Check for errors in logs
tail -100 ~/.cs/debug.log | grep -i error

# Network connectivity test
nc -zv node.cs.network 16178

Next Steps

Released under the MIT License.