3
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

ARMに立てたMID ServerでDockerコンテナのLinuxをDiscoveryする

3
Last updated at Posted at 2025-12-21

Version: Xanadu

やること

ARMのMac OS上に起動しているMID Serverで同じOS上にあるDockerコンテナのLinuxをDiscoveryしてServiceNowのCMDB情報に登録します

image.png

MID ServerをARMのDockerコンテナに立てることが出来ずこんなややこしい構成になってしまいました

この記事で立てたMID Serverを使います

Dockerはこの記事でインストールしています

Discoveryに関してはこちらにまとめています

Discovery用のID, PasswordでSSH可能なDockerコンテナを準備

こちらの手順を参考にssh可能なalmalinuxのDockerコンテナを用意します

作業用のディレクトリを作成して移動して

% mkdir almalinuxSSH
% cd almalinuxSSH 

Dockerfileを作成して

% vi Dockerfile

参考にしたサイトの手順 + https://qiita.com/20_percent_cooler/items/3df7d2a04753da32681e#comment-5b6f281763d22310a977 さんに教えていただいた以下の内容でDockerfileを作成して(sshのパスワードは伏せています)

FROM almalinux/9-base:latest

#RUN rpm --import https://repo.almalinux.org/almalinux/RPM-GPG-KEY-AlmaLinux
RUN yum update -y && yum install -y openssh-server openssh-clients procps-ng lsof
RUN mkdir /var/run/sshd

# root password setup
RUN echo 'root:********' | chpasswd

# Reset user to root
USER root

EXPOSE 22

RUN systemctl enable sshd

ファイルが作成されたことを確認して

% ls -ltr
total 8
-rw-r--r--  1 user  staff  311 12  7 16:28 Dockerfile

Dockerのimageを作成して

% docker build -t sshtest ./
[+] Building 40.0s (9/9) FINISHED                                                                                                                                                                                        docker:desktop-linux
 => [internal] load build definition from Dockerfile                                                                                                                                                                                     0.0s
 => => transferring dockerfile: 381B                                                                                                                                                                                                     0.0s
 => [internal] load metadata for docker.io/almalinux/9-base:latest                                                                                                                                                                       5.8s
 => [internal] load .dockerignore                                                                                                                                                                                                        0.0s
 => => transferring context: 2B                                                                                                                                                                                                          0.0s
 => CACHED [1/5] FROM docker.io/almalinux/9-base:latest@sha256:ecbec18349654a87355ea7a099e9e0181b48a5bb16f67022fcc587ef43108994                                                                                                          0.0s
 => => resolve docker.io/almalinux/9-base:latest@sha256:ecbec18349654a87355ea7a099e9e0181b48a5bb16f67022fcc587ef43108994                                                                                                                 0.0s
 => [2/5] RUN yum update -y && yum install -y openssh-server openssh-clients procps-ng lsof                                                                                                                                             31.7s
 => [3/5] RUN mkdir /var/run/sshd                                                                                                                                                                                                        0.1s
 => [4/5] RUN echo 'root:passw0rd' | chpasswd                                                                                                                                                                                            0.2s 
 => [5/5] RUN systemctl enable sshd                                                                                                                                                                                                      0.1s 
 => exporting to image                                                                                                                                                                                                                   2.0s 
 => => exporting layers                                                                                                                                                                                                                  1.6s 
 => => exporting manifest sha256:255164157e0517a3c48680e6e173b2cd57095ffb7fb5b5834ab859d537a315f1                                                                                                                                        0.0s 
 => => exporting config sha256:e02c3026c0764df9809095834ea3965bd50aafedc7bcf92ab2b27b13d6d6cb87                                                                                                                                          0.0s
 => => exporting attestation manifest sha256:3901f2d3ffc2a2f403854150bcbb4973e0328f92606d6aa5f66a3f9669bf45f7                                                                                                                            0.0s
 => => exporting manifest list sha256:7d75b80c5e3f7eef894f769e88929a085dcdaa9a240566882cc0b68ccb13f85c                                                                                                                                   0.0s
 => => naming to docker.io/library/sshtest:latest                                                                                                                                                                                        0.0s
 => => unpacking to docker.io/library/sshtest:latest                                                                                                                                                                                     0.4s

View build details: docker-desktop://dashboard/build/desktop-linux/desktop-linux/upg6ip2lyow55xerdjm9ear0j 

