Monday, February 1, 2016

Logging and Emailing EMC ReceverPoint Journal Lag Alerts with ksh Script

rpa_stats.ksh

Each value passed the high and low watermarks cause a mail to be sent and also a log message to be writen.

#####BEGIN#####
 #!/bin/ksh
RPAUSER=username
RPAIP=10.11.12.16
RPAPREFIX=CG_
STATUSFILE=/home/aixadm/bin/rpa_stats.status.txt
RUNDIR=/home/aixadm/bin
FILENAME=rpa_stats.log
LOGFILE=$RUNDIR/$FILENAME
TMPLOGFILE=$LOGFILE.tmp
HIMARK=3400
LOMARK=250
LASTLAG=`cat $STATUSFILE`
MAXLOGSIZE_inKB=10000
MAILTO="T-DM-Systems@anti.com.tr,SANTeam@anti.com.tr"

# exec 2>/dev/null
exec 2>>/home/aixadm/bin/rpa.err.log
unalias rm
du -k $LOGFILE|read LOGSIZE fn
if [[ $LOGSIZE -gt $MAXLOGSIZE_inKB ]] then
  find $RUNDIR -name "$FILENAME.[0-9]*_[0-9]*[0-9]" -exec gzip {} \;
  find $RUNDIR -name "$FILENAME.*.gz" -mtime +30 -exec rm {} \;
  mv $LOGFILE $LOGFILE.`date '+%Y%m%d_%H%M%S'|tr -d '\n'`
fi

total_lag_gb=0
echo "\n"|ssh $RPAUSER@$RPAIP get_group_statistics|egrep "$RPAPREFIX.*|Journal lag"|sed '/CG_.*:/N;s/\n/ /'|grep "GB$"|sort -k4n|
while read cg j l lag
do
  if [[ $cg == "Journal" ]] then
    continue
  fi
  print $cg "\t\t" $lag >> $TMPLOGFILE
  lag_gb="`echo $lag|sed -e 's/GB//'`"
  total_lag_gb=`echo "scale=2\n$total_lag_gb+$lag_gb"|bc`
done
print "Total Copy Journal Lag: " $total_lag_gb >> $TMPLOGFILE

if [[ $total_lag_gb -gt $HIMARK && $LASTLAG -le $HIMARK ]] then
  print "The total copy cournal lag is more than the HIMARK=" $HIMARK " GBs" >> $TMPLOGFILE
  date >> $TMPLOGFILE
  echo "##################################################################################" >> $TMPLOGFILE
  $RUNDIR/postmail_HTML_RPA.pl "WARNING: The RPA Total Copy Journal Lag Has Exceeded The High Watermark" $MAILTO < $TMPLOGFILE
  cat $TMPLOGFILE >> $LOGFILE
  rm $TMPLOGFILE
  echo $total_lag_gb > $STATUSFILE
  exit
fi
if [[ $total_lag_gb -lt $HIMARK && $LASTLAG -ge $HIMARK ]] then
  print "The total copy cournal lag has gone below the HIMARK=" $HIMARK " GBs" >> $TMPLOGFILE
  date >> $TMPLOGFILE
  echo "##################################################################################" >> $TMPLOGFILE
  $RUNDIR/postmail_HTML_RPA.pl "INFO: The RPA Total Copy Journal Lag Has Gone Below The High Watermark" $MAILTO < $TMPLOGFILE
  cat $TMPLOGFILE >> $LOGFILE
  rm $TMPLOGFILE
  echo $total_lag_gb > $STATUSFILE
  exit
fi
if [[ $total_lag_gb -lt $LOMARK && $LASTLAG -ge $LOMARK ]] then
  print "The total copy cournal lag is less than the LOMARK=" $LOMARK " GBs" >> $TMPLOGFILE
  date >> $TMPLOGFILE
  echo "##################################################################################" >> $TMPLOGFILE
  $RUNDIR/postmail_HTML_RPA.pl "OK: The RPA Total Copy Journal Lag Has Gone Below The Low Watermark" $MAILTO < $TMPLOGFILE
  cat $TMPLOGFILE >> $LOGFILE
  rm $TMPLOGFILE
  echo $total_lag_gb > $STATUSFILE
  exit
