Koozali.org: home of the SME Server

monitoring status of disk redundacy and server uptime more simply

Offline electroman00

  • ****
  • 491
  • +0/-0
Re: monitoring status of disk redundacy and server uptime more simply
« Reply #45 on: June 12, 2009, 03:57:59 AM »
Cool....

You made the font larger.....yuck.

Code: [Select]
print "***** SERVER TYPE ***************\n";
system("uname -a | col -b",$return);
print "\n";

Cut that....and add this to top somewhere....

Code: [Select]
print "***** OS Info ***************\n";
system("uname -orp | col -b",$return);
print "\n";

Notice the uname options

Offline purvis

  • ****
  • 567
  • +0/-0
Re: monitoring status of disk redundacy and server uptime more simply
« Reply #46 on: June 12, 2009, 04:04:10 AM »
i made a change in the above code to select a longer report.
notice the reference to another webpage at the bottom of index.php


Offline purvis

  • ****
  • 567
  • +0/-0
Re: monitoring status of disk redundacy and server uptime more simply
« Reply #47 on: June 12, 2009, 04:05:12 AM »
our employees are getting old.

thanks for all your help
i believe this is something we can use, do you think.
i did like the uptime parameters giving some kind of server performance figures though.

good night

i will run this on my mac at home and see how it looks
maybe there needs to be a version that prints a larger font, ha ha.


« Last Edit: June 12, 2009, 04:15:50 AM by purvis »

Offline purvis

  • ****
  • 567
  • +0/-0
Re: monitoring status of disk redundacy and server uptime more simply
« Reply #48 on: June 15, 2009, 06:37:18 AM »
well sure enough, the first server in at an off site location had an unclean raid1 array.
reviewing options now while backing up


Offline purvis

  • ****
  • 567
  • +0/-0
Re: monitoring status of disk redundacy and server uptime more simply
« Reply #49 on: June 15, 2009, 11:20:52 PM »
i had the same problem as smeusr  in a post here
http://forums.contribs.org/index.php/topic,44094.0.html

He reported this below on this forum
Quote
    Hi, I just checked the health of my mirrored drives from the console and I got the following read out.

    -----------------------------------------
    Personalities : [raid1]
    md2 : active raid1 sdb2[1]
          312464128 blocks [2/1] [_U]

    md1 : active raid1 sda1[0] sdb1[1]
          104320 blocks [2/2] [UU]

    unused devices: <none>




a reply said to do this to correct the issue
Quote
mdadm -a /dev/md2 /dev/sda2


it corrected my problem, now i have this result form my php program above index.php on directory "/primary/serverstatus"

Quote
Server Status Report

Current date : 06-15-2009  16:18:24 CDT
    Location : Management office
    URL name : www.myurlserver.com
 Server name : server2
Hours uptime :  14:27
Active users :     0 users

***** RAID STATUS **********
Personalities : [raid1]
md2 : active raid1 sda2[0] sdb2[1]
      312464128 blocks [2/2] [UU]

md1 : active raid1 sda1[0] sdb1[1]
      104320 blocks [2/2] [UU]

unused devices:

***** DISK STATUS **********
Filesystem         Size  Used Avail Use% Mounted on
/dev/mapper/main-root
            292G   44G  233G   16% /
/dev/md1          99M   41M   53M   44% /boot
none            442M     0  442M    0% /dev/shm


---end of report---

A more detailed report is available here.

i was also able to easily monitor my raid rebuild about 70 miles, being i was working all night doing a backup, i did some remote control on the server by having a windows pc setup to manage the sme server and provide daily backups.

the rebuild took about 80 minutes.
Once other people got to the office this morning from a weekend, i showed them how to monitor the rebuild while i slept.  This is the thing i was talking about earlier when you can never perceive the usefulness of something the serverstatus web pages i created with help from many of you.  To have somebody help monitor the rebuild status and   also include the staff watching the rebuild, it sure made things easier for the acceptance of what was going on and a acceptance for the staff not to do any work until the rebuild was done. I was able to monitor the rebuild on my iphone as well, kool.
 








« Last Edit: June 15, 2009, 11:37:18 PM by purvis »

Offline janet

  • ****
  • 4,812
  • +0/-0
Re: monitoring status of disk redundacy and server uptime more simply
« Reply #50 on: June 16, 2009, 12:41:05 AM »
purvis

Quote
....and a acceptance for the staff not to do any work until the rebuild was done...

A degraded array is still functional.
An array being resynchronised is also still functional, and in either case the server can still be used by users.
Please search before asking, an answer may already exist.
The Search & other links to useful information are at top of Forum.

Offline purvis

  • ****
  • 567
  • +0/-0
Re: monitoring status of disk redundacy and server uptime more simply
« Reply #51 on: June 18, 2009, 12:12:10 PM »
Thanks Mary

