Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Z
zabbix
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
infra
ansible-shared
zabbix
Commits
a41da22c
Commit
a41da22c
authored
6 years ago
by
Robin Sonnabend
Browse files
Options
Downloads
Patches
Plain Diff
Use apt to query the installed zabbix version
parent
13c147f3
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
zabbix-repo/files/check-update.py
+26
-5
26 additions, 5 deletions
zabbix-repo/files/check-update.py
zabbix-repo/templates/crontab.j2
+1
-1
1 addition, 1 deletion
zabbix-repo/templates/crontab.j2
with
27 additions
and
6 deletions
zabbix-repo/files/check-update.py
+
26
−
5
View file @
a41da22c
...
@@ -2,10 +2,30 @@
...
@@ -2,10 +2,30 @@
import
urllib.request
import
urllib.request
import
re
import
re
import
subprocess
as
sp
PATTERN
=
r
'
<a\shref=
"
(?P<link>\d\.\d/)
"
>(?P<version>\d\.\d)/</a>\s+(?P<date>\d{2}-[A-Z][a-z]{2}-\d{4} \d{2}:\d{2})\s+-
'
PATTERN
=
r
'
<a\shref=
"
(?P<link>\d\.\d/)
"
>(?P<version>\d\.\d)/</a>\s+(?P<date>\d{2}-[A-Z][a-z]{2}-\d{4} \d{2}:\d{2})\s+-
'
PKG_NAME
=
"
zabbix-server-pgsql
"
def
get_versions
():
def
parse_apt_version
(
version_str
):
return
list
(
map
(
int
,
version_str
.
split
(
"
:
"
)[
1
].
split
(
"
-
"
)[
0
].
split
(
"
.
"
)))[:
2
]
def
get_installation
():
command
=
[
"
apt
"
,
"
show
"
,
PKG_NAME
]
version
=
None
source
=
None
for
line
in
sp
.
check_output
(
command
,
stderr
=
sp
.
PIPE
,
universal_newlines
=
True
).
splitlines
():
if
line
.
startswith
(
"
Version:
"
):
version
=
parse_apt_version
(
line
.
split
(
"
:
"
,
1
)[
1
])
elif
line
.
startswith
(
"
APT-Sources:
"
):
source
=
line
.
split
(
"
:
"
,
1
)[
1
].
strip
()
return
version
,
source
def
get_remote_versions
():
response
=
urllib
.
request
.
urlopen
(
"
https://repo.zabbix.com/zabbix/
"
)
response
=
urllib
.
request
.
urlopen
(
"
https://repo.zabbix.com/zabbix/
"
)
page_content
=
response
.
read
().
decode
(
"
utf-8
"
)
page_content
=
response
.
read
().
decode
(
"
utf-8
"
)
for
match
in
re
.
findall
(
PATTERN
,
page_content
):
for
match
in
re
.
findall
(
PATTERN
,
page_content
):
...
@@ -16,10 +36,11 @@ def get_versions():
...
@@ -16,10 +36,11 @@ def get_versions():
def
main
():
def
main
():
import
sys
current_version
,
source
=
get_installation
()
current_version
=
sys
.
argv
[
1
]
if
not
source
.
startswith
(
"
http://repo.zabbix.com/
"
):
current_major
,
current_minor
=
map
(
int
,
current_version
.
split
(
"
.
"
))
return
highest_version
,
date
=
sorted
(
get_versions
())[
-
1
]
current_major
,
current_minor
=
current_version
highest_version
,
date
=
sorted
(
get_remote_versions
())[
-
1
]
if
(
current_major
,
current_minor
)
<
highest_version
:
if
(
current_major
,
current_minor
)
<
highest_version
:
print
(
print
(
"
New Zabbix version is available: {} from {}, please upgrade!
"
.
format
(
"
New Zabbix version is available: {} from {}, please upgrade!
"
.
format
(
...
...
This diff is collapsed.
Click to expand it.
zabbix-repo/templates/crontab.j2
+
1
−
1
View file @
a41da22c
{{60|random(seed=inventory_hostname)}} {{6|random(seed=inventory_hostname)}} * * * root /usr/local/sbin/check-update.py
{{zabbix_version}}
{{60|random(seed=inventory_hostname)}} {{6|random(seed=inventory_hostname)}} * * * root /usr/local/sbin/check-update.py
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment