
|
View Full Version : network status page
AlaskanWolf 01-25-2002, 05:57 AM I would like to know if anyones got a script that can change in real time, simply showing if the service's on a server is up or down (IE: network status page)
I remember a long while back a guy created one for the cobalt raqs, long since i forgotten...
HostingDirect 01-25-2002, 11:11 AM Marty at http://tlcwe.com put out a nice free one and it can be downloaded in the free scripts area at http://scripts.tlcwe.com . I have a copy up on my site at http://www.hdllc.net/netstatus/ . It has an admin screen where you can setup and select the IP and ports to monitor.
The Prohacker 01-25-2002, 12:24 PM <?php
$domain = "localhost";
function lookup($hport,$Something,$who){
$fp = fsockopen($who, $hport, &$errno, &$errstr, 4);
if (!$fp){
$data = "<tr><td width=\"40%\"><font face=\"Times New Roman\" color=\"#000000\"><strong>$Something :</td></strong></font><td width=\"60%\"><font color=\"#FF0000\" face=\"Times New Roman\"><strong>Down</strong><em>($who)</em></font></td></tr>";
} else {
$data = "<tr><td width=\"40%\"><font face=\"Times New Roman\" color=\"#000000\"><strong>$Something :</strong></td></font><td width=\"60%\"><font face=\"Times New Roman\"><strong><font color=\"#008000\">Running</font> </strong><em>($who)</em></font></td></tr>";
fclose($fp);
}
return $data;
}
echo "<table border=\"0\" cellpadding=\"0\" width=\"75%\">";
echo lookup("80","Web Server","$domain");
echo lookup("3306","MySQL Server","$domain");
echo lookup("21","FTP Server","$domain");
echo lookup("22","SSH Server","$domain");
echo lookup("110","Mail Server","$domain");
echo "</table>";
?>
Thats just the source from our status page, its not pretty but it works....
AlaskanWolf 01-25-2002, 04:22 PM thanks guys, just what i was looking for!
AlaskanWolf 01-26-2002, 07:37 PM I installed both scripts, but noticed that if a server is down or rebooting, the page just sits there (loading...typical white screen in IE)
anyone got any suggestions to that it doesnt hang on the server thats down or rebooting?
Marty 01-26-2002, 10:19 PM As I pointed out in the email, this is a bug in php 4.0.6. I haven't been able to test it in php 4.1.1. php 4.0.6 does not recognize or use the timeout set in fsockopen function.
dbarker 01-27-2002, 05:52 AM Hey,
I'm looking for something similar but I have a Windows 2000 machine. I have PHP 4.1.1 installed but I'm not sure if I can get mySQL on a Win2k machine, do you know if it's possible?
If not does anyone know any network status pages that use Access?
Thanks,
David
ShaunM 01-27-2002, 06:24 AM Alaskinwolf, whats up man :)
Check out my site (under my forum) i have somthing about a network status script i just wrote. Mine is just a peice of what that one at http://tlcwe.com is. Basically it's just the announcements section. It will be free just like the rest of my scripts. If your looking for a webbased network status page i recommend demarc. It's still under devel but it's a kick ass utility. We at ochosting are using ipmonitor right now ( in my opinion it's a POS) but it works (for now) Demarc is great if you dont want to use it to notify you.
The reason i say that is because if a server or service does go down it will just keep emailing and emailing and emailing you. Theirs no limit like their is with ip monitor. Demarc was alittle difficult to setup but i like it alot.
The one problem i see with http://tlcwe.com (we tryed it out because we were going to use it for a network status page showing if any of our pipe's out were down) is that it checks if the link is up when you load the page and sometimes it gives a red when it's actually up. Also say for somereason 100+ people hit that page at once now you have 100 port connections to those servers, or if sombody setup a script to auto load that site quickly it could be used as a port flooder.
Wait... I actually wrote a network status think like you asking for. I started to write it and got it all working when i decided to scrap the project and do it diffrently. It's a exact dup of his except that it's in perl and it runs as cron so that you wont have these port connection problems, also mine only pings, no tcp connections. His wont ping, only will tcp connect. Give me a im if you want to check it out.
Now that i have Rambeled on i will stop.
Marty 01-28-2002, 03:01 PM Shawn is correct. The port connections could be a problem. I plan to modify the script to use a cron to do the checks. Currently it polls each port a max of three times with a timeout of 0.1 sec. Once it gets a positive result it doesn't poll that port again. Problem is that if the server that hosts the script and the servers being monitored are not in the same noc, the script can return false negatives due to general network slowdowns. I will be rewriting the script to use a cron so I can be more conservative in the polling of ports. The timeout could be set longer without affecting the speed of the page load.
ShaunM 01-28-2002, 04:03 PM Marty,
We talked on im before, if you want my scraped perl project let me know. I remember you saying you didnt know perl but you may be able to use my perl script for the status and your php backend for the announcements section
Marty 01-28-2002, 08:38 PM I remember our conversations. I would rather stick with port connections for the checking the status as I want to be able to poll particular services on a server, however your perl script is ideal for doing what you had in mind, which was to ping various ip's to check the status on various pieces or hardware, like routers. I may contact you about it at some point.
ShaunM 01-29-2002, 03:16 AM marty: ok, also i can add things like port connections to it. Perl has all kinds of cool modules you can use for checking if http, https, ftp, tcp, ssh, telnet, blah, blah, blah are responding.
You know where i'm at :)
MikeF 01-29-2002, 10:56 AM Hi folks,
Marty and ShaunM I have a website, in for example, NOC A/web site A and a web site in NOC B/web site B that has resold accounts with it(in that NOC).
I would be interested in buying a script(if you could resolve the port connections issue) that would
on a "Network Status" html page on the server in NOC A/web site A display:
-http
-pop3
-smtp
-mysql
-ssh
-telnet
-ftp
-dns
-load averages
-memory usage
and percent uptime
all the above for the site in NOC A and on the same html page or I guess a seperate html page display all of the above for the site in NOC B.
What do you think?
Marty 01-29-2002, 12:29 PM Originally posted by ShaunM
marty: ok, also i can add things like port connections to it. Perl has all kinds of cool modules you can use for checking if http, https, ftp, tcp, ssh, telnet, blah, blah, blah are responding.
You know where i'm at :)
Like I said, I am a perl idiot!! That is pretty cool. I will put some thought into this and let you know.
dbarker 01-29-2002, 12:48 PM Hey,
I'm not really much of a perl or PHP nut but I know my way around ASP fairly well. If you ever want someone to have a go at doing a port to ASP so it runs nativly on Win2k with out the need for a PHP or Perl "plug in". Just give me an email or PM.
David
ShaunM 01-30-2002, 12:43 AM mikef, for what you need why not just use demarc? It's a free and nice little util.
i could finish the rest of that one script and add port connections into it i guess. If i do, do it i dont charge for my scripts but if you want you can donate... I'll think about it. Depends how much extra time i have at night.
Domenico 01-30-2002, 08:25 PM Just use this one! It's all you need ;-)
You don't need other files (images). All you need is in here.
Try it!
Domenico
<?php
$box = $HTTP_SERVER_VARS["SERVER_NAME"];
$boxip = $HTTP_SERVER_VARS["SERVER_NAME"] . " (" . gethostbyname($HTTP_SERVER_VARS["SERVER_NAME"]) . ")";
?>
<table width="100%" height="400">
<tr>
<td width="100%">
<center>
<p><font face="Arial" size="2"><b>System Uptimes</b></font></p>
<p> <font size="-1"><?php echo $box; ?>:
</font> <font size="-1">
<script language="php">
$date = (date("l, M d, Y - h:i:s A"));
$uptime = system(uptime);
</script>
</font></p>
<p><br><font face="Arial" size="2"><b>System Services</b><?
$noc_http = fsockopen("$box", 80, $errno, $errstr, 30);
if(!$noc_http) {
$noc_http = "red";
} else {
fclose($noc_http);
$noc_http = "green";
}
$noc_ssh = fsockopen("localhost", 22, $errno, $errstr, 30);
if(!$noc_ssh) {
$noc_ssh = "red";
} else {
fclose($noc_ssh);
$noc_ssh = "green";
}
$noc_telnet = fsockopen("localhost", 23, $errno, $errstr, 30);
if(!$noc_telnet) {
$noc_telnet = "red";
} else {
fclose($noc_telnet);
$noc_telnet = "green";
}
$noc_ftp = fsockopen("localhost", 21, $errno, $errstr, 30);
if(!$noc_ftp) {
$noc_ftp = "red";
} else {
fclose($noc_ftp);
$noc_ftp = "green";
}
$noc_smtp = fsockopen("localhost", 25, $errno, $errstr, 30);
if(!$noc_smtp) {
$noc_smtp = "red";
} else {
fclose($noc_smtp);
$noc_smtp = "green";
}
$noc_pop3 = fsockopen("localhost", 110, $errno, $errstr, 30);
if(!$noc_pop3) {
$noc_pop3 = "red";
} else {
fclose($noc_pop3);
$noc_pop3 = "green";
}
$noc_mysql = fsockopen("localhost", 3306, $errno, $errstr, 30);
if(!$noc_mysql) {
$noc_mysql = "red";
} else {
fclose($noc_mysql);
$noc_mysql = "green";
}
?> </font></p>
<table width="400" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<div align="center"></div>
</td>
<td>
<div align="center"><font size="-1">http</font></div>
</td>
<td>
<div align="center"><font size="-1">ssh</font></div>
</td>
<td>
<div align="center"><font size="-1">telnet</font></div>
</td>
<td>
<div align="center"><font size="-1">ftp</font></div>
</td>
<td>
<div align="center"><font size="-1">smtp</font></div>
</td>
<td>
<div align="center"><font size="-1">pop3</font></div>
</td>
<td>
<div align="center"><font size="-1">mysql</font></div>
</td>
</tr>
<tr>
<td>
<div align="center"><font size="-1"><?php echo $box; ?></font></div>
</td>
<td>
<div align="center" style="font-size: 20pt; color: <? echo($noc_http); ?>" width="15" height="15">•</div>
</td>
<td>
<div align="center" style="font-size: 20pt; color: <? echo($noc_ssh); ?>" width="15" height="15">•</div>
</td>
<td>
<div align="center" style="font-size: 20pt; color: <? echo($noc_telnet); ?>" width="15" height="15">•</div>
</td>
<td>
<div align="center" style="font-size: 20pt; color: <? echo($noc_ftp); ?>" width="15" height="15">•</div>
</td>
<td>
<div align="center" style="font-size: 20pt; color: <? echo($noc_smtp); ?>" width="15" height="15">•</div>
</td>
<td>
<div align="center" style="font-size: 20pt; color: <? echo($noc_pop3); ?>" width="15" height="15">•</div>
</td>
<td>
<div align="center" style="font-size: 20pt; color: <? echo($noc_mysql); ?>" width="15" height="15">•</div>
</td>
</tr>
</td>
</tr>
</table>
<p> </p>
</center>
</td>
</tr>
</table>
demarc looks hard to install :confused:
MikeF 01-30-2002, 09:54 PM Originally posted by teck
demarc looks hard to install :confused:
I looked at it too. Then looked at it again...it scared the begezzzes out o' me...the install stuff. :stickout
Domenico 01-30-2002, 10:09 PM Hi MikeF,
Did you allready tried the php script I posted above?
Dom,
What if I wanted the script to run on a 3rd part box monitoring a box? It seems like it just monitors localhost but just because localhost can get to the box doesnt mean an offsite host can.
cahostnet 01-30-2002, 10:22 PM Script worked for me just as is. I'll have to take some time and look at to make it work on a remote server and also monitor several servers at a time. Though I'm not a programmer so it may take some time.
Yeah, it worked fine as is. Maybe someone can come up with something to work for multiple servers/offsite. As for multiple servers, it could be a simple copy/paste. Not sure about the offsite option though.
MikeF 01-30-2002, 10:31 PM Originally posted by Domenico
Hi MikeF,
Did you allready tried the php script I posted above?
Hi Domenico, I am sorry if you got the wrong impression and if i offended you. I havent tried your script yet...been drinking too much wine tonight:stickout , I was referring to demarc and I think teck was to, We werent referring to your script.
Ok? sorry of I offended you. I gotta go i am losing my spelling ability!
I dont think you offended him Mike :)
AlaskanWolf 01-31-2002, 12:02 AM Originally posted by ShaunM
Alaskinwolf, whats up man :)
The one problem i see with http://tlcwe.com (we tryed it out because we were going to use it for a network status page showing if any of our pipe's out were down) is that it checks if the link is up when you load the page and sometimes it gives a red when it's actually up. Also say for somereason 100+ people hit that page at once now you have 100 port connections to those servers, or if sombody setup a script to auto load that site quickly it could be used as a port flooder.
We had the backend of the code completely re-written and also added a uptime monitor to the new scripts and we now have a network monitor that works off cron instead of updating in realtime :)
CWDSolutions 01-31-2002, 12:29 AM Hello Everyone,
I modified the script posted by Domenico to check multiple
servers and changed the layout a bit.
To use for multiple servers add them to the $box array at the top
of the script, can be the domain or IP. Seems to work fine, will
print each in there own table to the browser:
NOTE: To install the below code just copy and paste it, and change the server names.
<?php
$box = array("server1domainname", "server2IP");
?>
<table width="100%" height="400">
<tr>
<td width="100%">
<center>
<p><br><font face="Arial" size="2"><b>System Services</b><br><br>
<table width="300" cellspacing="0" cellpadding="2" border="1" bordercolor="#666666" bordercolordark="#FFFFFF">
<tr>
<td bgcolor="#800000" colspan=2><font color="#FFFFFF" face="Verdana, Arial" size="2"><b>Legend</b></font></td>
</tr>
<tr>
<td><font face="Verdana, Arial" size="2"><b>Ok</b></font></td>
<td><font face="Verdana, Arial" size="4" color="green">•</font></td>
</tr>
<tr>
<td><font face="Verdana, Arial" size="2"><b>No Responce</b></font></td>
<td><font face="Verdana, Arial" size="4" color="red">•</font></td>
</tr>
</table><br><?
foreach($box as $server) {
$noc_http = fsockopen("$server", 80, $errno, $errstr, 30);
if(!$noc_http) {
$noc_http = "red";
} else {
fclose($noc_http);
$noc_http = "green";
}
$noc_ssh = fsockopen("$server", 22, $errno, $errstr, 30);
if(!$noc_ssh) {
$noc_ssh = "red";
} else {
fclose($noc_ssh);
$noc_ssh = "green";
}
$noc_telnet = fsockopen("$server", 23, $errno, $errstr, 30);
if(!$noc_telnet) {
$noc_telnet = "red";
} else {
fclose($noc_telnet);
$noc_telnet = "green";
}
$noc_ftp = fsockopen("$server", 21, $errno, $errstr, 30);
if(!$noc_ftp) {
$noc_ftp = "red";
} else {
fclose($noc_ftp);
$noc_ftp = "green";
}
$noc_smtp = fsockopen("$server", 25, $errno, $errstr, 30);
if(!$noc_smtp) {
$noc_smtp = "red";
} else {
fclose($noc_smtp);
$noc_smtp = "green";
}
$noc_pop3 = fsockopen("$server", 110, $errno, $errstr, 30);
if(!$noc_pop3) {
$noc_pop3 = "red";
} else {
fclose($noc_pop3);
$noc_pop3 = "green";
}
$noc_mysql = fsockopen("$server", 3306, $errno, $errstr, 30);
if(!$noc_mysql) {
$noc_mysql = "red";
} else {
fclose($noc_mysql);
$noc_mysql = "green";
}
?> </font></p>
<table width="400" border="1" cellspacing="0" cellpadding="3" bordercolor="#666666" bordercolordark="#FFFFFF">
<tr>
<td bgcolor="#800000" colspan=8><font color="#FFFFFF" face="Verdana, Arial" size="2"><b>System Monitor</b></font></td>
</tr>
<tr>
<td colspan=1 bgcolor="#FFF4BB"><font face="Verdana, Arial" size="2"><b>Server</b></font></td>
<td colspan=7><font color="#800000" face="Verdana, Arial" size="2"><b><?php echo $server; ?></td>
</tr>
<td colspan=1 bgcolor="#FFF4BB"><font face="Verdana, Arial" size="2"><b>Date</b></font></td>
<td colspan=7><font color="#800000" face="Verdana, Arial" size="2"><b><?php
echo date("l, M d, Y - h:i:s A");
?></b>
</font>
</td>
</tr>
<tr>
<td bgcolor="#FFF4BB">
<font face="Verdana, Arial" size="2"><b>Services</b></font>
</td>
<td bgcolor="#F1F1F1">
<div align="center"><font face="Verdana, Arial" size="-2"><b>http</b></font></div>
</td>
<td bgcolor="#F1F1F1">
<div align="center"><font face="Verdana, Arial" size="-2"><b>ssh</b></font></div>
</td>
<td bgcolor="#F1F1F1">
<div align="center"><font face="Verdana, Arial" size="-2"><b>telnet</b></font></div>
</td>
<td bgcolor="#F1F1F1">
<div align="center"><font face="Verdana, Arial" size="-2"><b>ftp</b></font></div>
</td>
<td bgcolor="#F1F1F1">
<div align="center"><font face="Verdana, Arial" size="-2"><b>smtp</b></font></div>
</td>
<td bgcolor="#F1F1F1">
<div align="center"><font face="Verdana, Arial" size="-2"><b>pop3</b></font></div>
</td>
<td bgcolor="#F1F1F1">
<div align="center"><font face="Verdana, Arial" size="-2"><b>mysql</b></font></div>
</td>
</tr>
<tr>
<td bgcolor="#FFF4BB">
<font face="Verdana, Arial" size="2"><b>Status</b></font>
</td>
<td>
<div align="center" style="font-size: 20pt; color: <? echo($noc_http); ?>" width="15" height="15">•</div>
</td>
<td>
<div align="center" style="font-size: 20pt; color: <? echo($noc_ssh); ?>" width="15" height="15">•</div>
</td>
<td>
<div align="center" style="font-size: 20pt; color: <? echo($noc_telnet); ?>" width="15" height="15">•</div>
</td>
<td>
<div align="center" style="font-size: 20pt; color: <? echo($noc_ftp); ?>" width="15" height="15">•</div>
</td>
<td>
<div align="center" style="font-size: 20pt; color: <? echo($noc_smtp); ?>" width="15" height="15">•</div>
</td>
<td>
<div align="center" style="font-size: 20pt; color: <? echo($noc_pop3); ?>" width="15" height="15">•</div>
</td>
<td>
<div align="center" style="font-size: 20pt; color: <? echo($noc_mysql); ?>" width="15" height="15">•</div>
</td>
</tr>
</td>
</tr>
</table>
<?php
}
?>
</center>
</td>
</tr>
</table>
Hope this helps.
Regards,
Ray
Originally posted by teck
demarc looks hard to install :confused:
But it's worth it :-)
Seriously, it's not at all that hard to install, and it really is a good generic system. It has quirks of it's own, but I like it anyways :-)
Starhost 01-31-2002, 04:00 AM add dns its running on port 53
cahostnet 01-31-2002, 08:37 AM Good stuff. Now that we're at it. Why not build an array where you can add other ports such as 8080 8443 etc. The reason for this is this way if those ports aren't running on all servers, you don't get a red for it. Some way to specify which ports are running on specific servers so it can check them for that specific server.
Just a thought.
MikeF 01-31-2002, 09:21 AM Originally posted by cahostnet
Good stuff. Now that we're at it. Why not build an array where you can add other ports such as 8080 8443 etc. The reason for this is this way if those ports aren't running on all servers, you don't get a red for it. Some way to specify which ports are running on specific servers so it can check them for that specific server.
Just a thought.
That's a great idea. I know my new server will be running on 8080.
...hung over this morning and -20 degrees F outside.:bawling:
cperciva 01-31-2002, 09:50 AM Originally posted by MikeF
That's a great idea. I know my new server will be running on 8080.
You know you've been using computers for too long when you read that as "will be running on an 8080", and immediately start working out whether it is possible to fit a fully RFC compliant* HTTP/TCP/IP stack within the addressable 64kB and how fast it would run.
* the tiny web servers which /. likes to beat up are invariably not RFC-compliant
MikeF 01-31-2002, 10:05 AM Originally posted by cperciva
You know you've been using computers for too long when you read that as "will be running on an 8080", and immediately start working out whether it is possible to fit a fully RFC compliant* HTTP/TCP/IP stack within the addressable 64kB and how fast it would run.
* the tiny web servers which /. likes to beat up are invariably not RFC-compliant
You will know I havent been using computers long enough when I say, "I dont have a clue as to what you said above means." :stickout
Marty 01-31-2002, 10:14 AM Originally posted by cahostnet
Good stuff. Now that we're at it. Why not build an array where you can add other ports such as 8080 8443 etc. The reason for this is this way if those ports aren't running on all servers, you don't get a red for it. Some way to specify which ports are running on specific servers so it can check them for that specific server.
Just a thought.
NetStatus Monitor v2.0 will do this along with the use of a cron to access status. It also, via installing a php script on each monitored server, reports server loads and current uptime of each server. I have not written the documentation yet, but will get that together soon and release it as gpl software. You can see a sample of the output at http://2hostdns.com/netstatus
You will not that the rehoboth server does not have SSL and has a N/A instead of a red indicator. When you enter a server through the control panel, you can choose which services you would like to monitor. It also now has edit functionality so you can go back and change the settings for the servers to change the services that are monitored at any time.
Basically, there is a script on the host computer, that is executed via cron and regular intervals. I have it set at 5 minutes. That script accessed the database and gets the server names and ip's. It also gets the service names and ports. It then does a port connection on each monitored service at each server. It then accesses the script that is installed on each monitored server and collects the uptime and load averages of that server. All this information is then written to a delimited text file on the host server. The display script simply reads the text file and displays the results within your template.
cahostnet 01-31-2002, 10:35 AM Marty, it looks good. Let us know when it's released so we can give it a try.
Marty check status page out Here (http://network.radhost.com)
We have modified your script adding server loads,we scan the entire page via cron every 3 to 5 minutes then dump info from cron in a db then pull db info into the status page.
Joey
goodness0001 01-31-2002, 11:27 PM Where are these scripts available?
Marty 02-01-2002, 12:14 AM I will post mine here when it is available. I don't want to post a link to the page since it leads to a commercial site and there are strict rules against blatent advertising on this board.
goodness0001 02-01-2002, 12:29 AM Thanks, I like the idea of the cron much better as the way the script originated, it hangs there if an IP is offline which i understand is a PHP issue.
Private message, your script is very nice and graphically pleasing
:)
DigitalXWeb 02-01-2002, 12:57 AM Originally posted by Marty
I will post mine here when it is available. I don't want to post a link to the page since it leads to a commercial site and there are strict rules against blatent advertising on this board.
Thanks Marty!! I look forward to its release..
Host Visions 02-01-2002, 03:19 PM CWD - thank you for this!
If I wanted to display a different 'name' instead of the actual server name or IP, how would I go about this? I'm sorry, I'm not very knowledgable on php scripting.
Thanks again!
goodness0001 02-01-2002, 06:33 PM Yes, i am eager for the 2.0 version as it will be much better because if a server is offline the script hangs and isnt much good.
universal2001 02-01-2002, 11:17 PM You need to make the dates/time editable... PLEASE PLEASE do this in version 2.0 :)
cahostnet 02-01-2002, 11:28 PM universal2001, why would you want the date/time editable? The script is suppose to get the date/time from the server so that if you did infact rebooted the server or it went down, your users/visitors would know so. If not don't show status.
Can you explain your reasoning for this? Maybe I'm missing something.
Editting post. Understand what why one would want this now.
Thanks..
AlaskanWolf 02-02-2002, 12:03 AM very likely his servers reside in a different state, country then where his company is located or he has other reasons
I dont see anything dishonest about wanting to edit the time or date fields....Jumping onto the "dishonesty wagon" is a bit streaching it
I would like to see it get back on track about the orignal post, not about version 1s and 2s and 3s about a specific program
cahostnet 02-02-2002, 12:06 AM I see the point now. Didn't mean to call anyone dishonest. Sorry about that. Yeah, lets get back to getting this script done!! :)
The Prohacker 02-02-2002, 12:34 AM <?php
$box = array("server1domainname", "server2IP");
//Added from: http://www.terrabyte.dc.com.au/melbdate.txt
$hourdiff = "16"; //Off set from your servers time, to your time...
?>
<table width="100%" height="400">
<tr>
<td width="100%">
<center>
<p><br><font face="Arial" size="2"><b>System Services</b><br><br>
<table width="300" cellspacing="0" cellpadding="2" border="1" bordercolor="#666666" bordercolordark="#FFFFFF">
<tr>
<td bgcolor="#800000" colspan=2><font color="#FFFFFF" face="Verdana, Arial" size="2"><b>Legend</b></font></td>
</tr>
<tr>
<td><font face="Verdana, Arial" size="2"><b>Ok</b></font></td>
<td><font face="Verdana, Arial" size="4" color="green">•</font></td>
</tr>
<tr>
<td><font face="Verdana, Arial" size="2"><b>No Responce</b></font></td>
<td><font face="Verdana, Arial" size="4" color="red">•</font></td>
</tr>
</table><br><?
foreach($box as $server) {
$noc_http = fsockopen("$server", 80, $errno, $errstr, 30);
if(!$noc_http) {
$noc_http = "red";
} else {
fclose($noc_http);
$noc_http = "green";
}
$noc_ssh = fsockopen("$server", 22, $errno, $errstr, 30);
if(!$noc_ssh) {
$noc_ssh = "red";
} else {
fclose($noc_ssh);
$noc_ssh = "green";
}
$noc_telnet = fsockopen("$server", 23, $errno, $errstr, 30);
if(!$noc_telnet) {
$noc_telnet = "red";
} else {
fclose($noc_telnet);
$noc_telnet = "green";
}
$noc_ftp = fsockopen("$server", 21, $errno, $errstr, 30);
if(!$noc_ftp) {
$noc_ftp = "red";
} else {
fclose($noc_ftp);
$noc_ftp = "green";
}
$noc_smtp = fsockopen("$server", 25, $errno, $errstr, 30);
if(!$noc_smtp) {
$noc_smtp = "red";
} else {
fclose($noc_smtp);
$noc_smtp = "green";
}
$noc_pop3 = fsockopen("$server", 110, $errno, $errstr, 30);
if(!$noc_pop3) {
$noc_pop3 = "red";
} else {
fclose($noc_pop3);
$noc_pop3 = "green";
}
$noc_mysql = fsockopen("$server", 3306, $errno, $errstr, 30);
if(!$noc_mysql) {
$noc_mysql = "red";
} else {
fclose($noc_mysql);
$noc_mysql = "green";
}
?> </font></p>
<table width="400" border="1" cellspacing="0" cellpadding="3" bordercolor="#666666" bordercolordark="#FFFFFF">
<tr>
<td bgcolor="#800000" colspan=8><font color="#FFFFFF" face="Verdana, Arial" size="2"><b>System Monitor</b></font></td>
</tr>
<tr>
<td colspan=1 bgcolor="#FFF4BB"><font face="Verdana, Arial" size="2"><b>Server</b></font></td>
<td colspan=7><font color="#800000" face="Verdana, Arial" size="2"><b><?php echo $server; ?></td>
</tr>
<td colspan=1 bgcolor="#FFF4BB"><font face="Verdana, Arial" size="2"><b>Date</b></font></td>
<td colspan=7><font color="#800000" face="Verdana, Arial" size="2"><b><?php
$timeadjust = ($hourdiff * 60 * 60);
$melbdate = date("l, M d, Y - h:i s",time() + $timeadjust);
echo $melbdate;
?></b>
</font>
</td>
</tr>
<tr>
<td bgcolor="#FFF4BB">
<font face="Verdana, Arial" size="2"><b>Services</b></font>
</td>
<td bgcolor="#F1F1F1">
<div align="center"><font face="Verdana, Arial" size="-2"><b>http</b></font></div>
</td>
<td bgcolor="#F1F1F1">
<div align="center"><font face="Verdana, Arial" size="-2"><b>ssh</b></font></div>
</td>
<td bgcolor="#F1F1F1">
<div align="center"><font face="Verdana, Arial" size="-2"><b>telnet</b></font></div>
</td>
<td bgcolor="#F1F1F1">
<div align="center"><font face="Verdana, Arial" size="-2"><b>ftp</b></font></div>
</td>
<td bgcolor="#F1F1F1">
<div align="center"><font face="Verdana, Arial" size="-2"><b>smtp</b></font></div>
</td>
<td bgcolor="#F1F1F1">
<div align="center"><font face="Verdana, Arial" size="-2"><b>pop3</b></font></div>
</td>
<td bgcolor="#F1F1F1">
<div align="center"><font face="Verdana, Arial" size="-2"><b>mysql</b></font></div>
</td>
</tr>
<tr>
<td bgcolor="#FFF4BB">
<font face="Verdana, Arial" size="2"><b>Status</b></font>
</td>
<td>
<div align="center" style="font-size: 20pt; color: <? echo($noc_http); ?>" width="15" height="15">•</div>
</td>
<td>
<div align="center" style="font-size: 20pt; color: <? echo($noc_ssh); ?>" width="15" height="15">•</div>
</td>
<td>
<div align="center" style="font-size: 20pt; color: <? echo($noc_telnet); ?>" width="15" height="15">•</div>
</td>
<td>
<div align="center" style="font-size: 20pt; color: <? echo($noc_ftp); ?>" width="15" height="15">•</div>
</td>
<td>
<div align="center" style="font-size: 20pt; color: <? echo($noc_smtp); ?>" width="15" height="15">•</div>
</td>
<td>
<div align="center" style="font-size: 20pt; color: <? echo($noc_pop3); ?>" width="15" height="15">•</div>
</td>
<td>
<div align="center" style="font-size: 20pt; color: <? echo($noc_mysql); ?>" width="15" height="15">•</div>
</td>
</tr>
</td>
</tr>
</table>
<?php
}
?>
</center>
</td>
</tr>
</table>
Ok, you adjust your offset at the top, its currently 16, but can be what you want.....
smartbackups 02-02-2002, 12:37 AM How about changing it to use a gif or png for up or down. The .'s are a little small.
Awesome job, coming along really fast.
The Prohacker 02-02-2002, 12:40 AM I'm not good with GFX, but if you'll post them, I'll code it to use it....
Maybe, I should put this on a site, if I could get the authors permission, a thread on a BB isn't good, but decent...
The Prohacker 02-02-2002, 12:42 AM Also, should I make it so, all you have to do is adjust a few varibles to change the colors? Might make it easier for everyone, if you want it, I'll do that also.... Not exactly hard..
smartbackups 02-02-2002, 12:44 AM I "borrowed" these. :)
The Prohacker 02-02-2002, 01:09 AM Ok, did an image one, I borrowed these images also....
So, what do people think about an independant project page? Might be easier to keep track of this...
next thing you know there will be notification options :)
The Prohacker 02-02-2002, 01:21 AM Originally posted by teck
next thing you know there will be notification options :)
This can be done, but not with the current setup, it would require cron.....
smartbackups 02-02-2002, 02:00 AM Nah I have netsaint for that. :) Netsaint is not friendly for hosting clients.
The Prohacker 02-02-2002, 02:18 AM Originally posted by smartbackups
Nah I have netsaint for that. :) Netsaint is not friendly for hosting clients.
Net Saint isn't friendly period, to anyone...
CWDSolutions 02-02-2002, 03:05 AM Hello Everyone,
I have done some additional modifications, to shorten the code
as well as made it possible to add as many ports as you wish
using an array.
Add servers to an array to be checked
Add ports to an array to be checked
Below is the new code, also note the images used here are from
the erlier post so you download them there:
<html>
<head>
<title>Server Status</title>
</head>
<body>
<div align="center">
<?php
// Newstatus system
// Original code by: Domenico
// Time difference added by: The Pro Hacker
// Re-write by: CWD Solutions
// Lets setup the array for the servers
$box = array("server2name" => "server1.com", "server1name" => "server2.com");
// Setup the array of ports you want tested and listed
$port = array("http" => "80", "ssh" => "22", "telnet" => "23",
"ftp" => "21", "smtp" => "25", "pop3" => "110", "mysql" => "3306",
"dns" => "53");
//Added from: http://www.terrabyte.dc.com.au/melbdate.txt
$hourdiff = "16"; //Off set from your servers time, to your time...
// You DO NOT need to modify anything below this line.
// Count the number of ports for later use
$totalports = count($port);
// List the servers and test them
foreach($box as $servename => $server) {
?>
<table width="400" border="1" cellspacing="0" cellpadding="3" bordercolor="#666666" bordercolordark="#FFFFFF">
<tr>
<td bgcolor="#800000" colspan=<?php echo $totalports+1; ?>"><font color="#FFFFFF" face="Verdana, Arial" size="2"><b>System Monitor</b></font></td>
</tr>
<tr>
<td colspan=1 bgcolor="#FFF4BB"><font face="Verdana, Arial" size="2"><b>Server</b></font></td>
<td colspan=<?php echo $totalports; ?>"><font color="#800000" face="Verdana, Arial" size="2"><b><?php echo $servename; ?></td>
</tr>
<tr>
<td colspan=1 bgcolor="#FFF4BB"><font face="Verdana, Arial" size="2"><b>Date</b></font></td>
<td colspan=<?php echo $totalports; ?>"><font color="#800000" face="Verdana, Arial" size="2"><b><?php
$timeadjust = ($hourdiff * 60 * 60);
$melbdate = date("l, M d, Y - h:i s",time() + $timeadjust);
echo $melbdate;
?></b>
</font>
</td>
</tr>
<tr>
<td bgcolor="#FFF4BB"><font face="Verdana, Arial" size="2"><b>Services</b></font></td>
<?php
// Loop through the ports and check them
foreach($port as $portname => $thename){
?>
<td align="center" bgcolor="#F1F1F1"><font face="Verdana, Arial" size="-2"><b><?php echo $portname; ?></b></font></td>
<?php
}
?>
</tr>
<tr>
<td bgcolor="#FFF4BB">
<font face="Verdana, Arial" size="2"><b>Status</b></font>
</td>
<?php
// Test the ports listed in the array
foreach($port as $portname => $theport) {
$count++;
$portnameimg = fsockopen("$server", $theport, $errno, $errstr, 30);
if(!$portnameimg) {
$portnameimg = "<img src=\"red.gif\">";
} else {
fclose($portnameimg);
$portnameimg = "<img src=\"green.gif\">";
}
?>
<td align="center"><? echo($portnameimg); ?></td>
<?php
}
?>
</tr>
</table>
<br>
<?php
}
?>
<table width="300" cellspacing="0" cellpadding="2" border="1" bordercolor="#666666" bordercolordark="#FFFFFF">
<tr>
<td bgcolor="#800000" colspan=2><font color="#FFFFFF" face="Verdana, Arial" size="2"><b>Legend</b></font></td>
</tr>
<tr>
<td><font face="Verdana, Arial" size="2"><b>Ok</b></font></td>
<td align="center"><img src="green.gif"></td>
</tr>
<tr>
<td><font face="Verdana, Arial" size="2"><b>No Responce</b></font></td>
<td align="center"><img src="red.gif"></td>
</tr>
</table>
</div>
</body>
</html>
Enjoy!
Regards,
Ray
iamdave 02-02-2002, 04:00 AM Hey guys what do u think I should use the NetStatus Monitor or the script that everyone so kindly worked on added to?
I would like to use the script that will use the least amount of memory.
Ive already installed both and like both, however I would like to know which one is better.
Im thinking the NetStatus Monitor is better cuz its just generated, but the other one is accessing the port everytime someone access the netstatus page-and as someone said this could become a problem with someone flooding the port.
AlaskanWolf 02-02-2002, 05:51 AM well all of these scripts in their current states do the exact same thing, they all flood the ports anytime the page is updated or accessed
MCHost-Marc 02-02-2002, 06:06 AM Originally posted by AlaskanWolf
well all of these scripts in their current states do the exact same thing, they all flood the ports anytime the page is updated or accessed
Install the script and:
php status.php > status.html
Set a cron to run that every 'x' minutes. ;)
goodness0001 02-02-2002, 11:26 AM I get parse error on line 23
The Prohacker 02-02-2002, 02:53 PM Originally posted by goodness0001
I get parse error on line 23
Make sure your line 23 looks like this:
$hourdiff = "16";
just change the 16, make sure the " " are all there and the ; is at the end...
goodness0001 02-03-2002, 05:45 PM the netstatus script is very very good, took a little bit to figure it out with my server configurations and php configurations but it works very well and is very easy on the servers.
Marty 02-04-2002, 01:44 PM Here you go! NetStatus Monitor v2.0. Data is now generated in the background via cron job and written to a datafile. Refreshing the data display no longer creates more port connections. You can control the number of port connections by controling the interval at which the cron runs. Also, you can now specify which services are monitored on a per server basis. You can also edit servers and services as needed. It now displays the output of a shell "uptime" command from each server to display days of uptime since last reboot and the server load averages.
Enjoy!
Attachement deleted, corrected version on page 6
cahostnet 02-04-2002, 02:09 PM Got a parse error on the upgrade on like 44.
Marty 02-04-2002, 02:15 PM Sorry, you are correct. Try again.
Attachement deleted, corrected version on page 6
In manage/index.php, I got:
Warning: Supplied argument is not a valid MySQL result resource in /home/user/public_html/status1/manage/index.php on line 86
When trying to add a server:
Warning: Bad arguments to implode() in /home/user/public_html/status1/manage/process.php on line 56
Warning: Cannot add header information - headers already sent by (output started at /home/user/public_html/status1/includes/database.php:97) in /home/user/public_html/status1/manage/process.php on line 60
cahostnet 02-04-2002, 02:22 PM that worked. Now I have to run the cron job. What's the syntax for that?
Marty 02-04-2002, 02:28 PM Originally posted by teck
In manage/index.php, I got:
Warning: Supplied argument is not a valid MySQL result resource in /home/user/public_html/status1/manage/index.php on line 86
When trying to add a server:
Warning: Bad arguments to implode() in /home/user/public_html/status1/manage/process.php on line 56
Warning: Cannot add header information - headers already sent by (output started at /home/user/public_html/status1/includes/database.php:97) in /home/user/public_html/status1/manage/process.php on line 60
teck,
is this a new install or an upgrade?
You have to setup a cron to run the script every 5 minutes or so.. There really is no syntax to run that will do it for you.
Marty 02-04-2002, 02:30 PM Originally posted by cahostnet
that worked. Now I have to run the cron job. What's the syntax for that?
If you have curl installed, you can do:
0,5,10,15,20,25,30,35,40,45,50,55 0 0 0 0 curl http://yourdomain.com/netstatus/cron_script/cron_script.php
You can do it with lynx too. I think this will work:
0,5,10,15,20,25,30,35,40,45,50,55 0 0 0 0 lynx -dump http://yourdomain.com/netstatus/cron_script/cron_script.php
Marty,
New install. I created my db's, edited the file, then went to manage/index.php and the errors came up.
cahostnet 02-04-2002, 02:32 PM thanks.... I ran the script but didn't receive any data. I received all N/M I am using the IP address of the server not the website address. It was mapping the script_files.php right after the ip address so it wouldn't fine the path b/c it was wrong.
Marty 02-04-2002, 02:33 PM you need to point your browser to the netstatus/install/install.php file first. This will create the appropriate tables in the database.
Marty 02-04-2002, 02:35 PM Originally posted by cahostnet
thanks.... I ran the script but didn't receive any data. I received all N/M I am using the IP address of the server not the website address. It was mapping the script_files.php right after the ip address so it wouldn't fine the path b/c it was wrong.
You must have a copy of the server_script.php file on each monitored server so that it is accessible at http://server_ip/server_script.php
cahostnet 02-04-2002, 02:36 PM Never mind the N/M issue found out why. But this is what I get when I try to add the services.
Warning: Cannot add header information - headers already sent by (output started at ../includes/database.php:97) in ../manage/process.php on line 76
Any thoughts?
Originally posted by Marty
you need to point your browser to the netstatus/install/install.php file first. This will create the appropriate tables in the database.
I forgot to mention I already did that :)
Marty 02-04-2002, 02:39 PM Originally posted by cahostnet
Never mind the N/M issue found out why. But this is what I get when I try to add the services.
Warning: Cannot add header information - headers already sent by (output started at ../includes/database.php:97) in ../manage/process.php on line 76
Any thoughts?
Yea, Open the database.php file that is on the server and make sure there are not lines or spaces after the last ?>. IF there are, delete them.
Marty 02-04-2002, 02:43 PM Danged if I don't need some sleep. There was some spaces, as I suspected. Here is the another zip file.
Corrected zip on page 7
Marty 02-04-2002, 02:47 PM teck,
Other than the spaces in the database.php file, I can't see anything that should cause the mysql result resource error. Usually this is a result of the database not being connected to properly. You might want to double check your database details. If this is a cpanel server, remember that the database name will actually be username_databasename where username is your account username.
Yeah, I know about the dbname and stuff. Hmm, I deleted the last line/space in database.php and I'm still getting an error. I even tried redoing it fresh. I'll go try this on another server.
edit:
It cant be a db connect problem since when I goto install.php, I get:
NetStatus Table Creation!
Creating table ns_news: [OK]
Creating table ns_servers: [OK]
Creating table ns_services: [OK]
All tables have been created. You can not go the index.php page of in the manage directory here. We would advise that that manage directory should be password protected via a .htaccess file.
Marty 02-04-2002, 02:59 PM teck,
I think I know what is going on. You have to added monitored services first. Scroll down the manage screen. If no services are in the database (i.e. httpd, smtp, etc.) then it errors out when adding servers. So go back and add services first, then add the servers you wish to monitor. And, when adding a service, you have to have selected at least one service to monitor. I think I need some error checking around this area.
Okay... I added a service, added server.. refreshed screen.. still had the same error. I also went to the root directory of netstatus and got this:
Warning: file("server_files/server_file.txt") - No such file or directory in /home/user/public_html/status1/index.php on line 33
..The above file does not exist, all I have is a index.html. I did chmod the server_files dir 777
Warning: First argument to array_slice() should be an array in /home/user/public_html/status1/index.php on line 38
Warning: Invalid argument supplied for foreach() in /home/user/public_html/status1/index.php on line 39
Warning: First argument to array_splice() should be an array in /home/user/public_html/status1/index.php on line 52
Warning: Invalid argument supplied for foreach() in /home/user/public_html/status1/index.php on line 54
edit: I also uploaded the script to the monitored server and the local server as well.
Marty 02-04-2002, 03:10 PM Error checking now in place:
Corrected zip on page 7
Smirks 02-04-2002, 03:10 PM I'm having the same problems as teck.... word for word...
On manage page I get:
Warning: Supplied argument is not a valid MySQL result resource in /web/htdocs/support/status/manage/index.php on line 86
On index page I get:
Warning: file("server_files/server_file.txt") - No such file or directory in /web/htdocs/support/status/index.php on line 33
Warning: First argument to array_slice() should be an array in /web/htdocs/support/status/index.php on line 38
Warning: Invalid argument supplied for foreach() in /web/htdocs/support/status/index.php on line 39
Warning: First argument to array_splice() should be an array in /web/htdocs/support/status/index.php on line 52
Warning: Invalid argument supplied for foreach() in /web/htdocs/support/status/index.php on line 54
Marty 02-04-2002, 03:12 PM Originally posted by teck
Okay... I added a service, added server.. refreshed screen.. still had the same error. I also went to the root directory of netstatus and got this:
Warning: file("server_files/server_file.txt") - No such file or directory in /home/user/public_html/status1/index.php on line 33
..The above file does not exist, all I have is a index.html. I did chmod the server_files dir 777
Warning: First argument to array_slice() should be an array in /home/user/public_html/status1/index.php on line 38
Warning: Invalid argument supplied for foreach() in /home/user/public_html/status1/index.php on line 39
Warning: First argument to array_splice() should be an array in /home/user/public_html/status1/index.php on line 52
Warning: Invalid argument supplied for foreach() in /home/user/public_html/status1/index.php on line 54
edit: I also uploaded the script to the monitored server and the local server as well.
Those errors are there, because the cron script has not run. The script will create and write the server_file.txt on the fly.
I had the same error as you in the manage script after cleaning the database and trying to add a server. But when I added a service first, the error went away. In the latest attachement, I included some error checking to prevent one from entering a server without having something to be monitored.
cahostnet 02-04-2002, 03:13 PM Excuse my ignorance but when you add the cron_script.php file on remote servers, I think you have to modify the script. For example, it connects to the database so it can't be local any longer. Am I missing something. As I understand it, you have to place this script on every machine you want to add. When you do that all configurations changes so therefore you have to modify the script. I tried this by basically making the include file path a url and then I get the following.
I think I'm missing the picture.
Also the As of information isn't showing up.
Warning: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) in cron_script.php on line 30
Warning: MySQL Connection Failed: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) in cron_script.php on line 30
Can't Connect to Database: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
thanks..
Marty 02-04-2002, 03:17 PM You don't put cron_script.php on the remote server. You put the server_script.php on the remote server, per the instructions. The only script that has to be cron'd is the cron_script.php file and it is on the local server with the database. It will call the server_script.php of each server, and collect it's output. There should only be one cron job. It should be on the local server running the cron_script.php from its current location within the directory structure. It is the server_script.php that is uploaded to each individual monitored server.
cahostnet 02-04-2002, 03:20 PM Thank you, now I got it.
Smirks 02-04-2002, 03:29 PM Originally posted by Marty
Those errors are there, because the cron script has not run. The script will create and write the server_file.txt on the fly.
I had the same error as you in the manage script after cleaning the database and trying to add a server. But when I added a service first, the error went away. In the latest attachement, I included some error checking to prevent one from entering a server without having something to be monitored.
I've added services, but it still is showing up. I've tried re-installing several times....no luck.
Marty 02-04-2002, 03:30 PM Teck,
My applogies. The install script is not creating one of the required tables, even though it says that it is.
I have corrected an tested it now.
Smirks 02-04-2002, 03:32 PM Originally posted by Marty
Teck,
My applogies. The install script is not creating one of the required tables, even though it says that it is.
I have corrected an tested it now.
Can you just post the necessary SQL statement to run on the DB? I don't want to reinstall again......
Thanks,
C
Marty 02-04-2002, 03:34 PM CREATE TABLE ns_servers (
ID tinyint(4) NOT NULL auto_increment,
server_name varchar(30) NOT NULL default '',
ip_number varchar(25) NOT NULL default '',
mon_services varchar(40) default NULL,
PRIMARY KEY (ID),
UNIQUE KEY ID (ID),
KEY ID_2 (ID)
)
Smirks 02-04-2002, 03:36 PM Originally posted by Marty
CREATE TABLE ns_servers (
ID tinyint(4) NOT NULL auto_increment,
server_name varchar(30) NOT NULL default '',
ip_number varchar(25) NOT NULL default '',
mon_services varchar(40) default NULL,
PRIMARY KEY (ID),
UNIQUE KEY ID (ID),
KEY ID_2 (ID)
)
Excellent, it all works now!
Thanks!
cahostnet 02-04-2002, 03:39 PM OK, moving along. I have one issue now. One of my server only support port 8080 (using H-Sphere) and the cron_script can't connect to the server using the regular port 80. Is there a work around?
Thanks.. that got rid of the problems. Now.. the root dir of netstatus doesn't show the servers..
I've curl'ed the cron_script file, uploaded the server_script file..
Marty 02-04-2002, 03:42 PM Originally posted by cahostnet
OK, moving along. I have one issue now. One of my server only support port 8080 (using H-Sphere) and the cron_script can't connect to the server using the regular port 80. Is there a work around?
I am not sure I understand. Where is the cron_script failing, and what method are you using to execute it at this point. Is it failing to check any of the ports, or is it that you want it to check httpd at port 8080 on that server only, while checking 80 on the others?
cahostnet 02-04-2002, 03:51 PM Is it failing to check any of the ports, or is it that you want it to check httpd at port 8080 on that server only, while checking 80 on the others?
YES!
Smirks 02-04-2002, 03:51 PM Originally posted by cahostnet
OK, moving along. I have one issue now. One of my server only support port 8080 (using H-Sphere) and the cron_script can't connect to the server using the regular port 80. Is there a work around?
I had a similar issue, here's how I solved it....
I opened cron_script/cron_script.php and went to where it says:
$result=file("http://$ip_number/server_script.php");
I changed it to:
if ($server_name == "alternate.server.com") {
$result=file("http://$ip_number:81/server_script.php");
} else {
$result=file("http://$ip_number/server_script.php");
}
Of course you change alternate.server.com to the host that runs on the other port, then change 81 to whatever port the webserver runs on.
That does work for me.... :)
Marty 02-04-2002, 03:53 PM Originally posted by Smirks
I had a similar issue, here's how I solved it....
I opened cron_script/cron_script.php and went to where it says:
$result=file("http://$ip_number/server_script.php");
I changed it to:
if ($server_name == "alternate.server.com") {
$result=file("http://$ip_number:81/server_script.php");
} else {
$result=file("http://$ip_number/server_script.php");
}
Of course you change alternate.server.com to the host that runs on the other port, then change 81 to whatever port the webserver runs on.
That does work for me.... :) Okay, yea, that will work.
cahostnet 02-04-2002, 03:53 PM BINGO, that worked great!!! :)
DONE!! Yeah.
Marty and Smirks thanks for your help and Marty thanks for the script.
Marty 02-04-2002, 03:55 PM Originally posted by cahostnet
BINGO, that worked great!!! :)
DONE!! Yeah.
Marty and Smirks thanks for your help and Marty thanks for the script.
No problem. Sorry for all the difficulty in getting it to work right.
Marty 02-04-2002, 03:57 PM Originally posted by teck
Thanks.. that got rid of the problems. Now.. the root dir of netstatus doesn't show the servers..
I've curl'ed the cron_script file, uploaded the server_script file..
teck,
Has the cron actually executed yet. If not then, it will not show anything. Also, have you put all the server_script.php files in the right place so that they are accessible via http://server_ip/server_script.php, if not then it is probably writing out a blank file.
Smirks 02-04-2002, 07:42 PM If any of you are like me you'll notice that sometimes lynx doesn't get the job done. Or, you may not have lynx (or curl) installed to do the trick. Below is a perl script that uses LWP and HTTP::Request to get the job done. It's pretty simple and straight forward. Use at your own risk (all I know is it works on my server).
#!/usr/bin/perl
use HTTP::Request::Common;
use LWP::UserAgent;
if ( $ARGV[0] eq "" ) {
print "usage: $0 <url>\n";
exit;
} else {
$ua = new LWP::UserAgent;
$request = new HTTP::Request('GET', "$ARGV[0]");
$response = $ua->request( $request );
}
I call this run_cron.pl and it's in the cron_script/ directory. To us it setup a crontab entry like so:
*/5 * * * * /path/to/netstatus/cron_script/run_cron.pl http://your.url/netstatus/cron_script/cron_script.pl
That should do the trick and you won't need lynx or curl installed.
Good luck, and I hope this helps. :D
Starhost 02-04-2002, 07:47 PM I just run php as cgi.
So I added:
#!/usr/bin/php
To the top of cron_script.php and everything is working fine. Now I got 1 SUGGESTION ad an option to email when 1 of teh services isn't responding.
Marty 02-04-2002, 10:05 PM Originally posted by Starhost
I just run php as cgi.
So I added:
#!/usr/bin/php
To the top of cron_script.php and everything is working fine. Now I got 1 SUGGESTION ad an option to email when 1 of teh services isn't responding.
That is planned for version 3. There will be a switch in the database.php file to turn this off or on. The email functionality will be part of the cron_script.php. I haven't really thought through the logic yet. I would actually like to expand the script to collect uptime data and report % uptime. Of course, if the host server goes down, that would really skew the results, wouldn't it? I may have to look at a way to have a script on a back up server that would check the main server and collect data when it is down, and then when the main server goes backup, have it execute a script on the main server to upload the data that the backup server collected. Boy, this could get complex.
MikeF 02-04-2002, 10:27 PM Hi folks, i ahve tried to install Marty's script and got the following errors when I ran install/install.php
Parse error: parse error in /home/httpd/docs/network_status/includes/database.php on line 34
Warning: Access denied for user: 'web@localhost' (Using password: NO) in /home/httpd/docs/network_status/install/install.php on line 35
Warning: MySQL Connection Failed: Access denied for user: 'web@localhost' (Using password: NO) in /home/httpd/docs/network_status/install/install.php on line 35
Can't Connect to Database: Access denied for user: 'web@localhost' (Using password: NO)
Please advise.
cahostnet 02-04-2002, 10:36 PM Make sure you have the correct database information is your database.php file. It looks like the script isn't using a password. Set the database name, userid and password for it. You must create the database first and assign rights to it before running the script.
I think that's the problem but not 100% sure. Someone who knows what they're doing might help!! :)
MikeF 02-04-2002, 10:59 PM Originally posted by cahostnet
You must create the database first and assign rights to it before running the script.
I think that's the problem but not 100% sure. Someone who knows what they're doing might help!! :)
Well I sure dont know what I am doing:stickout
I tried using what I gues you would call my root username and password and that didnt work.
I have created the database via phpmyadmin. But I do not know how to assign rights to the database and what the rights should be.
I see there is a "Check Database Privileges" where i can choose the database I created. Then i see;
Action Host User Database Table Privileges
Revoke agilehosting.com root All All ALL PRIVILEGES
Revoke localhost root All All ALL PRIVILEGES
Do I need to "Add a new User" and creat a user name and password then assign Privileges(if so what should they be?)?
cahostnet 02-04-2002, 11:14 PM Yes, create a new user and give it full rights to the new database you created. Give it DBA access. They must be able to create/delete tables etc.
MikeF 02-05-2002, 01:37 AM Originally posted by cahostnet
Yes, create a new user and give it full rights to the new database you created. Give it DBA access. They must be able to create/delete tables etc.
Well I am batting a 1000. I created a new user with a new username and password. I entered this into database.php and I get the following error still:
Parse error: parse error in /home/httpd/docs/network_status/includes/database.php on line 34
Warning: Access denied for user: 'web@localhost' (Using password: NO) in /home/httpd/docs/network_status/install/install.php on line 35
Warning: MySQL Connection Failed: Access denied for user: 'web@localhost' (Using password: NO) in /home/httpd/docs/network_status/install/install.php on line 35
Can't Connect to Database: Access denied for user: 'web@localhost' (Using password: NO)
for the new user I set 'Host" as localhost should it maybe have been "Any Host"?
Marty 02-05-2002, 07:37 AM You first must correct this error:
Parse error: parse error in /home/httpd/docs/network_status/includes/database.php on line 34
That error indicates that you have messed up the syntax of the database.php file when you edited it. Pull a new copy of the database.php file out of the zip, and enter your username and pass and database name in it without deleting any quotes or semicolons. Just replace the word changme and nothing else.
Marty 02-05-2002, 07:39 AM Originally posted by MikeF
for the new user I set 'Host" as localhost should it maybe have been "Any Host"?
It should be localhost. But you need to fix the parse error before you trouble shoot password and user issues. The database.php file is not even being read, so you will be user and pass errors even if you have the correct user and pass in the database.php file.
MikeF 02-05-2002, 09:03 AM Originally posted by Marty
You first must correct this error:
Parse error: parse error in /home/httpd/docs/network_status/includes/database.php on line 34
That error indicates that you have messed up the syntax of the database.php file when you edited it. Pull a new copy of the database.php file out of the zip, and enter your username and pass and database name in it without deleting any quotes or semicolons. Just replace the word changme and nothing else.
Thanks Marty...my duh moment goes to show that I REALLY dont what i am doing...I appreciate your patience, help and the script. I am sure I will be getting it to work some time today...its not your fault i am clueless.
I put the database name, username, password in place of the #comments after the "changeme"; ain't I sumpin' :stickout
I'll give it a try now.
MikeF 02-05-2002, 12:42 PM Hi,
I think i may be making progress. My most recent error on executing the script install is:
Warning: Access denied for user: 'network_admin@localhost' (Using password: YES) in /home/httpd/docs/network_status/install/install.php on line 35
Warning: MySQL Connection Failed: Access denied for user: 'network_admin@localhost' (Using password: YES) in /home/httpd/docs/network_status/install/install.php on line 35
Can't Connect to Database: Access denied for user: 'network_admin@localhost' (Using password: YES)
More advice please...:bawling:
Marty 02-05-2002, 01:05 PM You either have the database name, username, or password wrong or you have not granted that username rights to that database. That is the only reasons that the connection would fail.
Is the script on the same server as the MySQL database?
MikeF 02-05-2002, 01:16 PM Originally posted by Marty
You either have the database name, username, or password wrong or you have not granted that username rights to that database. That is the only reasons that the connection would fail.
Is the script on the same server as the MySQL database?
Hi Marty, yes it is on the same server as mysql database. Do i need to "Reload MySQL" after adding a user and setting priveledges?
Marty 02-05-2002, 01:52 PM Did you add the user via the command line. If so, I think you need to flush privilidges. You are going to need somebody more versed in MySQL administration for that question.
MikeF 02-05-2002, 02:54 PM Originally posted by Marty
Did you add the user via the command line. If so, I think you need to flush privilidges. You are going to need somebody more versed in MySQL administration for that question.
hi Marty,
I added the new user via phpmyadmin. Looking back on it I may not have needed to even needed to add a new user. I did it before I found out that the script wasnt running because i had
I put the database name, username, password in place of the #comments after the "changeme";
So i guess I'll try just deleting that user and try finding out if i need to "Reload MySQL".
My incompetence sure is dragging this out. :(
MikeF 02-05-2002, 05:10 PM Hey marty, i am gettin somewhere! i was able to get to the manage/index.php page.
But when i ran cron_script/cron_script.php I got:
Warning: php_hostconnect: connect failed in /home/httpd/docs/network_status/cron_script/cron_script.php on line 68
Warning: file("http://140.99.17.34/server_script.php") - Bad file descriptor in /home/httpd/docs/network_status/cron_script/cron_script.php on line 68
There is text file server_file.txt in the server_file directory.
I have uploaded the server_script.php to the location that above error shows and it was there before i ran cron_script.php.
Feeling better now. Still need some help though.
Marty 02-05-2002, 05:44 PM I went to your index page and got mysql connection errors. The cron script will not run unless it can connect to the database.
I am not sure why you are getting the file error. What control panel do your servers use?
Marty 02-05-2002, 05:47 PM Okay, I went back. You have the mysql portion working but I have no idea why the cron is failing on that line. There is not reason that it should fail.
You might try going to line 68 of the cron_script where you will find:
$result=file("http://$ip_number/server_script.php");
and change it to
$result=file("http://$ip_number:8080/server_script.php");
and see if it is a port issue. I have noticed that I can access your server_script.php via the browser using either port 80 or 8080.
Marty 02-05-2002, 05:50 PM Originally posted by Smirks
I had a similar issue, here's how I solved it....
I opened cron_script/cron_script.php and went to where it says:
$result=file("http://$ip_number/server_script.php");
I changed it to:
if ($server_name == "alternate.server.com") {
$result=file("http://$ip_number:81/server_script.php");
} else {
$result=file("http://$ip_number/server_script.php");
}
Of course you change alternate.server.com to the host that runs on the other port, then change 81 to whatever port the webserver runs on.
That does work for me.... :)
Mike, try this fix. where alternate.server.com would be agilehosting.com
AlaskanWolf 02-05-2002, 05:50 PM I have to say...this is the longest thread that i ever started :D :D :D
MikeF 02-05-2002, 06:02 PM Originally posted by Marty
Okay, I went back. You have the mysql portion working but I have no idea why the cron is failing on that line. There is not reason that it should fail.
You might try going to line 68 of the cron_script where you will find:
$result=file("http://$ip_number/server_script.php");
and change it to
$result=file("http://$ip_number:8080/server_script.php");
and see if it is a port issue. I have noticed that I can access your server_script.php via the browser using either port 80 or 8080.
By golly Marty I am almost there! The only thing I am lacking(besides a brain) is the uptime for one server.
Would you look at http://www.agilehosting.com/network_status/
and tell me what you think i may have done wrong? i have the crontab running every 10 mins and i changed the linein cron_script to this
$result=file("http://$ip_number:8080/server_script.php");
as you suggested.
Thanks for all your help!
Marty 02-05-2002, 10:24 PM I sent you some emails. Let me know if you did not get them.
iamdave 02-06-2002, 02:11 AM Can someone please post the steps to make the cron job?
Starhost 02-07-2002, 12:05 PM Logon in the shell and type:
crontab -e
Now you get a screen you can start entering the details afther pressing "i"
ENter the following line:
*/2 * * * * /path_to/cron_script.php > /dev/null
This will manage that the script is executed every 2 minutes. When you make a typo, press "Esc" and slect the char you would like to remove. Remove it bij pressing "x"
You can start editting again bij prtessing "i".
When you are ready, press "Esc" and type ":wq" that will save your cronscript.
I hoped it helped, if not please tell me what you don't understand.
Smirks 02-07-2002, 12:17 PM Originally posted by Starhost
Logon in the shell and type:
crontab -e
Now you get a screen you can start entering the details afther pressing "i"
ENter the following line:
*/2 * * * * /path_to/cron_script.php > /dev/null
This will manage that the script is executed every 2 minutes. When you make a typo, press "Esc" and slect the char you would like to remove. Remove it bij pressing "x"
You can start editting again bij prtessing "i".
When you are ready, press "Esc" and type ":wq" that will save your cronscript.
I hoped it helped, if not please tell me what you don't understand.
Please note: Using that method will only work if you have php installed as a binary (CGI). Other methods are listed in this thread (ie- lynx, perl).
optix 02-07-2002, 12:19 PM use the php mod system setup since it's based upon a usr/mnge dir. simplicity can sometimes be the easiest.
blazarium 02-07-2002, 03:27 PM It sure looks like a ton of wheel re-engineering going on.
Here's 2 programs that even the BIG BOYS still use to monitor their server farms (as well as other equipment).
BigBrother
http://bb4.com/
WhatsUpGold
http://www.ipswitch.com/Products/WhatsUp/
I'll apologize now if I'm totally off the mark and missunderstood the intent.
optix 02-07-2002, 04:19 PM I'm pretty sure "WhatsUpGold" is what I was talking about I just forgot the name. lol
The Prohacker 02-07-2002, 05:38 PM BigBrother
http://bb4.com/
Big Brother is Free for Non-Commercial Use:
Since this is a hosting site, it is considered commercial.....
WhatsUpGold
http://www.ipswitch.com/Products/WhatsUp/
WhatsUp Gold
Buy it for $1,090*/ $795
The scripts provided above are free........ I don't see it as reinventing the wheel.....
SwiftyHost 02-07-2002, 10:35 PM does martys script work on a windows based box as well? I want to use it to monitor both linux and windows
superiorhost 02-07-2002, 11:00 PM Hi Guys,
Got a question about the netstatus script.
How can I hide the IP numbers that are being checked from the public view. Showing the server name is good, but them seeing all the IP numbers,, well,, I don't like that. Is there a way to hide them?
Thanks,
Tim L :cool:
dbarker 02-08-2002, 03:19 AM Swifty,
The PHP status scripts that have been posted in the thread have all so far worked on my Win2k machine. Make sure you have PHP and possibly MySQL installed (although I think it's only Martys script that needs it)
David
AlaskanWolf 02-10-2002, 06:06 PM Marty, looks like you got some coding problems with v2 downloaded from the site
I added a port, it refreshed, now when i add a server, and ip i get this
255.255.255.255:80> </p> <p>Services to Monitor:<BR> <TABLE border=0 cellpadding=0 cellspacing=0> <TR> <TD align=left valign=top> <input type=
this is all in the text field where you are suppose to put the ip
1. also, why would i want to put 123.123.123.123:Port when the services do that anyway?
2. when intial page loads, there is no submit button to add a server name / ip....
3. going back to pre #1, that code shows up on the intial page too
255.255.255.255:80> </p> <p>Services to Monitor:<BR> <TABLE border=0 cellpadding=0 cellspacing=0> <TR> <TD align=left valign=top> </TD> </TR> </TABLE> <p> <input type=
Marty 02-11-2002, 02:46 PM Sorry, All is fixed. Go download it again at http://scripts.tlcwe.com/downloads/netstatus_v2.0.zip
The ip:port number entry basically allows you to put the serverscript on servers that run httpd on a port other than port 80, such as an HSphere server. There are some hacks in the thread that will do that, but I felt it would be easier for all involved if that was just added to the base script. So now if you have 255.255.255.255:8080, the script parses that data to get the ip number and the port so that it can find the server_script.php file on the monitored server by using http://255.255.255.255:8080/server_script.php. I think, as long as you are operating on port 80, that the script will allow you to leave off the :port number and work fine, but I have not tested it.
Marty 02-11-2002, 02:53 PM Originally posted by superiorhost
Hi Guys,
Got a question about the netstatus script.
How can I hide the IP numbers that are being checked from the public view. Showing the server name is good, but them seeing all the IP numbers,, well,, I don't like that. Is there a way to hide them?
Thanks,
Tim L :cool:
You can go to line 64 of the main index.php page and remove the html that displays the $servername[0] variable. In other words, go the main index.php file, find line 64, and delete the following:
<I>$server_name[0]</I>
Marty 02-11-2002, 03:00 PM oops! Double post!
palmtree 02-13-2002, 04:18 AM Hello all,
Must say thanks a lot for the script.. works great..
however, I'm having a problem getting it to run from crontab..
I've tried the suggested ways of doing in earlier in this thread, but it doesn't seem to work. I've also tried the perl script thing that was suggested..
I believe I have lynx installed (whereis lynx returns locations) and I should have php mods all installed as well..
I can run it from the browser without any problems, but when I make the 1st line change to !#/usr/bin/php , from the browser doesn't work..
Can you help?
Thanks!
#usr/bin/php :cartman:
:rolleyes: :D
palmtree 02-13-2002, 05:38 AM So r u saying to leave off the exclamation point at the beginning?
Well, no, that was my typo :)
I'm saying you probably mean !#/usr/bin/perl line at the beginning of the script?
Or if you are calling php from a html file, than you need either <?php or just <? at the beginning of the php code. And appropriate ending too.
Ales
palmtree 02-13-2002, 06:51 AM Well, I kinda already knew that.. :stickout
I have the script working from the browser.. I just need to know how to get the php script called from crontab..
Thanks..
Marty 02-13-2002, 08:08 AM If you have lynx or curl, using those methods, you should not put the path to php on the first line. The path to php will only work if you have php installed as a cgi and intend to run php directly from the command line.
palmtree 02-13-2002, 08:31 AM So if I use lynx, what do I put on the 1st line of the file?
Also, is the code mentioned earlier for lynx correct?
Thanks!
MikeF 02-13-2002, 10:12 AM Originally posted by palmtree
So if I use lynx, what do I put on the 1st line of the file?
Also, is the code mentioned earlier for lynx correct?
Thanks!
I dont know if this answers your question. Dont bash me too hard as i dont understand a lot of this stuff...but here is what i had to do:
1. i had a text file created, networkmonitor.cn
2. the followin in it all on one line;
*/5 * * * * /usr/local/bin/curl http://username:password@www.yoursite.com:8080/martysscriptsdirectory/cron_script/cron_script.php
3.as per marty's advice i apssword protect the directory where the script is located that is why the username and password is in there.
4. my apache "listens on 8080 that is why it is in there. you may not need that part.
5. at ssh/telnet commandline run: crontab /home/httpd/networkmonitor.cn
Hope this helps...remember I dont know much and my intent is honorable.
Marty 02-13-2002, 11:33 AM Originally posted by palmtree
So if I use lynx, what do I put on the 1st line of the file?
Also, is the code mentioned earlier for lynx correct?
Thanks!
If using lynx, you don't need to put anything on the first line of the cron_script.php. It will work fine as is.
Just log in to the server via telnet or ssh. Then type: crontab -e
Hit enter
You will now be editing your crontab file with the default editor on that linux box.
Place the following line in that crontab file that you are editing:
*/5 * * * * lynx -dump http://domain.com/netstatus/cron_script/cron_script.php
or if the cron_script directory is password protected:
*/5 * * * * lynx -dump http://user:pass@domain.com/netstatus/cron_script/cron_script.php
Save the crontab file and you are done.
cyrusTvirus 02-22-2002, 01:52 PM Originally posted by CWDSolutions
Hello Everyone,
I modified the script posted by Domenico to check multiple
servers and changed the layout a bit.
To use for multiple servers add them to the $box array at the top
of the script, can be the domain or IP. Seems to work fine, will
print each in there own table to the browser:
NOTE: To install the below code just copy and paste it, and change the server names.
<?php
$box = array("server1domainname", "server2IP");
?>
<table width="100%" height="400">
<tr>
<td width="100%">
<center>
<p><br><font face="Arial" size="2"><b>System Services</b><br><br>
<table width="300" cellspacing="0" cellpadding="2" border="1" bordercolor="#666666" bordercolordark="#FFFFFF">
<tr>
<td bgcolor="#800000" colspan=2><font color="#FFFFFF" face="Verdana, Arial" size="2"><b>Legend</b></font></td>
</tr>
<tr>
<td><font face="Verdana, Arial" size="2"><b>Ok</b></font></td>
<td><font face="Verdana, Arial" size="4" color="green">•</font></td>
</tr>
<tr>
<td><font face="Verdana, Arial" size="2"><b>No Responce</b></font></td>
<td><font face="Verdana, Arial" size="4" color="red">•</font></td>
</tr>
</table><br><?
foreach($box as $server) {
$noc_http = fsockopen("$server", 80, $errno, $errstr, 30);
if(!$noc_http) {
$noc_http = "red";
} else {
fclose($noc_http);
$noc_http = "green";
}
$noc_ssh = fsockopen("$server", 22, $errno, $errstr, 30);
if(!$noc_ssh) {
$noc_ssh = "red";
} else {
fclose($noc_ssh);
$noc_ssh = "green";
}
$noc_telnet = fsockopen("$server", 23, $errno, $errstr, 30);
if(!$noc_telnet) {
$noc_telnet = "red";
} else {
fclose($noc_telnet);
$noc_telnet = "green";
}
$noc_ftp = fsockopen("$server", 21, $errno, $errstr, 30);
if(!$noc_ftp) {
$noc_ftp = "red";
} else {
fclose($noc_ftp);
$noc_ftp = "green";
}
$noc_smtp = fsockopen("$server", 25, $errno, $errstr, 30);
if(!$noc_smtp) {
$noc_smtp = "red";
} else {
fclose($noc_smtp);
$noc_smtp = "green";
}
$noc_pop3 = fsockopen("$server", 110, $errno, $errstr, 30);
if(!$noc_pop3) {
$noc_pop3 = "red";
} else {
fclose($noc_pop3);
$noc_pop3 = "green";
}
$noc_mysql = fsockopen("$server", 3306, $errno, $errstr, 30);
if(!$noc_mysql) {
$noc_mysql = "red";
} else {
fclose($noc_mysql);
$noc_mysql = "green";
}
?> </font></p>
<table width="400" border="1" cellspacing="0" cellpadding="3" bordercolor="#666666" bordercolordark="#FFFFFF">
<tr>
<td bgcolor="#800000" colspan=8><font color="#FFFFFF" face="Verdana, Arial" size="2"><b>System Monitor</b></font></td>
</tr>
<tr>
<td colspan=1 bgcolor="#FFF4BB"><font face="Verdana, Arial" size="2"><b>Server</b></font></td>
<td colspan=7><font color="#800000" face="Verdana, Arial" size="2"><b><?php echo $server; ?></td>
</tr>
<td colspan=1 bgcolor="#FFF4BB"><font face="Verdana, Arial" size="2"><b>Date</b></font></td>
<td colspan=7><font color="#800000" face="Verdana, Arial" size="2"><b><?php
echo date("l, M d, Y - h:i:s A");
?></b>
</font>
</td>
</tr>
<tr>
<td bgcolor="#FFF4BB">
<font face="Verdana, Arial" size="2"><b>Services</b></font>
</td>
<td bgcolor="#F1F1F1">
<div align="center"><font face="Verdana, Arial" size="-2"><b>http</b></font></div>
</td>
<td bgcolor="#F1F1F1">
<div align="center"><font face="Verdana, Arial" size="-2"><b>ssh</b></font></div>
</td>
<td bgcolor="#F1F1F1">
<div align="center"><font face="Verdana, Arial" size="-2"><b>telnet</b></font></div>
</td>
<td bgcolor="#F1F1F1">
<div align="center"><font face="Verdana, Arial" size="-2"><b>ftp</b></font></div>
</td>
<td bgcolor="#F1F1F1">
<div align="center"><font face="Verdana, Arial" size="-2"><b>smtp</b></font></div>
</td>
<td bgcolor="#F1F1F1">
<div align="center"><font face="Verdana, Arial" size="-2"><b>pop3</b></font></div>
</td>
<td bgcolor="#F1F1F1">
<div align="center"><font face="Verdana, Arial" size="-2"><b>mysql</b></font></div>
</td>
</tr>
<tr>
<td bgcolor="#FFF4BB">
<font face="Verdana, Arial" size="2"><b>Status</b></font>
</td>
<td>
<div align="center" style="font-size: 20pt; color: <? echo($noc_http); ?>" width="15" height="15">•</div>
</td>
<td>
<div align="center" style="font-size: 20pt; color: <? echo($noc_ssh); ?>" width="15" height="15">•</div>
</td>
<td>
<div align="center" style="font-size: 20pt; color: <? echo($noc_telnet); ?>" width="15" height="15">•</div>
</td>
<td>
<div align="center" style="font-size: 20pt; color: <? echo($noc_ftp); ?>" width="15" height="15">•</div>
</td>
<td>
<div align="center" style="font-size: 20pt; color: <? echo($noc_smtp); ?>" width="15" height="15">•</div>
</td>
<td>
<div align="center" style="font-size: 20pt; color: <? echo($noc_pop3); ?>" width="15" height="15">•</div>
</td>
<td>
<div align="center" style="font-size: 20pt; color: <? echo($noc_mysql); ?>" width="15" height="15">•</div>
</td>
</tr>
</td>
</tr>
</table>
<?php
}
?>
</center>
</td>
</tr>
</table>
Hope this helps.
Regards,
Ray
Hi this script rules !!
Very professional ! I just have one question is it possible to add the server uptime into this script ?? If so how ? I have several customers looking into this feature, perhaps you can shed some light on this matter.
Tia,
Robbert
CWDHost.com 02-22-2002, 05:54 PM Tia,
The one you posted there is an older version of this script, the new
version I have posted below which allows you to add as many
ports as you want as well. Plus the code is alot shorter.
<html>
<head>
<title>Server Status</title>
</head>
<body>
<div align="center">
<?php
// Newstatus system
// Original code by: Domenico
// Time difference added by: The Pro Hacker
// Re-write by: CWD Solutions
// Lets setup the array for the servers
$box = array("server2name" => "server1.com", "server1name" => "server2.com");
// Setup the array of ports you want tested and listed
$port = array("http" => "80", "ssh" => "22", "telnet" => "23",
"ftp" => "21", "smtp" => "25", "pop3" => "110", "mysql" => "3306",
"dns" => "53");
//Added from: <a href="http://www.terrabyte.dc.com.au/melbdate.txt" target="_blank">http://www.terrabyte.dc.com.au/melbdate.txt</a>
$hourdiff = "16"; //Off set from your servers time, to your time...
// You DO NOT need to modify anything below this line.
// Count the number of ports for later use
$totalports = count($port);
// List the servers and test them
foreach($box as $servename => $server) {
?>
<table width="400" border="1" cellspacing="0" cellpadding="3" bordercolor="#666666" bordercolordark="#FFFFFF">
<tr>
<td bgcolor="#800000" colspan=<?php echo $totalports+1; ?>"><font color="#FFFFFF" face="Verdana, Arial" size="2"><b>System Monitor</b></font></td>
</tr>
<tr>
<td colspan=1 bgcolor="#FFF4BB"><font face="Verdana, Arial" size="2"><b>Server</b></font></td>
<td colspan=<?php echo $totalports; ?>"><font color="#800000" face="Verdana, Arial" size="2"><b><?php echo $servename; ?></td>
</tr>
<tr>
<td colspan=1 bgcolor="#FFF4BB"><font face="Verdana, Arial" size="2"><b>Date</b></font></td>
<td colspan=<?php echo $totalports; ?>"><font color="#800000" face="Verdana, Arial" size="2"><b><?php
$timeadjust = ($hourdiff * 60 * 60);
$melbdate = date("l, M d, Y - h:i s",time() + $timeadjust);
echo $melbdate;
?></b>
</font>
</td>
</tr>
<tr>
<td bgcolor="#FFF4BB"><font face="Verdana, Arial" size="2"><b>Services</b></font></td>
<?php
// Loop through the ports and check them
foreach($port as $portname => $thename){
?>
<td align="center" bgcolor="#F1F1F1"><font face="Verdana, Arial" size="-2"><b><?php echo $portname; ?></b></font></td>
<?php
}
?>
</tr>
<tr>
<td bgcolor="#FFF4BB">
<font face="Verdana, Arial" size="2"><b>Status</b></font>
</td>
<?php
// Test the ports listed in the array
foreach($port as $portname => $theport) {
$count++;
$portnameimg = fsockopen("$server", $theport, $errno, $errstr, 30);
if(!$portnameimg) {
$portnameimg = "<img src=\"red.gif\">";
} else {
fclose($portnameimg);
$portnameimg = "<img src=\"green.gif\">";
}
?>
<td align="center"><? echo($portnameimg); ?></td>
<?php
}
?>
</tr>
</table>
<br>
<?php
}
?>
<table width="300" cellspacing="0" cellpadding="2" border="1" bordercolor="#666666" bordercolordark="#FFFFFF">
<tr>
<td bgcolor="#800000" colspan=2><font color="#FFFFFF" face="Verdana, Arial" size="2"><b>Legend</b></font></td>
</tr>
<tr>
<td><font face="Verdana, Arial" size="2"><b>Ok</b></font></td>
<td align="center"><img src="green.gif"></td>
</tr>
<tr>
<td><font face="Verdana, Arial" size="2"><b>No Responce</b></font></td>
<td align="center"><img src="red.gif"></td>
</tr>
</table>
</div>
</body>
</html>
I'll have a look into the server uptime portion.
Regards,
Ray
The Prohacker 02-22-2002, 06:15 PM I'm sorry, but I didn't have time to do a great uptime function, but I knew a great script that did, phpSysinfo 1.9, so I grabbed it, and added credit for it.....
<html>
<head>
<title>Server Status</title>
</head>
<body>
<div align="center">
<?php
// Newstatus system
// Original code by: Domenico
// Time difference added by: The Pro Hacker
// Re-write by: CWD Solutions
// Lets setup the array for the servers
$box = array("server2name" => "server1.com", "server1name" => "server2.com");
// Setup the array of ports you want tested and listed
$port = array("http" => "80", "ssh" => "22", "telnet" => "23",
"ftp" => "21", "smtp" => "25", "pop3" => "110", "mysql" => "3306",
"dns" => "53");
//Added from: http://www.terrabyte.dc.com.au/melbdate.txt
$hourdiff = "16"; //Off set from your servers time, to your time...
// You DO NOT need to modify anything below this line.
// Count the number of ports for later use
$totalports = count($port);
// Get uptime for Linux boxes... Taken from phpSysinfo 1.9
$text['days'] = "days";
$text['hours'] = "hours";
$text['minutes'] = "minutes";
$fd = fopen('/proc/uptime', 'r');
$ar_buf = split(' ', fgets($fd, 4096));
fclose($fd);
$sys_ticks = trim($ar_buf[0]);
$min = $sys_ticks / 60;
$hours = $min / 60;
$days = floor($hours / 24);
$hours = floor($hours - ($days * 24));
$min = floor($min - ($days * 60 * 24) - ($hours * 60));
if ($days != 0) {
$result = "$days ".$text['days']." ";
}
if ($hours != 0) {
$result .= "$hours ".$text['hours']." ";
}
$result .= "$min ".$text['minutes'];
// List the servers and test them
foreach($box as $servename => $server) {
?>
<table width="400" border="1" cellspacing="0" cellpadding="3" bordercolor="#666666" bordercolordark="#FFFFFF">
<tr>
<td bgcolor="#800000" colspan=<?php echo $totalports+1; ?>"><font color="#FFFFFF" face="Verdana, Arial" size="2"><b>System Monitor</b></font></td>
</tr>
<tr>
<td colspan=1 bgcolor="#FFF4BB"><font face="Verdana, Arial" size="2"><b>Server</b></font></td>
<td colspan=<?php echo $totalports; ?>"><font color="#800000" face="Verdana, Arial" size="2"><b><?php echo $servename; ?></td>
</tr>
<tr>
<td colspan=1 bgcolor="#FFF4BB"><font face="Verdana, Arial" size="2"><b>Date</b></font></td>
<td colspan=<?php echo $totalports; ?>"><font color="#800000" face="Verdana, Arial" size="2"><b><?php
$timeadjust = ($hourdiff * 60 * 60);
$melbdate = date("l, M d, Y - h:i s",time() + $timeadjust);
echo $melbdate;
?></b>
</font>
</td>
</tr>
<tr>
<td bgcolor="#FFF4BB"><font face="Verdana, Arial" size="2"><b>Services</b></font></td>
<?php
// Loop through the ports and check them
foreach($port as $portname => $thename){
?>
<td align="center" bgcolor="#F1F1F1"><font face="Verdana, Arial" size="-2"><b><?php echo $portname; ?></b></font></td>
<?php
}
?>
</tr>
<tr>
<td bgcolor="#FFF4BB">
<font face="Verdana, Arial" size="2"><b>Status</b></font>
</td>
<?php
// Test the ports listed in the array
foreach($port as $portname => $theport) {
$count++;
$portnameimg = fsockopen("$server", $theport, $errno, $errstr, 30);
if(!$portnameimg) {
$portnameimg = "<img src=\"red.gif\">";
} else {
fclose($portnameimg);
$portnameimg = "<img src=\"green.gif\">";
}
?>
<td align="center"><? echo($portnameimg); ?></td>
<?php
}
?>
</tr>
</table>
<br>
<?php
}
?>
<table width="300" cellspacing="0" cellpadding="2" border="1" bordercolor="#666666" bordercolordark="#FFFFFF">
<tr>
<td bgcolor="#800000" colspan=2><font color="#FFFFFF" face="Verdana, Arial" size="2"><b>Legend</b></font></td>
</tr>
<tr>
<td><font face="Verdana, Arial" size="2"><b>Ok</b></font></td>
<td align="center"><img src="green.gif"></td>
</tr>
<tr>
<td><font face="Verdana, Arial" size="2"><b>No Responce</b></font></td>
<td align="center"><img src="red.gif"></td>
</tr>
</table>
<br>
<table width="300" cellspacing="0" cellpadding="2" border="1" bordercolor="#666666" bordercolordark="#FFFFFF">
<tr>
<td bgcolor="#800000" colspan=2><font color="#FFFFFF" face="Verdana, Arial" size="2"><b>Uptime</b></font></td>
</tr>
<tr>
<td><font face="Verdana, Arial" size="2"><b>Up</b></font></td>
<td align="center"><? echo $result; ?></td>
</tr>
</table>
</div>
</body>
</html>
cyrusTvirus 02-22-2002, 07:31 PM Heya,
Thanks looks very very impressive !!
Thanks again,
Robbert
goodness0001 03-03-2002, 12:30 AM Is it just me or does it take forever for this script to finish running...or am i doing something wrong??
ok...
I am not getting these 2 errors:
Warning: Supplied argument is not a valid File-Handle resource in /usr/local/psa/home/vhosts/dellz.com/httpdocs/monitor/index2.php on line 36
Warning: Supplied argument is not a valid File-Handle resource in /usr/local/psa/home/vhosts/dellz.com/httpdocs/monitor/index2.php on line 37
Any ideas
The Prohacker 03-03-2002, 01:00 AM Originally posted by goodness0001
Is it just me or does it take forever for this script to finish running...or am i doing something wrong??
ok...
I am not getting these 2 errors:
Warning: Supplied argument is not a valid File-Handle resource in /usr/local/psa/home/vhosts/dellz.com/httpdocs/monitor/index2.php on line 36
Warning: Supplied argument is not a valid File-Handle resource in /usr/local/psa/home/vhosts/dellz.com/httpdocs/monitor/index2.php on line 37
Any ideas
Which script are you running? The lastest one with the Uptime addon? And what version PHP? And is it running in safemode?
cyrusTvirus 03-03-2002, 09:30 AM The uptime function incorporated in the script is taken from the phpsysinfo, however the script takes the uptime from one server. If you do have several different servers in the script defined you all get a uptime matching the first server. So all uptimes are exacty the same..... Which is not true ofcourse...
Is there a way I can change that ? If so...how ?
Cause I preferably want to show the different uptimes.
Thanks in advance.
Robbert:D
The Prohacker 03-03-2002, 11:09 AM Originally posted by cyrusTvirus
The uptime function incorporated in the script is taken from the phpsysinfo, however the script takes the uptime from one server. If you do have several different servers in the script defined you all get a uptime matching the first server. So all uptimes are exacty the same..... Which is not true ofcourse...
Is there a way I can change that ? If so...how ?
Cause I preferably want to show the different uptimes.
Thanks in advance.
Robbert:D
I didn't even think about that when making it... I'll have to look into how that could be done... It might require a script be on the server your measuring... If thats it, it should be pretty easy....
goodness0001 03-03-2002, 12:42 PM I have a solution for the uptime:
on the network status script by tlcwe, they use a passthru script
echo shell_exec(uptime);
of course with the tags. Place this on each server you are monitoring
What i did was just use:
<tags> include 'http://www.server.com/passthru.php'; <tags>
Write an inlcude for each server...I just posted them at the bottom of the script which is fine and made a label for each.
I found out why the script was running so slow, it was the way it was trying to grab the uptime, so i used the script prior to the uptime and it worked perfectly.
goodness0001 03-03-2002, 10:42 PM Since i couldnt get the load average to work right with the last modification i just rigged this up using scripts.tlcwe.com idea using php uptime function:
<html>
<head>
<title>Server Status</title>
</head>
<body>
<div align="center">
<?php
// Newstatus system
// Original code by: Domenico
// Time difference added by: The Pro Hacker
// Re-write by: CWD Solutions
// Lets setup the array for the servers
$box = array("name" => "domain.com", "name" => "domain.com", "name" =>
"domain.com", "name" =>"domain.com", "name" =>"domain.com",
"name" =>"domain.com", "name" =>"domain.com", "name" =>"domain.com",);
// Setup the array of ports you want tested and listed
$port = array("http" => "80", "ssh" => "22", "ftp" => "21", "smtp" => "25", "pop3" => "110", "mysql" => "3306",
"dns" => "53");
//I had to comment this out because it was causing PHP errors, but left it for due credit.
//Added from: <a href="http://www.terrabyte.dc.com.au/melbdate.txt" target="_blank"><a href="http://www.terrabyte.dc.com.au/melbdate.txt"
//target="_blank">http://www.terrabyte.dc.com.au/melbdate.txt</a></a>
//$hourdiff = "16"; //Off set from your servers time, to your time...
// You DO NOT need to modify anything below this line.
// Count the number of ports for later use
$totalports = count($port);
// List the servers and test them
foreach($box as $servename => $server) {
?>
<table width="400" border="1" cellspacing="0" cellpadding="3" bordercolor="#666666" bordercolordark="#FFFFFF">
<tr>
<td bgcolor="#006699" colspan=<?php echo $totalports+1; ?>"><font color="#FFFFFF" face="Verdana, Arial" size="2"><b>System
Monitor</b></font></td>
</tr>
<tr>
<td colspan=1 bgcolor="#FFF4BB"><font face="Verdana, Arial" size="2"><b>Server</b></font></td>
<td colspan=<?php echo $totalports; ?>"><font color="#000000" face="Verdana, Arial" size="2"><b><?php echo $servename; ?></td>
</tr>
<tr>
<td colspan=1 bgcolor="#FFF4BB"><font face="Verdana, Arial" size="2"><b>Date</b></font></td>
<td colspan=<?php echo $totalports; ?>"><font color="#000000" face="Verdana, Arial" size="2"><b><?php
$timeadjust = ($hourdiff * 60 * 60);
$melbdate = date("l, M d, Y - h:i s",time() + $timeadjust);
echo $melbdate;
?></b>
</font>
</td>
</tr>
<tr>
<td bgcolor="#FFF4BB"><font face="Verdana, Arial" size="2"><b>Services</b></font></td>
<?php
// Loop through the ports and check them
foreach($port as $portname => $thename){
?>
<td align="center" bgcolor="#F1F1F1"><font face="Verdana, Arial" size="-2"><b><?php echo $portname; ?></b></font></td>
<?php
}
?>
</tr>
<tr>
<td bgcolor="#FFF4BB">
<font face="Verdana, Arial" size="2"><b>Status</b></font>
</td>
<?php
// Test the ports listed in the array
foreach($port as $portname => $theport) {
$count++;
$portnameimg = fsockopen("$server", $theport, $errno, $errstr, 30);
if(!$portnameimg) {
$portnameimg = "<img src=\"red.gif\">";
} else {
fclose($portnameimg);
$portnameimg = "<img src=\"green.gif\">";
}
?>
<td align="center"><? echo($portnameimg); ?></td>
<?php
}
?>
</tr>
</table>
<p><br>
<?php
}
?>
<br>
</p>
<table width="56%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="22%" bgcolor="#006699"><font color="#FFFFFF" bgcolor=#006699><b><font face="Arial">System
Health</font></b></font></td>
<td width="78%" bgcolor="#006699"> </td>
</tr>
<tr>
<td width="22%" bgcolor="#FFF4BB" height="24"><b>Servername</b></td>
<td width="78%" bgcolor="#FFF4BB" height="24">
<?php include 'http://www.xxx.com/server_script.php'; ?>
</td>
</tr>
<tr>
<td width="22%" bgcolor="#FFF4BB" height="25"><b>Servername</b></td>
<td width="78%" bgcolor="#FFF4BB" height="25">
<?php include 'http://www.xxx.com/server_script.php'; ?>
</td>
</tr>
<tr>
<td width="22%" bgcolor="#FFF4BB" height="23"><b>Servername</b></td>
<td width="78%" bgcolor="#FFF4BB" height="23">
<?php include 'http://www.xxx.com/server_script.php'; ?>
</td>
</tr>
<tr>
<td width="22%" bgcolor="#FFF4BB" height="24"><b>Servername</b></td>
<td width="78%" bgcolor="#FFF4BB" height="24">
<?php include 'http://xxx.com/server_script.php'; ?>
</td>
</tr>
<tr>
<td width="22%" bgcolor="#FFF4BB" height="24"><b>Servername</b></td>
<td width="78%" bgcolor="#FFF4BB" height="24">
<?php include 'http://xxx.com/server_script.php'; ?>
</td>
</tr>
<tr>
<td width="22%" bgcolor="#FFF4BB" height="24"><b>Servername</b></td>
<td width="78%" bgcolor="#FFF4BB" height="24">
<?php include 'http://xxx.com/server_script.php'; ?>
</td>
</tr>
<tr>
<td width="22%" bgcolor="#FFF4BB" height="23"><b>Servername</b></td>
<td width="78%" bgcolor="#FFF4BB" height="23">
<?php include 'http://xxx.com/server_script.php'; ?>
</td>
</tr>
<tr>
<td width="22%" bgcolor="#FFF4BB" height="23"><b>Servername</b></td>
<td width="78%" bgcolor="#FFF4BB" height="23">
<?php include 'http://www.xxx.com/server_script.php'; ?>
</td>
</tr>
</table>
<p><br>
<br>
<br>
<br>
<br>
<br>
name
<?php include 'http://www.xxx.com/server_script.php'; ?>
<br>
</p>
<table width="300" cellspacing="0" cellpadding="2" border="1" bordercolor="#666666" bordercolordark="#FFFFFF">
<tr bgcolor="#006699">
<td colspan=2><font color="#FFFFFF" face="Verdana, Arial" size="2"><b>Legend</b></font></td>
</tr>
<tr>
<td><font face="Verdana, Arial" size="2"><b>Ok</b></font></td>
<td align="center"><img src="green.gif"></td>
</tr>
<tr>
<td><font face="Verdana, Arial" size="2"><b>No Responce</b></font></td>
<td align="center"><img src="red.gif"></td>
</tr>
</table>
</div>
</body>
</html>
Jojja 04-28-2002, 10:00 AM I am using Marty's Netstatus 2.0 (great script) but I cannot figure out how to adjust the time so that it will show my local time and not the server time.
Can anyone help with that ??
Thanks
Mike
BMurtagh 04-28-2002, 02:29 PM i edited dom's script to add the dns like someone wanted above, btw, that's for letting me see the source, that was my first ever experience with php scripting, thanks.
<?php
$box = $HTTP_SERVER_VARS["SERVER_NAME"];
$boxip = $HTTP_SERVER_VARS["SERVER_NAME"] . " (" . gethostbyname($HTTP_SERVER_VARS["SERVER_NAME"]) . ")";
?>
<table width="100%" height="400">
<tr>
<td width="100%">
<center>
<p><font face="Arial" size="2"><b>System Uptimes</b></font></p>
<p> <font size="-1"><?php echo $box; ?>:
</font> <font size="-1">
<script language="php">
$date = (date("l, M d, Y - h:i:s A"));
$uptime = system(uptime);
</script>
</font></p>
<p><br><font face="Arial" size="2"><b>System Services</b><?
$noc_http = fsockopen("$box", 80, $errno, $errstr, 30);
if(!$noc_http) {
$noc_http = "red";
} else {
fclose($noc_http);
$noc_http = "green";
}
$noc_ssh = fsockopen("localhost", 22, $errno, $errstr, 30);
if(!$noc_ssh) {
$noc_ssh = "red";
} else {
fclose($noc_ssh);
$noc_ssh = "green";
}
$noc_telnet = fsockopen("localhost", 23, $errno, $errstr, 30);
if(!$noc_telnet) {
$noc_telnet = "red";
} else {
fclose($noc_telnet);
$noc_telnet = "green";
}
$noc_ftp = fsockopen("localhost", 21, $errno, $errstr, 30);
if(!$noc_ftp) {
$noc_ftp = "red";
} else {
fclose($noc_ftp);
$noc_ftp = "green";
}
$noc_smtp = fsockopen("localhost", 25, $errno, $errstr, 30);
if(!$noc_smtp) {
$noc_smtp = "red";
} else {
fclose($noc_smtp);
$noc_smtp = "green";
}
$noc_pop3 = fsockopen("localhost", 110, $errno, $errstr, 30);
if(!$noc_pop3) {
$noc_pop3 = "red";
} else {
fclose($noc_pop3);
$noc_pop3 = "green";
}
$noc_mysql = fsockopen("localhost", 3306, $errno, $errstr, 30);
if(!$noc_mysql) {
$noc_mysql = "red";
} else {
fclose($noc_mysql);
$noc_mysql = "green";
}
$noc_dns = fsockopen("localhost", 53, $errno, $errstr, 30);
if(!$noc_dns) {
$noc_dns = "red";
} else {
fclose($noc_dns);
$noc_dns = "green";
}
?> </font></p>
<table width="400" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<div align="center"></div>
</td>
<td>
<div align="center"><font size="-1">http</font></div>
</td>
<td>
<div align="center"><font size="-1">ssh</font></div>
</td>
<td>
<div align="center"><font size="-1">telnet</font></div>
</td>
<td>
<div align="center"><font size="-1">ftp</font></div>
</td>
<td>
<div align="center"><font size="-1">smtp</font></div>
</td>
<td>
<div align="center"><font size="-1">pop3</font></div>
</td>
<td>
<div align="center"><font size="-1">mysql</font></div>
</td>
<td>
<div align="center"><font size="-1">dns</font></div>
</td>
</tr>
<tr>
<td>
<div align="center"><font size="-1"><?php echo $box; ?></font></div>
</td>
<td>
<div align="center" style="font-size: 20pt; color: <? echo($noc_http); ?>" width="15" height="15">•</div>
</td>
<td>
<div align="center" style="font-size: 20pt; color: <? echo($noc_ssh); ?>" width="15" height="15">•</div>
</td>
<td>
<div align="center" style="font-size: 20pt; color: <? echo($noc_telnet); ?>" width="15" height="15">•</div>
</td>
<td>
<div align="center" style="font-size: 20pt; color: <? echo($noc_ftp); ?>" width="15" height="15">•</div>
</td>
<td>
<div align="center" style="font-size: 20pt; color: <? echo($noc_smtp); ?>" width="15" height="15">•</div>
</td>
<td>
<div align="center" style="font-size: 20pt; color: <? echo($noc_pop3); ?>" width="15" height="15">•</div>
</td>
<td>
<div align="center" style="font-size: 20pt; color: <? echo($noc_mysql); ?>" width="15" height="15">•</div>
</td>
<td>
<div align="center" style="font-size: 20pt; color: <? echo($noc_dns); ?>" width="15" height="15">•</div>
</td>
</tr>
</td>
</tr>
</table>
<p> </p>
</center>
</td>
</tr>
</table>
iamdave 05-05-2002, 11:03 PM Is there anyway to get the System Uptime without running php in non safe mode? And without writing a cron?
Shauna 05-07-2002, 01:02 AM Add this code to a php doc:
<?php echo shell_exec(uptime);
?>
MrLister 05-07-2002, 01:20 AM I tried install DeMarc once, boy did I get a headache. In the end it failed. :(
iamdave 05-07-2002, 01:23 AM Originally posted by Shauna
Add this code to a php doc:
<?php echo shell_exec(uptime);
?>
I specifically asked for a script that would get the uptime without having to have safe mode off.
Warning: Cannot execute using backquotes in safe mode in /usr/local/psa/home/vhosts/domain.com/httpsdocs/adm1n/uptime.php on line 2
Shauna 05-07-2002, 02:49 AM Sorry, my bad - guess my eyes are too tired, I managed to misread.
Marty 05-07-2002, 02:40 PM Originally posted by iamdave
Is there anyway to get the System Uptime without running php in non safe mode? And without writing a cron?
There is know way to do it in php, that I know of. It requires a system command, and the only way to execute system commands is with safe mode off. Maybe it can be done in another language, I am not sure. You might want to ask this at a coders forum like www.sitepointforums.com.
The Prohacker 05-07-2002, 04:23 PM You could do it with perl:
#!/usr/bin/perl
print "Content-type: text/html\n\n";
chop($uptime = `uptime`);
$uptime =~ s/\t/ /g;
$uptime =~ s/\s/\ \;/g;
print qq{
<b>Uptime:</b>
$uptime<p>
};
Its not pretty but it works...
iamdave 05-07-2002, 08:39 PM Originally posted by The Prohacker
You could do it with perl:
#!/usr/bin/perl
print "Content-type: text/html\n\n";
chop($uptime = `uptime`);
$uptime =~ s/\t/ /g;
$uptime =~ s/\s/\ \;/g;
print qq{
<b>Uptime:</b>
$uptime<p>
};
Its not pretty but it works...
I got an Internal Server Error. You sure it works?
The Prohacker 05-07-2002, 10:46 PM Originally posted by iamdave
I got an Internal Server Error. You sure it works?
Runs fine here.... Make sure you chmod it 755.....
Also, you may want to comment out:
$uptime =~ s/\s/\ \;/g;
iamdave 05-07-2002, 11:02 PM Nope didn't work here.
iamdave 05-07-2002, 11:13 PM I didn't know how to call it. This below worked!
#!/usr/bin/perl
print qq{
<HTML><HEAD></HEAD><BODY>
Status for $ENV{SERVER_NAME}
};
&uptime;
## UPTIME
sub uptime {
chop($uptime = `uptime`);
$uptime =~ s/\t/ /g;
$uptime =~ s/\s/\ \;/g;
print qq{
$uptime<p>
};
}
Anyone get this to work on NT4? I get the following when attempting to add a server:
Notice: Undefined variable: action in e:\www\netstatus\manage\process.php on line 32
Warning: Cannot add header information - headers already sent by (output started at e:\www\netstatus\manage\process.php:32) in e:\www\netstatus\manage\process.php on line 110
Any ideas what is wrong?
Thanks.
The Prohacker 06-03-2002, 12:20 PM Originally posted by temp
Anyone get this to work on NT4? I get the following when attempting to add a server:
Notice: Undefined variable: action in e:\www\netstatus\manage\process.php on line 32
Warning: Cannot add header information - headers already sent by (output started at e:\www\netstatus\manage\process.php:32) in e:\www\netstatus\manage\process.php on line 110
Any ideas what is wrong?
Thanks.
I think this could only work on linux.. I'm not sure, which script at you using?
Sorry, the netstatus script. I thought I read that someone got it running on Win2000 so I figured I would give NT a shot.
Thanks.
The Prohacker 06-03-2002, 12:47 PM Originally posted by temp
Sorry, the netstatus script. I thought I read that someone got it running on Win2000 so I figured I would give NT a shot.
Thanks.
Exactly what script... paste it in your next post please, there are way to many scripts in this thread already :stickout
It very well could work on NT4, but I'm not sure, what version of PHP are you using?
(With Comments removed to save space) I am running PHP 4.2.1 (latest as of friday)
Main script:
<?php
include("../includes/database.php");
mysql_connect($db_Hostname, $db_UserName, $db_Password) || die("Can't Connect to Database: ".mysql_error());
mysql_select_db($db_Database);
?>
<html>
<head>
<title>NetStatus Control Panel</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
body { font-family: Geneva, Arial, Helvetica, san-serif; font-size: 14px}
td { font-family: Geneva, Arial, Helvetica, san-serif; font-size: 14px}
a:active { color: #0099CC; text-decoration: none}
a:hover { color: #CCCCCC; text-decoration: none}
a:link { color: #0099CC; text-decoration: none}
a:visited { color: #0099CC; text-decoration: none}
-->
</style>
</head>
<body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="100%" border="0" cellspacing="0" cellpadding="5">
<tr>
<td width="50%" align="left" valign="top">
<p><font size="5">NetStatus Monitor</font><br>
Control Panel</p>
</td>
<td width="50%" align="right" valign="top"><font size="1">Copyright ©2002
<a href="http://scripts.tlcwe.com">TLC Web Enterprise</a><br>
All rights reserved.</font></td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="4">
<tr>
<td bgcolor="#0099CC"> </td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="4">
<tr>
<td height="100%" align="center" valign="top" colspan="2">
<table width="100%" border="0" cellspacing="1" cellpadding="4" bgcolor="#CCCCCC">
<tr>
<td align="center" bgcolor="#CCCCCC"><b><font size="3">Servers</font></b></td>
</tr>
<tr>
<td align="center" bgcolor="#FFFFFF">
<table width="100%" border="0" cellspacing="1" cellpadding="4" bgcolor="#0099CC">
<tr bgcolor="#0099CC" align="center" valign="top">
<td><font color="#FFFFFF"><b>Server Name</b></font></td>
<td><font color="#FFFFFF"><b>IP Number:Port</b></font></td>
<td><font color="#FFFFFF"><b>Services</b></font></td>
<td> </td>
</tr>
<?php
$sql = "Select *
From ns_servers
order by server_name";
$res = mysql_query($sql);
while ( $row = mysql_fetch_array($res) ) {
$mon_services = explode(",", $row[mon_services]);
$service = "";
foreach ($mon_services as $value) {
$sql1 = "Select service_name from ns_services where ID = '$value'";
$res1 = mysql_query($sql1);
$name = mysql_fetch_array($res1);
$service .= "| $name[service_name] |";
}
echo "<tr align=\"center\" valign=\"top\" bgcolor=\"#FFFFFF\">
<td>".stripslashes($row[server_name])."</td>
<td>$row[ip_number]</td>
<td>$service</td>
<td><A HREF=\"edit_server.php?id=$row[ID]\">Edit</A> | <A HREF=\"process.php?action=delete_server&id=$row[ID]\">Delete</A></td>
</tr>";
}
?>
</table>
<p><b>Add Server</b></p>
<form name="form1" method="post" action="process.php?action=add_server">
<p>Server Name:<br>
<input type="text" name="server_name" size="20">
</p>
<p>IP Number:Port:<br>
<input type="text" name="ip_number" size="20" value="255.255.255.255:80">
</p>
<p>Services to Monitor:<BR>
<TABLE border=0 cellpadding=0 cellspacing=0>
<TR>
<TD align=left valign=top>
<?php
$sql = "Select *
From ns_services
order by service_name";
$res = mysql_query($sql);
while ( $row = mysql_fetch_array($res) ) {
echo "<input type=\"checkbox\" name=\"mon_service[]\" value=\"$row[ID]\"> $row[service_name]<BR>";
}
?>
</TD>
</TR>
</TABLE>
<p>
<input type="submit" name="Submit" value="Submit">
</p>
</form>
<p> </p>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="50%" align="center" valign="top">
<table width="100%" border="0" cellspacing="1" cellpadding="4" bgcolor="#CCCCCC">
<tr>
<td align="center"><b><font size="3">Services</font></b></td>
</tr>
<tr>
<td align="center" bgcolor="#FFFFFF">
<table width="100%" border="0" cellspacing="1" cellpadding="4" bgcolor="#0099CC">
<tr bgcolor="#0099CC" align="center" valign="top">
<td><font color="#FFFFFF"><b>Service Name</b></font></td>
<td><font color="#FFFFFF"><b>Service Port</b></font></td>
<td> </td>
</tr>
<?php
$sql = "Select *
From ns_services
order by service_name";
$res = mysql_query($sql);
while ( $row = mysql_fetch_array($res) ) {
echo "<tr align=\"center\" valign=\"top\" bgcolor=\"#FFFFFF\">
<td>".stripslashes($row[service_name])."</td>
<td>$row[service_port]</td>
<td><A HREF=\"process.php?action=delete_service&id=$row[ID]\">Delete</A></td>
</tr>";
}
?>
</table>
<p><b>Add Service</b></p>
<form name="form2" method="post" action="process.php?action=add_service">
<p>Service Name:<br>
<input type="text" name="service_name" size="20">
</p>
<p>Service Port:<br>
<input type="text" name="service_port" size="20">
</p>
<p>
<input type="submit" name="Submit2" value="Submit">
</p>
</form>
<p> </p>
</td>
</tr>
</table>
</td>
<td width="50%" align="center" valign="top">
<table width="99%" border="0" cellspacing="1" cellpadding="4" align="center" bgcolor="#CCCCCC">
<tr>
<td align="center" valign="top"><b><font size="3">News</font></b></td>
</tr>
<tr>
<td align="center" valign="top" bgcolor="#FFFFFF">
<table width="100%" border="0" cellspacing="1" cellpadding="4" bgcolor="#0099CC">
<tr bgcolor="#0099CC">
<td><font color="#FFFFFF"><b>Date/Time</b></font></td>
<td><b><font color="#FFFFFF">Announcement</font></b></td>
<td> </td>
</tr>
<?php
$sql = "Select *
from ns_news
order by date desc";
$res = mysql_query($sql);
while ( $row = mysql_fetch_array($res) ) {
echo "<tr bgcolor=\"#FFFFFF\">
<td>$row[date]</td>
<td>".stripslashes($row[text])."</td>
<td><A HREF=\"process.php?action=delete_news&id=$row[ID]\">Delete</A></td>
</tr>";
}
?>
</table>
<p><b>Add News</b></p>
<form name="form3" method="post" action="process.php?action=add_news">
<p>Announcement<br>
<textarea name="text" cols="30" rows="10"></textarea>
</p>
<p>
<input type="submit" name="Submit3" value="Submit">
</p>
</form>
<p> </p>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
The above script calls this process script where the errors occur:
<?php
include("../includes/database.php");
mysql_connect($db_Hostname, $db_UserName, $db_Password) || die("Can't Connect to Database: ".mysql_error());
mysql_select_db($db_Database);
switch ($action) {
case "delete_server";
$sql = "Delete from ns_servers where ID = '$id'";
mysql_query($sql);
header("location: index.php");
exit;
case "delete_service";
$sql = "Delete from ns_services where ID = '$id'";
mysql_query($sql);
header("location: index.php");
exit;
case "delete_news";
$sql = "Delete from ns_news where ID = '$id'";
mysql_query($sql);
header("location: index.php");
exit;
case "add_server";
if (empty($mon_service)) {
echo "<CENTER>Error: You must select at least one service to monitor for this server from the checkbox list. If there was not list, then you must enter Services to monitor before you can add servers. Scroll down the control panel page and look for Add Services.</CENTER>";
die();
}
if ( empty($server_name) || empty($ip_number) ) {
echo "<CENTER>Error: You must enter a value for both the server name and the ip number!<P>
Please use the back button and try again!</CENTER>";
die();
}
$mon_services = implode(",", $mon_service);
$server_name = addslashes($server_name);
$sql = "Insert into ns_servers (server_name, ip_number, mon_services) values ('$server_name', '$ip_number', '$mon_services')";
mysql_query($sql);
header("location: index.php");
exit;
case "edit_server";
if ( empty($server_name) || empty($ip_number) ) {
echo "<CENTER>Error: You must enter a value for both the server name and the ip number!<P>
Please use the back button and try again!</CENTER>";
die();
}
$mon_services = implode(",", $mon_service);
$server_name = addslashes($server_name);
$sql = "Update ns_servers
Set server_name='$server_name',
ip_number = '$ip_number',
mon_services = '$mon_services'
where ID='$id'";
mysql_query($sql);
header("location: index.php");
exit;
case "add_service";
if ( empty($service_name) || empty($service_port) ) {
echo "<CENTER>Error: You must enter a value for both the service name and the server port!<P>
Please use the back button and try again!</CENTER>";
die();
}
$service_name = addslashes($service_name);
$sql = "Insert into ns_services (service_name, service_port) values ('$service_name', '$service_port')";
mysql_query($sql);
header("location: index.php");
exit;
case "add_news";
if ( empty($text) ) {
echo "<CENTER>Error: You must enter a value for both the server name and the ip number!<P>
Please use the back button and try again!</CENTER>";
die();
}
$text = addslashes($text);
$sql = "Insert into ns_news (text, date) values ('$text', now())";
mysql_query($sql);
header("location: index.php");
exit;
default;
header("location: index.php");
exit;
}
?>
Errors occur when attempting to add a server, add a service to monitor, or even add 'news'.
Sorry for taking up so much space. Thanks for your help.
freehtml 09-07-2005, 01:14 AM Anymore updates to this script?
TopHostSupport 09-08-2005, 04:22 PM Originally posted by freehtml
Anymore updates to this script?
Wow, "almost" 3 year old thread brought back to life.
palmtree 09-08-2005, 04:23 PM I thought the same thing :-) Didn't even know I was still "subscribed" to the thread after that long..
MyLOCA 03-08-2006, 06:25 AM No update :(
Find another script
jt2377 03-10-2006, 02:11 AM where can i download the original script? i'll like to take a look at it.
thank
Techark 03-10-2006, 03:32 AM I think you are about 4 years to late, I am sure the download is long gone.
meh, go back to the front page 3 or 4 marty did attach the version 2 on the forum which still can be downloaded from there
i am trying it out but dont know where to upload the server_script.php file to, i have put it everywhere root , public_html all still cant find the server_script when pointing to the ip address/server_script.php
anyone know how?
TopHostSupport 03-22-2006, 12:03 PM meh, go back to the front page 3 or 4 marty did attach the version 2 on the forum which still can be downloaded from there
i am trying it out but dont know where to upload the server_script.php file to, i have put it everywhere root , public_html all still cant find the server_script when pointing to the ip address/server_script.php
anyone know how?
/usr/local/apache/htdocs
hey emax what are you using to implement support ticket, payment and auto signup from, its not clientexec is it?
Warning: fopen(../template//template.html): failed to open stream: No such file or directory in /home/hostdwho/public_html/netstatus/index.php
any idea?
superiorhost 10-07-2007, 02:35 PM I have a copy of this script if anyone can make it work in php5.
I have not found anything nearly as good for keeping an eye on things at a glance.
It worked fine, until we upgraded to php5.2.3 . Now, it just sits on the last page it wrote to the file.
Anyone??? :-)
Tim L
Dougy 10-07-2007, 08:20 PM <?php
$domain = "localhost";
function lookup($hport,$Something,$who){
$fp = fsockopen($who, $hport, &$errno, &$errstr, 4);
if (!$fp){
$data = "<tr><td width=\"40%\"><font face=\"Times New Roman\" color=\"#000000\"><strong>$Something :</td></strong></font><td width=\"60%\"><font color=\"#FF0000\" face=\"Times New Roman\"><strong>Down</strong><em>($who)</em></font></td></tr>";
} else {
$data = "<tr><td width=\"40%\"><font face=\"Times New Roman\" color=\"#000000\"><strong>$Something :</strong></td></font><td width=\"60%\"><font face=\"Times New Roman\"><strong><font color=\"#008000\">Running</font> </strong><em>($who)</em></font></td></tr>";
fclose($fp);
}
return $data;
}
echo "<table border=\"0\" cellpadding=\"0\" width=\"75%\">";
echo lookup("80","Web Server","$domain");
echo lookup("3306","MySQL Server","$domain");
echo lookup("21","FTP Server","$domain");
echo lookup("22","SSH Server","$domain");
echo lookup("110","Mail Server","$domain");
echo "</table>";
?>
Thats just the source from our status page, its not pretty but it works....
Being that thread was bumped up, I'll thank you for this now.
I have a copy of this script if anyone can make it work in php5.
I have not found anything nearly as good for keeping an eye on things at a glance.
It worked fine, until we upgraded to php5.2.3 . Now, it just sits on the last page it wrote to the file.
Anyone??? :-)
Tim L
Set up a place for it to be downloaded.
superiorhost 10-07-2007, 09:09 PM Hi,
Thanks,, but I need a way to see multiple servers on one glance like this:
http://www.superior-host.com/netstatus/
As you can see.... it is frozen in time..
It hasn't changed since the 2nd. :-(
Tim L
Dougy 10-07-2007, 09:25 PM Hi,
Thanks,, but I need a way to see multiple servers on one glance like this:
http://www.superior-host.com/netstatus/
As you can see.... it is frozen in time..
It hasn't changed since the 2nd. :-(
Tim L
I'm working on a simple easy to integrate in a site script based from Prohacker's one quoted above.
superiorhost 10-09-2007, 02:52 PM Hi Dougy,
I missed you asking for a link to download it.
Here you go:
http://superior-host.com/netstatus_v2[1].0.zip
The code you pasted is ok.. but it isn't half what this netstatus script was. It just seems like it has to be something simple that is keeping it from working with php5.
TiM L
|