目次 表示
Perl API では、下記のクラスとメソッドが使用可能です。
new |
CollageQueryオブジェクトを生成します。以下のメソッドを使用するために必須です。 |
destroy |
CollageQueryオブジェクトを削除します。CollageQueryオブジェクトが不必要になった際に呼び出す必要があります。 |
getServicesForHostGroup(String hostGroup) |
指定されたホストグループの host-service-attributes ハッシュ値へのリファレンスを返します。 |
getHostsForHostGroup(String hostGroup) |
指定されたホストグループのホスト名や機器名のハッシュ値へのリファレンスを返します。 |
getHostGroups() |
すべてのホストグループ名と説明へのリファレンスを返します。 |
getHostGroup(String hgName) |
ひとつのホストグループの属性が含まれるハッシュ値を返します。 |
getServicesForHost(String host) |
ホストに対するすべての services-attributes のハッシュ値へのリファレンスを返します。 |
getHosts() |
すべての Host-attributes のハッシュ値へのリファレンスを返します。 |
getHostStatusForHost(String host) |
あるホストに対するすべてのステータス属性のハッシュ値を返します。 |
getDeviceForHost(String host) |
ホストに対する機器の属性のハッシュ値を返します。 |
getService(String serviceName, String hostName) |
サービス属性のハッシュ値を返します。 |
getServices() |
Host-service-attributes のハッシュ値へのリファレンスを返します。 |
getMonitorServers |
monitorserver-attributes のハッシュ値へのリファレンスを返します。 |
getHostsForMonitorServer(String MonitorServer) |
指定された監視サーバに対するホストのハッシュ値へのリファレンスを返します。 |
getHostGroupsForMonitorServer(String MonitorServer) |
host groups-attributes のハッシュ値へのリファレンスを返します。 |
これらのメソッドは、プライマリキーをイベントID、セカンダリキーを属性として、イベントのハッシュ値へのリファレンスを返します。
注意: timeField (String) は "FirstInsertDate" か "LastInsertDate"になりえます。Null値だった場合、範囲は適応されません。
getEventsForDevice(String identification, String timeField, Date fromDate, Date toDate) |
getEventsForService(String serviceDescription, String HostName, String timeField, Date fromDate, Date toDate) |
getEventsForHost(String HostName, String timeField, Date fromDate, Date toDate) |
以下のコードは、CollageQuery モジュールの使用例です。
# Use the CollageQuery module use CollageQuery ;
# Declare the CollageQuery object my $t;
# Create an object and make sure we can connect to Collage
$t=CollageQuery->new() or die "Error: connect to CollageQueryfailed\n";
# Print the attributes for a host group "demo-systems"
$getparam = "demo-systems";
# getHostGroup returns a hash of attributes and values
my %hash = $t->getHostGroup($getparam);
foreach my $key (sort keys %hash) {
print "\t$key=$hash{$key}\n";
} # Now print the services and attributes for a host
$getparam = "demo-host";
# getServicesForHost returns a reference to a hash of service hashes
my $ref = $t->getServicesForHost($getparam);
# Iterate for each service
foreach my $service (sort keys %{$ref}) {
print "\tService=$service\n";
# Now iterate for each attribute.
foreach my $attribute (sort keys %{$ref->{$service}}) {
# print the attribute and attribute value
print "\t\t$attribute=".$ref->{$service}->{$attribute}."\n";
}
# Finished so destroy the object
$t->destroy();
Per l の CollageQuery API を使用した例は、以下のようになりなす。注意:これらのファイルは Perl Samples で参照することができます。
test1.pl |
このスクリプトは、API のどのメソッドでも起動します。コマンドライン経由で起動し、結果を STDOUT に返します。 |
api_sample2.pl |
これは、Collage クラスとテスト用のメソッドを選択することを可能にした CGI プログラムです。 |
api_sample3.pl |
これは、api_sample2.pl の改造版で、より使いやすいフォームでデータを出力します。 |