Automation tool

I’m always looking for ways to help in automation. A friend pointed this one out. Much easier than writing a python script to parse dynamic web content. Siculi

xymon client init.d script

#!/sbin/sh
#
case "$1" in
start)
        [ -f /opt/cmtools/xymon/client/runclient.sh ] || exit 0
        su - cmuser  -c "/opt/cmtools/xymon/client/runclient.sh start --hostname=cmssbea10.my.domain"
        ;;
stop)
        su - cmuser -c "/opt/cmtools/xymon/client/runclient.sh stop --hostname=cmssbea10.my.domain"
        ;;
*)
        echo "Usage: $0 { start | stop }"
        exit 1
        ;;
esac
exit 0

Xymon on Solaris 10 containers & see minimum one second step error

Source

You are running Xymon in Solaris 10 containers & see the following logs:

2010-08-27 15:19:30 RRD error updating /opt/csw/xymon/data/rrd/buildbox1/ifstat.mac.rrd from 169.169.169.169: /opt/csw/xymon/data/rrd/cmsys2/ifstat.mac.rrd: illegal attempt to update using time 1282947570 when last update time is 1282947570 (minimum one second step)
2010-08-27 15:19:30 RRD error updating /opt/csw/xymon/data/rrd/buildbox1/ifstat.mac.rrd from 169.169.169.169: /opt/csw/xymon/data/rrd/cmsys2/ifstat.mac.rrd: illegal attempt to update using time 1282947570 when last update time is 1282947570 (minimum one second step)

The problem is Xymon client can send 2 pairs of data at the same timestamp.

Find the line in your xymon file

/usr/bin/kstat -p -s '[or]bytes64'

Change it to:

/usr/bin/kstat -p -s '[or]bytes64' | egrep -v 'wrsmd|mac' | sort

BIND server setup

