Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Tue 20 Feb 2018, 14:06
All times are UTC - 4
 Forum index » House Training » Users ( For the regulars )
[Solved] How to add new option for Connection Applet?
Moderators: Flash, Ian, JohnMurga
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [6 Posts]  
Author Message
puppy_apprentice


Joined: 07 Feb 2012
Posts: 173

PostPosted: Sun 11 Feb 2018, 12:48    Post subject:  [Solved] How to add new option for Connection Applet?  

I'm surfing internet via USB dongle and i have a few GB allowance. Need to store RX and TX to count how many free data from my allowance left. So far i've used a script like this:

Code:

#!/bin/sh
date
netstat -ie | grep -A6 "$1" | grep "packets"


from terminal:

Code:

>saveinetdata ppp0 >>inetdataused.txt


but a few times i've forgotten to call my script. So better solution will be if i could attach my script to Connection Applet option: Disconnect from network. So always when i will close connection i will store usage statistics.

Last edited by puppy_apprentice on Tue 13 Feb 2018, 15:54; edited 1 time in total
Back to top
View user's profile Send private message 
matchpoint

Joined: 26 Jan 2018
Posts: 93

PostPosted: Sun 11 Feb 2018, 19:59    Post subject:    

Puppy_apprentice Dude!

Since I think you're pretty resourceful, and, depending on the connection manager you're running, I'd say you'll be able to take this advice and run with it!
Back to top
View user's profile Send private message 
puppy_apprentice


Joined: 07 Feb 2012
Posts: 173

PostPosted: Mon 12 Feb 2018, 14:31    Post subject:  

Thx for hint. I will try. But i need to execute my script just before closing internet connection. Puppy Connection Applet is showing Tx and Rx in a tooltip but when i choose disconnect option all values are resetting. My script showing the same values for Rx and Tx only when I'm connected. When I'm off my script is showing zeroes like Connection Applet.

I could use vnStat daemon, but my script is just enough for my needs. Does Puppy Connection Applet is using any script? Or i have to recompile (where i can find sources) it to add new option to store usage data?
Back to top
View user's profile Send private message 
puppy_apprentice


Joined: 07 Feb 2012
Posts: 173

PostPosted: Mon 12 Feb 2018, 18:38    Post subject:  

Ok, i've found something. PupDial is storing statistics (overall usage) in:

Code:
/var/local/pupdial/isp1/


But it saves them only when you disconnect from internet using option form PupDial App. If you use Network Applet option: "Disconnect from network" last session usage is not added to previous. It will be better to save usage statistics for all connections scripts like: PupDial, Freesbee, GPRsConect using option "Disconnect from network" from Puppy Connection Applet. Who is author of this applet?
Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 1449
Location: Japan

PostPosted: Mon 12 Feb 2018, 21:11    Post subject:  

puppy_apprentice wrote:
It will be better to save usage statistics for all connections scripts
May depend on the way you close your connection, but at least when you use the tray icon and choose "Disconnect from network" this should work:

Edit the script /usr/local/apps/Connect/AppRun . At the end find the section that handles the option --disconnect. The case statement ends the connection depending on the tool you are using, so whatever command you put in front of this case statement will be executed right before closing the connection. A good place to run your script:
    --disconnect) #disconnect using default tool.
    saveinetdata ppp0 >>inetdataused.txt
    case $CURREXEC in
    net-setup.sh) exec /etc/rc.d/rc.network stop 1>&2 ;; #Dougal.
    pgprs-connect) pppd call gprs-disconnect-chatmm; killall pppd ;; #guessing, i need help here.
    pupdial) killall wvdial; killall pppd ;;
    pppoe_gui) pppoe_gui ;;
    connectwizard) connectwizard ;;
    Pwireless2) Pwireless2 ;;
    net_wiz_classic) net_wiz_classic ;;
    sns) /usr/local/simple_network_setup/rc.network stop ;;
    frisbee) [ -f /usr/local/bin/frisbee ] && /usr/local/frisbee/disconnect ;; #130104
    esac
    ;;
    *) exec /usr/local/bin/defaultconnect 1>&2 ;;
    esac
Back to top
View user's profile Send private message 
puppy_apprentice


Joined: 07 Feb 2012
Posts: 173

PostPosted: Tue 13 Feb 2018, 06:14    Post subject:  

My script saveinetdata:

Variant 1:
Code:

actif=`route | grep "default" | awk '{ print $8 '}` #determine active interface
date >> /root/$actif-log.txt
netstat -ie | grep -A6 $actif | grep "packets" >> /root/$actif-log.txt


Variant 2:
Code:

#!/bin/sh
actif=`route | grep "default" | awk '{ print $8 '}` #determine active interface
date >> /root/$actif-log.txt
ifconfig $actif | grep "bytes" >> /root/$actif-log.txt



1) have tried matchpoint solution:

There is no directory in Puppy /etc called 'network', 'if-down.d', 'if-post-down.d' and file 'interfaces'.
But i've made those:

In /etc i've made those:
Code:

network
|-- if-down.d
|   `-- script
|-- if-post-down.d
|   `-- script
|-- if-pre-down.d
|   `-- script
`-- interfaces


script:
Code:

#!/bin/sh
# filename: saveinetdata

if [ "$IFACE" = "ppp0" ]; then
  saveinetdata
fi


interfaces:
Code:

iface ppp0 inet wvdial


If i want to get statistics i have to first use in terminal:
Code:

ifup ppp0 #to configure interface


and later:

Code:

ifdown ppp0 #to run script


ifdown give me the same result like my script used from terminal.

2) Mochimopel solution works as expected.

Code:

--disconnect) #disconnect using default tool.
saveinetdata #or ifdown ppp0
case $CURREXEC in
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 1 [6 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » House Training » Users ( For the regulars )
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0400s ][ Queries: 14 (0.0061s) ][ GZIP on ]