Jira Service Management の管理者向けの利用開始ガイド
最初に、Jira Service Management の使用を開始する方法を確認します。
カスタム パターンを作成するには、Discovery/pattern フォルダーに移動します。ここでは、末尾に .pat が付いた新しいファイル (UTF-8) を作成できて、必要なパターン タイプの既存のパターンをコピーして変更できます。新しいパターンを開発してテストするベスト プラクティスは、別の Discovery ツール インスタンスを抽出して、処理する結果データを返すホストまたはデバイスへの接続をセットアップすることです。
次に、「メイン」の HostInfo パターンを除くすべてのパターンを削除します (Linux_Hostinfo_Hostname.pat、Windows_Hostinfo_Hostname_Model.pat、SNMP_Deviceinfo_Default.pat)。Hostname が含まれている「メイン」の HostInfo オブジェクトは必須です。このセットアップでは、他のすべてのパターンの応答を待たずに新しいパターンを高速テストできます。
新しいパターンに必要なすべての XML ノード、つまり Discovery オブジェクトに対するコマンドの結果データを処理する C# クラスを含む <Processing> ノードが必ず含まれるようにしてください。この機能では、Discovery ツールが <Processing> ノードを含む C# ソース コードを読み取り、PatternExec クラスの PerformAction メソッドを呼び出します。
PerformAction メソッドは必須です。Discovery ツールは、次の 3 つのオブジェクトを含むオブジェクト配列によってこのメソッドを呼び出します。
パラメーター | objectType | 説明 |
---|---|---|
parameters[0] | 初期パターン コマンドの結果を含む | |
parameters[1] | iProvider | 検出システムに接続されている実行中のプロバイダー クラスを含みます。 このプロバイダーは、必要に応じて他のコマンドを実行するためにパターンで使用されます。 |
parameters[2] | object | スキャンの開始時に最初に作成される HostInfo-/Device-オブジェクトを含みます。 1
2
3
4
5
public void PerformAction(object[] parameters)
{
HostInfo hostInfo = (HostInfo)parameters[2];
try
{ |
ホストまたはデバイスへの接続では、Discovery ツールで使用するプロバイダーのタイプが 4 つあります。次では、接続とデータ収集コマンドの実行を処理するプロバイダーについて説明します。
パターン内では、システムからさらに情報が必要な場合に、実際に接続されているプロバイダーを使用して追加のコマンドを実行できます。
SSH プロバイダー クラスは Linux システムに接続し、Insight のパターンで使用できます。
1
2
3
4
5
6
7
8
using Insight.Discovery.ProviderClasses; // Include the ProviderClasses Namespace at the Head of the PatternCode
using Insight.Discovery.InfoClasses; // Include the InfoClasses Namespace at the Head of the PatternCode
// Casting the connected Provider out of the parameters from the PerformAction-Method
SSHProvider ssh = (SSHProvider)parameters[1];
// using the SSH-Provider to execute a command and receiving the result.
var result = (SSHExecuteResult)ssh.ExecuteCommand("hostname"); // returning the hostname of a Linux System
たとえば、cast SSHProvider は "Linux_Hostinfo_Hostname.pat" パターンで使います。
WMI プロバイダー クラスは Windows システムに接続し、Insight のパターンで使用できます。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
using Insight.Discovery.ProviderClasses; // Include the ProviderClasses Namespace at the Head of the PatternCode
using Insight.Discovery.InfoClasses; // Include the InfoClasses Namespace at the Head of the PatternCode
// Casting the connected Provider out of the parameters from the PerformAction-Method
WMIProvider wmiProvider = (WMIProvider)parameters[1];
// using the WMI-Provider to read a Registry Value.
var result = (WMIRegValueResult)wmiProvider.GetRegistryValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\<Key>", "DisplayName");
// using the WMI-Provider to get a List of all Registry-Sub-Keys.
var result = (WMIRegValueListResult)wmiProvider.GetSubKeysFromRegistry("SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\");
//using the WMI-Provider to execute a WMI query receiving the result.
var result = (WMIQueryResult)wmiProvider.ExecuteWMIQuery("netstat -an");
//using the WMI-Provider to execute a command and receiving the result.
var result = (WMIExecuteResult)wmiProvider.ExecuteWMICommand("netstat -an");
SNMP プロバイダー クラスは SNMP デバイスに接続し、Insight のパターンで使用できます。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
using Insight.Discovery.ProviderClasses; // Include the ProviderClasses Namespace at the Head of the PatternCode
using Insight.Discovery.InfoClasses; // Include the InfoClasses Namespace at the Head of the PatternCode
// Casting the connected Provider out of the parameters from the PerformAction-Method
SNMPProvider snmp = (SNMPProvider)parameters[1];
// using the SNMP-Provider to execute a SNMPGet command and receiving the results
var result = (SNMPExecuteResult)snmp.ExecuteCommand("1.3.6.1.2.1.1.6.0", ScanProcessType.SNMP_GET, true);
// using the SNMP-Provider to execute a SNMPWalk command and receiving the results
var result = (SNMPExecuteResult)snmp.ExecuteCommand("1.3.6.1.2.1.2.2.1.2", ScanProcessType.SNMP_WALK, true);
// using the SNMP-Provider to execute a SNMPWalk command with contextName and receiving the results
var result = (SNMPExecuteResult)snmp.ExecuteCommand("1.3.6.1.2.1.2.2.1.2", ScanProcessType.SNMP_WALK, "myContext",true);
SNMP プロバイダー クラスは VMware ESXi システムに接続し、Insight のパターンで使用できます。
1
2
3
4
5
6
7
8
using Insight.Discovery.ProviderClasses; // Include the ProviderClasses Namespace at the Head of the PatternCode
using Insight.Discovery.InfoClasses; // Include the InfoClasses Namespace at the Head of the PatternCode
// Casting the connected Provider out of the parameters from the PerformAction-Method
VIMProvider snmp = (SNMPProvider)parameters[1];
// using the VIM-Provider to execute a command and receiving the results
var result = (VIMCommandResult)snmp.ExecuteCommand("HostSystem");
さらに、次の機能も利用できます。
アプリの InstallDate など Discovery-Object の Date 属性を設定する場合は、特定の形式 ("MM/dd/yyyy") にする必要があります。 提供される ImportService.ImportDate メソッドを使って変換を実行できます。
1
2
3
4
5
6
7
using Insight.Discovery.Tools; // Include the Discovery Tools Namespace at the Head of the PatternCode
// using the ImportDate Method to transform the Date string of a result Object
discoveryObject.InstallDate = ImportService.Instance.ImportDate("resultDateString");
// The following input formats will be transformed:
// "MM/dd/yy", "M/dd/yy", "MM/dd/yyyy", "M/dd/yyyy", "MM/dd/yy", "M/d/yy", "MM/d/yyyy", "M/d/yyyy", "yyyyMMdd", "yyMMdd", "dd.MM.yy", "dd.MM.yyyy", "MMM-dd-yy", "MMM-dd-yyyy", "yyyy-MM-dd" |
Discovery ログ ファイルにエントリを書き込む場合は、提供される LogService クラスを使用できます。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
using Insight.Discovery.Tools; // Include the Discovery Tools Namespace at the Head of the PatternCode
// creating a "normal" log entry
LogService.Instance.LogNormal("My normal log entry");
// creating a "debug" log entry with additional Exception object
try
{
LogService.Instance.LogDebug("a debug log entry");
// Code that could raise an exception
}
catch (Exception ex)
{
LogService.Instance.LogError("Log of an exception", ex);
} |
Asset Discovery を使用して独自の情報を返すために作成できるカスタム パターンの例を次に示します。
SNMP デバイスの情報は拡張できます。検出する必要がある値を返す OID 番号を把握する必要があります。処理スクリプトでは、OID の戻り値が ExtendedInformation にマッピングされます。
次の例では、異なる RAM 情報を検出するために 3 つの OID を送信しています。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<?xml version="1.0" encoding="utf-8"?>
<ScanPattern xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Version>3.0.1</Version>
<PatternID>RIADA-Cust-SNMP-1</PatternID>
<OrderNr>0</OrderNr>
<ProcessType>SNMP_GET</ProcessType>
<PatternType>SNMPExtendedValues</PatternType>
<Command>
<![CDATA[
1.3.6.1.4.1.2021.4.5.0;1.3.6.1.4.1.2021.4.6.0;1.3.6.1.4.1.2021.4.11.0
]]>
</Command>
<Processing>
<![CDATA[
using System;
using System.Collections.Generic;
using Insight.Discovery.InfoClasses.CommandResult.ResultTypes;
using Insight.Discovery.Tools;
using Insight.Discovery.InfoClasses;
using Insight.Discovery.InfoClasses.CommandResult;
namespace Insight.Discovery {
public class PatternExec {
public void PerformAction(object[] parameters)
{
DeviceInfo deviceInfo = (DeviceInfo)parameters[2];
if (deviceInfo.ExtendedInformations.IsNullOrEmpty())
deviceInfo.ExtendedInformations = new List<ExtendedInformation>();
try
{
var commandResult = (SNMPExecuteResult)parameters[0];
commandResult.LogResult();
foreach (KeyValuePair<string, object> item in commandResult)
{
switch (item.Key)
{
case "1.3.6.1.4.1.2021.4.5.0": // OID to get available RAM
if (item.Value != null)
{
try
{
long t = 0;
long.TryParse(item.Value.ToString().Replace("\n", "").Trim(), out t);
if (t > 0)
{
deviceInfo.ExtendedInformations.Add(new ExtendedInformation() { Name = "RAM Total", Value = (t / 1024).ToString() });
}
}
catch
{
//
}
}
break;
case "1.3.6.1.4.1.2021.4.6.0": // OID to get used RAM
if (item.Value != null)
{
try
{
long t = 0;
long.TryParse(item.Value.ToString().Replace("\n", "").Trim(), out t);
if (t > 0)
{
deviceInfo.ExtendedInformations.Add(new ExtendedInformation()
{ Name = "RAM Used", Value = (t / 1024).ToString() });
}
}
catch
{
//
}
}
break;
case "1.3.6.1.4.1.2021.4.11.0": // OID to get free RAM
if (item.Value != null)
{
try
{
long t = 0;
long.TryParse(item.Value.ToString().Replace("\n", "").Trim(), out t);
if (t > 0)
{
deviceInfo.ExtendedInformations.Add(new ExtendedInformation() { Name = "RAM Free", Value = (t / 1024).ToString() });
}
}
catch
{
//
}
}
break;
}
}
}
catch (Exception ex)
{ LogService.Instance.LogDebug("Error getting Extended SNMP RAM Information.", ex); }
}
}
}
]]>
</Processing>
</ScanPattern> |
検出されたライセンス情報をアプリに追加することは可能です。たとえば、ライセンス ファイルが存在することがわかっている場合は、このファイルを読み取るパターンを追加できます。
次の例で、パターンは Linux アプリ「apt」のライセンスキーを含むファイル「lic」を読み取っています。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?xml version="1.0" encoding="utf-8"?>
<!-- © Mindville -->
<ScanPattern xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Version>1.0.1</Version>
<PatternID>Mindville-Cust-Linux-AppPK-1</PatternID>
<OrderNr>0</OrderNr>
<ProcessType>SSHExecute</ProcessType>
<PatternType>ApplicationProductKey</PatternType>
<ApplicationName>apt</ApplicationName>
<Command>
<![CDATA[
cat /etc/apt/lic
]]>
</Command>
<Processing>
<![CDATA[
using System;
using Insight.Discovery.InfoClasses;
using Insight.Discovery.Tools;
using Insight.Discovery.InfoClasses.CommandResult.ResultTypes;
using System.Collections.Generic;
namespace Insight.Discovery {
public class PatternExec {
public void PerformAction(object[] parameters)
{
HostInfo hostInfo = (HostInfo) parameters[2];
try
{
SSHExecuteResult sshExecuteResult = (SSHExecuteResult)parameters[0];
sshExecuteResult.LogResult();
string input = sshExecuteResult;
if (input != string.Empty)
{
if(hostInfo.OS.License == null)hostInfo.OS.License = new LicenseInfo();
hostInfo.OS.License.LicenseKey = input.Trim();
}
}
catch (Exception ex)
{ LogService.Instance.LogDebug("Error getting apt product key Information", ex); }
}
}
}
]]>
</Processing>
</ScanPattern> |
任意のオブジェクト タイプの情報を拡張できます。次の例では、ホスト情報をいくつかの追加情報で拡張しています。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<?xml version="1.0" encoding="utf-8"?>
<ScanPattern xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Version>1.0.1</Version>
<PatternID>Mindville-Cust-Linux-OpenPorts-1</PatternID>
<OrderNr>700</OrderNr>
<ProcessType>SSHExecute</ProcessType>
<PatternType>Host</PatternType>
<Command>
<![CDATA[
netstat -an
]]>
</Command>
<Processing>
<![CDATA[
using System;
using System.Collections.Generic;
using Insight.Discovery.Tools;
using Insight.Discovery.InfoClasses;
using Insight.Discovery.InfoClasses.CommandResult.ResultTypes;
using Insight.Discovery.Tools.Networking;
namespace Insight.Discovery {
public class PatternExec {
public void PerformAction(object[] parameters)
{
HostInfo hostInfo = (HostInfo)parameters[2];
try
{
SSHExecuteResult sshExecuteResult = (SSHExecuteResult)parameters[0];
sshExecuteResult.LogResult();
string input = sshExecuteResult;
if (input != string.Empty)
{
if (hostInfo != null)
{
string[] lines = input.Split('\n');
ExtendedInformation tcpPortInfo = new ExtendedInformation() { Name = "TCP Ports", Value = string.Empty };
ExtendedInformation udpPortInfo = new ExtendedInformation() { Name = "UDP Ports", Value = string.Empty };
for (int i = 0; i < lines.Length; i++)
{
if (!string.IsNullOrEmpty(lines[i]) && lines[i].Contains(":")
&& (lines[i].ToLower().StartsWith("tcp") || lines[i].ToLower().StartsWith("udp")))
{
string[] parts = lines[i].TrimReduce().Split(' ');
try
{
for (int x = 0; x < parts.Length; x++)
{
if (parts[x].Contains("]"))
{
parts[x] = parts[1].Substring(parts[x].IndexOf("]"));
}
if (parts[0].ToLower().StartsWith("tcp") && !string.IsNullOrEmpty(parts[x]) &&
parts[x].Contains(":"))
{
if (!tcpPortInfo.Value.Contains(parts[x].Split(':')[1]))
{
tcpPortInfo.Value += parts[x].Split(':')[1] + ",";
break;
}
}
if (parts[0].ToLower().StartsWith("udp") && !string.IsNullOrEmpty(parts[x]) &&
parts[x].Contains(":"))
{
if (!udpPortInfo.Value.Contains(parts[x].Split(':')[1]))
{
udpPortInfo.Value += parts[x].Split(':')[1] + ",";
break;
}
}
}
}
catch
{
//
}
}
}
if (hostInfo.ExtendedInformations.IsNullOrEmpty())
hostInfo.ExtendedInformations = new List<ExtendedInformation>();
if (!string.IsNullOrEmpty(tcpPortInfo.Value) && tcpPortInfo.Value.EndsWith(","))
{
tcpPortInfo.Value = tcpPortInfo.Value.Substring(0, tcpPortInfo.Value.Length - 1);
hostInfo.ExtendedInformations.Add(tcpPortInfo);
}
if (!string.IsNullOrEmpty(udpPortInfo.Value) && udpPortInfo.Value.EndsWith(","))
{
udpPortInfo.Value = udpPortInfo.Value.Substring(0, udpPortInfo.Value.Length - 1);
hostInfo.ExtendedInformations.Add(udpPortInfo);
}
}
}
}
catch (Exception ex)
{ LogService.Instance.LogDebug("Error getting ReferencedHosts Information", ex); }
}
}
}
]]>
</Processing>
</ScanPattern> |
提供されるパターンは変更できますが、推奨されません。
不足している情報がある場合、ベスト プラクティスは新しいパターンを追加することです。不足している情報は Discovery オブジェクトにマージされます。提供されるパターンを変更した場合は、Discovery ツールを更新することによって、そのパターンを外部に保存して変更が失われたようにする必要があります。
Discovery ツールをアップデーターで更新するときは、更新したパターンを上書きする前にアップデーターから確認が行われます。
パターン ファイル全体を無効にするには、[パターン] タブに移動して不要なパターンの選択を解除します。
パターン ファイルの特定のスキャン範囲を無効にするには、[スキャンの設定] に移動して使用しないパターン ファイルを選択します。
この内容はお役に立ちましたか?