Skip to content

Instantly share code, notes, and snippets.

View manuelmorales's full-sized avatar

Manuel Morales manuelmorales

View GitHub Profile
db.currentOp().inprog.ForEach(
function(operation) {
if(operation.secs_running > 30) db.killOp(operation.opid))
})
// kills long running ops in MongoDB (taking seconds as an arg to define "long")
// attempts to be a bit safer than killing all by excluding replication related operations
// and only targeting queries as opposed to commands etc.
killLongRunningOps = function(maxSecsRunning) {
currOp = db.currentOp();
for (oper in currOp.inprog) {
op = currOp.inprog[oper-0];
if (op.secs_running > maxSecsRunning && op.op == "query" && !(/^local/.exec(op.ns))) {
print("Killing opId: " + op.opid
@manuelmorales
manuelmorales / 0_reuse_code.js
Created December 16, 2013 23:27
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@manuelmorales
manuelmorales / gist:2558759
Created April 30, 2012 14:24 — forked from lennart/gist:1717337
A Gentoo startup script for the newrelic server monitor daemon
#!/sbin/runscript
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $
depend() {
need net
}
start() {