Thursday, August 25, 2011

Finding and deleting old log files

Occassionally you need to clean up some disk space. The quickest and easiest thing to do is often to look for log files that have been rolled by some other process.

For Example:
find . -name *.log.5 -exec /bin/rm '{}' \;
Of course, you need to understand the naming convention of your logs.  Here's a quick example of finding and removing files with a date appended to the original log name.  This command will remove all the log files for the first 9 days of August 2011.

find . -name *.log.2011-08-0* -exec /bin/rm '{}' \;

Thursday, July 21, 2011

Jython Snippet - Max Heap or All appServers on Node XYZ

#########
#get max heap size for all JVMs on a given node. Must connect to dmgr for this to work
#########
myNode='mw-node-001'
serverList = AdminServerManagement.listServers("",myNode)
for server in serverList:
   serverName=AdminConfig.showAttribute(server,'name')
   maxHeapL=AdminServerManagement.listJVMProperties(myNode,serverName,'maximumHeapSize')
   maxHeap=str(maxHeapL)
   print serverName + " " + maxHeap

Thursday, June 16, 2011

Complete Idiot's Guide To Jython for Noob Dummies

It's been a long time since I have jython'ed.  Here's a tip...

you can't concatenate an integer and a string.  Make sense, but it's a pain for someone that's used to doing a lot of perl/shell type scripting.


if you try something like this:

cntr=1
print "counter is " +cntr
you're going to get an error similar to:
TypeError: __add__ nor __radd__ defined for these operands

So how do you do this?  It's almost too easy:
cntr=1
print "counter is " +cntr.toString()

Thursday, September 16, 2010

Enabling trace on Datasources in WAS 7

In the Admin Console, you can add 2 Custom Properties to a datasource to enable trace level logging.

Go to your datasource, and click on the "Custom Properties" link to the right of the middle frame and add the following:

traceLevel (value is 7)
traceFile (value is fully qualified file name for the data to be written to)

Once I set these up, I usually cycle the nodeagent on one of our servers, and then do a test connection when it's back. This proves to me the setting is correct and something will be written to the log.  once I know this is ok, I can cycle the appServers I am concerned about for the settings to take hold.

Friday, March 12, 2010

How can I tell if a perl module is installed?

TO LOOK FOR A SPECIFIC MODULE:
find `perl -e '{print join $/, grep {/[^.]/} @INC}'` -name '*pm' 2>/dev/null |grep -i <>

where <> is the name of the module you are looking for

TO LIST ALL INSTALLED MODULES:
find `perl -e '{print join $/, grep {/[^.]/} @INC}'` -name '*pm' 2>/dev/null

Tuesday, March 9, 2010

Updating PHP variables without access to PHP.ini

http://www.karakas-online.de/EN-Book/change-php-parameters.html

has the following information:

although you will probably not achieve the desired result, due to restrictions that your ISP has set in place, to change the maximum execution time limit of your PHP scripts, add:

php_value max_execution_time 60

This will set the time limit to 60 seconds.


In general, to set values in an .htaccess file, use the following format:

php_value PHP-VARIABLE VALUE

where the string php-value is a literal.

Wednesday, April 22, 2009

IIS Integrated Authentication Gets Wrong User

Here's an interesting scenario we just went through and I thought I would share in case anyone else is searching for a fix to a similar issue... I recently wrote a set of web pages and cgi scripts for deploying OSB10gR3, WLI 9.2.2 and ALDSP3.0.1 assets from a web page. The idea is that developers can install assets to development themselves (without giving full admin access to the consoles) and not have to wait on the Middleware team to do installs for them. Part of the code checks the user that is hitting the page and validates they are authorized to run the install scripts in the environment they are trying to install to... The web pages are running in IIS Version 6.0 and I have Authenticated Integration enabled. The scripts worked great, except for 1 person, who was somehow hitting the page with a different userid than the one they were logged into Windows with... Turns out... We logged into his Windows XP machine and opened "User Accounts" in the Control Panel for his PC. Under the "Advanced" tab, there was an account set up for connecting to the specific server my pages are running on with the account name we saw when he tried hitting my web pages. We removed this entry, and tried hitting the page again (no reboot required) and the page recognized him as the corrct user. Simple fix, but it took a little while for us to find it.

Monday, April 20, 2009

Monday, March 30, 2009

Obtain a list of JPDs?

I'm expanding my search for help with a WLST script that will terminate all the aborted processes in WLI 9.2.2 I have an open case with Oracle, but we haven't come up with my "ideal" solution. What I have right now is a Java program that I can pass a JPD to, and it will terminate all the aborted processes for that JPD. This works ok, but I would like to find a way for the program to find all the JPDs in the environment and then parse through them. Ideally, all of this would be done in WLST, but I can live with Java if it gets the job done. Anyone out there have thoughts on how to do this? Unfortunately, I am a middleware guy and not a Java programmer, so I can't do much with this on my own. The code I have right now is included below:

