Skip to content

Instantly share code, notes, and snippets.

@giuliano108
Last active January 2, 2016 02:09
Show Gist options
  • Save giuliano108/8235364 to your computer and use it in GitHub Desktop.
Save giuliano108/8235364 to your computer and use it in GitHub Desktop.
Nagios Grid Sort
// ==UserScript==
// @name Nagios grid sort
// @namespace http://108.bz/
// @version 0.1
// @description
// @match https://nagios.blah.net/nagios/cgi-bin/status.cgi?hostgroup=blah&style=grid
// @require http://code.jquery.com/jquery-2.0.3.min.js
// @require http://tinysort.sjeiti.com/dist/jquery.tinysort.min.js
// ==/UserScript==
var status_table = jQuery('table.status')
var status_table_headers = jQuery('table.status>tbody>tr').first().remove()
var status_table_thead = jQuery('<thead></thead>').appendTo(status_table)
status_table_headers.appendTo(status_table_thead)
jQuery('table.status>tbody>tr').tsort('td:eq(0)',{sortFunction:function(a,b){
na = a.e.text().trim().match(/[0-9]+/);
if (!na) return 0;
na = parseInt(na);
nb = b.e.text().trim().match(/[0-9]+/);
if (!nb) return 0;
nb = parseInt(nb);
return na===nb?0:(na>nb?1:-1);
}})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment