Applicable to:
- SolusVM
Question
How to get daily bandwidth statistics for a particular VPS in SolusVM
Answer
This functionality is yet to be implemented in SolusVM.
As a workaround,
Create a script running every day to collect the daily bandwidth usage of a particular VPS. Here is the draft:
- Connect to Master node via SSH
-
Create a script /root/script.sh with the content like below
CONFIG_TEXT: #!/bin/bash
FILE=/home/bandwidth.txt
FILE2=/home/daily.txt
key="$1"
PaWD=$(cat /usr/local/solusvm/includes/solusvm.conf | awk -F ":" '{print $3}')
DB=$(cat /usr/local/solusvm/includes/solusvm.conf | awk -F ":" '{print $1}')
DBUSER=$(cat /usr/local/solusvm/includes/solusvm.conf | awk -F ":" '{print $2}')
HOST=$(cat /usr/local/solusvm/includes/solusvm.conf | awk -F ":" '{print $4}')
date=`date`
if [ ! -f "$FILE" ]; then
touch $FILE
echo "0" > $FILE
fii=$(mysql --user="$DBUSER" --password="$PaWD" $DB -Ne"select bandwidthused from vservers where vserverid=$key") j=$(cat $FILE) y=`expr $i - $j`
echo $date >> $FILE2
echo $y >> $FILE2
echo $i > $FILE -
Add execution permission to script:
# chmod + x /root/script.sh
- Create a cron task as follows:
CONFIG_TEXT: 59 23 * * * /root/script.sh 775
This cron will invoke the script for VPS with VPS ID 775. It will calculate how much bandwidth was used for a day.
Cron will be running at 23:59 every day.
Comments
0 commentsPlease sign in to leave a comment.