Thursday, December 1, 2011

Add NetApp filer to Oracle Grid Control

Configuring Netapp filer for Oracle enterprise Manager Grid Control 10g R3 – R5 and 11g.

If you would like to see the Netapp stats in Grid control here is what you do:

Make sure SNMP is enabled on the filer.

SNMP has versions 1,2 and 3.
Oracle says they only support version 1, but I have used version 3 successfully

Here is a doc for that:

snmp goes over port 162 so you will need that open between the OEM server and the NetApp filer.

Set up OEM (Grid Control) Menu
In OEM select the preferences from the top left.
From the menu on the left side select target sub-tabs and move the NetApp Filers over to the right side.
Hit apply. Now when you click on the targets tab you will the the NetApp Filers option in the horizontal menu.
You will not see any filers, you have to add them.

Set up agent
To add a filer, you have to choose an agent, you do not need a agent on the filer.
The agent can be any of your agents you have installed, it is like a relay.

If you have an agent installed on the Grid Control server that is a good on to use.

Click on setup (in the upper left of web page)– agents (in the blue menu bar)

Select the agent you are going to use and click the agent link.

In the drop down list in the middle left side select add “Network Appliance Filer”

For the name put in the hostname of the filer

For the hostname, put in the hostname of the filer.

Click the test connection button, it should work. If not, you may have a communication problem over port 162.

Now when you click the NetApp Filers menu item you will see the filer there and you will be able to drill down into the stats.

It collects data every 15 minutes.

Wednesday, October 12, 2011

Catch Oracle error for Entity Framework update

In this example you have a unique constraint on a column(s) and you want to have the error returned to a label on the current page, allowing the user to correct their data entry. I am not using on linq or Entity Sql to do the update.

Here is some code from the details view, notice we are using the OnItemInserted call to the code behind.

DetailsView ID="DetailsView" runat="server" Height="50px" Width="125px"
AutoGenerateRows="False" DataKeyNames="TIMESHEET_ID" AutoGenerateInsertButton="True" DefaultMode="Insert"
DataSourceID="TimesheetEntityModel" OnModeChanging="OnModeChanging1" OnItemInserted="DetailsViewInserted"


Here is the C# code behind to trap the Oracle error

protected void DetailsViewInserted(object sender, DetailsViewInsertedEventArgs e)

if (e.Exception != null)
MessageLabel.Text = e.Exception.InnerException.Message;
e.ExceptionHandled = true;
e.KeepInInsertMode = true;


This will just send the Oracle error back, It may still be too cryptic for users. You can add a contains like .InnerException.Message.Contains("ORA-123456") to search the error message and send back something more refined.

I have added the OnModeChanging function for reference. It returns the user to the main page if they hit cancel.

protected void OnModeChanging1(object sender, DetailsViewModeEventArgs e)

if (e.NewMode == DetailsViewMode.Edit || e.NewMode == DetailsViewMode.Insert)
if (e.CancelingEdit)
MessageLabel.Text = "Insert cancelled.";

//MessageLabel.Text = "Insert completed.";


Thursday, September 29, 2011

Adding a Oracle blob using the .NET entity framework.

Recently I have been experimenting with some .NET programming using the Oracle ODAC beta This version of the odac allows you to use the .NET entity framework. You need Visual Studio 2010. So far it is  a lot of fun.
If you are a programmer and have not used the entity framework  there is a very good tutorial here:
The above tutorial uses SQL server. I am hitting the Oracle database in this example.

Table Structure
  ATTACHMENT_ID  NUMBER                         NOT NULL,
  DATA           BLOB,

Here is the setup to add a row.

This code is the form view, pretty standard stuff,

<asp:DetailsView ID="DetailsView1" runat="server" Height="50px" Width="171px"
        AutoGenerateRows="False" DataKeyNames="ATTACHMENT_ID"
        AutoGenerateInsertButton="False" DefaultMode="Insert"
        oniteminserting="AttachmentsDetailsView_ItemInserting"  >

        <asp:BoundField DataField="ATTACHMENT_ID" HeaderText="ATTACHMENT_ID"
            SortExpression="ATTACHMENT_ID" ReadOnly="True" Visible="false" />
        <asp:TemplateField HeaderText="REQUEST_ID" SortExpression="REQUEST_ID">
                <asp:Label ID="Label1" runat="server" Text='<%# Session["ccREQUESTID"] %>'></asp:Label>
                <asp:TextBox ID="TextBox1" ReadOnly="True" runat="server" Text='<%# Session["ccREQUESTID"] %>'></asp:TextBox>
        <asp:BoundField DataField="DESCRIPTION" HeaderText="DESCRIPTION"
            SortExpression="DESCRIPTION" />
        <asp:BoundField DataField="DATE_ATTACHED" HeaderText="DATE_ATTACHED"
            SortExpression="DATE_ATTACHED" Visible="false" />
            <asp:BoundField DataField="FILE_NAME" HeaderText="FILE_NAME"
            SortExpression="FILE_NAME" visible="false" />
            <asp:TemplateField HeaderText="DATA" SortExpression="DATA">
                    <asp:Label ID="Label2" runat="server" Text='<%# Bind("DATA") %>'></asp:Label>
                   <asp:FileUpload ID="FileUpload1" runat="server" />
        <asp:CommandField ShowCancelButton="False" ShowInsertButton="True" />
    <asp:Label ID="Label3" runat="server" Text="Select a file and click insert."></asp:Label>
<br /><br />
Here is the C# code behind for the  oniteminserting call.

protected void AttachmentsDetailsView_ItemInserting(object sender, DetailsViewInsertEventArgs e)
           // Entities ctx = new Entities();
            byte[] myFileBytes = null;
            FileUpload myUpload = (FileUpload)DetailsView1.FindControl("FileUpload1");

             // Need  if not post back

             if (myUpload.HasFile)
                     myFileBytes = myUpload.FileBytes;

                     e.Values["REQUEST_ID"] = Convert.ToDecimal(Session["ccREQUESTID"]);
                     e.Values["DATA"] = myFileBytes;
                     e.Values["FILE_NAME"] = Path.GetFileName(myUpload.PostedFile.FileName);
                     e.Values["DATE_ATTACHED"] = DateTime.Now;
                     Label3.Text = "Successfully Attached. You may attach another or select button below";

                 catch (Exception ex)
                  Label3.Text = "ERROR: " + ex.Message.ToString();
                  e.Cancel = true;

                 Label3.Text = "You have not specified a file.";
                 e.Cancel = true;

Let me know if you want some code to update the row with the blob in it

Steven Moslin