fi
if [[ $total_lag_gb -gt $LOMARK && $LASTLAG -le $LOMARK ]] then
  print "The total copy cournal lag has exceeded the LOMARK=" $LOMARK " GBs" >> $TMPLOGFILE
  date >> $TMPLOGFILE
  echo "##################################################################################" >> $TMPLOGFILE
  $RUNDIR/postmail_HTML_RPA.pl "INFO: The RPA Total Copy Journal Lag Has Exceeded The Low Watermark" $MAILTO < $TMPLOGFILE
  cat $TMPLOGFILE >> $LOGFILE
  rm $TMPLOGFILE
  echo $total_lag_gb > $STATUSFILE
  exit
fi
echo $total_lag_gb > $STATUSFILE
cat $TMPLOGFILE >> $LOGFILE
rm $TMPLOGFILE
date >> $LOGFILE
echo "##################################################################################" >> $LOGFILE
######END#####





postmail_HTML_RPA.pl

#####BEGIN#####
 #!/usr/bin/perl
#$ENV{'LANG'} = 'tr_TR';
#system("export LANG=tr_TR");
#   $_[0] --> Subject
#   $_[1] --> Mail Address
#   Stdin --> Body

  $SMTPSERVER = "tekno3.fw.tekno.com.tr";
  #$SMTPSERVER = "mailse3.anti.com.tr";
  $MAILFROM   = "T-DM Systems ";
  $_[0] = $ARGV[0];
  $_[1] = $ARGV[1];

  if ( $_[1] eq "" || $_[1] eq " " ) { exit;}
#  if ( ! -s $_[2] ) { exit(0) };
  $| = 1;
  open(STDERR, "> /dev/null");

  use Net::SMTP;
