{"_id":"_design/summary","_rev":"4-ea29b4205c4fed402a477c4d0218ccb1","language":"javascript","views":{"app_resources":{"map":"function(doc) {\n\tfor(id in doc){\n\t\tif(id.match(/^apps.+$/i)){\n\t\t\tindex = doc[id].length -1 \n\t\t\temit(doc._id,doc[id][index][0])//doc[id][index])\n\t\t}\n\t}\n}","reduce":"function(keys,values){\n\tvar cpu = 0 ;\n\tvar mem_avail = 0 ;\n\tvar mem_used = 0\n\n\tfor(i in values){\n\t\trow = values[i]\n\t\tmem_avail \t+= row.memory_available\n\t\tmem_used \t+= (row.memory_available*row.memory_usage/100)\n\t\tcpu\t\t+= row.cpu_usage\n\t}\n\n\tif(mem_avail > 999 && mem_avail < 999999){\n\t\tunits=\"MB\"\n\t}else {\n\t\tunits=\"GB\"\n\t}\n\tmem_avail = parseFloat(mem_avail.toFixed(2))\n\tmem_used = parseFloat(mem_used.toFixed(2))\n\n\treturn {\"app_count\":values.length,\"memory_available\":mem_avail,\"memory_usage\":mem_used,\"cpu_usage\":cpu,\"units\":units}\n}"},"app_names":{"map":"function(doc) {\n\tfor(id in doc){\n\t\tif(id.match(/^apps.+$/i)){\n\t\t\tindex = doc[id].length -1 \n\t\t\temit(doc._id,id)\n\t\t}\n\t}\n}","reduce":"function(keys,values){\n\tvar cpu = 0 ;\n\tvar mem = 0 ;\n\treturn values\n}"},"folder_size":{"map":"function(doc) {\n\tfor(id in doc){\n\t\tif(id.match(/^folder.+$/i)){\n\n\t\t\tindex = doc[id].length -1 \n\t\t\tif (doc[id][index].length > 0){\n\t\t\t\temit(doc._id,doc[id][index][0])//doc[id][index])\n\t\t\t}\n\t\t}\n\t}\n}","reduce":"function(keys,values){\n\tvar size=0\n\tvar units = {\"MB\":1000,\"GB\":1000000,\"TB\":1000000000}\n\tfor(i in values){\n\t\trow = values[i]\n\t\tsvalue = row.size.match(/^[\\d,.]+/i)\n\t\tukey \t= row.size.match(/[a-z]+$/i)\n\t\tsize\t+= parseFloat(svalue)*units[ukey]\n\t}\n\tif (size > 999 && size < 999999){\n\t\tunits=\"MB\"\n\t\tsize /=1000\n\t}else if(size > 999999 && 999999999){\n\t\tunits=\"GB\"\n\t\tsize /=1000000\n\t}else{ \n\t\tunits = \"TB\"\n\t\tsize /=1000000000\n\t}\n\treturn {\"folder_count\":values.length,\"size\":size,\"units\":units} //parseFloat(values[0].size.match(/^[\\d,.]+/))\n}"},"app_status":{"map":"function(doc) {\n\tfor(id in doc){\n\t\tif(id.match(/^apps.+$/i)){\n\t\t\tindex = doc[id].length -1 \n\t\t\tif(doc[id][index].length > 0){\n\t\t\t\temit(doc._id,doc[id][index])\n\t\t\t}\n\t\t}\n\t}\n}","reduce":"function(keys,values){\n\tvar status = {\"crash\":0,\"idle\":0,\"running\":0}\n\tfor(i in values){\n\t\tfor(ii in values[i]){\n\t\t\trow = values[i][ii]\n\t\t\tid = row.status\n\t\t\tif(status[id] != null){\n\t\t\t\tstatus[id] += 1\n\t\t\t}\n\n\t\t}\n\t}\n\treturn status\n}"},"resource_usage_trend":{"map":"function(doc) {\n\tfor(id in doc){\n\t\tif(id.match(/^apps.+$/i)){\n\t\t\tend = doc[id].length -1\n\t\t\tbeg = doc[id].length - 10\n\t\t\tfor(var i = end; i > beg ; --i){\n\t\t\t\temit(doc._id,doc[id][i])//doc[id][index])\n\t\t\t}\n\t\t}\n\t}\n}","reduce":"function(keys,values){\n\tvar cpu = 0 ;\n\tvar mem_avail = 0 ;\n\tvar mem_used = 0\n\tvar size = 20\n\tfor(i in values){\n\t\tend = values[i].length -1\n\t\tbeg = end - size\n\t\tfor(ii in values[i]){\n\t\t\trow = values[i][ii]\n\t\t\tmem_avail \t+= row.memory_available\n\t\t\tmem_used \t+= (row.memory_available*row.memory_usage/100)\n\t\t\tcpu\t\t+= row.cpu_usage\n\t\t}\n\t\t\t\n\t\t\n\t}\n\n\tif(mem_avail > 999 && mem_avail < 999999){\n\t\tunits=\"MB\"\n\t}else {\n\t\tunits=\"GB\"\n\t}\n\tmem_avail = parseFloat(mem_avail.toFixed(2))\n\tmem_used = parseFloat(mem_used.toFixed(2))\n\t//return row\t//return values[0].slice(beg,end)\n\treturn {\"app_count\":values.length,\"memory_available\":mem_avail,\"memory_usage\":mem_used,\"cpu_usage\":cpu,\"units\":units}\n}"}}}
