-
Notifications
You must be signed in to change notification settings - Fork 0
/
flows_pi1.json
1 lines (1 loc) · 5.24 KB
/
flows_pi1.json
1
[{"id":"6f7d319e.7b6f3","type":"tab","label":"PiCam1"},{"id":"96fd196d.3190c8","type":"tls-config","z":"","name":"","cert":"","key":"","ca":"","verifyservercert":false},{"id":"ca04540.db43fb","type":"aws-config","z":""},{"id":"b026a4bf.c3f7c8","type":"watch","z":"6f7d319e.7b6f3","name":"PhotosDir","files":"/home/pi","x":80,"y":40,"wires":[["142e2d8f.68f2a2"]]},{"id":"142e2d8f.68f2a2","type":"delay","z":"6f7d319e.7b6f3","name":"","pauseType":"timed","timeout":"3","timeoutUnits":"seconds","rate":"1","nbRateUnits":"3","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":310,"y":40,"wires":[["befa8ac1.b20b68"]]},{"id":"b7f156.5d0c8ea8","type":"exec","z":"6f7d319e.7b6f3","command":"/usr/bin/find","addpay":true,"append":"/home/pi -type f -name 'pi*_img*.jpg' -mtime +7 -delete","useSpawn":false,"timer":"3","name":"","x":310,"y":420,"wires":[["ea04c941.cf2fa8"],["ea04c941.cf2fa8"],["ea04c941.cf2fa8"]]},{"id":"4c60b11b.15207","type":"comment","z":"6f7d319e.7b6f3","name":"Purge images 7+ days old every hour","info":"","x":190,"y":460,"wires":[]},{"id":"9c173dc9.4cc99","type":"inject","z":"6f7d319e.7b6f3","name":"","topic":"","payload":"","payloadType":"date","repeat":"3600","crontab":"","once":false,"x":110,"y":420,"wires":[["b7f156.5d0c8ea8"]]},{"id":"8fb26bc7.a5ee88","type":"http request","z":"6f7d319e.7b6f3","name":"","method":"use","ret":"txt","url":"","tls":"96fd196d.3190c8","x":790,"y":300,"wires":[["a574f089.0cde1"]]},{"id":"4162fa76.998b04","type":"function","z":"6f7d319e.7b6f3","name":"Config Splunk HEC","func":"// strip off the last three numbers\nvar trimEpochDate = new Date().valueOf().toString();\ntrimEpochDate = trimEpochDate.substr(0,trimEpochDate.length-3);\n\n// node.warn(JSON.stringify(msg));\n// node.warn(escape(msg));\n\n// add ImageMacigck field to msg\n// assuming size, filename already present\nvar imMeanVal = msg.payload;\nmsg.imMeanVal = imMeanVal;\n\nmsg.payload = {\n \"time\": parseInt(trimEpochDate),\n \"host\":\"pi1\",\n \"source\":\"blob storage\",\n \"event\": JSON.stringify(msg)\n}\nmsg.headers = {\n \"Authorization\" : \"Splunk 31E9DF7E-6A39-43B6-9C8A-7E6A562EE006\",\n \"Content-Type\" : \"application/json\",\n \"Cache-Control\": \"no-cache\"\n}\n\nmsg.url = \"https://maui.local:8088/services/collector/event\";\nmsg.method = \"POST\";\n\nreturn msg;","outputs":"1","noerr":0,"x":570,"y":300,"wires":[["8fb26bc7.a5ee88"]]},{"id":"a574f089.0cde1","type":"debug","z":"6f7d319e.7b6f3","name":"","active":false,"console":"false","complete":"true","x":970,"y":300,"wires":[]},{"id":"add9cdbb.24a91","type":"amazon s3 out","z":"6f7d319e.7b6f3","aws":"ca04540.db43fb","bucket":"macewan-home-backdoor","filename":"","localFilename":"","region":"us-west-2","name":"","x":850,"y":240,"wires":[]},{"id":"492e883e.c3cce8","type":"function","z":"6f7d319e.7b6f3","name":"Config AWS Blob","func":"msg.filename = msg.file;\n// msg.localFilename = msg.payload;\nmsg.localFilename = msg.upstreamPayload\nreturn msg;","outputs":1,"noerr":0,"x":570,"y":240,"wires":[["add9cdbb.24a91"]]},{"id":"3037507e.e3798","type":"http request","z":"6f7d319e.7b6f3","name":"","method":"use","ret":"txt","url":"","tls":"96fd196d.3190c8","x":750,"y":420,"wires":[["789f1c89.d487c4"]]},{"id":"ea04c941.cf2fa8","type":"function","z":"6f7d319e.7b6f3","name":"Config Splunk HEC","func":"// strip off the last three numbers\nvar trimEpochDate = new Date().valueOf().toString();\ntrimEpochDate = trimEpochDate.substr(0,trimEpochDate.length-3);\n\nmsg.payload = {\n \"time\": parseInt(trimEpochDate),\n \"host\":\"pi1\",\n \"source\":\"purge images\",\n \"event\": JSON.stringify(msg)\n}\nmsg.headers = {\n \"Authorization\" : \"Splunk 31E9DF7E-6A39-43B6-9C8A-7E6A562EE006\",\n \"Content-Type\" : \"application/json\",\n \"Cache-Control\": \"no-cache\"\n}\n\nmsg.url = \"https://maui.local:8088/services/collector/event\";\nmsg.method = \"POST\";\n\nreturn msg;","outputs":"1","noerr":0,"x":530,"y":420,"wires":[["3037507e.e3798"]]},{"id":"789f1c89.d487c4","type":"debug","z":"6f7d319e.7b6f3","name":"","active":false,"console":"false","complete":"true","x":930,"y":420,"wires":[]},{"id":"9436bb91.423778","type":"exec","z":"6f7d319e.7b6f3","command":"/usr/bin/identify","addpay":true,"append":"","useSpawn":false,"timer":"3","name":"","x":560,"y":100,"wires":[["57d22fc6.70036"],[],[]]},{"id":"befa8ac1.b20b68","type":"function","z":"6f7d319e.7b6f3","name":"Config ImageMagick","func":"var imageMagickArgs = \"-format '%[mean]' \" + msg.payload\nvar upstreamFile = msg.file;\nvar upstreamSize = msg.size;\nvar upstreamPayload = msg.payload;\n\nmsg = {\n \"payload\": imageMagickArgs,\n \"file\": upstreamFile,\n \"size\": upstreamSize,\n \"upstreamPayload\": upstreamPayload\n}\nreturn msg;","outputs":1,"noerr":0,"x":320,"y":100,"wires":[["9436bb91.423778"]]},{"id":"57d22fc6.70036","type":"switch","z":"6f7d319e.7b6f3","name":"","property":"payload","propertyType":"msg","rules":[{"t":"gte","v":"4500","vt":"num"}],"checkall":"true","outputs":1,"x":530,"y":180,"wires":[["492e883e.c3cce8","4162fa76.998b04"]]},{"id":"93e832e8.3543d","type":"comment","z":"6f7d319e.7b6f3","name":"Check the image's mean with ImageMagick","info":"If the image is mainly black (ie. too dark due to night), we'll skip saving it to AWS.","x":390,"y":140,"wires":[]}]