Koozali.org: home of the SME Server

monitoring status of disk redundacy and server uptime more simply

Offline purvis

  • ****
  • 567
  • +0/-0
Hi everyone !

Seems a few things are becoming more easier and some things are just getting harder and more difficult.
I have been running sme server as a server for some time now and i would like to try to automate a few things that for some of you out there is probably a piece of cake in the sme server linux world.

I do not have a list but most things would be in a linux environment.
Two things would be very helpful, get the disk redundacy status and server status(server uptime) into two individual text files. I guess  an automated process by a cron method would be the best way to go. Hummm, i have no idea what a cron is but reason says it is a batch process that is run at a particular time or mutilple times of the day.

I have books on linux but it would be nice to have first a helping hand on something simple from this forum being it is going to run on a sme server.

So to start with something simple. Have every hour a program to report the server uptime into a text file then have the same text file copied to a directory where it can be read by a web browser. So the steps would be.
1.run a script at a particular time
2.script creates a directory if one does not exist to place the text file
3.script writes some information into the text files such as a heading for the server and current date and time 
4.script runs some program to attain the server uptime and outputs the information into a text file
5.script creates a web directory to hold the text file if it does not exist.
6 script copies the text file created to the webpage directory
7 script ends

The second process would do something similiar, but get the disk redundacy status.


A later process could read the text files and do something, specially on the disk redundacy status if there where some problem showing, like maybe have a cron send an email to report a problem.

A good idea would also be a way of turning off  a cron  scripted program with a file being used as a flag to abort the script or email being sent.

I have been thinking about this for years and it is time act, now that todays phones have easy access to the web and we can be john on the spot when trouble come our way or we just want to check on processes remotely that usually have no security issues.


 
Thanks for any help on these subjects.







Offline CharlieBrady

  • *
  • 6,918
  • +3/-0
Re: monitoring status of disk redundacy and server uptime more simply
« Reply #1 on: June 10, 2009, 02:05:03 AM »
RAID status is emailed to you immediately it changes - why would you want anything else?

Why are you concerned about system uptime?

Offline purvis

  • ****
  • 567
  • +0/-0
Re: monitoring status of disk redundacy and server uptime more simply
« Reply #2 on: June 10, 2009, 02:50:29 AM »
Charlie that is GREAT news but i have a problem with that in that emails are rarely read because there seems to be so much other insignificant emails coming from the servers, plus not all my servers are setup where i can easily get to the emails.

Even if they where emailed, it would seem i might want to choose different email accounts, etc, etc.

I also have windows workstations that read files from the server as well, and these computers can be setup to read files to tell if there is something wrong.

I have my reasons.

I have found the echo, date, uptime command. i just need help with the automation part that will give me a start.



Offline CharlieBrady

  • *
  • 6,918
  • +3/-0
Re: monitoring status of disk redundacy and server uptime more simply
« Reply #3 on: June 10, 2009, 04:51:35 AM »
Even if they where emailed, it would seem i might want to choose different email accounts, etc, etc.

You can choose to have the emails forwarded to any email account you nominate.

It seems that you haven't read the documentation very well. I suggest you read it at least twice more.

Offline purvis

  • ****
  • 567
  • +0/-0
Re: monitoring status of disk redundacy and server uptime more simply
« Reply #4 on: June 10, 2009, 04:54:14 AM »
ok i created a script file called webstatus1 that creates the file "status1.prn"  in a folder called "/home/e-smith/files/primary/html/serverstatus"

it writes this report that is easy to read on my iphone web browser ............
-------------------------------------------------------------
Server Status Report

Location: Management Office
Name: server0
Date of Report:
Tue Jun  9 22:38:49 CDT 2009

Uptime:
 22:38:49 up  5:56,  1 user,  load average: 0.00, 0.00, 0.00

Disk Redundacy Status:
Personalities : [raid1]
md2 : active raid1 sda2[0] sdb2[1]
      245007232 blocks [2/2] [UU]
     
md1 : active raid1 sda1[0] sdb1[1]
      104320 blocks [2/2] [UU]
     
unused devices: <none>

--end of report--

---------------------------------------------------------

the script to write the file and placedin the "/usr/sbin" directory
script name is "webstatus1"
----------------------------------------------------------------------------------------------------------
#!/bin/sh
mkdir /home/e-smith/files/primary/html/serverstatus
echo "Server Status Report"  > /home/e-smith/files/primary/html/serverstatus/status1.prn
echo ""  >> /home/e-smith/files/primary/html/serverstatus/status1.prn
echo "Location: Management Office" >> /home/e-smith/files/primary/html/serverstatus/status1.prn
echo "Name: server0"  >> /home/e-smith/files/primary/html/serverstatus/status1.prn
echo "Date of Report:" >> /home/e-smith/files/primary/html/serverstatus/status1.prn
date     >> /home/e-smith/files/primary/html/serverstatus/status1.prn
echo ""  >> /home/e-smith/files/primary/html/serverstatus/status1.prn
echo "Uptime: "  >> /home/e-smith/files/primary/html/serverstatus/status1.prn
uptime   >> /home/e-smith/files/primary/html/serverstatus/status1.prn
echo ""  >> /home/e-smith/files/primary/html/serverstatus/status1.prn
echo "Disk Redundacy Status:"  >> /home/e-smith/files/primary/html/serverstatus/status1.prn
cat /proc/mdstat   >> /home/e-smith/files/primary/html/serverstatus/status1.prn
echo ""  >> /home/e-smith/files/primary/html/serverstatus/status1.prn
echo "--end of report--" >> /home/e-smith/files/primary/html/serverstatus/status1.prn
-----------------------------------------------------------------------------------------------



