|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
I'm currently working on a script that's going to check the status of my servers. It is going to first ping a set of servers, then depending on what happens there it's going to go and check to see if deamons are running on remote servers (pop3, httpd, smtp, ftpd...) I'm having a slight problem with my sub that checks the web server. It tries to connect to port 80 and tries to grab the index.html file. What looks to be the problem is the checkweb() sub isn't getting the $host passed to it. And I can't figure it out. I know this code might not be great but if someone could help me out I'd really appreciate it. Attached is the code.
|
|
#2
|
|||
|
|||
|
That's because you're not accepting it in checkweb(); the beginning of checkweb needs to look like this:
Code:
sub checkweb
{
my $host = shift;
local($/);
....
That will shift() the @_ arrary (a special array that contains all the elsements you pass to a sub) and give $host the value of what was shift-ed out. BTW, very nice script. I did notice, however that you @pinghosts array is a regular array, but you're trying to use associations. You need to be using a hash: Code:
my @pinghosts = ( "ns1.tacoking.net" => "63.174.17.49", "ns2.tacoking.net" => "63.174.17.61", .... # Should be: my %pinghosts = ( "ns1.tacoking.net" => "63.174.17.49", "ns2.tacoking.net" => "63.174.17.61", You can't use the key/value system in regular arrays. (BTW, hash is the same thing as an associative array) |
|
#3
|
|||
|
|||
|
Yup that did it. I don't know how i missed that. I've been playing with this sucker for 3 days or so and for some reason I never saw that my $host = shift; was missing from the checkweb() sub. Ohh well!. Thanks for the help! I really appreciate it.
|
|
#4
|
|||
|
|||
|
There are systems that do this
You're kind of reinventing the wheel here, there's 'mon', big brother, and tons of other monitoring tools that do all of this out of the box...
|
|
#5
|
|||
|
|||
|
BCNU
You may as well give a look at BCNU, a PERL and shell based server monitoring tool:
URL |
|
#6
|
|||
|
|||
|
There's nothing wrong with writing something customly. Infact, I do it everytime. You'll hardly ever find me using somebody else's stuff
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Perl Programming > Server Status Script. |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|