Linux / UNIX Tech Support Forum
This is a discussion on Shell Script To Log Uptime, Connect Time, Bytes Sent Received Of a PPP Connection within the Shell scripting forums, part of the Development/Scripting category; Useing redhat 7.3. i need a script to log the uptime of a ppp connection. it need to display the ...
|
|||||||
| Shell scripting You can discuss the shell scripting, request shell scripts and scripting techniques |
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
Useing redhat 7.3.
i need a script to log the uptime of a ppp connection. it need to display the time it started and terminated and the amount of ime it ran for. help!!!!! it need to run a cron job and then display the stats. as i said help plz plz!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| Sponsored Links | ||
|
|
|
||||
|
Usually, you need to create a shell script as follows in /etc/ppp/ip-down.local
Code:
#!/bin/sh OUT=/var/log/pppd.acct.log echo "Connect time: $CONNECT_TIME" > $OUT echo "Bytes sent: $BYTES_SENT" >> $OUT echo "Bytes Received: $BYTES_RCVD" >> $OUT
__________________
Vivek Gite Linux Evangelist |
|
|||
|
Thanks for the prompt response.
How would i be able to measure total connection time aswell i would need this to run in the crontab as a daily uptime report that get emailed to me if the connection goes down with the stats: connect time total connect time date bytes sent/recieved Sorry im new to scripting, still learning. |
|
||||
|
Create a script called ppp.sh:
Code:
#!/bin/sh
OUT=/var/log/pppd.acct.log.$(date +"%d-%m-%Y")
log(){
echo "Connect time: $CONNECT_TIME" >> $OUT
echo "Bytes sent: $BYTES_SENT" >> $OUT
echo "Bytes Received: $BYTES_RCVD" >> $OUT
}
email(){
/bin/mail -S 'ppp log' you@example.com < /var/log/pppd.acct.log.$(date +"%d-%m-%Y")
}
case "$1" in
ppplog)
log
;;
pppemail)
email
;;
*)
echo "Usage: $0 {ppplog|pppemail}"
esac
Code:
@daily /path/to/ppp.sh pppemail Code:
/path/to/ppp.sh ppplog
__________________
Vivek Gite Linux Evangelist |
|
|||
|
Thanks!!!!!!!!!
Everything is in place if i run the script i recieve an email but with blank stats eg: Connect time: Bytes sent: Bytes Received: Do i need to wait for the crontab to run as there is not info. and how do i add to have a field in there total time= ??hrs min sec |
|
||||
|
You are using old Redhat software. I'm not sure if pppd support those settings. Just go through pppd man page and search for those 3 variables. If they are present in man page you will be able to use them.
__________________
Vivek Gite Linux Evangelist |
![]() |
| Tags |
| /etc/ppp/ip-down.local , bytes_rcvd , ppp bytes_sent , ppp connect_time , pppd , pppd down script , redhat |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) |
|
| Thread Tools | |
| Display Modes | |
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Script To Kill process if time and memories of more than 30% | lliriK | Shell scripting | 9 | 28-04-2009 12:43 AM |
| Backup Shell Script That Searches for all the files greater then 200 bytes | nextcmchiranjeevi | Shell scripting | 2 | 11-02-2009 11:44 PM |
| Script for checking uptime on multiple hosts | madhusudany2k | Shell scripting | 0 | 12-08-2008 08:24 PM |
| SNMP Error:no response received | manish_2479 | Networking, Firewalls and Security | 2 | 14-06-2007 04:17 AM |
| how to delete 0 bytes file | puppen | Linux software | 2 | 15-05-2007 09:45 PM |