Perl Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPerl Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old March 27th, 2001, 10:05 PM
TacoKing TacoKing is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2001
Location: Erie, PA
Posts: 1 TacoKing User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 m 44 sec
Reputation Power: 0
Send a message via ICQ to TacoKing Send a message via AIM to TacoKing
Unhappy

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.

Reply With Quote
  #2  
Old March 29th, 2001, 09:43 AM
JonLed JonLed is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Aug 2000
Location: Indiana
Posts: 614 JonLed User rank is Corporal (100 - 500 Reputation Level)JonLed User rank is Corporal (100 - 500 Reputation Level)JonLed User rank is Corporal (100 - 500 Reputation Level)JonLed User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 4 h 49 m 49 sec
Reputation Power: 10
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)

Reply With Quote
  #3  
Old March 29th, 2001, 10:38 AM
TacoKing TacoKing is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2001
Location: Erie, PA
Posts: 1 TacoKing User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 m 44 sec
Reputation Power: 0
Send a message via ICQ to TacoKing Send a message via AIM to TacoKing
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.

Reply With Quote
  #4  
Old March 29th, 2001, 06:22 PM
bside bside is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2001
Location: Northern California
Posts: 0 bside User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to bside
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...

Reply With Quote
  #5  
Old March 30th, 2001, 12:49 PM
FAQchest FAQchest is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2001
Location: San Diego
Posts: 0 FAQchest User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
BCNU

You may as well give a look at BCNU, a PERL and shell based server monitoring tool:
URL

Reply With Quote
  #6  
Old March 30th, 2001, 04:21 PM
JonLed JonLed is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Aug 2000
Location: Indiana
Posts: 614 JonLed User rank is Corporal (100 - 500 Reputation Level)JonLed User rank is Corporal (100 - 500 Reputation Level)JonLed User rank is Corporal (100 - 500 Reputation Level)JonLed User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 4 h 49 m 49 sec
Reputation Power: 10
There's nothing wrong with writing something customly. Infact, I do it everytime. You'll hardly ever find me using somebody else's stuff

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPerl Programming > Server Status Script.


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate 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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
Stay green...Green IT