Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19
script to check log file....
Results 1 to 4 of 4

Thread: script to check log file....

  1. #1
    Mentor
    Join Date
    May 2001
    Location
    New Jersey
    Posts
    1,473

    script to check log file....

    hey guys,

    i need help writing a script to check a log file and then e-mail the output to me.

    so far is have this:

    #!/bin/bash
    less /var/log/file.log | grep smbd*


    ok, i want every line that starts with smbd from the file.log to be mailed to me. When i run this on the command line it works right but i'm stuck at geting it mailed to me.

    how do i do that? i have to direct it somewhere right?

    I want to run this as a cron job to run every hour.

  2. #2
    Senior Member
    Join Date
    Sep 2002
    Posts
    421

    Re:script to check log file....

    You can do something like this:
    {
    echo "To: You I guess <you@yourdomain.com>"
    echo "From: deamon <root@yourbox.com>"
    echo "Subject: Whatever"

    grep smbd /var/log/file.log #why use less when you already use grep?
    }|exim -bm your_addy@your_domain.com

    (or pipe it to sendmail -t if that's what you use)

    However, why re-invent the wheel? There are tons of logcheckers out there that do a very good job and don't just blindly mail you stuff a certain daemon spit out (though they can be configured to do that). I use logcheck myself as one means to monitor our servers. Try it.

  3. #3
    Mentor
    Join Date
    May 2001
    Location
    New Jersey
    Posts
    1,473

    Re:script to check log file....

    [quote author=demian link=board=9;threadid=8156;start=0#msg74172 date=1069282037]
    You can do something like this:
    {
    echo "To: You I guess <you@yourdomain.com>"
    echo "From: deamon <root@yourbox.com>"
    echo "Subject: Whatever"
    [/quote]

    thats what i was thinking of

    grep smbd /var/log/file.log #why use less when you already use grep?
    }|exim -bm your_addy@your_domain.com

    (or pipe it to sendmail -t if that's what you use)
    Mostly because i dont know what i'm doing.

    However, why re-invent the wheel? There are tons of logcheckers out there that do a very good job and don't just blindly mail you stuff a certain daemon spit out (though they can be configured to do that). I use logcheck myself as one means to monitor our servers. Try it.
    i do use logcheck but i just wanted something quick and dirty the check a change i made to samba.

    I didnt even think about making logcheck run every hour, i have it running once a day now, i just wanted something i could stick in cron for a couple of hours, thats all.

  4. #4
    Moderator
    Good Guru
    Schotty's Avatar
    Join Date
    Jul 2001
    Location
    Milwaukee, WI
    Posts
    5,760

    Re:script to check log file....

    Just shooting ideas out there; I used to do admin work as you recall (or not), and the method I used was several xterms all running various ssh sessions. I had ntop, logfile tails, firewall tails. I had one of each for 4 boxes. I ened up REALLY loving fluxbox (group tabs and name them) and totally getting a boner over shit like tabbed kterm/gnome-terminal. Makes alot better use of screen real-estate.

    I am assuming your box is using log rotation of some sort, in the morning review the previous day and just fire up a tail of the log current ... day/file/whatever.

    Anyhoo, thats what I did; it worked great for ME. I have no idea if it works well for you or not.

Similar Threads

  1. Script to check new email
    By kasparovcom in forum Linux - General Topics
    Replies: 1
    Last Post: 11-21-2011, 07:38 PM
  2. command in bash script to check if tar is currupt or not
    By expresstom in forum Linux - Software, Applications & Programming
    Replies: 2
    Last Post: 05-15-2011, 09:07 PM
  3. trouble with Apache File Permissions Script
    By Ed McCorduck in forum Programming
    Replies: 13
    Last Post: 03-13-2010, 11:17 AM
  4. Help with ctreating a script to track changes made to a file
    By sed_addictive in forum Redhat / Fedora
    Replies: 1
    Last Post: 06-10-2009, 01:20 PM
  5. Script for file backups
    By vwgtiturbo in forum Linux Distros
    Replies: 9
    Last Post: 08-11-2004, 04:44 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •