"reduce":"function(keys,values){\n\tvar cpu = 0 ;\n\tvar mem = 0 ;\n\treturn values\n}"
"map":"function(doc) {\n\tfor(id in doc){\n\t\tif(id.match(/^apps.+$/i) && doc[id].length > 0){\n\t\t\tindex = doc[id].length -1 \n\t\t\tvar size = doc[id].length\n\t\t\tvar offset = 25\n\t\t\t//\n\t\t\t// We get the last 25 rows ( a days worth of observations\n\t\t\t//\n\t\t\tvar rows = doc[id].slice(size-offset,size)\n\t\t\tfor(var i=0; i < rows.length; i++){\n\t\t\t\tfor(var j=0; j < rows[i].length; j++){\n\t\t\t\t\tvar info = {}\n\t\t\t\t\tinfo[id]=rows[i][j]\n\t\t\t\t\t\n\t\t\t\t\temit(doc._id,info)\t\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t}\n\t}\n}",
"reduce":"function(keys,values){\n\tvar m = {} ;\n\tvar r = {}\n\tfor (var i =0; i < values.length; i++){\n\t\tvar rows = values[i]\n\t\tfor (node in rows){\n\t\t\tvar log = rows[node]\n\t\t\tif(m[node] == null){\n\t\t\t\tm[node]={}\n\t\t\t\tr[node]=[]\n\t\t\t}\n\t\t\tvar app = log.label.toLowerCase()\n\t\t\tif(m[node][app] == null){\n\t\t\t\tm[node][app] = 1\n\t\t\t\tr[node].push(app)\n\t\t\t}\n\t\t}\n\t}\n\treturn r\n\t\n}"
},
"folder_size":{
"map":"function(doc) {\n\tfor(id in doc){\n\t\tif(id.match(/^folder.+/) && doc[id].length > 0){\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}\n\t}\n}",
@ -28,8 +28,8 @@
"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\n\tfor(i in values){\n\t\trow = values[i]\n\t\tfor(id in row){\n\t\t\tmem_avail = (mem_avail < row[id].memory_available)?row[id].memory_available:mem_avail \n\t\t}\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\trec = values[i]\n\t\tfor(key in rec){\n\t\t\trow = rec[key]\n\t\t\tvar id = row.label\n\t\t\tif(r[key] == null){ r[key] = {} }\n\t\t\tif (r[key][id] == null){\n\t\t\t\tr[key][id] = {\"beg\":null,\"end\":null,\"crash\":0,\"idle\":0,\"running\":0}\n\t\t\t}\n\t\t\tr[key][id][row.status] += 1\n\t\t\tif(r[key][id].beg == null){\n\t\t\t\tr[key][id].beg = ([row.year,row.month,row.day]).join('/')+' '+([row.hour,row.minute]).join(':')\n\t\t\t}\n\t\t\tr[key][id].end = ([row.year,row.month,row.day]).join('/')+' '+([row.hour,row.minute]).join(':')\n\t\t}\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)?doc[id].length -25 :0\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}"
"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)?doc[id].length -25 :0\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\tvar info = {}\n\t\t\t\t\tinfo[id] = rec[ii]\n\t\t\t\t\temit(doc._id,info)//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\tvar rvalues = values[i]\n\t\tfor(id in rvalues){\n\t\t\trow = rvalues[id]\n\t\t\tmem_avail = parseFloat(row.memory_available) ;//mem_avail < row.memory_available)?row.memory_available:mem_avail \n\t\t\tapp_id = row.label.toLowerCase()\n\t\t\tif(r[id] == null){\n\t\t\t\t\n\t\t\t\tr[id] = {}\n\t\t\t}\n\t\t\tif(r[id][app_id] == null){\n\t\t\t\tr[id][app_id] = {memory_available:0,cpu:[],memory_used:[],dates:[]}\n\t\t\t}\n\n\t\t\tr[id][app_id].memory_available += mem_avail\n\t\t\t//app_id = row.label.toLowerCase()\n\n\t\t\tif(mem_avail > 999 && mem_avail < 999999){\n\t\t\t\tunits=\"MB\"\n\t\t\t\t\n\t\t\t}else {\n\t\t\t\tunits=\"GB\"\n\t\t\t}\t\n\t\t\tr[id][app_id].units = units\n\t\t}\n\t\tfor(var id in rvalues){\n\t\t\trow = rvalues[id]\n\t\t\tapp_id = row.label.toLowerCase()\n\t\t\tif(r[id][app_id].units == 'MB'){\n\t\t\t\tr[id][app_id].memory_available = parseFloat((r[id][app_id].memory_available/ 1000).toFixed(2))\n\t\t\t}else{\n\t\t\t\t//\n\t\t\t\t// assuming we have GB\n\t\t\t\tr[id][app_id].memory_available = parseFloat((r[id][app_id].memory_available/ 1000000).toFixed(2))\n\t\t\t}\n\t\t\tdate = new Date(row.year,row.month,row.day,row.hour,row.minute)\n\t\t\tdate = ([row.hour,row.minute]).join('H:')//{month:row.month,year:row.year,day:row.day,hour:row.hour,minute:row.minute}\n\t\t\tr[id][app_id].dates.push(date)\t\t\t\t\t\n\t\t\t//r[id][app_id].end = \t([row.year,row.month,row.day]).join('/')+' '+([row.hour,row.minute]).join(':')\n\t\t\tmem_avail = r[id][app_id].memory_available == 0?1:r[id][app_id].memory_available\n\t\t\tr[id][app_id].memory_used.push(parseFloat((mem_avail*row.memory_usage).toFixed(2)))\n\t\t\tr[id][app_id].cpu.push(row.cpu_usage)\n\t\t\t\n\t\t\t\n\t\t}\n\t\t\n\t}\n\treturn r\n}"