Solaris WBEM Services の管理

ロギングプロパティの設定

Solaris_LogServiceProperties クラスのインスタンスを作成し、そのインスタンスのプロパティ値を設定すれば、アプリケーションやプロバイダでロギングをどのように扱うかを制御できます。次の例は、ロギングプロパティの設定方法を示したものです。プロパティは、/usr/sadm/lib/wbem/WbemServices.properties ファイルに格納されます。


例 5-1 ロギングプロパティの設定


public class SetProps {
    public static void main(String args[]) throws CIMException {

	if ( args.length != 3) {
	    System.out.println("Usage: SetProps host username password"); 
	    System.exit(1);
	}

	CIMClient cc = null;
	try {
	    CIMNameSpace cns = new CIMNameSpace(args[0]);
	    cc = new CIMClient(cns, args[1], args[2]);

	 	CIMObjectPath logpropcop = new CIMObjectPath("Solaris_Log
   ServiceProperties");
	    Enumeration e = cc.enumInstances(logpropcop, true);
		for (; e.hasMoreElements(); ) {
			CIMObjectPath op = (CIMObjectPath)e.nextElement();
			CIMInstance ci = cc.getInstance(op);
			ci.setProperty("Directory", new CIMValue("/tmp/bar1/"));
			ci.setProperty("FileSize", new CIMValue("10"));
			ci.setProperty("NumFiles", new CIMValue("2"));
			ci.setProperty("SyslogSwitch", new CIMValue("off"));
			cc.setInstance(logpropcop,ci);
		}
 }
	catch (Exception e) {
	    System.out.println("Exception: "+e);
		e.printStackTrace();
	}

	// close session.
	if(cc != null) {
	    cc.close();
	}    
}