Note: Our IP range is 192.168.0.0/24
This instruction set is based upon this range. Therefore anywhere you see this number, you may replace with your IP range.

  1. CD into working dir
    user@box:/# cd /etc/bind
  2. Backup the origininal
    ?user@box:/# cp named.conf.local named.conf.local.orig
    ?user@box:/# cp named.conf.options named.conf.options.orig
  3. Create the zone.
    user@box:/etc/bind$ vi named.conf.local
    //
    // Do any local configuration here
    //
    
    // Consider adding the 1918 zones here, if they are not used in your
    // organization
    //include "/etc/bind/zones.rfc1918";
    
    # ZONE DEFINITION
    zone "corp.h8n.com" {
    	type master;
    	file "/etc/bind/zones/corp.h8n.com.db";
    	};
    
    # ZONE DEFINITION FOR REVERSE DNS
    zone "0.168.192.corp.h8n.com" {
    	type master;
    	file "/etc/bind/zones/rev.0.168.192.corp.h8n.com";
    };
  4. Modify the forwarder. Define the DNS(s) to which this DNS will forward requests it can’t process
    user@box:/etc/bind$ vi named.conf.options
    options {
    	directory "/var/cache/bind";
    
    	// If there is a firewall between you and nameservers you want
    	// to talk to, you may need to fix the firewall to allow multiple
    	// ports to talk.  See http://www.kb.cert.org/vuls/id/800113
    
    	// If your ISP provided one or more IP addresses for stable 
    	// nameservers, you probably want to use them as forwarders.  
    	// Uncomment the following block, and insert the addresses replacing 
    	// the all-0's placeholder.
    
    	// forwarders {
    	// 	0.0.0.0;
    	// };
    
       forwarders {
          8.8.8.8;
          4.2.2.1;
          4.2.2.2;
       };
    	auth-nxdomain no;    # conform to RFC1035
    	listen-on-v6 { any; };
    	listen-on { 127.0.0.1; 192.168.0.0/24; };
    };
  5. Add the zone definition files
    root@box:/etc/bind# mkdir zones
    root@box:/etc/bind# cd zones
    root@box:/etc/bind/zones$ vi corp.h8n.com.db
    
    ;
    ; DNS zone for corp.h8n.lan
    ;
    $ORIGIN corp.h8n.com.
    $TTL 1D
    ; any time you make a change to the domain, bump the
    ; "serial" setting below. the format is easy:
    ; YYYYMMDDI, with the I being an iterator in case you
    ; make more than one change during any one day
    corp.h8n.com. IN SOA cmlin01.corp.h8n.com. dnsadmin.corp.h8n.com. (
    20120725;
    28800;
    604800;
    604800;
    86400;
    )
    ; cmlin01.corp.h8n.lan serves this domain as the name server (NS)
    corp.h8n.com. IN NS cmlin01.corp.h8n.com.
    
    ;
    ; Define domain functions with CNAMEs
    ; <cname> CNAME <hostname>
    ;
    jenkins IN CNAME cmlin01
    cacti IN CNAME cmlin01
    dns IN CNAME cmlin01
    ntp IN CNAME cmlin01
    
    ldap IN CNAME cmlin02
    phpmyadmin IN CNAME cmlin02
    xymon IN CNAME cmlin02
    
    nexus IN CNAME cmlin03
    django IN CNAME cmlin03
    cmdb IN CNAME cmlin03
    svn IN CNAME cmlin03
    wiki IN CNAME cmlin03
    
    shareddrive IN CNAME nas
    nfs IN CNAME nas
    ;
    ; Define our hostnames for static IP's
    ;
    printer.corp.h8n.com. IN A 192.168.0.10
    nas.corp.h8n.com. IN A 192.168.0.20
    cmlin01.corp.h8n.com. IN A 192.168.0.26
    cmlin02.corp.h8n.com. IN A 192.168.0.24
    cmwin01.corp.h8n.com. IN A 192.168.0.27
    cmosx01.corp.h8n.com. IN A 192.168.0.29
    cmosx02.corp.h8n.com. IN A 192.168.0.30
    cmosx03.corp.h8n.com. IN A 192.168.0.31
    cmlin03.corp.h8n.com. IN A 192.168.0.32
    cmwin02.corp.h8n.com. IN A 192.168.0.33
    cmosx04.corp.h8n.com. IN A 192.168.0.34
    cmwin03.corp.h8n.com. IN A 192.168.0.36
    cmosx05.corp.h8n.com. IN A 192.168.0.37
    
    ; Just in case someone asks for localhost.corp.h8n.lan
    localhost IN A 127.0.0.1
  6. Reverse Pointers. NOTE: The IP is a reverse of hte range we use.
    Our range is 192.168.0.0/24 so the file is 0.168.192…

    cmuser@cmlin01:/etc/bind/zones$ more rev.0.168.192.corp.h8n.com 
    ;
    ; This is our reverse DNS zone file
    ;
    
    ;$ORIGIN 0.168.192.corp.h8n.com.
    $TTL 1D
    corp.h8n.com. IN SOA cmlin01.corp.h8n.com. dnsadmin.corp.h8n.com. (
                            20120716;
                            28800; 
                            604800;
                            604800;
                            86400; 
    )
    
    ;0.168.192.corp.h8n.com IN NS cmlin02.corp.h8n.com.
    @         IN    NS     cmlin01.
    #26       IN    PTR    corp.h8n.com
    10       IN    PTR    printer.corp.h8n.com.
    20       IN    PTR    nas.corp.h8n.com.
    25       IN    PTR    cmlin02.corp.h8n.com.
    26       IN    PTR    cmlin01.corp.h8n.com.
    27       IN    PTR    cmwin01.corp.h8n.com.
    28       IN    PTR    bethosx.corp.h8n.com.
    29       IN    PTR    cmosx01.corp.h8n.com.
    30       IN    PTR    cmosx02.corp.h8n.com.
    31       IN    PTR    cmosx03.corp.h8n.com.
    32       IN    PTR    cmlin03.corp.h8n.com.
    33	 IN    PTR    cmwin02.corp.h8n.com.
    34       IN    PTR    cmosx04.corp.h8n.com.
    35       IN    PTR    jsandlin-mini.corp.h8n.com.
    36       IN    PTR    cmwin03.corp.h8n.com.
    37	 IN    PTR    cmosx05.corp.h8n.com.

