Tiny Core Linux

Tiny Core Extensions => TCE Talk => Topic started by: remus on February 19, 2012, 11:25:12 PM

Title: Server monitoring with email alerts
Post by: remus on February 19, 2012, 11:25:12 PM
Hi all,

The tinycore based samba server is up and running for two weeks now, and is working well.
I've tested a few different combinations of tinycore and samba and have come up with the following stable recipie.

Tinycore v 3.8.4
Samba v 3.4.5

I'm storing my tce folder on a small partition I created as our community centre does not have enough usb flash drives to spare.

Bit of forum searching uncovered the tce-setdrive command, which allowed me to set the tce folder without the gui :)

I am going on a trip with the church in April to a hospital they are setting up in the solomon islands and am considering installing tinycore+samba as a file server for them. Does anyone know if there is a tc extension that sends regular system status via email ? I've found nagios with google, and it looks ok, if there is nothing already available, i'll make it into an extension. They have internet via satellite at the site.
Title: Re: Server monitoring with email alerts
Post by: Rich on February 19, 2012, 11:46:15 PM
Hi remus
Depending on what you are trying to do, you might be able  to set up a script to gather the information you wish
to monitor. Use  cron  to run it once a day, and possibly  alpine  to send an email.
Title: Re: Server monitoring with email alerts
Post by: remus on February 20, 2012, 01:32:39 AM
Hi Rich,
I guess I could do it with shell scripts.

I have a bit of learning to do here.
- enabling emailing in tinycore
- gathering system status, samba logs, hard drive health status
- emailing it out of tinycore

Hmm looks achievable.

Whats the best approach to gathering system satus information, and putting it into an email ?
Title: Re: Server monitoring with email alerts
Post by: Rich on February 20, 2012, 01:52:27 AM
Hi remus
It depends on what kind of data you wish to gather. In general, the script would start by creating a temporary
work directory.
1. mkdir workdirectory
2. Copy any required log files to it.  (Samba, dmesg > filename, syslog, etc.)
3. Use the hdparm utility for drive information   (hdparm [switches] > filename)
4. Use ifconfig > filename  to check for excessive network errors
5. tar zcf workdirectory.tar.gz workdirectory   (assumes you are just above workdirectory when executed)

That should give you a starting point. Sorry, I don't have any experience with automating emails, maybe
someone else will offer some advice.
Title: Re: Server monitoring with email alerts
Post by: bmarkus on February 20, 2012, 02:14:58 AM
Try logwatch http://sourceforge.net/projects/logwatch/ (http://sourceforge.net/projects/logwatch/)

Unfortunately it is not in the repo but it is written in Perl, so no need to compile.
Title: Re: Server monitoring with email alerts
Post by: remus on February 21, 2012, 10:34:29 PM
Thanks for the Logwatch link, I'll check it out tonight.

Heres another tool that looks interesting: http://mmonit.com/monit/ (http://mmonit.com/monit/)
I've started the build process and ran into problem's, I'll post some of the error messages when i get home tonight.
Title: Re: Server monitoring with email alerts
Post by: remus on February 22, 2012, 02:02:06 AM
I got a bunch of odd make errors when I tried to build monit, sorry but I'll post proper examples when I get home, it had something to do with   PAM   is that a part of an existing extension ?
Title: Re: Server monitoring with email alerts
Post by: Rich on February 22, 2012, 02:06:07 AM
Hi remus
There is the  Linux-PAM.tcz  extension as well as the  dev  version.
Title: Re: Server monitoring with email alerts
Post by: remus on February 22, 2012, 07:37:51 AM
How did you find that Rich ?
I searched for pam and PAM with ab with no luck.
I just now tried with the wild card *PAM and *pam but that did not work. Experimented with wild cards and they do seem to work

In the past I've browsed the repository here : http://distro.ibiblio.org/tinycorelinux/4.x/x86/tcz/ (http://distro.ibiblio.org/tinycorelinux/4.x/x86/tcz/) but that takes a bit of bandwidth to load.
Title: Re: Server monitoring with email alerts
Post by: Rich on February 22, 2012, 10:53:07 AM
Hi remus
In this case I used the provides function to search for pam. That function searches for a match anywhere in the files list.
Just be aware that this type of search can return many other extensions as well.
Title: Re: Server monitoring with email alerts
Post by: remus on February 22, 2012, 06:18:56 PM
Can you give me an example ?

I've googled "Linux provides function" which returns a staggering amount of hits about how great linux is :) but nothing about how to search through the repository file list.
Title: Re: Server monitoring with email alerts
Post by: gerald_clark on February 22, 2012, 06:34:59 PM
Linux does not have a provides function.
Perhaps your time would be better spent reading the wiki and searching the fora.
Title: Re: Server monitoring with email alerts
Post by: Rich on February 22, 2012, 08:49:10 PM
Hi remus
Sorry, I left out the part  about opening AppBrowser, and then changing the search button to  Provides.
Title: Re: Server monitoring with email alerts
Post by: remus on February 23, 2012, 02:58:31 AM
Thanks Rich.
Title: Re: Server monitoring with email alerts
Post by: vinnie on February 23, 2012, 04:16:24 AM
OT:  In a little we will have the tag and this should not happen again!  :D
Title: Re: Server monitoring with email alerts
Post by: remus on March 06, 2012, 06:48:37 AM
monit.tcz has been added to the repo.

I'm going through the monit documentation and it says

Code: [Select]
Using init to start Monit is probably the best way to run Monit if you want to be certain that you always have a running Monit daemon on your system.

To setup Monit to run from init, you can either use the set init statement in Monit's control file or use the -I option from the command line. Here is what you must add to /etc/inittab:

  # Run Monit in standard run-levels
  mo:2345:respawn:/usr/local/bin/monit -Ic /etc/monitrc
After you have modified init's configuration file, you can run the following command to re-examine /etc/inittab and start Monit:

  telinit q
For systems without telinit:

  kill -1 1

I was just adding "sudo monit" to the /opt/bootlocal.sh file and that seems to work just fine.

I found this about init
Definition: Init: The first process to run immediately after the operating system loads. It starts the system in single-user mode or spawns a shell to read the startup files, and opens ports designated as login ports.


Any comments about this would be appreciated.
Title: Re: Server monitoring with email alerts
Post by: Rich on March 06, 2012, 10:39:43 AM
Hi remus
That sounds like the right way to go, though you don't need to use sudo.
The calling sequence goes:
Code: [Select]
/init->/etc/inittab->/etc/rcS->/etc/init.d/tc-config->/opt/bootsync.sh->/opt/bootlocal.shIf the sequence fails before reaching  bootsync.sh  or  bootlocal.sh  you won't have network support.
Without the network, monit can not send an email, so placing it in  inittab  won't really buy you anything.
Even if you wanted to modify inittab and add it to your backup, I don't know if the restore function
occurs early enough in the boot process for that to work.