|
[{"id":"fdf4c19d.020b4","type":"exec","command":"ifconfig","append":"","useSpawn":false,"name":"ifconfig","x":250,"y":120,"z":"4e9fa0fb.b1606","wires":[["a9026acc.56fd98","9ac15a53.653ea8"],[],[]]},{"id":"fb5f1434.04a0e8","type":"twitter out","twitter":"","name":"Tweet ip","x":810,"y":120,"z":"4e9fa0fb.b1606","wires":[]},{"id":"8cc3ead1.733c18","type":"inject","name":"get ip - eth0","topic":"ip","payload":"eth0","payloadType":"none","repeat":"","crontab":"","once":true,"x":97,"y":120.5,"z":"4e9fa0fb.b1606","wires":[["fdf4c19d.020b4"]]},{"id":"a9026acc.56fd98","type":"debug","name":"","active":false,"console":false,"complete":false,"x":399,"y":66.5,"z":"4e9fa0fb.b1606","wires":[]},{"id":"d580cc31.2a7f3","type":"debug","name":"test out","active":true,"console":"false","complete":"false","x":628,"y":65.5,"z":"4e9fa0fb.b1606","wires":[]},{"id":"9ac15a53.653ea8","type":"function","name":"Extract network config","func":"// This node parses the info from the command \"ifconfig\" \n// and outputs a string such as:\n\n//\"TestRasPi network config for eth0 \n//inet addr: 192.168.0.120 \n//Bcast: 192.168.0.255 \n//Mask: 255.255.255.0\"\n\n// This parsed info can then be passed to whatever service you want it to be sent out on. My favorite is twitter.\n// Function created by Teslafly - Feel free to do anything you want with it.\n\n// user variables\nvar DefaultIP = \"192.168.0.100\"; // Change to whatever ip adress you dont want your system to tweet on.\n\n\n\n// beginning of function\n/////////////////////////////////////////////////////////\n// Initialize variables\nvar input, tokens, inet, bcast, mask;\nvar outString = \"TestRasPi network config for eth0\\n\"; // start message of outstring, change if you want the beginning of your message to be different.\n\n// Parse the entire string by spaces, and put each item into an array called tokens\n\ninput = msg.payload;\ntokens = input.split(\":\", 10);\n\n// Get the 7th token (example: \"addr:192.168.0.120\")\n// and get the substring from character 6 to the end\ninet = tokens[7].split(\" \", 1);\noutString += \"\\n\" + \"inet addr: \" + inet[0];\n\n// Get the 8th token (example: \"Bcast:192.168.0.255\")\n// and get the substring from character 7 to the end\nbcast = tokens[8].split(\" \", 1);\noutString += \"\\n\" + \"Bcast: \" + bcast[0];\n\n// Get the 9th token (example: \"Mask:255.255.255.0\")\n// and get the substring from character 6 to the end\nmask = tokens[9].split(\" \", 1);\noutString += \"\\n\" + \"Mask: \" + mask[0];\n\n// Don't send a message if the IF is the known default. Change to default ip.\nif (inet==DefaultIP) { \n//outString = \"\"; // set output to null if ip is the same so no message is sent\nreturn null;\n}else{\n// return the final output\nreturn {payload: outString};\n}\n","outputs":1,"x":450,"y":120,"z":"4e9fa0fb.b1606","wires":[["d580cc31.2a7f3","1b91eb52.e46e15"]]},{"id":"1b91eb52.e46e15","type":"delay","name":"let init","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":650,"y":120,"z":"4e9fa0fb.b1606","wires":[["fb5f1434.04a0e8"]]}] |