The degraded array has gone on for 10 months, since September 3,2008. Gustav hurricane. No telling what actually happened with the power. Now the raid status is being monitored. A nice web browser home page is what 2 users are getting.

Offline bloodshoteye

  • ****
  • 232
  • +0/-0
  • Grateful thanks to SME devs
Re: monitoring status of disk redundacy and server uptime more simply
« Reply #52 on: June 24, 2009, 12:47:17 PM »
@purvis

Thanks for this - I'd buy you more than one beer if you lived in my neighborhood :)
- this is such a handy php script!!

Glad I stumbled across it.
Cheers,
SME Server is a fantastic product - thank you!

Offline chris burnat

  • ****
  • 1,135
  • +2/-0
    • http://www.burnat.com
Re: monitoring status of disk redundacy and server uptime more simply
« Reply #53 on: June 26, 2009, 10:27:10 AM »
This thread to refers to add-on software.
Moving to contribs section as requested.
- chris
If it does not work out of the box, please fill in a Bug Report @ Bugzilla (http://bugs.contribs.org)  - check: http://wiki.contribs.org/Bugzilla_Help .  Thanks.

Offline purvis

  • ****
  • 567
  • +0/-0
Re: monitoring status of disk redundacy and server uptime more simply
« Reply #54 on: July 19, 2009, 03:45:24 PM »
I would like to report back on my progress here with getting a report of the RAID1 condition and a few other things, such as files open in a SMB connection.


To get  the condition of a raid array on the sme server.
First, i built some bash scripts to create some txt files periodically that had information in them i wanted and place them into a webpage file. I started using file extensions of .PRN then changed to .TXT file extensions.  It was a learning experience for me as a beginner with linux, and where i as a user(admin)  has to copy procedures to get things going. 
But is soon found out how to use some simple php code to generated what i wanted into a web page servered by the sme server, which was far better and simpler.

I created a directory under the primary ibay called "'/home/e-smith/files/ibays/Primary/html/serverstatus"
I placed into the directory three php files that would run linux system commands and php commands to return minimum information, but important to me.

I used the chmod program to set the whole serverstatus directory to 777 which Charlie mentioned was some kind of  security issue, then i believe somebody mentioned 775. I think now i understand Charlie's concern but i have not had time to work with chmod command and i needed to get things a rolling on to get the job done, but i want to come back to the chmod 777 thing some time soon.

I like having the directory name set to serverstatus for reasons it makes it easier to set some policies on windows clients using IEURLLOCK to access the web server but that is another story.

All this has come from help from others but i would like to wrap it up here with the three php files i am now using.

"lgreport.php" is just an extended and more detailed report than what the first report "index.php" reports on. I am using index.php as the short report because i do not want anybody browsing my web page directory "serverstatus".  Who knows what i will put in there later. I also built a php file to report smb workstations longed on and open files on the server. This has been a big help in troubleshooting files left open with a little thing call "opportunistic file locking" and also just viewing what files are open and by whom for various other reasons. Do you know how hard it is to get files the opened and by who on a windows computer easily?

Naturally, like most users, we are running windows workstations. Here is how i am the using the web pages.
On the workstations, i created a directory called "C:\WEBPAGES", and placed two url shortcuts in the directory.

serverstatus.url
Code: [Select]
[InternetShortcut]
URL=http://192.168.1.191/serverstatus

filesopen.url
Code: [Select]
[InternetShortcut]
URL=http://192.168.1.191/serverstatus/sambausersopen.php

i have a batch file on every computer that performs all the setup after bootup

I placed the command "START C:\WEBPAGES\SERVERSTATUS.URL"  as one of the last commands in my batch file.
Now upon any bootup from a windows workstation, which should be done daily in the morning, the users can study the reports for a bad raid array and low disk space useage.

I placed a shortcut to the directory "C:\WEBPAGES" on each users desktop so that anybody could easily get to the webpages. Sure is better than favorites and can be used with any web browser.


Here are the php files i use and i left some extra code in there for testing that is commented out with "\\" characters that may or may not be useful to others.



index.php

Code: [Select]
<!--DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"-->

<html>

<head><title>Server Status</title></head>

<body>
<tt>
<b>
<div>
<?php
print "<pre>";
echo  
'<font size="4">';
print 
"Server Status Report\n";
print 
"\n";
print 
"Current date : ";
system("date +'%m-%d-%Y  %T %Z' | col -b",$return);
print 
"    URL name : ";
print  (
$_SERVER['SERVER_NAME']);
print 
"\n";
print 
" Server name : ";
system("uname -n | col -b",$return);


print 
"************** UPTIME ***************\n";
system("uptime | col -b",$return);
print 
"\n";

print 
"\n";
print 
"************** RAID STATUS **********\n";
system("cat /proc/mdstat | col -b",$return);
print 
"\n";

print 
"************** DISK STATUS **********\n";
system("df -h | col -b",$return);
//system("df  | col -b",$return);
print "\n";


print 
"\n---end of report---\n";
print 
"</pre>";
?>


<p>A more detailed report is <a href="lgreport.php">available here</a>.</p>
</div>
</body>
</html>

lgreport.php
Code: [Select]
<!--DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"-->

<html>

<head><title>Server Status</title></head>

<body>
<tt>
<b>
<div>
<?php
print "<pre>";
echo  
'<font size="4">';
print 
"Server Status Report\n";
print 
"\n";
print 
"Current date : ";
system("date +'%m-%d-%Y  %T %Z' | col -b",$return);
print 
"    URL name : ";
print  (
$_SERVER['SERVER_NAME']);
print 
"\n";
print 
" Server name : ";
system("uname -n | col -b",$return);

print 
"************** UPTIME ***************\n";
system("uptime | col -b",$return);
print 
"\n";

print 
"\n";
print 
"************** RAID STATUS **********\n";
system("cat /proc/mdstat | col -b",$return);
print 
"\n";

print 
"************** DISK STATUS **********\n";
// system("df -h | col -b",$return);
system("df  | col -b",$return);
print 
"\n";


print 
"************** ETHERNET PORT STATUS ******\n";
system("ifconfig | col -b",$return);
print 
"\n";

print 
"************** SERVER TYPE ***************\n";
system("uname -orp | col -b",$return);
print 
"\n";

print 
"************** SERVER MEMORY *************\n";
system("free  | col -b",$return);
print 
"\n";


// print "************** RPM PACKAGES INSTALLED ****\n";
// system("rpm -qa --last | col -b",$return);
// print "\n";

// print "************** UPDATES FOR INSTALLED PACKAGES ****\n";
// system("yum list updates | col -b",$return);
// print "\n";

// print "**************************************************\n";
// system("printenv  | col -b",$return);
// print "\n";

print "\n---end of report---\n";
print 
"</pre>";
?>

</div>
</body>

sambausersopen.php
Code: [Select]
<!--DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"-->

<html>

<head><title>Server Status</title></head>

<body>
<tt>
<b>
<div>
<?php
print "<pre>";
echo  
'<font size="4">';
print 
"Server Status Report\n";
print 
"\n";
print 
"Current date : ";
system("date +'%m-%d-%Y  %T %Z' | col -b",$return);
print 
"    URL name : ";
print  (
$_SERVER['SERVER_NAME']);
print 
"\n";
print 
" Server name : ";
system("uname -n | col -b",$return);

print 
"************** UPTIME ***************\n";
system("uptime | col -b",$return);
print 
"\n";

print 
"\n";

print 
"************** SMB STATUS ****************\n";
system("smbstatus | col -b",$return);
print 
"\n";

print 
"\n---end of report---\n";
print 
"</pre>";
?>

</div>
</body>
</html>

I had copied some code in the program to format the uptime information to something better, but it just did not work, so now i am coping out the return code of whatever sme server returns.

I do not know much about linux and somethings are very wierd, but i am finding out one thing. In linux "EVERTHING IS A FILE"

Now, at my office i can write a program to access these web pages one after another by either a web browser or a program i write to retrieve the web pages with a program to interpret the pages for my use.


« Last Edit: July 19, 2009, 03:53:20 PM by purvis »

Offline purvis

  • ****
  • 567
  • +0/-0
Re: monitoring status of disk redundacy and server uptime more simply
« Reply #55 on: July 19, 2009, 06:14:45 PM »
it would be nice to get the command smartctl to run from a php script, but the test i have done report a permission problem.
one command,  "smartctl -i /dev/sda" and "smartctl -i /dev/sdb" would show the raid1 drives serial number and help to identify the drive when a problem is detected.
there are other command such as "smartctrl -H /dev/sd?" does a quick test of the drives too.
Maybe somebody knows how to make it where these programs can be run from a php script.

Code: [Select]
<!--DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"-->

<html>

<head><title>Hard Drive Test</title></head>

<body>
<tt>
<b>
<div>
<?php
print "<pre>";
echo  
'<font size="4">';

print 
"\n";
print 
"***** RAID STATUS **********\n";
system("cat /proc/mdstat | col -b",$return);
print 
"\n";

print 
"***** DISK STATUS **********\n";
system("df  | col -b",$return);
print 
"\n";


print 
"********** dev/sda  information **********\n";
system("smartctl -i  /dev/sda | col -b",$return);
print 
"\n";

print 
"*** quick smartdrive test on dev/sda *****\n";
system("smartctl -H /dev/sda | col -b",$return);
print 
"\n";


print 
"</pre>";
?>

</div>
</body>
</html>


Thanks in advance.
paul