import com.bea.wli.management.runtime.*;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.rmi.PortableRemoteObject;
import java.util.Date;
import java.text.SimpleDateFormat;
import weblogic.management.MBeanHome;
import java.util.*;
import com.bea.wli.bpm.runtime.ProcessStatus;


public class TerminateProcess {


public static void main(String[] args){

    //Parameters to be configured
    //String JPDURI = "/IDXWEB/processes/Process.jpd";
    //String Provider_URL = "t3://localhost:7001";
    //String Security_Principal = "weblogic";
    //String Security_Credentials = "weblogic";



   if (args.length != 5) {
        System.out.println("Usage: ADMIN_URI JDP_URI ADMIN_USERNAME ADMIN_PASSWORD BATCH_COUNT");
        return;
    }
  String adminURL = args[0];
  System.out.println("Admin URL is$$$ "+adminURL);
  String jpdURI = args[1];
  System.out.println("jpdURI is$$$ "+jpdURI);
  String adminUserName = args[2];
  String adminPassword = args[3];
  int exitCount = Integer.parseInt(args[4]);
  boolean blnExitOnCount = false;//Flag to run the terminate process in batch. If true, it will
                                               //only the number of instances in the exitCount parameter.
                                               //If false, it will terminate all the instances of that JPD.

 try {
    String CONTEXT_FACTORY = "weblogic.jndi.WLInitialContextFactory";
    Properties p = new Properties();
    p.put(Context.INITIAL_CONTEXT_FACTORY, CONTEXT_FACTORY );
    p.put(Context.PROVIDER_URL, adminURL );
    p.put(Context.SECURITY_PRINCIPAL,adminUserName);
    p.put(Context.SECURITY_CREDENTIALS,adminPassword);

    Context ctx = new InitialContext(p);

    MBeanHome home = (MBeanHome)ctx.lookup(MBeanHome.ADMIN_JNDI_NAME);

    Set s = home.getMBeansByType("ProcessRuntime");
    Iterator it = s.iterator();

    while (it.hasNext())
    {
            ProcessRuntimeMBean bean = (ProcessRuntimeMBean)it.next();

            //Query for JPD
            ProcessInstanceQuery query = new ProcessInstanceQuery();
            query.setStatus(ProcessStatus.ABORTED);
            query.setServiceURI(jpdURI);
   ProcessInstanceQueryResult info = bean.getProcessInstances(query);
            String[] instances = info.getInstanceIds();
            System.out.println("Instance Ids " + instances.toString());
            System.out.println("Instance Count " + instances.length);

            for(int i=0;i= exitCount-1))
                {
                    System.exit(0);
                }
            }
    }
    } catch (Exception ex) {
        System.out.println(ex);
        ex.printStackTrace();
    }

}

}

Monday, March 9, 2009

Ctrl-S in vi hangs my edit session

Sometimes I'm a bit stubborn and continue to work around an issue even though I know there must be a better way. Here's a great example: Working in vi, every now and again, I find myself hitting Ctrl-S when I want to save (Ctrl-S is a windows shortcut for Save for those that don't know...) And when you do that vi gets very unhappy. in fact, it seems to stop responding to all commands, and the only way I was ever able to "fix" my mistake was to close my connection to the server, and log back in. Then I would need to delete the .swp file vi creates when you are in an edit session, and then I could go back in and make all those changes over again (because, of course, I couldn't really save it...) I've been doing this sporadically, as needed, for the better part of 3 years. Today I got fed up and a quick google search (less than a minute) turned up a solution. Ctrl-Q will apparently put vi back in its place and accepting cryptic orders from me again.

Thursday, February 26, 2009

Virus shutting off access to outside world

A while back I ran into an issue when one of my PCs was infected with some kind of virus that stopped my access to go out to various virus protection websites, Google, etc. It turns out there is a file in Windows similar the one I am familiar with in UNIX called hosts. Here's a quick tip to help regaina ccess to the outside world if you run into a similar issue... C:\windows\system32\drivers\etc\hosts Make sure the only line in this file is "127.0.0.1 Localhost" If you've been infected by a spyware/Virus/Trojan/Adware... etc... it may have change this file so when you type in google.com or some other address it could redirect you over a specified ip, instead of looking up the address "normally."

Wednesday, February 25, 2009

