MongoDB shell version v4.0.0
connecting to: mongodb://192.168.16.111:20001/admin
MongoDB server version: 3.4.9
WARNING: shell and server versions do not match
{
"host" : "iZ2zeem1uivcbfbr01nmnrZ:20000",
"version" : "3.4.9",
"process" : "mongos",
"pid" : NumberLong(10828),
"uptime" : 24441734,
"uptimeMillis" : NumberLong("24441733680"),
"uptimeEstimate" : NumberLong(24441733),
"localTime" : ISODate("2018-08-02T09:34:54.400Z"),
"asserts" : {
"regular" : 0,
"warning" : 0,
"msg" : 0,
"user" : 1763423,
"rollovers" : 0
},
"connections" : {
"current" : 86,
"available" : 52342,
"totalCreated" : 118672
},
"extra_info" : {
"note" : "fields vary by platform",
"page_faults" : 14
},
"network" : {
"bytesIn" : NumberLong("467536962787"),
"bytesOut" : NumberLong("111369070632"),
"physicalBytesIn" : NumberLong("467536962787"),
"physicalBytesOut" : NumberLong("108213593338"),
"numRequests" : NumberLong("2582169303")
},
"opcounters" : {
"insert" : 619611,
"query" : 406777,
"update" : 122426978,
"delete" : 61,
"getmore" : 308,
"command" : 215576153
},
"sharding" : {
"configsvrConnectionString" : "config/iZ2ze7s6pfi7t4x18mx417Z:22000,iZ2ze7s6pfi7t4x18mx418Z:22000,iZ2ze7s6pfi7t4x18mx419Z:22000",
"lastSeenConfigServerOpTime" : {
"ts" : Timestamp(1533202490, 2),
"t" : NumberLong(3)
}
},
"tcmalloc" : {
"generic" : {
"current_allocated_bytes" : 4007000,
"heap_size" : NumberLong("3108966400")
},
"tcmalloc" : {
"pageheap_free_bytes" : 36864,
"pageheap_unmapped_bytes" : NumberLong("3090604032"),
"max_total_thread_cache_bytes" : NumberLong(1073741824),
"current_total_thread_cache_bytes" : 5583584,
"total_free_bytes" : 14318504,
"central_cache_free_bytes" : 3283112,
"transfer_cache_free_bytes" : 5451808,
"thread_cache_free_bytes" : 5583584,
"aggressive_memory_decommit" : 0,
"formattedString" : "------------------------------------------------\nMALLOC: 4007000 ( 3.8 MiB) Bytes in use by application\nMALLOC: + 36864 ( 0.0 MiB) Bytes in page heap freelist\nMALLOC: + 3283112 ( 3.1 MiB) Bytes in central cache freelist\nMALLOC: + 5451808 ( 5.2 MiB) Bytes in transfer cache freelist\nMALLOC: + 5583584 ( 5.3 MiB) Bytes in thread cache freelists\nMALLOC: + 8577216 ( 8.2 MiB) Bytes in malloc metadata\nMALLOC: ------------\nMALLOC: = 26939584 ( 25.7 MiB) Actual memory used (physical + swap)\nMALLOC: + 3090604032 ( 2947.4 MiB) Bytes released to OS (aka unmapped)\nMALLOC: ------------\nMALLOC: = 3117543616 ( 2973.1 MiB) Virtual address space used\nMALLOC:\nMALLOC: 2014 Spans in use\nMALLOC: 115 Thread heaps in use\nMALLOC: 4096 Tcmalloc page size\n------------------------------------------------\nCall ReleaseFreeMemory() to release freelist memory to the OS (via madvise()).\nBytes released to the OS take up virtual address space but no physical memory.\n"
}
},
"mem" : {
"bits" : 64,
"resident" : 174,
"virtual" : 3426,
"supported" : true
},
"metrics" : {
"cursor" : {
"timedOut" : NumberLong(380),
"open" : {
"multiTarget" : NumberLong(0),
"singleTarget" : NumberLong(0),
"pinned" : NumberLong(0),
"total" : NumberLong(0)
}
},
"commands" : {
"<UNKNOWN>" : NumberLong(1),
"aggregate" : {
"failed" : NumberLong(142),
"total" : NumberLong(8980)
},
"authenticate" : {
"failed" : NumberLong(12),
"total" : NumberLong(12)
},
"buildInfo" : {
"failed" : NumberLong(0),
"total" : NumberLong(635407)
},
"collStats" : {
"failed" : NumberLong(65),
"total" : NumberLong(6827)
},
"count" : {
"failed" : NumberLong(388),
"total" : NumberLong(491985789)
},
"create" : {
"failed" : NumberLong(0),
"total" : NumberLong(10)
},
"createIndexes" : {
"failed" : NumberLong(1),
"total" : NumberLong(69)
},
"createUser" : {
"failed" : NumberLong(6),
"total" : NumberLong(10)
},
"currentOp" : {
"failed" : NumberLong(0),
"total" : NumberLong(15)
},
"dbStats" : {
"failed" : NumberLong(7),
"total" : NumberLong(917)
},
"delete" : {
"failed" : NumberLong(0),
"total" : NumberLong(705)
},
"distinct" : {
"failed" : NumberLong(17),
"total" : NumberLong(5105)
},
"drop" : {
"failed" : NumberLong(0),
"total" : NumberLong(67)
},
"dropDatabase" : {
"failed" : NumberLong(0),
"total" : NumberLong(7)
},
"dropIndexes" : {
"failed" : NumberLong(7),
"total" : NumberLong(23)
},
"enableSharding" : {
"failed" : NumberLong(1),
"total" : NumberLong(2)
},
"explain" : {
"failed" : NumberLong(0),
"total" : NumberLong(13)
},
"find" : {
"failed" : NumberLong(131),
"total" : NumberLong(1764517)
},
"findAndModify" : {
"failed" : NumberLong(1),
"total" : NumberLong(772)
},
"getLastError" : {
"failed" : NumberLong(0),
"total" : NumberLong(1989)
},
"getLog" : {
"failed" : NumberLong(0),
"total" : NumberLong(2)
},
"getMore" : {
"failed" : NumberLong(17),
"total" : NumberLong(1791)
},
"getnonce" : {
"failed" : NumberLong(0),
"total" : NumberLong(38)
},
"insert" : {
"failed" : NumberLong(0),
"total" : NumberLong(207939962)
},
"isMaster" : {
"failed" : NumberLong(0),
"total" : NumberLong(35391424)
},
"killCursors" : {
"failed" : NumberLong(0),
"total" : NumberLong(79)
},
"listCollections" : {
"failed" : NumberLong(0),
"total" : NumberLong(862)
},
"listDatabases" : {
"failed" : NumberLong(0),
"total" : NumberLong(263)
},
"listIndexes" : {
"failed" : NumberLong(0),
"total" : NumberLong(8)
},
"logout" : {
"failed" : NumberLong(0),
"total" : NumberLong(8658)
},
"mapReduce" : {
"failed" : NumberLong(24),
"total" : NumberLong(64)
},
"ping" : {
"failed" : NumberLong(0),
"total" : NumberLong(5980)
},
"profile" : {
"failed" : NumberLong(4),
"total" : NumberLong(4)
},
"renameCollection" : {
"failed" : NumberLong(0),
"total" : NumberLong(2)
},
"repairDatabase" : {
"failed" : NumberLong(0),
"total" : NumberLong(1)
},
"replSetGetStatus" : {
"failed" : NumberLong(88870),
"total" : NumberLong(88870)
},
"rolesInfo" : {
"failed" : NumberLong(0),
"total" : NumberLong(491)
},
"saslContinue" : {
"failed" : NumberLong(4),
"total" : NumberLong(183362)
},
"saslStart" : {
"failed" : NumberLong(8),
"total" : NumberLong(91691)
},
"serverStatus" : {
"failed" : NumberLong(0),
"total" : NumberLong(223111)
},
"shardCollection" : {
"failed" : NumberLong(0),
"total" : NumberLong(3)
},
"update" : {
"failed" : NumberLong(0),
"total" : NumberLong(552681439)
},
"usersInfo" : {
"failed" : NumberLong(0),
"total" : NumberLong(493)
},
"whatsmyuri" : {
"failed" : NumberLong(0),
"total" : NumberLong(54513)
}
}
},
"ok" : 1
}
Bye
UserParameter=MongoDB.Status[*],/bin/echo "db.serverStatus().$1" |/usr/bin/mongo 192.168.16.111:20001/admin -ulichao -plichao | grep "\<$2\>" |awk -F : ‘{print $$2}‘ |awk -F , ‘{print $$1}‘
UserParameter=MongoDB.byesOut,/bin/echo "db.serverStatus().network" |/usr/bin/mongo 192.168.16.111:20001/admin -ulichao -plichao | grep "bytesOut" | awk -F : ‘{print $2}‘ | awk -F , ‘{print $1}‘ | awk -F \" ‘{print $2}‘
UserParameter=MongoDB.bytesIn,/bin/echo "db.serverStatus().network" |/usr/bin/mongo 192.168.16.111:20001/admin -ulichao -plichao | grep "bytesIn" | awk -F : ‘{print $2}‘ | awk -F , ‘{print $1}‘ | awk -F \" ‘{print $2}‘
添加完畢儲存儲存退出。
然後直接匯入模板監控即可。模板在這:https://pan.baidu.com/s/1PFrhealedPUejz7ACI_WVA
添加到web上我麼你可以在圖形上看到
到此mongo監控完畢。