Inside the  /etc/cron.hourly directory i create a file with the command "echo > webstatus1".
Now i will pray it works.







« Last Edit: June 10, 2009, 05:42:45 AM by purvis »

Offline mercyh

  • *
  • 824
  • +0/-0
    • http://mercyh.org
Re: monitoring status of disk redundacy and server uptime more simply
« Reply #5 on: June 10, 2009, 04:38:02 PM »
It doesn't get much more simple than this. (This does need to run on a windows machine)

http://wiki.contribs.org/Netkeeper_Remote_Server_Monitor


Offline CharlieBrady

  • *
  • 6,918
  • +3/-0
Re: monitoring status of disk redundacy and server uptime more simply
« Reply #6 on: June 10, 2009, 05:13:19 PM »
Inside the  /etc/cron.hourly directory i create a file with the command "echo > webstatus1".
Now i will pray it works.

Praying doesn't work. And neither will creating a webstatus1 file which contains nothing but a blank line.

Perhaps you mean:

echo /usr/sbin/webstatus1 > /etc/cron.hourly/webstatus1

Your script, BTW, will be more readable and maintainable if you do:

#!/bin/sh
mkdir -p /home/e-smith/files/primary/html/serverstatus
exec >/home/e-smith/files/primary/html/serverstatus/status1.prn
echo "Server Status Report"
echo
echo "Location: Management Office"
...

Offline electroman00

  • ****
  • 491
  • +0/-0
Re: monitoring status of disk redundacy and server uptime more simply
« Reply #7 on: June 10, 2009, 09:20:35 PM »
purvis good start and excellent concept.

Suggested Improvements.........sys_status.sh

Code: [Select]
#!/bin/sh

 # ========= System Status ===================
 clear
 
 # Initialize variables
 #f_path=/home/e-smith/files/primary/html/serverstatus
 f_path=/tmp
 f_name=status1.dat
 location="Management Office"
 server_name="Server 0"
 
 # create & change to status directory if not exist
 
 if [ ! -d $f_path ]; then
 echo "===== MKDIR >>" $f_path
 mkdir -p $f_path
 fi
 echo "===== CD >>" $f_path
 cd $f_path
 
 # server status
echo "Server Status Report"  > $f_path/$f_name

echo "Location: " $location >> $f_path/$f_name

echo "Server Name: " $server_name >> $f_path/$f_name

echo "Snapshot Time: " `date` >> $f_path/$f_name

echo "Uptime: " `uptime` >> $f_path/$f_name

echo "*********** Raid Status ***********"  >> $f_path/$f_name
cat /proc/mdstat >> $f_path/$f_name

echo "*********** Network Status ***********"  >> $f_path/$f_name
ifconfig >> $f_path/$f_name

echo "--End of Report--" >> $f_path/$f_name

# Print the Status Report to the console
cat $f_path/$f_name


Go for it.... :smile:

hth

Offline electroman00

  • ****
  • 491
  • +0/-0
Re: monitoring status of disk redundacy and server uptime more simply
« Reply #8 on: June 10, 2009, 09:35:21 PM »
You could also add....

Code: [Select]
echo "*********** Drive/s Status ***********"  >> $f_path/$f_name
df >> $f_path/$f_name

hth  :smile:

Offline Stefano

  • *
  • 10,836
  • +2/-0
Re: monitoring status of disk redundacy and server uptime more simply
« Reply #9 on: June 10, 2009, 09:43:53 PM »
@purvis and all: you don't need such a script..

Code: [Select]
yum install logwatch
man logwatch

regarding
Quote
in that emails are rarely read because there seems to be so much other insignificant emails coming from the servers

- there's no insignificant mails form the server and ignoring what server tell you could be a big error
- in case of raid failure you will receive a mail that you can't ignore

my 2c
Stefano

Offline electroman00

  • ****
  • 491
  • +0/-0
Re: monitoring status of disk redundacy and server uptime more simply
« Reply #10 on: June 10, 2009, 09:53:49 PM »
Just brain farting here a little, hth...

You could change this line

Code: [Select]
echo "Server Status Report"  > $f_path/$f_name
to

Code: [Select]
echo "Server Status Report for $HOSTNAME"  > $f_path/$f_name
hth & more fun


Offline electroman00

  • ****
  • 491
  • +0/-0
Re: monitoring status of disk redundacy and server uptime more simply
« Reply #11 on: June 10, 2009, 10:30:56 PM »
Stefano

You forgot to link to your wiki howto for logwatch.

Offline CharlieBrady

  • *
  • 6,918
  • +3/-0
Re: monitoring status of disk redundacy and server uptime more simply
« Reply #12 on: June 10, 2009, 10:41:11 PM »
@purvis and all: you don't need such a script..

They don't believe me - why would they believe you? :-)

Offline electroman00

  • ****
  • 491
  • +0/-0
Re: monitoring status of disk redundacy and server uptime more simply
« Reply #13 on: June 10, 2009, 10:43:07 PM »
They don't believe me - why would they believe you? :-)

Do believe you missed the OP's point.

Offline Stefano

  • *
  • 10,836
  • +2/-0
Re: monitoring status of disk redundacy and server uptime more simply
« Reply #14 on: June 10, 2009, 10:54:01 PM »
They don't believe me - why would they believe you? :-)

"repetita iuvant", Charlie ;-)