rasti.hil@hilandco.com +41 79 367-9677

Search This Blog

How to create your first Management Plug-in in Grid Control

1) Adding a Target Instance to the targets.xml File

Add this following line to %AGENT_HOME%\sysman\emd\targets.xml file:

<Target TYPE="first_task_type" NAME="first_task"/>

After that you have to reload:

%AGENT_HOME%\BIN> emctl reload

Or restart the agent:

%AGENT_HOME%\BIN> emctl stop agent
%AGENT_HOME%\BIN> emctl start agent

You can upload and see the status:

%AGENT_HOME%\BIN> emctl upload agent
%AGENT_HOME%\BIN> emctl status agent

2) Create target type metadata

%AGENT_HOME%\sysman\admin\metadata\first_task_type.xml

<?xml version="1.0" ?>
<!DOCTYPE TargetMetadata SYSTEM "../dtds/TargetMetadata.dtd">

<TargetMetadata META_VER="1.0" TYPE="first_task_type">
<Display>
<Label NLSID="my_name">first_task_type_label</Label>
</Display>

<AltSkipCondition METRIC="Response" COLUMN="State" />

<Metric NAME="Response" TYPE="TABLE">
<Display>
<Label NLSID="resp">Response</Label>
</Display>

<TableDescriptor>
<ColumnDescriptor NAME="Status" TYPE="NUMBER" IS_KEY="FALSE">
<Display>
<Label NLSID="resp_status">Status</Label>
</Display>
</ColumnDescriptor>
</TableDescriptor>

<QueryDescriptor FETCHLET_ID="OSLineToken">
<Property NAME="scriptsDir" SCOPE="SYSTEMGLOBAL">scriptsDir</Property>
<Property NAME="perlBin" SCOPE="SYSTEMGLOBAL">perlBin</Property>
<Property NAME="command" SCOPE="GLOBAL">
%perlBin%/perl %scriptsDir%/first_task_script.pl
</Property>
<Property NAME="startsWith" SCOPE="GLOBAL">em_result=</Property>
<!-- <Property NAME="delimiter" SCOPE="GLOBAL">|</Property>-->

</QueryDescriptor>
</Metric>

<InstanceProperties>
</InstanceProperties>

</TargetMetadata>


3) Create perl script which is used by the target type metadata file.

%AGENT_HOME%\sysman\admin\scripts\first_task_script.pl



# first_task_script.pl
#
# NAME
# first_task_script.pl - Returns an always up value
#
# DESCRIPTION
# Returns an always true value for every evaluation.


print "em_result=1\n";




4) Define the schedule of metric collection:

%AGENT_HOME%\sysman\admin\default_collection\first_task_collection.xml

<!DOCTYPE TargetCollection SYSTEM "../dtds/TargetCollection.dtd">
<TargetCollection TYPE="first_task_type" >
<CollectionItem NAME = "Response" REQUIRED="TRUE">
<Schedule>
<IntervalSchedule INTERVAL="5" TIME_UNIT="Min"/>
</Schedule>
<Condition COLUMN_NAME="Status" CRITICAL="0" OPERATOR="EQ" OCCURRENCES="2" />
</CollectionItem>
</TargetCollection>


5) Validation with ILint
Go to the directory:%AGENT_HOME%\BIN and run the following command:

emctl ilint
-m %AGENT_HOME%\sysman\admin\metadata\first_task_type.xml
-i %AGENT_HOME%\sysman\emd\targets.xml
-c %AGENT_HOME%\sysman\admin\default_collection\first_task_collection.xml
-t first_task
–r Response

6) Validation with emPDK
Go to the directory where you have installed emPDK.jar and run the following command:

emcli check_mp
-metadata_file="%AGENT_HOME%\sysman\admin\metadata\first_task_type.xml"
-collection_file="%AGENT_HOME%\sysman\admin\default_collection\first_task_collection.xml"


7) At finally you can see it in Grid Control
(go to Targets -> Host -> select the host -> Targets -> first_task


You can read more:
Developing a Management Plug-in