My "virtual friend" Unnikrishnan Pillai, who I've worked with when calling Oracle Support in the past recently posted an example WLST script for creating JDBC datasources, which ended with "MultiDataSources coming soon..." (See Unni's Blog Post: http://unni-at-work.blogspot.com/2009/02/creating-jdbc-data-source-using-wlst_20.html ) I tried to add a comment to his blog with my own example WLST script for creating MultiDatasources, but received an error, so I figured I would post it here, and Unni... you can feel free to take this as a starting point and clean it up, or ignore it completely. But, I thought I would share in case there is anyone out there wondering how to do this. Feel free to post comments and/or ask questions if you need help with this script. The script creates a multiu datasource, pointing to 2 instances of an Oracle 10G RAC database...

connect('weblogic','weblogic','t3://localhost:70001')
edit()
startEdit(-1,-1,'false')

cd('/')
cmo.createJDBCSystemResource('DS1')
cd('/JDBCSystemResources/DS1/JDBCResource/DS1')
set('Name','DS1')
cd('/JDBCSystemResources/DS1/JDBCResource/DS1/JDBCDataSourceParams/DS1')
set('JNDINames',jarray.array([String('DS1')], String))
cd('/JDBCSystemResources/DS1/JDBCResource/DS1/JDBCDriverParams/DS1')
set('Url','jdbc:oracle:thin:@myDBServer1:1521:myDBSchema1')
set('DriverName','oracle.jdbc.xa.client.OracleXADataSource')
set('Password','myPass')
cd('/JDBCSystemResources/DS1/JDBCResource/DS1/JDBCConnectionPoolParams/DS1')
set('TestTableName','SQL SELECT 1 FROM DUAL')
cd('/JDBCSystemResources/DS1/JDBCResource/DS1/JDBCDriverParams/DS1/Properties/DS1')
cmo.createProperty('user')
cd('/JDBCSystemResources/DS1/JDBCResource/DS1/JDBCDriverParams/DS1/Properties/DS1/Properties/user') set('Value','myUser')
cd('/JDBCSystemResources/DS1/JDBCResource/DS1/JDBCDataSourceParams/DS1')
set('GlobalTransactionsProtocol','TwoPhaseCommit')
cd('/JDBCSystemResources/DS1')
set('Targets',jarray.array([ObjectName('com.bea:Name=AdminServer,Type=Server')], ObjectName))

cd('/')
cd('/JDBCSystemResources/DS2/JDBCResource/DS2')
set('Name','DS2')
cd('/JDBCSystemResources/DS2/JDBCResource/DS2/JDBCDataSourceParams/DS2')
set('JNDINames',jarray.array([String('DS2')], String))
cd('/JDBCSystemResources/DS2/JDBCResource/DS2/JDBCDriverParams/DS2')
set('Url','jdbc:oracle:thin:@myDBServer2:1521:myDBSchema2')
set('DriverName','oracle.jdbc.xa.client.OracleXADataSource')
set('Password','myPass')
cd('/JDBCSystemResources/DS2/JDBCResource/DS2/JDBCConnectionPoolParams/DS2')
set('TestTableName','SQL SELECT 1 FROM DUAL')
cd('/JDBCSystemResources/DS2/JDBCResource/DS2/JDBCDriverParams/DS2/Properties/DS2')
cmo.createProperty('user')
cd('/JDBCSystemResources/DS2/JDBCResource/DS2/JDBCDriverParams/DS2/Properties/DS2/Properties/user')
set('Value','slims_upt')
cd('/JDBCSystemResources/DS2/JDBCResource/DS2/JDBCDataSourceParams/DS2')
set('GlobalTransactionsProtocol','TwoPhaseCommit')
cd('/JDBCSystemResources/DS2')
set('Targets',jarray.array([ObjectName('com.bea:Name=AdminServer,Type=Server')], ObjectName))

cd('/')
cmo.createJDBCSystemResource('MultiDS')
cd('/JDBCSystemResources/MultiDS/JDBCResource/MultiDS')
set('Name','MultiDS')
cd('/JDBCSystemResources/MultiDS/JDBCResource/MultiDS/JDBCDataSourceParams/MultiDS')
set('JNDINames',jarray.array([String('MultiDS')], String))
set('AlgorithmType','Load-Balancing')
set('DataSourceList','DS1,DS2')
cd('/JDBCSystemResources/MultiDS')
set('Targets',jarray.array([ObjectName('com.bea:Name=AdminServer,Type=Server')], ObjectName))

activate()

Thursday, January 29, 2009

java.lang.NoSuchMethodError: getWLSTOptions

