You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
2 lines
7.3 KiB
JavaScript
2 lines
7.3 KiB
JavaScript
{"_id":"_design/summary","_rev":"17-7946b6365b1273500fad19ffce81ff4c","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\tvar logs = doc[id][index]\n\t\t\tfor(var i=0; i < logs.length; i++){\n\t\t\t\temit(doc._id,logs[i])\n\t\t\t}\n\t\t\t//emit(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= (mem_avail < row.memory_available)?row.memory_available:mem_avail\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\tvar logs = doc[id][index]\n\t\t\tfor(var i=0; i < logs.length; i++){\n\t\t\t\temit(doc._id,logs[i])\n\t\t\t}\n\t\t\t//if (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\tsize = parseFloat(size.toFixed(2))\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 - 25\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 = [] ;\n\tvar mem_avail = [] ;\n\tvar mem_used = []\n\tvar size = 20\n\tvar beg = null\n\tvar end = null\n\tapps = {}\n\tapp_count = 0\n\tfor(i in values){\n\t\t//end = values[i].length -1\n\t\t//beg = end - size\n\t\tfor(ii in values[i]){\n\t\t\trow = values[i][ii]\n\t\t\tapps[row.label] = 1\n\t\t\tif(beg == null){\n\t\t\t\tbeg = ([row.year,row.month,row.day]).join('/')+' ' +([row.hour,row.minute]).join(':')\n\t\t\t}\n\t\t\tmem_avail.push( parseFloat(row.memory_available.toFixed(2)))\n\t\t\tmem_used.push(row.memory_available*row.memory_usage/100)\n\t\t\tcpu.push(row.cpu_usage)\n\t\t\t\n\t\t}\n\t\tend = ([row.year,row.month,row.day]).join('/')+' ' +([row.hour,row.minute]).join(':')\n\t\n\t\t\n\t}\n\t//\n\t// counting applications found in the logs\n\t// There is no requirement on consistency of the logs\n\t//\n\tfor(i in apps){\n\t\tapp_count += 1\n\t}\n\t\n\t//return row\t//return values[0].slice(beg,end)\n\treturn {\"app_count\":app_count,\"beg\":beg,\"end\":end,\"memory_available\":mem_avail,\"memory_usage\":mem_used,\"cpu_usage\":cpu}\n}"},"app_status_details":{"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\tbeg = doc[id].length -25 \n\t\t\tvar logs = doc[id].slice(beg,index);//[index]\n\n\t\t\tfor(var i=0; i < logs.length; i++){\n\t\t\t\tvar rec = logs[i]\n\t\t\t\tfor (ii in rec){\n\t\t\t\t\temit(doc._id,rec[ii])\n\t\t\t\t}\n\t\t\t}\n\t\t\t//emit(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\tr = {}\n\t//\n\t// retrieving the memory available\n\tfor(i in values){\n\t\trow = values[i]\n\t\tmem_avail = (mem_avail < row.memory_available)?row.memory_available:mem_avail \n\t}\n\t//\n\t// Determining appropriate units of measurement\n\t//\n\t\t\n\tif(mem_avail > 999 && mem_avail < 999999){\n\t\tunits=\"MB\"\n\t}else {\n\t\tunits=\"GB\"\n\t}\n\n\n\tfor(i in values){\n\n\t\trow = values[i]\n\t\tvar id = row.label\n\t\t\n\t\tif (r[id] == null){\n\t\t\tr[id] = {\"beg\":null,\"end\":null,\"crash\":0,\"idle\":0,\"running\":0}\n\t\t}\n\t\tr[id][row.status] += 1\n\t\tif(r[id].beg == null){\n\t\t\tr[id].beg = ([row.year,row.month,row.day]).join('/')+' '+([row.hour,row.minute]).join(':')\n\t\t}\n\t\tr[id].end = ([row.year,row.month,row.day]).join('/')+' '+([row.hour,row.minute]).join(':')\n\t}\n\n\n\t//mem_avail = parseFloat(mem_avail.toFixed(2))\n\t//mem_used = parseFloat(mem_used.toFixed(2))\n\n\treturn r //{\"app_count\":values.length,\"memory_available\":mem_avail,\"memory_usage\":mem_used,\"cpu_usage\":cpu,\"units\":units}\n}"},"app_resource_usage_details":{"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\tbeg = doc[id].length -25 \n\t\t\tvar logs = doc[id].slice(beg,index);//[index]\n\n\t\t\tfor(var i=0; i < logs.length; i++){\n\t\t\t\tvar rec = logs[i]\n\t\t\t\tfor (ii in rec){\n\t\t\t\t\temit(doc._id,rec[ii])\n\t\t\t\t}\n\t\t\t}\n\t\t\t//emit(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\tr = {}\n\t//\n\t// retrieving the memory available\n\tfor(i in values){\n\t\trow = values[i]\n\t\tmem_avail = (mem_avail < row.memory_available)?row.memory_available:mem_avail \n\t}\n\t//\n\t// Determining appropriate units of measurement\n\t//\n\t\t\n\tif(mem_avail > 999 && mem_avail < 999999){\n\t\tunits=\"MB\"\n\t}else {\n\t\tunits=\"GB\"\n\t}\n\n\n\tfor(i in values){\n\n\t\trow = values[i]\n\t\tvar id = row.label\n\t\t\n\t\tif (r[id] == null){\n\t\t\tr[id] = {\"beg\":null,\"end\":null,\"memory_used\":[],\"cpu\":[]}\n\t\t}\n\n\t\tr[id].memory_used \t.push ( parseFloat((mem_avail*row.memory_usage/100).toFixed(2)) )\n\t\tr[id].cpu\t.push(row.cpu_usage)\n\t\tif(r[id].beg == null){\n\t\t\tr[id].beg = ([row.year,row.month,row.day]).join('/')+' '+([row.hour,row.minute]).join(':')\n\t\t}\n\t\tr[id].end = ([row.year,row.month,row.day]).join('/')+' '+([row.hour,row.minute]).join(':')\n\t}\n\n\n\t//mem_avail = parseFloat(mem_avail.toFixed(2))\n\t//mem_used = parseFloat(mem_used.toFixed(2))\n\n\treturn r //{\"app_count\":values.length,\"memory_available\":mem_avail,\"memory_usage\":mem_used,\"cpu_usage\":cpu,\"units\":units}\n}"}}}
|