Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Traffic counter?
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

Traffic counter?

NeoonNeoon Community Contributor, Veteran

Hi,

I need a little script or programm which shutdowns the vps after lets say 950gig to prevent additional bills. Any idea? I would need it for Wheezy.

Comments

  • MakenaiMakenai Member
    edited May 2014

    Shouldn't be hard to write your own, just a few lines of bash and put it in crontab.

    1. Read /sys/class/net/eth0/statistics/tx_bytes

    2. if $file > 1020054732800

    3. shutdown

    Don't have time to write it right now, but you got the idea, maybe someone else here can help you.

    edit: Make sure you're running 64bit before doing this, else the statistics counter doesn't show up numbers larger than 2^32

    Thanked by 1hostnoob
  • edited May 2014

    Makenai what if the server reboots for whatever reason and he for example had already 945 GB used up? I bet you know what will happen, right? TX will nicely fall back to 0 and start counting again and so this little bash script is useless.

    You need something that really monitors and saves the traffic state all the time.

  • Can't you ask your provider to put caps in place?

  • yywudiyywudi Member

    maybe find some script that read the solusvm bandwidth usage via solusvm API and monitor to choose if shutdown the VPS?

  • AlexanderMAlexanderM Member, Top Host, Host Rep

    @yywudi said:
    maybe find some script that read the solusvm bandwidth usage via solusvm API and monitor to choose if shutdown the VPS?

    Why so complex

  • yywudiyywudi Member
    edited May 2014

    @AlexanderM said:
    Why so complex

    i'm just thinking how to get the accurate BW usage.

  • NeoonNeoon Community Contributor, Veteran

    @AThomasHowe he using OneApp thingy and he told me it is not possible.

    10$ for 1TB is not that expansive but it should not me.

  • What kind of traffic is using up the bandwidth, @Infinity580, and what kind of VPS is it? You could use IP tables traffic shaping if it's like, torrents using up all your b/w or HTTP or whatever. IP Tables would probably get a bit messy if your bandwidth is spread out over several ports, though.

  • NeoonNeoon Community Contributor, Veteran

    KVM, just mix Torrent/Webserver etc.

  • neqsteneqste Member
    edited May 2014

    @Infinity580 said:
    AThomasHowe he using OneApp thingy and he told me it is not possible.

    10$ for 1TB is not that expansive but it should not me.

    to cron add this bash script.

    #/!bin/bash
    
    byte='cat /sys/class/net/eth0/statistics/tx_bytes'
    if $byte > 1020054732800
    then shutdown -n
    fi
    
    Thanked by 1Neoon
  • Infinity580 said: KVM, just mix Torrent/Webserver etc.

    If it's just two or three ports this server fault thread might be a good start then.

  • neqsteneqste Member

    trickle nobody talks about that.

    But that is great.

    Thanked by 1Neoon
  • NeoonNeoon Community Contributor, Veteran

    @neqste byte contains only cat /sys/class/net/eth0/statistics/tx_bytes so it dosent work.

  • @Makenai said:
    Shouldn't be hard to write your own, just a few lines of bash and put it in crontab.

    1. Read /sys/class/net/eth0/statistics/tx_bytes

    2. if $file > 1020054732800

    3. shutdown

    Don't have time to write it right now, but you got the idea, maybe someone else here can help you.

    edit: Make sure you're running 64bit before doing this, else the statistics counter doesn't show up numbers larger than 2^32

    Awesome. I didn't know about that file.

  • NeoonNeoon Community Contributor, Veteran
    edited June 2014

    @Zen seems a bit buggy: /home/check: line 11: 4437091: command not found (if $byte > 1020054732800)

  • Well guys; you know, there's this wonderful system package called "vnstat" which can be used to create databases per network interface and actually log real traffic usage, both live and over time.

    You can also plot the output, and use that to stem your madness.

  • @GoodHosting said:
    Well guys; you know, there's this wonderful system package called "vnstat" which can be used to create databases per network interface and actually log real traffic usage, both live and over time.

    You can also plot the output, and use that to stem your madness.

    +1. I use it on all my servers. It might not be 100% accurate, but it should work for what the OP wants to do especially since it is persistent across reboots.

Sign In or Register to comment.