Hi,
concerning the topic "how to get the CPU temperature" here is a way to do it on AX88u (here is a simplified Python function):
def getCpuTemp():
f = open("/sys/class/thermal/thermal_zone0/temp")
temp = f.read()
f.close()
return int(temp)/1000
Note: if you decide to implement it in Python you should add some error management to the above code depending on how you use it, e.g. in case the file is not there (in AX88u it should be always there, but on a different router it could be in another place or just be missing).
P.S.: I've seen other topics against the use of Python on the router due to higher resources usage, however the real point should not be to avoid the use of Python, but to try to avoid calling python scripts as you do with other binary executables in bash scripts (quote: βDonβt cross the streams.β).
Bash in itself is fast and light, however the burden starts to be heavy when you call multiple external executables in the script (even compiled binaries). Every single external script/command called involves, besides disk/cache access, allocating and running an additional process, if in a script you call many times external programs to perform small tasks the overhead is significant and it would probably be much more effective and efficient to run everything in a single Python (even better from byte-code) or Perl script.
To sum up:
- Bash is fast and efficient al long as it doesn't run a lot of external commands (but its native functions are very limited so thus you need rely heavily on externals).
- Perl is very fast in parsing files, but if you need to use additional perl libraries this would make more difficult to manage the dependencies on the router and it even might become significantly more resource intensive.
- Python is fast and has a good number of native functions plus with the ability to run byte code so it's in game with the Perl scenario.
So if you can do it with native bash involving a very limited number of external commands in it, go for it. If you need a lot of external commands I'd say to consider Perl, which is very fast in parsing text and files. If you need Perl libraries I'd say to give it a shot with Python and its native features. Mostly the decision depends on how complex are the scripts and the hardware on which they will run.