Is this possible? Store data from Asus Router ajax .asp page for Temperature data.
-
Must be doing something wrong I am getting null in the local expression
Looks like the path is wrong it should be root not my home dir
Doesn't work either if I put in root instead of ~
I then tried copying the id_rsa file into my home directory and the .ssh folder in there. But it still doesn't work. So I am stuck now.
-
OK. The
~
means the home directory of the login user, and where MSR is running, that appears to be/home/stuart
, so that's why the first attempt doesn't work.The second attempt doesn't work because you used
root/...
instead of/root/...
... it's a path, not a username, so it needs to begin with a/
. Just changing that is unlikely to work, either, because regular users (like stuart) do not have (and should never have) access to the.ssh
directory of any other user, especially that ofroot
.You need to copy the public and private key files to somewhere where Reactor has access, and specify the full path to that directory in the command line's
-i
option.Alternately, use the public key for user stuart as the trusted key on the router, and let that user make the connection. This is by far preferable, as copying
root
's private key around to other places and giving it lower access permissions presents serious security risks. -
OK thanks, I changed the command in the rule to this now:
ssh -i /root/.ssh/id_rsa admin@192.168.0.1 'cat /sys/class/thermal/thermal_zone0/temp'
I am no longer getting any alert errors in MSR but the local expression is not being populated. As your edit just said that is likely why.
I then tried this command instead.
ssh -i home/stuart/.ssh/id_rsa admin@192.168.0.1 'cat /sys/class/thermal/thermal_zone0/temp'
and
ssh -i /home/stuart/.ssh/id_rsa admin@192.168.0.1 'cat /sys/class/thermal/thermal_zone0/temp'
But I get alert errors again.
"Alternately, use the public key for user stuart as the trusted key on the router, and let that user make the connection."
That might be the best option. I need to work out how to ssh-keygen for a particular user though ?
-
toggledbitsreplied to cw-kid on Jul 26, 2023, 8:04 PM last edited by toggledbits Jul 26, 2023, 4:10 PM
@cw-kid said in Is this possible? Store data from Asus Router ajax .asp page for Temperature data.:
I need to work out how to ssh-keygen for a particular user though ?
Why? Just use the existing key in
~stuart/.ssh
. If there isn't one, you just runssh-keygen
as user stuart rather than asroot
(nosudo
either). -
Got it I just connected to the MSR host logging in as me rather than root user and ran the keygen again, it created the two key files in my own .ssh folder now. I will add that to the router and try again. Thanks
-
-
@cw-kid the
\n
at the end is a newline character. Linux is quite literal. You can push that string through the expressionint()
function and it will convert it to a number and ignore the newline. -
@toggledbits said in Is this possible? Store data from Asus Router ajax .asp page for Temperature data.:
You can push that string through the expression int() function
No idea what that means, but I will search. I also need to do some thing with that data like round it, as it says"66986" which should read as 66.99 degrees
-
OK I see what you mean my local expression is a string. But how to change it to int ?
When you create a local expression it gives you no option of the type it should be.
-
-
int(RouterCPUTemp) / 1000
-
-
You can wrap that in a
round()
if you only want one decimal (for example)...round( int( RouterCPUTemp ) / 1000, 1 )
-
cw-kidreplied to toggledbits on Jul 26, 2023, 8:44 PM last edited by cw-kid Jul 26, 2023, 4:46 PM
@toggledbits said in Is this possible? Store data from Asus Router ajax .asp page for Temperature data.:
round( int( RouterCPUTemp ) / 1000, 1 )
Even better, you have made my day! Thank you.
I have been worrying about my router getting too hot, now I will know if it does.
-
This post is deleted!
-
-
Maybe I should also add a timeout to the ssh commands ?
ssh -o ConnectTimeout=10 -i ~/.ssh/id_rsa admin@192.168.0.1 'cat /sys/class/thermal/thermal_zone0/temp'
-
Think I just found a bug? try naming a local expression as "2.4GTempRaw" without the quotes in a rule and see what happens. I am stuck and cannot delete the expression or exist the rule. Had to refresh the browser to recover. Should of known not to put a dot in the name LOL.
I might have just corrupted the rule now I cannot add an expression named "24GTempRaw"
Or maybe its the numbers it doesn't like.
OK that's better.
-
-
This is much more powerful than I imagined. Seems you can send any old linux command like "free" to see the memory usage. I haven't figured out how to extract and parse just a part of the returned data yet though, say just the "Used" memory value.
(string) " total used free shared buffers cached\nMem: 426020 303308 122712 3404 0 39212\n-/+ buffers/cache: 264096 161924\nSwap: 0 0 0\n"
"303308" is the used memory value, no idea how to extract just that part of the data to another local expression though as its not formatted like JSON data would be.
19/77