Monday, March 28, 2011

Linux, check interface status

In some cases you might want to check the status of your network interfaces from a script. In a "normal" situation you can just run a ifconfig command and look if your interface is up or down however when you want to do this automated from within a script you do not want the complete output of ifconfig. You might just want a simple "up" or a simple "down" string returned. If you for example want to use this within a custom check in Nagios or Oracle Enterprise Manager.

You have some options, in the example below I will provide a "up" or a "down" string based upon the status of the interface. However you might also go for a even more simplistic way by returning a zero or one value. the script is based upon the fact that you will provide a parameter with the interface name, for example eth0 or en0. in case you provide a interface name that is none existing get a error message something like "ifconfig: interface eth0 does not exist". You can use the standard option to suppress this error message by using the default way to suppers stderr message by adding a "2> /dev/null" at the end of your script.


#!/bin/bash

IFCONFIG="/sbin/ifconfig $1"

ISIT=`$IFCONFIG | grep "UP" | wc -l`;

if test $ISIT -gt 0;
then
echo "up";
else
echo "down";
fi


Oracle OEM and User-Defined Metrics

When you are using a Oracle Enterprise Manager Grid Control approach within your Oracle landscape to monitor and maintain your application and database landscape you can make use of all kinds of predefined checks Oracle will provide you. Even do this is already a great library of important checks and alerts it can always (and will) happen that after some time you would like to extend the functionality. For example if you have build some custom applications you might want to have some checks in place to do some very specific checking on things that will only be applicable for your specific application. To enable you to create your own checks Oracle has provided the "User-Defined Metrics" UDM in short.

User-Defined Metrics can be build using SQL or using scripting languages such as bash. For now we will quickly focus on how to build a simple check with SQL. In the example below I will show how you can build a check on the number of invalid objects in your database.

The first thing you need to do is to find a way how you can achieve what you want via a SQL script. In case of the number of invalid objects you can use the query below;
SELECT
COUNT(1)
FROM dba_objects
WHERE status = 'INVALID'

Now we have to define the User-Defined metrics in Oracle Enterprise Manager. To do so navigate to "targets" -> "Databases". Below at the end of the page you will find a link "User-Defined Metrics" which will bring you to the page as show in the screenshot below.

You can see I have already created a couple of them. If you want to create a new User-Defined Metrics you can create one by using the "Create Like" button or the "create" button. We will be using the create button which brings you to the page shown below:

We will have to complete a couple of things, first we have to name the UDM. For now I have named it "TEST-invalid". The query is the same as the query shown above. Now we have to enter a username and password. I have used system for this. This might however not be the most optimal choice from a security point of view and you might run into some issues with the security department. What you might want to consider is creating a specific user for the checks to be executed however that is up to the security standards and compliancy you have to keep in mind in your specific environment.

In below screenshot we have to set some some more things. For example the thresholds. This will determine when to raise a warning or state a critical state. I have set in this example that if the value of the script is between 10 and 50 it will be a warning and if it is above 50 it will become critical. In the real world you do not want a single invalid object however this is to state what you can do with it. I have also set a alert message which will state in case of 15 invalid objects "uhoh 50 objects are wrong".

I have also stated that every 15 minutes the system will have to check. If you push test you will get the value and you will see if it is working. When you press OK the check will be created.

In our case 94 objects are invalid so now we can see it on the database page in Oracle Enterprise manager as you can see below. This is only a warning. You can automatilcy have script started and all kind of things however I will go into that at a later stage in another blogpost.

When you click on the message you will be able to see in more detail the current status and the history. This can be good to keep a close eye on your system and the trends in the system.

Wednesday, March 02, 2011

Solved: Logged in user does not have permission to access this page.

When you work with a new installation of the Oracle Install Base module you may encounter some issues when you try to enter a note. This is also encountered in some of the setup done for the vision installation of Oracle e-Business Suite Release 12. I encountered it during some tests of a R12 vision installation. The issue is that if you click "create" button in the notes page in Oracle Install Base you will get a error page stating "Logged in user does not have permission to access this page". No other explanation is given. Looking at metalink the following cause is given in note 455871.1 "The function JTF_CAL_FUNCTION_SECURITY is not added to Oracle Install Base Menu as a SubMenu.". This note is giving you a solution for release 11.5.10.2 and some hints for release 12.

As it turns out the note is not spot on for release 12. What you need to do to get it working for release 12 is the following:

Step 1:
- login to the system and select the system Administrator responsibility
- Go to "security" -> "responsibilities" -> "Define"
- query the Install Base responsibility which is giving you the issue
- copy the value of the "menu" field

Step 2:
- Within the system administrator responsibility go to "applications" and then "Menu".
- Query the correct menu by searching the "User Menu Name" which you retrieved from step1

Step 3:
Now you have to create a new submenu under the menu.
- Leave the "prompt" value blank
- Enter the value "JTF HTML Calendar-Tasks-Notes Function security menu" in the submenu field.
- Enter the value "JTF HTML Calendar Function Security" in the function field
- Save the new submenu

Step 4:
bounce the Apache server so the webserver cache is cleared.

Now you should be able to login to Oracle e-Business Suite and all should work. The change with the metalink note is the value that needs to be entered in the function field when creating a new submenu. The value stated in the metaling note will throw a error when done in a release 12 instance.