Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place! |
| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
05-15-2008, 03:50 PM
|
#1
|
|
LQ Newbie
Registered: Apr 2008
Posts: 13
Rep:
|
bizarre dial out issue - cant just dial a number then quit
First, yes, I am a noob. I touched on Linux a little over the years.I rencently got LFS 6.3 to fully go on a laptop (I even wrote scripts for the process), and I know some of the basic commands. For a new project, I used net-install Debian and got Nagios up and running.
What I am trying to accomplish as part of Nagios' notification process is to have the server simply dial a phone number, wait 30 seconds, then hang up (and exit the command invoking that process). The reason for this is so my boss and I wake up during the night to a ringing phone.
It seems as though every program I have got to successfully call out (wvdial, cu, pon) takes far too long to timeout and exit. I do not want any extra waiting or attempting ppp connections, so that Nagios can move on to the next notification command.
From what I can figure, those programs I mentioned previously all call to CHAT to actually dial. For the life of me, I cannot make CHAT dial the modem from the command line. I cannot figure out where to put ttyS0 in the command, or if it even uses it. Also, I attempted to use a chatscript and reference chat to it, but there is no details on where/how/if you add the port.
Does anyone have any ideas, or know how to make CHAT work from the command line? Any help is appreciated. If you need any more details, I will gladly provide them as best I can.
Thank you,
Darrell
|
|
|
|
05-15-2008, 04:48 PM
|
#2
|
|
Moderator
Registered: May 2001
Posts: 24,827
|
Quote:
Originally Posted by noob_d
It seems as though every program I have got to successfully call out (wvdial, cu, pon) takes far too long to timeout and exit. I do not want any extra waiting or attempting ppp connections, so that Nagios can move on to the next notification command.
|
What you want is an asynchronous, external handler. Something like the handler below should work (I mean, it can't be simpler than that). What it does is tell 'at' to queue the command 'wvdialconf /etc/nagios/wvdial_mgr.conf' for immediate execution. The only thing *you* have to do is prep your wvdial or ppp or whatever else you use to dial out.
Code:
# "wvdial-a-manager" command definition
define command{
command_name wvdial-a-manager
command_line echo 'wvdialconf /etc/nagios/wvdial_mgr.conf'|at now
}
|
|
|
|
05-15-2008, 06:45 PM
|
#3
|
|
Guru
Registered: Aug 2004
Location: Brisbane
Distribution: Centos 6.4, Centos 5.9
Posts: 15,026
|
As this seems to be the problem:
"takes far too long to timeout and exit" I can think of a couple of solutions.
In bash, you put the phone cmd into the background
# Phone_and_terminate script
#!/bin/bash
phone_script &
#$! is last background cmd pid
sleep 30
kill -9 $!
In Perl, you'd use wrap a SIGALRM around it
To interrupt a long-running operation, set a SIGALRM handler to call die. Set an alarm with alarm, then eval your code:
Code:
$SIG{ALRM} = sub { die "timeout" };
eval {
alarm(3600);
# long-time operations here
alarm(0);
};
if ($@) {
if ($@ =~ /timeout/) {
# timed out; do what you will here
} else {
alarm(0); # clear the still-pending alarm
die; # propagate unexpected exception
}
}
|
|
|
|
05-23-2008, 08:16 AM
|
#4
|
|
LQ Newbie
Registered: Apr 2008
Posts: 13
Original Poster
Rep:
|
Well, I have found that I can set the S7 register to a lower time in wvdial.conf and the modem will just give up and exit the program. I appreciate the help.
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 01:22 AM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|