@jhturner108: - John. Her kernel version and android version are both older than the one on my Samsung Galaxy S3. I suspect the hardware is equally old.
The problem, I'm almost convinced, is that the older versions of the hardware coupled with the old Android version and Kernel version cannot properly handle the traffic that more modern devices can. Older devices are slower and the older software has some bugs that may be fixed in the later releases. So there is basically not a lot we can do except limp along by eliminating software that makes heavy use of the resources.
It appears that most of the recent problems that people have reported here were caused by the latest update to the Facebook app. Uninstalling it and using the web interface to Facebook appears to get rid of the problem for most people. My problem as well as another user's problem was that there was an update in end of Nov 2016 or beginning of Dec 2016 to the Ping & DNS app that caused the problem. Both he and I were already not using the Facebook app on our devices.
As for the script that I wrote, it was just to make it easier for me to see the problem beginning. Prior to writing the script, I was displaying the same information using other means in a more manual way. My script requires the loading of a Python language interpreter also. You are probably better off just using the manual display which I will describe for you.
The app that is necessary to do the manual display is an app that allows you to enter Linux command line commands to retrieve information from the Android OS. The one I use is "Terminal Emulator for Android" by Jack Palevich. It is available in Google Play.
Long before the mdnsd process shows up as using a lot of battery power in the Battery display, there are signs of trouble that just worse and worse until the mdnsd process starts looping and using up all available CPU time and draining the battery. The symptom of the problem is that a "netstat" command displays more than a few "udp" and "udp6" sockets using port 5353 when you run the "netstat" command. An truncated example of this is:
$ netstat | grep udp
udp 0 0 0.0.0.0:5353 0.0.0.0:* CLOSE
udp 4928 0 0.0.0.0:5353 0.0.0.0:* CLOSE
udp 4928 0 0.0.0.0:5353 0.0.0.0:* CLOSE
udp 112320 0 0.0.0.0:5353 0.0.0.0:* CLOSE
udp 112320 0 0.0.0.0:5353 0.0.0.0:* CLOSE
udp 112320 0 0.0.0.0:5353 0.0.0.0:* CLOSE
udp 118208 0 0.0.0.0:5353 0.0.0.0:* CLOSE
udp 127296 0 0.0.0.0:5353 0.0.0.0:* CLOSE
udp 132032 0 0.0.0.0:5353 0.0.0.0:* CLOSE
udp 143040 0 0.0.0.0:5353 0.0.0.0:* CLOSE
udp 159104 0 0.0.0.0:5353 0.0.0.0:* CLOSE
udp 159808 0 0.0.0.0:5353 0.0.0.0:* CLOSE
udp6 0 0 :::5353 :::* CLOSE
udp6 0 0 :::5353 :::* CLOSE
udp6 4224 0 :::5353 :::* CLOSE
udp6 4224 0 :::5353 :::* CLOSE
udp6 4224 0 :::5353 :::* CLOSE
udp6 4224 0 :::5353 :::* CLOSE
udp6 39936 0 :::5353 :::* CLOSE
udp6 39936 0 :::5353 :::* CLOSE
udp6 39936 0 :::5353 :::* CLOSE
udp6 39936 0 :::5353 :::* CLOSE
udp6 39936 0 :::5353 :::* CLOSE
udp6 41344 0 :::5353 :::* CLOSE
udp6 41344 0 :::5353 :::* CLOSE
udp6 57472 0 :::5353 :::* CLOSE
Here the command is "netstat" and the result is filtered by the "grep udp" to eliminate other extraneous output.
The second column of the output is the number of bytes of unprocessed udp input that is waiting to be processed by the owner process. The third column is 0 and the fourth column is a combination of IPv4 (udp) or IPv6 (udp6) address followed by a colon and the udp port number (5353).
If instead you use the command
$ netstat | grep -c 5353
you will get a number indicating the number of lines of netstat output that have the number 5353 in it.
We have found from experience that when the number of lines (sockets) is between 500 and 600, the mdnsd process starts to loop, probably because it is attempting to open another socket, but there are insufficient resources to do that so it ends up in a failure loop. Once that happens, your only recourse is to restart your device.
What you can do is to unload any apps that you know are resource intensive (Facebook, for example) and any other apps that may have been recently updated. Then slowly, one by one, add them back in. After each is added back in, you may not see any of the symptoms described above immediatedly. It sometimes doesn't show up till half a day later, so you'll have to be patient and periodically run the above command.
Sorry, I can't be more help. Feel free to ask any further questions. I look at this possibly once a day.
Henry