コンテナを起動します 手順だとportを1222:22で1222でsshできるようにしていましたがport22でDiscoveryをしたいので22:22にします

% docker run -itd --privileged -p 22:22 --name almalinuxSSH --hostname almalinuxSSH sshtest /sbin/init
66141b0706b88323c6299c177c5bbbcc8c7dbf415013e1b1cc853f947b7ee32c

localhostのport22にssh出来るか確認します 初めて接続するので本当に接続したいのか確認が出ますがyesを入力して進めます(localhost(127.0.0.1)でアクセスしていますがローカルのプライベートアドレス192.168〜でもおそらく繋がるはずです)

% ssh root@localhost             
The authenticity of host 'localhost (::1)' can't be established.
ED25519 key fingerprint is SHA256:yEAPCyoda4VfTvUeMNop3Zm42/JWnWOaB5e7V73jwCI.
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'localhost' (ED25519) to the list of known hosts.
root@localhost's password: 
[root@almalinuxSSH ~]# 

MID Serverの起動とValidate

Discoveryを行うには検出したい機器と同じセグメント(ネットワーク)内にMID Serverが必要です sudo付きで./start.shを実行します

% sudo ./start.sh        
Password:
The operation couldn’t be completed. Unable to locate a Java Runtime.
Please visit http://www.java.com for information on installing Java.

Starting ServiceNow MID Server...
Waiting for ServiceNow MID Server......
running: PID:1660

Discovery - MID Serversの一覧から該当のMID Serverを選択して確認します MID ServerのStatusがUpになりました

image.png

Validateしないと使えないはずなのでRelated LinksのValidateをクリックします あとついでにConfiguration ParametersのリストでNameを編集してMID Serverの名称に反映されるか試して成功しました

image.png

Discovery Scheduled

検出するスケジュールを設定しますDiscoveryは日次など定期的に実施されるものかなと思います Discovery - Discovery Schedulesを選択して[New] をクリックしてDiscovery Scheduleを作成します

Nameに適当な値を入力してMID Severに立てたMID Serverを指定して[Submit]します

image.png

本来はRunで定期的な予定を設定するものなのかもですが今回はお試しなのでOn Demandのままです

Discovery Scheduleが作成されました

image.png

Discovery IP Range

Discoveryする範囲をIPアドレスで指定します 作成されたDiscovery Scheduleを選択してDiscovery IP RangesでNewをクリックしてNameに適当な値を入力してStarting IPとEnding IPで検出したいIPの範囲を指定して[Submit]します 今回はローカルのセグメントのプライベートアドレスに合わせて192.168.3.1〜192.168.3.255にしています

image.png

Credential

検出するための機器の認証情報を作成します Discovery - Credentailsで一覧を表示して [New] をクリックして

image.png

表示された画面でName, User name, Passwordを設定して[Submit]します User nameとPasswordはSSH用に作成したDockerコンテナのものを設定します Applies toはALL MID serversを指定したままなので全てのMID ServerのDiscoveryで利用されます

image.png

Test Credential

レコード一覧から作成したCredentailを選択しRelated ListsのTest CredentialをクリックしTest Credentailダイアログを表示します 表示されたダイアログでTargetをlocalhost, Portを22, MID Serverを起動したMID Serverを選択して[OK]をクリックします

image.png

Test Credentialに成功するとCredential validatedが表示されます

image.png

Discovery

Disceovery Scheduleの画面に戻るのでRelated LinksからDiscover Nowを選択して今の設定でDiscoveryを実行してみます

image.png

Discovery Status

画面が遷移してDiscovery Statusが表示されます

image.png

レコードを選択すると詳細を確認できます

image.png

Related LinksでShow Discovery TimelineをクリックするとDiscoveyのTimelineを確認できます

image.png

Devicesを選択すると4つのDeviceを探しに行って2つ見つかって1つCMDB CIに登録されたようです

image.png

Device

CMDB CIが登録されたDeviceのCreatedをクリックするとDeviceが確認できました

image.png

DiscoveryされたCMDB CI

DeviceのCMDB CIを選択してOpen Recordをクリックして

image.png

DiscoveryされたCIを確認できました

image.png

Related ListでInstallされているpkgや

image.png

起動しているpsまで取得できています

image.png

3
0
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?