You can use strace on a specific pid to figure out what a specific process is doing, e.g.:
strace -fp <pid>
You might see something like:
select(9, [3 5 8], [], [], {0, 999999}) = 0 (Timeout)
var current_id; // id of first record on current page. | |
// go to page current+N | |
db.collection.find({_id: {$gt: current_id}}). | |
skip(N * page_size). | |
limit(page_size). | |
sort({_id: 1}); | |
// go to page current-N | |
db.collection.find({_id: {$lt: current_id}}). |
/opt/mongodb/bin/mongo --port 27017 --eval "db._adminCommand(\"listDatabases\").databases.forEach(function (d) {mdb = db.getSiblingDB(d.name); mdb.getCollectionNames().forEach(function(c) {s = mdb[c].stats(1024 * 1024); printjson(s)})})" | less |
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
Vagrant.configure("2") do |config| | |
# All Vagrant configuration is done here. The most common configuration | |
# options are documented and commented below. For a complete reference, | |
# please see the online documentation at vagrantup.com. | |
# Every Vagrant virtual environment requires a box to build off of. | |
config.vm.box = "quantal64" |
db.profiles.ensureIndex({collection: 1}); | |
db.profiles.ensureIndex({collection: 1, op: 1}); | |
db.profiles.ensureIndex({collection: 1, op: 1, skel: 1}); |
perl -ne '/([0-9a-z]{24,24})/ and print $1, "\n"' 01_07.txt | |
# run command with only 1 argument (-L 1, --max-lines 1) and ask before each command | |
ls -la | xargs --interactive -L 1 echo | |
# substitution in xargs | |
xargs -L 1 -I{} echo "ID IS: {}" | |
sed -i -e s/\,\.\$comment:.\".*\"// mongodb_short_sed.log |
=======load_avg.sh========= | |
#! /bin/bash | |
#if [ 0 == 1 ]; then | |
HOSTS=('pm.mongo1' 'pm.mongo2' 'pm.mongo3' 'pm.mongo4') | |
out="[new Date(\"$(date +"%F %H:%M:%S")\")" | |
for host in ${HOSTS[@]}; do | |
load_avg=$(ssh -p 60222 user@$host "cat /proc/loadavg") |
db.pin.tagtask.find().forEach(function(t) {if (t.status == 1) { var photo = db.photo.findOne({_id: t.photo_id}); printjson(photo)} }); |
perl -ne '/([0-9a-z]{24,24})/ and print $1, "\n"' 12_07.txt | xargs -L 1 -I{} mongo 127.0.0.1:2707/db --eval \ | |
"var _pid = '{}'; | |
print(_pid); | |
var pin = db.pin.find({_id: ObjectId(_pid)}); | |
if (pin && pin[0]._id) { | |
print('pin found: ' + pin[0]._id); | |
var photo = db.photo.find({_id: pin[0].p}); | |
if (photo && photo[0]._id) { | |
print('photo_id: ', photo[0]._id); | |
print('remove photo: ', db.photo.remove({_id: photo[0]._id}) ); |
#! /bin/bash | |
#if [ 0 == 1 ]; then | |
HOSTS=('pm.mongo1' 'pm.mongo2' 'pm.mongo3' 'pm.mongo4') | |
out="[new Date(\"$(date +"%F %H:%M:%S")\")" | |
for host in ${HOSTS[@]}; do | |
load_avg=$(ssh -p 60222 atairov@$host "cat /proc/loadavg") | |
read avg1 avg5 avg15 _tmp <<< $load_avg | |
out="$out, $avg1, null" |