Tuesday 20 December 2016

Solaris syslog monitoring script.

1)Configure all system logs to single file i.e /var/adm/messages

vi /etc/syslog.conf
##ident "@(#)syslog.conf        1.5     98/12/14 SMI"   /* SunOS 5.0 */
##
## Copyright (c) 1991-1998 by Sun Microsystems, Inc.
## All rights reserved.
##
## syslog configuration file.
##
## This file is processed by m4 so be careful to quote (`') names
## that match m4 reserved words.  Also, within ifdef's, arguments
## containing commas must be quoted.
##
#*.err;kern.notice;auth.notice                  /dev/sysmsg
#*.err;kern.debug;daemon.notice;mail.crit       /var/adm/messages
#
#*.alert;kern.err;daemon.err                    operator
#*.alert                                                root
#
#*.emerg                                                *
#
## if a non-loghost machine chooses to have authentication messages
## sent to the loghost machine, un-comment out the following line:
#auth.notice                    ifdef(`LOGHOST', /var/log/authlog, @loghost)
#
#mail.debug                     ifdef(`LOGHOST', /var/log/syslog, @loghost)
#
##
## non-loghost machines will use the following lines to cause "user"
## log messages to be logged locally.
##
#ifdef(`LOGHOST', ,
#user.err                                       /dev/sysmsg
#user.err                                       /var/adm/messages
#user.alert                                     `root, operator'
#user.emerg                                     *
#)
*.debug                                         /var/adm/messages
~
:wq!




#svcadm refresh system-log
#svcadm restart system-log


2)deploy server script on  centeral server.

server script:-

#!/bin/bash
#########################################
######### ################SCRIPT#######
##########SYS LOGS INFO##############
#####VERSION=1.0############################
##DESIGN&IMPLEMENTED:CHITTIBABU MIRIYALA#
#########################################
echo "From:chitti.babu@gmail.com" >"/tmp/syslog_output"
echo "To:chitti.babu@yahoo.com" >"/tmp/syslog_output"
echo "Subject:SOLARIS SERVERS SYSLOG  ">>"/tmp/syslog_output"
echo "Content-type: text/html">>/tmp/syslog_output
echo "<html>">>"/tmp/syslog_output"
echo "<body>">>"/tmp/syslog_output"
echo "<table>">>"/tmp/syslog_output"
for i in `cat /opt/scripts/solaris_list`
do
echo "<tr bgcolor=#FFB6C1><td align=center> $i</td></tr>"  >>"/tmp/syslog_output"
echo "<tr><td><pre>" >> "/tmp/syslog_output"
ssh -q $i '/opt/scripts/syslogs_client.sh'>>"/tmp/syslog_output"
echo "</pre></td></tr>" >> "/tmp/syslog_output"
done
#/bin/dmesg|grep ^"`date \"+%b %e\"`"|egrep -v "xntp|keyboard|wrong magic number|mail|auth.info|ntpdate|repeated|Duplicate|bpcd|Plugin">>"/tmp/syslog_output"
echo "</table>" >>"/tmp/syslog_output"
echo "</body>">>"/tmp/syslog_output"
echo "</html>">>"/tmp/syslog_output"
cat "/tmp/syslog_output"|/usr/sbin/sendmail -t
>"/tmp/syslog_output"





3)deploy client script on all clients

client script:-

# cat syslogs_client.sh
#!/bin/bash
#########################################
######### ################SCRIPT#######
##########SYS LOGS INFO##############
#####VERSION=1.0############################
##DESIGN&IMPLEMENTED:CHITTIBABU MIRIYALA#
#########################################
/bin/dmesg|grep ^"`date \"+%b %e\"`"|egrep -v "xntp|keyboard|wrong magic number|mail|auth.info|ntpdate|repeated|Duplicate|bpcd|Plugin"



No comments:

Post a Comment