473,471 Members | 1,874 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Wanting to ping our server to retrieve the status [PERL]

135 New Member
Guy's,

On my homepage website I want to display the current status of our server. The idea I have is to ping (or send my ip address) to our server every 5 mins and the result I get back should result (and display on my homepage) in a success or failure of the server.

Can someone please help me with the coding [PERL] for this or just start me off?

Many Thanks in advance.

Regards

Ravi
Jun 7 '07 #1
7 1948
miller
1,089 Recognized Expert Top Contributor
Greetings Ravi,

This seems like a strange goal. You want to display the network status of a server on a webpage located on the server? It seems apparant to me that if you can reach the webpage then you already know the server is up.

Anyway, putting aside my possible misunderstanding of your goal, it sounds like all you need is a perl daemon and a database.

The daemon/script simply pings some external location and updates the result to a database. The webpage then pulls the data from the database to display the status for whatever time period you wish to report. The only module that is really required for this is

cpan Net::Ping

Otherwise, all you need is use of the sleep function and know how to update a database.

- Miller
Jun 7 '07 #2
patelxxx
135 New Member
The task given to me is from work, they require a 'status' for the two servers they look after. This status of the servers will be displayed on the Content Management System, so that clients can see the update to date status of the servers.

Miller I'm a trainee Perl developer and you have so far truely helped me many times. Many many thanks mate.

Cheers

Ravi
Jun 7 '07 #3
miller
1,089 Recognized Expert Top Contributor
Ok. Well given that, what I described to you should work.

- Miller
Jun 7 '07 #4
patelxxx
135 New Member
Guy's,

If I was using a CSV file as apposed to a database how would that work? Do I just constantly update the CSV file or create a new one each time.

Many Thanks
Jun 8 '07 #5
patelxxx
135 New Member
Merged Thread: How to create a CSV file once I have pinged the server?

Hi Guy's,

Firstly I'm going to ping (Net::Ping) two servers, then I want to create a CSV file to store the server status.

How can I go about generating a csv file [in PERL] and then using that CSV to update our website homepage with the Current Server Status.

Many Thanks in advance.
Jun 8 '07 #6
miller
1,089 Recognized Expert Top Contributor
I would be tempted to append to one CSV file, but setup an automatic log rotating by naming the file according to the current year and month. Something like this would work:

Expand|Select|Wrap|Line Numbers
  1. # Giant Loop
  2. for (;;) {
  3.     # Code for Server Checking Here.
  4.  
  5.  
  6.  
  7.     # Output Data
  8.     if ($csv->combine(time, $status)) {
  9.         my $outfile = OUTDIR . OUTPREFIX . strftime("%Y%m",localtime) . '.csv';
  10.         open (OUT, ">> $outfile") or die "Can't open $outfile: $!";
  11.         print OUT $csv->string, "\n";
  12.         close OUT;
  13.     } else {
  14.         die "combine() failed on argument: ", $csv->error_input, "\n";
  15.     }
  16.  
  17.     sleep SLEEP_TIME;
  18. }
  19.  
  20. 1;
  21.  
  22. __END__
  23.  
And to find the current file for parsing, the following code would work:

Expand|Select|Wrap|Line Numbers
  1. use constant OUT_DIR => '/this/is/your/datadir/';
  2.  
  3. my $file = (sort glob(OUT_DIR . "*"))[-1];
  4.  
If you update every 5 minutes, then you can expect the monthly log file size to reach 8640 times the size of the line for each status. So probably a max size of 200k conservatively.

- Miller
Jun 8 '07 #7
miller
1,089 Recognized Expert Top Contributor
Hi Guy's,

Firstly I'm going to ping (Net::Ping) two servers, then I want to create a CSV file to store the server status.

How can I go about generating a csv file [in PERL] and then using that CSV to update our website homepage with the Current Server Status.

Many Thanks in advance.

I've already answered this question in the other thread. I will now merge those threads.

- Miller
Jun 8 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Sleiman | last post by:
Hello newsgroup readers I am looking for a php implementation for xmlrpc ping server. Do you have any idea where I can find one? Using mod_pubsub I can have a very nice blogchatter style of...
2
by: David Lozzi | last post by:
I need to determine from ASP if the database server is up and running, and if it isn't ping another database server. I posted this before about a different client, and I was told to request a file...
1
by: gallaczmit | last post by:
Will this code give me a true view of a computer's status? All I am looking for is to see if the computer is reachable or not. My end goal is to get a list of IP addresses from a MS SQL Server,...
0
by: Ed | last post by:
I've attached some VB.NET code I've hacked together (some taken from MS examples & newsgroup postings) that will perform a ping or IcmpSendEcho using the icmp.dll (see this for more info:...
21
by: Neel | last post by:
I am trying to "ping" a remote host in my C++/Redhat Linux code to check whether that host is connected or not. if (0 == system("ping -w 2 192.168.0.2)) But, in both cases...
1
by: Krish | last post by:
All, I have an offline application that works online for some data syncronization. For data syncronization I access a webservice. I want to show whether my application is online or not by checking...
4
by: =?Utf-8?B?QWxleCBLLg==?= | last post by:
Hi all I need a simple program that allows me to check if an IP address is pingable. I am not going to send/receive anything to the remote host, just check if it is visible. Something like...
3
by: patelxxx | last post by:
PERL Code to Ping a server: #!c:/Perl/bin/perl.exe use Net::Ping; use strict; use warnings; my $host = 192.168.0.1; # Real value removed by MODERATOR
3
by: imughal | last post by:
I got the perl script which does following task. This solution reads in a line from a text file that is passed in as input parameter 1 to a Perl script. This script will then ping the machine...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.