Skip to content

Commit 709a9d0

Browse files
hithwenofek
andauthored
Add windows support (#10737)
* Add support for windows Co-authored-by: Ofek Lev <ofekmeister@gmail.com>
1 parent d2c93d1 commit 709a9d0

13 files changed

Lines changed: 80 additions & 17 deletions

File tree

.azure-pipelines/changes.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646
- template: './templates/test-single-windows.yml'
4747
parameters:
4848
job_name: Changed
49-
check: '--changed datadog_checks_base datadog_checks_dev active_directory aspdotnet disk dns_check dotnetclr exchange_server iis network pdh_check sqlserver tcp_check win32_event_log windows_performance_counters windows_service wmi_check'
49+
check: '--changed datadog_checks_base datadog_checks_dev active_directory aspdotnet disk dns_check dotnetclr exchange_server ibm_mq iis network pdh_check sqlserver tcp_check win32_event_log windows_performance_counters windows_service wmi_check'
5050
${{ if eq(variables['System.PullRequest.IsFork'], 'False') }}:
5151
ddtrace_flag: '--ddtrace'
5252
validate_changed: changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import os
2+
from tempfile import TemporaryDirectory
3+
from zipfile import ZipFile
4+
5+
import requests
6+
7+
8+
CLIENT_VERSION = '9.2.2.0'
9+
CLIENT_ARCHIVE_NAME = f'{CLIENT_VERSION}-IBM-MQC-Redist-Win64.zip'
10+
CLIENT_URL = f'https://public.dhe.ibm.com/ibmdl/export/pub/software/websphere/messaging/mqdev/redist/{CLIENT_ARCHIVE_NAME}'
11+
CLIENT_TARGET_DIR = 'C:\\ibm_mq'
12+
13+
14+
def download_file(url, file_name):
15+
response = requests.get(url, stream=True)
16+
response.raise_for_status()
17+
18+
with open(file_name, 'wb') as f:
19+
for chunk in response.iter_content(16384):
20+
f.write(chunk)
21+
22+
23+
def main():
24+
with TemporaryDirectory() as d:
25+
temp_dir = os.path.realpath(d)
26+
27+
print('Downloading client')
28+
client_archive_path = os.path.join(temp_dir, CLIENT_ARCHIVE_NAME)
29+
download_file(CLIENT_URL, client_archive_path)
30+
31+
print('Extracting client')
32+
with ZipFile(client_archive_path) as zip_file:
33+
zip_file.extractall(CLIENT_TARGET_DIR)
34+
35+
36+
if __name__ == '__main__':
37+
main()

.azure-pipelines/templates/test-all-checks.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,11 @@ jobs:
226226
displayName: IBM i
227227
os: linux
228228
- checkName: ibm_mq
229-
displayName: IBM MQ
229+
displayName: IBM MQ (Linux)
230230
os: linux
231+
- checkName: ibm_mq
232+
displayName: IBM MQ (Windows)
233+
os: windows
231234
- checkName: ibm_was
232235
displayName: IBM WAS
233236
os: linux

datadog_checks_base/datadog_checks/base/data/agent_requirements.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ pyhdb==0.3.4
5959
pyjwt==1.7.1; python_version < "3.0"
6060
pyjwt==2.0.1; python_version > "3.0"
6161
pymongo==3.11.4
62-
pymqi==1.12.0; sys_platform != "win32"
62+
pymqi==1.12.0
6363
pymysql==0.9.3
6464
pyodbc==4.0.26
6565
pyro4==4.73; sys_platform == "win32"

ibm_mq/README.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@ This check monitors [IBM MQ][1] versions 8 to 9.0.
1010

1111
The IBM MQ check is included in the [Datadog Agent][2] package.
1212

13-
To use the IBM MQ check, you need to:
13+
To use the IBM MQ check, you need to make sure the [IBM MQ Client][3] 9.1+ is installed (unless a compatible version of IBM MQ server is installed on the Agent host).
14+
15+
#### On Linux
1416

15-
1. Make sure the [IBM MQ Client][3] 9.1+ is installed (unless a compatible version of IBM MQ server is installed on the Agent host).
16-
2. Update your `LD_LIBRARY_PATH` and `C_INCLUDE_PATH` to include the location of the libraries. (Create these two environment variables if they don’t exist yet.) For example:
17+
Update your `LD_LIBRARY_PATH` and `C_INCLUDE_PATH` to include the location of the libraries. (Create these two environment variables if they don’t exist yet.)
18+
For example, if you installed it in `/opt`:
1719

1820
```text
1921
export LD_LIBRARY_PATH=/opt/mqm/lib64:/opt/mqm/lib:$LD_LIBRARY_PATH
@@ -129,7 +131,12 @@ Update the bindings:
129131
sudo ldconfig
130132
```
131133

132-
#### Permissions and authentication
134+
#### On Windows
135+
136+
There is a file called `mqclient.ini` in the IBM MQ data directory. It is normally `C:\ProgramData\IBM\MQ`.
137+
Configure the environment variable `MQ_FILE_PATH`, to point at the data directory.
138+
139+
### Permissions and authentication
133140

134141
There are many ways to set up permissions in IBM MQ. Depending on how your setup works, create a `datadog` user within MQ with read only permissions.
135142

ibm_mq/manifest.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
"support": "core",
1212
"supported_os": [
1313
"linux",
14-
"mac_os"
14+
"mac_os",
15+
"windows"
1516
],
1617
"public_title": "Datadog-IBM MQ Integration",
1718
"categories": [

ibm_mq/requirements.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
pymqi==1.12.0; sys_platform != 'win32'
1+
pymqi==1.12.0

ibm_mq/tests/common.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,22 @@
44

55
import os
66

7+
import pytest
8+
79
from datadog_checks.dev import get_docker_hostname
10+
from datadog_checks.dev.ci import running_on_ci
11+
from datadog_checks.dev.utils import ON_WINDOWS
812

913
# Ignore missing library to not require it for e2e
1014
try:
1115
from datadog_checks.ibm_mq.metrics import COUNT, GAUGE
1216
except ImportError:
1317
COUNT = GAUGE = ''
1418

19+
RUNNING_ON_WINDOWS_CI = ON_WINDOWS and running_on_ci()
20+
skip_windows_ci = pytest.mark.skipif(RUNNING_ON_WINDOWS_CI, reason='MQ server cannot be setup on Windows VMs in CI')
21+
22+
1523
HERE = os.path.dirname(os.path.abspath(__file__))
1624
COMPOSE_DIR = os.path.join(HERE, 'compose')
1725

ibm_mq/tests/test_ibm_mq_e2e.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,18 @@
66

77
from datadog_checks.dev.utils import get_metadata_metrics
88

9-
from .common import MQ_VERSION, assert_all_metrics
9+
from .common import MQ_VERSION, assert_all_metrics, skip_windows_ci
10+
11+
pytestmark = [skip_windows_ci, pytest.mark.e2e]
1012

1113

12-
@pytest.mark.e2e
1314
def test_e2e_check_all(dd_agent_check, instance_collect_all):
1415
aggregator = dd_agent_check(instance_collect_all, rate=True)
1516

1617
assert_all_metrics(aggregator)
1718
aggregator.assert_metrics_using_metadata(get_metadata_metrics())
1819

1920

20-
@pytest.mark.e2e
2121
@pytest.mark.skipif(
2222
MQ_VERSION < 9, reason='Only test for for version >=9, for v8 use a custom image with custom setup.'
2323
)

ibm_mq/tests/test_ibm_mq_int.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
from datadog_checks.dev.utils import get_metadata_metrics
1515

1616
from . import common
17-
from .common import QUEUE_METRICS, assert_all_metrics
17+
from .common import QUEUE_METRICS, assert_all_metrics, skip_windows_ci
1818

19-
pytestmark = [pytest.mark.usefixtures("dd_environment"), pytest.mark.integration]
19+
pytestmark = [skip_windows_ci, pytest.mark.usefixtures("dd_environment"), pytest.mark.integration]
2020

2121

2222
def test_no_msg_errors_are_caught(get_check, instance, caplog):

0 commit comments

Comments
 (0)