Andrew Bogott has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/350920 )

Change subject: Monitor wikitech-static mediawiki version
......................................................................

Monitor wikitech-static mediawiki version

This will warn when wikitech-static diverges from the
latest MW version as reported on mediawiki.org.

It will never go critical or page, just warn until
someone upgrades.

Bug: T163721
Change-Id: If7d96b30db26e85ce2779b790520683db554f1ae
---
A modules/icinga/files/check_wikitech_static_version.py
M modules/icinga/manifests/plugins.pp
A modules/icinga/templates/check_commands/check_wikitech_static_version.cfg.erb
M modules/role/manifests/labs/openstack/nova/manager.pp
4 files changed, 71 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/puppet 
refs/changes/20/350920/1

diff --git a/modules/icinga/files/check_wikitech_static_version.py 
b/modules/icinga/files/check_wikitech_static_version.py
new file mode 100755
index 0000000..4115a84
--- /dev/null
+++ b/modules/icinga/files/check_wikitech_static_version.py
@@ -0,0 +1,47 @@
+#!/usr/bin/python
+
+import requests
+
+# This url ought to point us to the currently supported version as
+#  MediaWiki as declared on mediawiki.org:
+try:
+    latest_version_url = 
"https://www.mediawiki.org/w/api.php?action=expandtemplates&text=%7B%7BMW_stable_release_number%7D%7D&format=json&formatversion=2&prop=wikitext";
+    latest_req = requests.get(latest_version_url, verify=False)
+    latest_req.raise_for_status()
+    {u'expandtemplates': {u'wikitext': u'1.28.1'}}
+    latest_version = latest_req.json()['expandtemplates']['wikitext']
+except:
+    print "Failed to determine latest MediaWiki version from mediawiki.org"
+    exit(3)
+
+
+# And, this should grab the version of the currently running
+#  version on wikitech-static:
+try:
+    static_version_url = 
"https://wikitech-static.wikimedia.org/w/api.php?action=query&meta=siteinfo&siprop=general&format=json";
+    static_req = requests.get(static_version_url, verify=False)
+    static_req.raise_for_status()
+    static_version_string = static_req.json()['query']['general']['generator']
+    # static_version_string should be of the format "MediaWiki x.y.z"
+    static_version = static_version_string.split(' ')[1]
+except:
+    print "Failed to determine wikitech-static MediaWiki version"
+    exit(3)
+
+if not latest_version:
+    print "Failed to determine latest MediaWiki version from mediawiki.org"
+    exit(3)
+
+if not static_version:
+    print "Failed to determine wikitech-static MediaWiki version"
+    exit(3)
+
+if static_version == latest_version:
+    print("Wikitech-static is running the latest MediaWiki version, %s" %
+          latest_version)
+    exit(0)
+else:
+    print("Wikitech-static is running MediaWiki version %s.  "
+          "It needs to be upgraded to %s." % (static_version,
+                                              latest_version))
+    exit(1)
diff --git a/modules/icinga/manifests/plugins.pp 
b/modules/icinga/manifests/plugins.pp
index 05a755b..df6976a 100644
--- a/modules/icinga/manifests/plugins.pp
+++ b/modules/icinga/manifests/plugins.pp
@@ -73,6 +73,12 @@
         group  => 'root',
         mode   => '0755',
     }
+    file { '/usr/lib/nagios/plugins/check_wikitech_static_version':
+        source => 'puppet:///modules/icinga/check_wikitech_static_version.py',
+        owner  => 'root',
+        group  => 'root',
+        mode   => '0755',
+    }
     file { '/usr/lib/nagios/plugins/check_mysql-replication.pl':
         source => 'puppet:///modules/icinga/check_mysql-replication.pl',
         owner  => 'root',
@@ -152,6 +158,14 @@
         group      => 'icinga',
     }
 
+    nagios_common::check_command::config { 'check_wikitech_static_version.cfg':
+        ensure     => present,
+        content    => 
template('icinga/check_commands/check_wikitech_static_version.cfg.erb'),
+        config_dir => '/etc/icinga',
+        owner      => 'icinga',
+        group      => 'icinga',
+    }
+
     # Include check_elasticsearch from elasticsearch module
     include ::elasticsearch::nagios::plugin
 }
diff --git 
a/modules/icinga/templates/check_commands/check_wikitech_static_version.cfg.erb 
b/modules/icinga/templates/check_commands/check_wikitech_static_version.cfg.erb
new file mode 100644
index 0000000..08935f2
--- /dev/null
+++ 
b/modules/icinga/templates/check_commands/check_wikitech_static_version.cfg.erb
@@ -0,0 +1,4 @@
+define command{
+    command_name    check_wikitech_static_version
+    command_line    $USER1$/check_wikitech_static_version
+}
diff --git a/modules/role/manifests/labs/openstack/nova/manager.pp 
b/modules/role/manifests/labs/openstack/nova/manager.pp
index 51657c9..ee7c525 100644
--- a/modules/role/manifests/labs/openstack/nova/manager.pp
+++ b/modules/role/manifests/labs/openstack/nova/manager.pp
@@ -64,6 +64,12 @@
         check_command => 'check_wikitech_static',
     }
 
+    # T163721
+    monitoring::service { 'wikitech-static-version':
+        description   => 'Does wikitech-static need a version upgrade?',
+        check_command => 'check_wikitech_static_version',
+    }
+
     # For Math extensions file (T126628)
     file { '/srv/math-images':
         ensure => 'directory',

-- 
To view, visit https://gerrit.wikimedia.org/r/350920
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: If7d96b30db26e85ce2779b790520683db554f1ae
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Andrew Bogott <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to