Skip to content

Commit bc5688c

Browse files
19548 jenkins: add user agent to session headers
Adding a user agent header enables administrators to easily identify requests originating from Checkmk in Jenkins access logs or network monitoring tools. This will hopefully simplify monitoring and troubleshooting. The content of the user agent was intentionally done in this way so that it will pass the plugin consistency tests. CMK-32813 Change-Id: Ief3ebf00b9549aab0770142cf308883cd8c23c45
1 parent eff5a42 commit bc5688c

2 files changed

Lines changed: 24 additions & 1 deletion

File tree

.werks/19548.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
[//]: # (werk v3)
2+
# Jenkins: add User-Agent HTTP header to special agent
3+
4+
key | value
5+
---------- | ---
6+
date | 2026-03-24T12:32:16.794953+00:00
7+
version | 2.5.0b5
8+
class | feature
9+
edition | community
10+
component | checks
11+
level | 1
12+
compatible | yes
13+
14+
The Jenkins special agent now specifies the HTTP "User-Agent" header as
15+
`User-Agent: checkmk-special-jenkins-{version}`. The `version` variable here
16+
denotes which version of Checkmk is running.
17+
18+
This allows administrators to easily identify the agent in their access logs or
19+
network monitoring tools, simplifying the monitoring and troubleshooting of
20+
these inbound requests.
21+
22+
No user configuration is required for this change.

cmk/plugins/jenkins/special_agent/agent_jenkins.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
__version__ = "2.5.0b5"
2525

2626
AGENT = "jenkins"
27-
27+
USER_AGENT = f"checkmk-special-{AGENT}-{__version__}"
2828
PASSWORD_OPTION = "secret"
2929

3030

@@ -143,6 +143,7 @@ def handle_request(args, sections):
143143
# labels = {}
144144

145145
session = requests.Session()
146+
session.headers.update({"User-Agent": USER_AGENT})
146147
session.auth = (args.user, resolve_secret_option(args, PASSWORD_OPTION).reveal())
147148

148149
for section in sections:

0 commit comments

Comments
 (0)