Ok, this is an odd one, and my friends at Oracle are working on it, but we have no resolution yet. We have an AquaLogic Service Bus domain that consists of an Admin Server on HostA and a Managed Server on HostB. To start and stop the Admin Server, we use the provided shell scripts (RH Linux 4.0 ES) (startWebLogic.sh, stopWebLogic.sh) This has all been working fine for months.... Then, all of a sudden, when we try to stop the Admin weblogic server running the stopWebLogic.sh script and receive the following output: Stopping Weblogic Server... Problem invoking WLST - java.lang.NoSuchMethodError: getWLSTOptions Done What happened? I'm not sure yet, but if anyone has any thoughts, I'm all EARs ;)

Thursday, January 22, 2009

WLST script without a plain text password

One of the things that has annoyed me about WLST is the seemingly missing method of being able to invoke a WLST script without having a plain text userid and password either in the script or in a properties file. I came across a great post on the Oracle Blogs today by Bola Kothandaraman that describes how you can have a WLST script without having a plan text username and password to your admin Server. It's similar to the boot.properties file, but there are some nuances of this method that are described pretty well in this post (at least I think they are... see my current script issue below): http://blogs.oracle.com/bala/2008/09/encrypt_the_credentials_when_r.html UPDATE: I originally had posted that I was having issues with this method, but I found my problem, and it was a super dumb mistake on my part which I fixed and tested this morning. The method described above is working like a charm and I'm happy to understand how to use WLST without a plain text username and password now.

Wednesday, January 7, 2009

Deleting All Tables in a MySQL database

I recently came into a scenario where I wanted to delete all the tables in my MySQL 5.x database, but didn't want to have to drop and recreate the database (because I didn't have access to do this and was too impatient to wait for the help...) and I didn't want to have to manually enter in 50+ tables each time I needed to clean up. I finally figured out a decent solution... I grep the output from the mysqldump command, looking for only the lines that begin with the word DROP (i.e. Drop table such-and-such) and pipe those lines back into mysql. The result is something like the following, where you fill in the username, password and database with your own information... mysqldump -u [USERNAME] --password=[PASSWORD] [DATABASE] grep ^DROP mysql -u [USERNAME] --password=[PASSWORD] [DATABASE]

Wednesday, December 24, 2008

Easier WLST syntax

An easy way to simplify WLST script syntax while working in interactive mode is to use the easeSyntax() command after you log in. Using the Example from Satya Ghattu's blog ( http://satya-ghattu.blogspot.com/2008/11/easing-wlst-syntax-while-navigating.html ) cd(“/Servers/testServer”) ls() After executing easeSyntax() to navigate around you will use. cd /Servers/testServer ls piece of cake. Thanks for the tidbit, Satya. This will be a great timesaver for me as I am working on developing new WLST scripts. - Brian

Tuesday, December 23, 2008

Checking for Expired SSL certificates: keytool -list -keystore -alias <AliasIfYouKnowIt> -v

Tuesday, December 2, 2008

Creating Perl Modules

I've always been gun shy about creating perl modules for my code because I've never found a great tutorial that breaks it all down. Today it all changes as I cvame across this posting that does a pretty good job at breaking down how it all works. At least in a simple case... http://www.linuxformat.co.uk/modules.php?op=modload&name=News&file=article&sid=748

Getting the most recent row for each id

I was working on configTracker today (a pet project to watch server configurations for changes and do alerting, reporting, etc...) and ran into a scenario where I needed to find the most recent row in a table for a given id. The table has a column called aud_ts of type timestamp. and a column call host_id of type integer. After several iterations (my SQL skills are waining after not developing for 5 or so years....) I came up with: select host_id, max(aud_ts) from myTable group by host_id; Then, I can join this table against all the others in the system on host_id and aud_ts and know I'm getting the most recent info for this server.

Tuesday, November 25, 2008

Checking Hobbit Alerts

We use Hobbit to monitor many of our UNIX based systems. You can check your hobbit configuration by executing a command similar to the following:

./bin/bbcmd - -env=etc/hobbitserver.cfg hobbitd_alert - -test

Sunday, October 12, 2008

Searching for all the files containing a string

Recursively search all files from the current directory down, ignoring case: grep -ir search_string .
Recursively search all files from the current directory down, ignoring case, and only get the file listing: grep -irl search_string .

Ramblings of an Admining Newbie

I'm using this blog more or less as a place to put some notes to myself about things as I learn them. I'm working as a Middleware administrator, which I've been doing for a few years in WebSphere land, but now I have moved over to WebLogic land, and am also responsible for the SOA products Oracle (formerly BEA) has to offer... Aqualogic Service Bus (ALSB), WebLogic Integration (WLI), and Aqualogic Data Services Platform (ALDSP). So, this blog will be a hodgepodge of ramblings, helpful notes, and rants. The views expressed on this blog are in NO WAY the view of my employer, who I won't even share here so you don't get the wrong idea.... :)