How to get daily bandwidth statistics for a particular VPS in SolusVM

Have more questions? Submit a request

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:

  1. Connect to Master node via SSH
  2. 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

  3. Add execution permission to script:

    # chmod + x /root/script.sh

  4. 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.

Articles in this section

Was this article helpful?
0 out of 0 found this helpful
Share

Comments

0 comments

Please sign in to leave a comment.