SVN Revert codebase to a previous revision

  1. Figure out revision number of old good version
    svn log http://svn.domain.com/app/branches/3_3_0 -r {2010-09-15}:{2010-09-20}
    
  2. See what code will be reverted
    svn merge --dry-run -r 25951:25950  http://svn.domain.com/app/branches/3_3_0
    
  3. Perform the revision
    svn merge -r 25951:25950  http://svn.domain.com/app/branches/3_3_0
    
  4. Commit your change
    svn commit -m "Description"
    

Merge all changes from branch to trunk while leaving merge conflicts up to developers

  1. This document is assuming you have already checked out & updated trunk.
    svn checkout http://server/svn/project/trunk ~/workspaces/project_trunk
    svn update ~/workspaces/project_trunk
  2. Check out the branch to merge from
    svn checkout http://server/svn/project/branches/0.0.6 ~/workspaces/project_0.0.6
  3. Figure out the revision the branch began
    $ svn log --verbose --stop-on-copy http://server/svn/project/branches/0.0.6
    ------------------------------------------------------------------------
    r3 | joe | 2010-08-03 12:50:08 -0700 (Tue, 03 Aug 2010) | 1 line
    Changed paths:
       A /branches/0.0.6/test
       A /branches/0.0.6/global
    
    Adding dirs for test sprint 1
    ------------------------------------------------------------------------
    r2 | joe | 2010-08-03 12:49:12 -0700 (Tue, 03 Aug 2010) | 1 line
    Changed paths:
       A /branches/0.0.6 (from /trunk:1)
    
    Creating branch for test Sprint 1
    ------------------------------------------------------------------------

    NOTE: The revision where the branch was created ($BCV = 2)

  4. CD into the trunk you are merging to & get the revision num.
    cd /workspaces/project_trunk
    svn update

    This will return a message “At revision XXXXX”

    jsmith@PC-JSMITH /workspaces/project_trunk
    $ svn update
    At revision 92.

    $TV=92

  5. CD to your trunk which you are merging TO
    $ cd /workspaces/project_trunk
  6. Merge the changes from the branch to the trunk
    $ svn merge --accept postpone -r ${BCV}:${TV} http://server/svn/project/branches/0.0.6
    --- Merging r2 through r92 into '.':
    C    test-3pom.xml
    Skipped 'foo.bar'
    C    test-parentpom.xml
    U    test-1srcmainjavacomarrisilibTest.java
    U    test-1srcmainjavacomarrisilibApp.java
    C    test-1pom.xml
    C    test-2pom.xml
    Summary of conflicts:
    Text conflicts: 4
    Skipped paths: 1
  7. Generate a report of merge conflicts
    cd /workspaces/project_trunk
    find . -type f -name "*.working"

    EX:

    jsmith@PC-JSMITH /workspaces/project_trunk/trunk
    $ find . -type f -name "*.working"
    ./test-1/pom.xml.working
    ./test-2/pom.xml.working
    ./test-3/pom.xml.working
    ./test-parent/pom.xml.working

    Copy this list into an email & remove working from the end of each line.

  8. Get rid of all conflict resolution files
    find . -type f -name "*.working" -exec rm {} ;
    find . -type f -name "*-left.r*" -exec rm {} ;
    find . -type f -name "*-left.l*" -exec rm {} ;
  9. Commit your changes
    svn commit -m "EM-300 - Merge project 0.0.6 to trunk"
  10. Send email to DEV team to handle merge conflicts