#  print "Content-type: text/html", "\n\n";

  $smtp = Net::SMTP->new($SMTPSERVER,Timeout => 15, Debug => 1);
  if ( ! $smtp ) { return; }
        die "Couldn't connect to server" unless $smtp;

  $MAILTO=$_[1];

  $smtp->mail( $MAILFROM );

  # .... Send Mail to related receivers
  @RCVR = split(/,/,$_[1]);
  foreach $receiver (@RCVR)
  {
    $smtp->to( $receiver );
  }


  # Start the mail
  $smtp->data();

  # Send the header
  $smtp->datasend("To: ".$MAILTO."\n");
  $smtp->datasend("From: ".$MAILFROM."\n");
  $smtp->datasend("Subject: ". $_[0] ."\n");
  $smtp->datasend("MIME-Version: 1.0\n");
  $smtp->datasend("Content-type: text/html\n\n");
  $smtp->datasend("\n");

  #$smtp->datasend( $_[2]);
  foreach $satir ( ) {                  #stdin'den geleni gonder
    $smtp->datasend( $satir."
\n" );
  }

  # Send the termination string
  $smtp->dataend();
  # Close the connection
  $smtp->quit();

######END#####

Printing EMC ReceverPoint Journal Lag with ksh Script

 rpa_stats_simple.ksh

#!/bin/ksh
RPAUSER=username
RPAIP=10.11.12.13
#RPAPREFIX is the standart prefix generally used before consistency group name
RPAPREFIX=CG_

total_lag_gb=0
echo "\n"|ssh $RPAUSER@$RPAIP get_group_statistics|egrep "$RPAPREFIX.*|Journal lag"|sed '/CG_.*:/N;s/\n/ /'|grep "GB$"|sort -k4n|
while read cg j l lag
do
  print $cg "\t\t" $lag
  lag_gb="`echo $lag|sed -e 's/GB//'`"
  total_lag_gb=`echo "scale=2\n$total_lag_gb+$lag_gb"|bc`
done
print "Total Copy Journal Lag: " $total_lag_gb
if [[ $total_lag_gb -gt 2900 ]]; then
  print "Total copy cournal lag is more than 2900 GBs"
fi
date

"FAILED pre-installation verification" during VIOS upgrade (updateios)

While trying to upgrade to VIOS 2.2.4.10 from 2.2.2.1 I got weird error messages about the missing filesets. There was two kinds of error messages on different VIO servers like those:

/usr/ios/cli/ioscli updateios -dev /mnt -accept -install


FAILURES
--------
  Filesets listed in this section failed pre-installation verification
  and will not be installed.

  Missing Filesets
  ----------------
  The following filesets could not be found on the installation media.
  If you feel these filesets really are on the media, check for typographical
  errors in the name specified or, if installing from directory, check for
  discrepancies between the Table of Contents file (.toc) and the images that
  reside in the directory.

    b                                       
    b                                       
    b                     

    p                                       
    p                                       

  << End of Failure Section >>

+-----------------------------------------------------------------------------+
                   BUILDDATE Verification ...
+-----------------------------------------------------------------------------+
Verifying build dates...done
FILESET STATISTICS
------------------
  228  Selected to be installed, of which:
      228  FAILED pre-installation verification

####################
/usr/ios/cli/ioscli updateios -dev /mnt -accept -install

0503-019 installp:  Implementation is an invalid level.
        ALL levels must be in one of the following formats: 
                vv.rr.mmmm.ffff OR vv.rr.mmmm.fffff.ppppppppp

    mit.script                              
    mit.script                              
    +                                       

  << End of Failure Section >>

+-----------------------------------------------------------------------------+
                   BUILDDATE Verification ...
+-----------------------------------------------------------------------------+
Verifying build dates...done
FILESET STATISTICS
------------------
  208  Selected to be installed, of which:
      208  FAILED pre-installation verification
  ----


SOLUTION:
I discovered two old timed files in /tmp. Removing them solved the problem in one type of systems. On the others removing all /tmp content cleared the problem.

cd /tmp
ls -l .list_filesets.*
-rw-r--r--    1 root     staff          1580 Dec 27 2011  .list_filesets.out
-rw-r--r--    1 root     staff          1238 Dec 27 2011  .list_filesets.toc

rm .list_file*
/usr/ios/cli/ioscli updateios -dev /mnt -accept -install

Friday, November 6, 2015

nnmon 11 released by BİÇDA

nnmon is a central database and a web interface for the nmon program's data. It's completely free software and released under GPLv3.

The first version was ready on 10/25/2010 for internal use of my employer company and the first publicly released version was 0.4 with the date of 06/29/2011.

On the central database side, both many kinds of UNIXs can be used. It needs a Postgresql DB, python script environment and psycopg2 Phyton Postgresql module. Refer to the README.md and INSTALL files for further information.

Client side is a simple Perl script which runs nmon in the file output mode and sends data to the server via TCP socket. It is tested on many versions of AIX, Solaris and different Linux distributions.

Web interface is a pure php application with a client tree on the left hand side and visual 2D graphs on the right.





For authentication it is possible to use two different LDAP (Active Directory) servers at the same time and user name based access list control from DB table is implemented and also documented in the INSTALL file.

For downloading the files use the command below or the package download URL.

git clone --branch v11.0 https://github.com/bilisimcalisanlari/nnmon.git

Git clone URL: https://github.com/bilisimcalisanlari/nnmon.git
Download URL: https://github.com/bilisimcalisanlari/nnmon/archive/v11.0.tar.gz

To begin the installation you must first read the INSTALL file.


https://www.facebook.com/bicda
ozelbaris@gmail.com

Sunday, December 26, 2010

Add Subtitle to an Avi in a Black Rectangle with Mencoder

With the command below it is possible to add a subtitle to a movie which allready had a subtitle  embedded. It is impossible to make readable a second subtitle on it without this command.

Not: This works on Linux OS.

mencoder -oac copy -ovc xvid -xvidencopts fixed_quant=3 -sub-bg-alpha 1 -subpos 90 -subcp cp1254 -sub "Akira.Kurosawa.Seven.Samurai.1.sub" -o "a1.avi" "Akira.Kurosawa.Seven.Samurai.1.avi"

-sub-bg-alpha 1 (Draws a black rectangle, 150 draws semi transparant rect.)
-subpos 90 ( 90 is the bottom, 50 is the middle of the screen)
-subcp cp1254 ( For Turkish encoding )

Monday, June 21, 2010

Sample emms .emacs configuration

You should install mp3info linux package with emms, if you want to see the song title instead of filename with the full path. For Ubuntu it is;
sudo apt-get install emms mp3info

Below configuration prints the song title if exists, else it removes the path info and displays only filename on the mod-line. And also it defines some global keys and auto loads a playlist.

(display-time)
(require 'emms)
(require 'emms-setup)
(emms-default-players)
(emms-standard)
(emms-all)
(require 'emms-player-simple)
(require 'emms-source-file)
(require 'emms-source-playlist)
(setq emms-info-asynchronously nil)
(setq emms-player-list '(emms-player-mpg321
emms-player-ogg123
emms-player-mplayer))

;;(require 'emms-mode-line)
;;(emms-mode-line 1)
(require 'emms-playing-time)
(emms-playing-time 1)

(setq emms-mode-line-mode-line-function
(lambda nil
(let ((track (emms-playlist-current-selected-track)))
(let ((title (emms-track-get track 'info-title)))
(let ((name (emms-track-get track 'name)))
(if (not (null title))
(format emms-mode-line-format title)
(if (not (null (string-match "^url: " (emms-track-simple-description track))))
(format emms-mode-line-format "Internet Radio")
(setq name2 (replace-regexp-in-string ".*\/" "" name))
(format emms-mode-line-format name2))))))))
(emms-mode-line-disable)
(emms-mode-line-enable)
(load "emms")
(global-set-key (kbd "C-c p") 'emms-pause)
(global-set-key (kbd "C-c u") 'emms-volume-raise)
(global-set-key (kbd "C-c d") 'emms-volume-lower)
(global-set-key (kbd "C-c f") 'emms-show)
(global-set-key (kbd "C-c n") 'emms-next)
(global-set-key (kbd "C-c P") 'emms-previous)
(global-set-key (kbd "C-c r") 'emms-random)
(global-set-key (kbd "C-c s") 'emms-stop)
(autoload 'emms "/home/barol/mp3/sample.mp3" t) ;;must be valid path
(emms-add-playlist "/home/barol/sample.playlist")
(emms-shuffle)

Thursday, January 7, 2010

Connect to AIX 6.1 with XDMCP Query

Remote dtlogin is disabled in AIX 6.1. To make dtlogin listen UDP 177 port for remote connections, you have to make following modifications.

1. Comment out this line in the /usr/lib/X11/xdm/xdm-config
DisplayManager.requestPort: 0

2. Comment out these three lines in the /usr/lib/X11/xdm/Xaccess
* #any host can get a login window
* CHOOSER BROADCAST #any indirect host can get a chooser
LISTEN * ff02:0:0:0:0:0:0:12b

3. Comment the "local" line and add
:0 foreign /usr/lpp/X11/defaults/xserverrc -T -force :0

4. Be sure X11.Dt filesets are installed.

5. startsrc -s dtsrc

6. ps -ef|grep dtlogin
netstat -an|grep 177
tail /var/dt/Xerrors

If everything is ok, you can try it with Exceed or from a Linux PC's xterm "X :0 -query IP".

Ignore "A graphics adapter was not found." errors. You can get rid of it by adding "DT_NO_DISPLAY_CHECK=true" to /etc/environment.

dtlogin listens the UDP 177 port, then redirects connection back to the source's 6000 port.