LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 01-25-2013, 04:53 PM   #1
emmeteo
LQ Newbie
 
Registered: May 2012
Posts: 25

Rep: Reputation: Disabled
Make ubuntu recognize a particular event


Hi everyone,
I have an issue whit vnstat. Here's the story:
I use a gprs usb modem to surf the internet, but my isp doesen't want me to do more than ten gigabyte of traffic (download + upload) per month.
So I've installed vnstat.
Then I created a database for the ppp0 interface and all works fine.
The vnstat daemon also works fine and it is always up, nevertheless when I connect the usb modem and start to use the internet, the database remain unapdated and unupdateable until I type sudo vnstat -u (update the database).
Only after the first time that I type "vnstat -u", vnstat starts to update the previously frozen database, but all the bytes I download or upload before that command are not counted.

Since vnstat seems to work, the daemon is on and I don't know where is the problem, I've suggested myself to find a way to make Ubuntu recognize when the ppp0 interface is connected and the automatically launch "vnstat -u" so, magically, the database will be again updateable as soon as I connect the usb modem.
Is there any way to do that without bother crontab?
I hope I was clear.
Thank you.
 
Old 01-25-2013, 08:59 PM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
If you use NetworkManager then you can make it run scripts if the device is activated and de-activated.
As unprivileged user create a script called "vnstat":
Code:
#!/bin/sh
# First arg short device name, second arg the action:
case "$2" in up|down) /usr/bin/vnstat -u -i $1;; 
 *) echo "Dont know what to do with device \"$1\", action \"$2\"." >/dev/stderr;;
esac; exit 0
then install it:
Code:
sudo install -o root -g root -m 0755 vnstat /etc/NetworkManager/dispatcher.d/vnstat
and that should be all there's to it.
 
2 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Getting Lirc to recognize only first event of "hanging" button. Possible? martdj Linux - Software 1 11-14-2011 03:33 AM
QT: how to make a member in a clicked event independent. bastl Programming 0 03-03-2009 04:01 PM
How to make the right mouse button run a script (event trigger) xmrkite Linux - Hardware 5 10-17-2006 01:29 PM
How to make kdm recognize enlightenment? Hungry ghost Fedora 7 07-14-2005 06:42 PM
How to Make Slack Recognize My Monitor? bongski55 Slackware 6 10-30-2003 01:34 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 02:15 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration