Temperature monitoring

Rand

Guru
Joined
Dec 30, 2013
Messages
906
Can't you simply run a cron job?
Cron-> Log
tail on log whenever you want to look

Or run sth like librenms/nagios to do it for you and get nice charts too ;)
 

Rand0mUser

Dabbler
Joined
Jun 1, 2019
Messages
22
Hello,

No, a cron job is not good, the python server must be launched and stay online so I can access it at any time when the Freenas system is up.

I just need to refresh the url in web browser and see last temps. I think I'll have to run it as a script.
 

Rand

Guru
Joined
Dec 30, 2013
Messages
906
So start it in the background, put a small script around it with pid check to see if its already running else (re-)start it
 

Rand0mUser

Dabbler
Joined
Jun 1, 2019
Messages
22
Hello,

I wrote a short script and tried few things:

- adding a cronjob to launch the sript at startup (it's not working, since FreeNAS will overwrite cron file at startup based upon FreeNAS default and settings done using WebUI)
- adding the script to rc.d (it's not working, since FreeNAS will overwrite rc.d file at startup based upon FreeNAS default and settings done using WebUI)
- adding script to cron or rc.d in a jail running on the FreeNAS (since my temperature monitoring files are located at /root/scripts and I dont want jail to access this path, it's not good either or I should just move everything)

Best way to make the script working would be that FreeNAS WebUI Cron Jobs can support @Reboot directive, so I created a ticket for that in the FreeNAS issue tracker: FreeNAS Cron Jobs don't support @reboot directive .

If this feature is fixed, using @Reboot in WebUI will allow users to easily launch scripts at startup. Maybe it will be OK for next update.
 

Jacopx

Patron
Joined
Feb 19, 2016
Messages
367
Hello,

I wrote a short script and tried few things:

- adding a cronjob to launch the sript at startup (it's not working, since FreeNAS will overwrite cron file at startup based upon FreeNAS default and settings done using WebUI)
- adding the script to rc.d (it's not working, since FreeNAS will overwrite rc.d file at startup based upon FreeNAS default and settings done using WebUI)
- adding script to cron or rc.d in a jail running on the FreeNAS (since my temperature monitoring files are located at /root/scripts and I don't want jail to access this path, it's not good either or I should just move everything)

Best way to make the script working would be that FreeNAS WebUI Cron Jobs can support @Reboot directive, so I created a ticket for that in the FreeNAS issue tracker: FreeNAS Cron Jobs don't support @reboot directive .

If this feature is fixed, using @Reboot in WebUI will allow users to easily launch scripts at startup. Maybe it will be OK for next update.
Why you can't simply add the execution to the FreeNAS GUI Cron Jobs?
 

Rand0mUser

Dabbler
Joined
Jun 1, 2019
Messages
22
Hello,

Because the python web server has to be launched only once at startup and then run in the background. It can't be launched every x minutes nor seconds. There is a crontab directive for such use, it's:

Code:
@reboot


But it's not supported by FreeNAS for now, that's the reason why I created a ticket in issue tracker.
 

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504

Rand0mUser

Dabbler
Joined
Jun 1, 2019
Messages
22
Hello,

I alreay tried, and it's not working adding this command as Post Init:

Code:
cd /root/scripts/ && python -m http.server 8014


Seems like those Post Init commands just won't let a process run in the background as needed. As explained here, it will only run at system boot. Or did I miss something? Command is working fine from the shell.
 

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504
cd /root/scripts/ && python -m http.server 8014
That seems like a very strange way to run it--I'd expect python -m /root/scripts/http.server 8014 might work better.
 

Rand0mUser

Dabbler
Joined
Jun 1, 2019
Messages
22
Thanks, I just tried but it's still the same, the command just won't keep running in the background when launched using Post Init settings in the webUI.
 
Last edited:

Rand0mUser

Dabbler
Joined
Jun 1, 2019
Messages
22

Chris Moore

Hall of Famer
Joined
May 2, 2015
Messages
10,080
Is your command in a file that is executed as a script?
 

Rand0mUser

Dabbler
Joined
Jun 1, 2019
Messages
22
Hello,

I tried both command and script file. Both are not working since the way Init tasks are made will not let a command run in the background.
 

Rand0mUser

Dabbler
Joined
Jun 1, 2019
Messages
22
Hello,

I upgraded to a new server, so I worked on fixing this and I found out an easy way I wanted to share with the forum. I managed to get what I wanted by creating a jail, installing apache24 on it, and setting mountpoint from temperature-monitoring script directory to /temp directory of apache web server.

A small howto:

Create a jail from webUI, let's call it "Apache"
Log in to the jail:

Code:
iocage list
jexec "your-jail-number" tcsh


Then install apache and create temp directory

Code:
pkg install apache24
sysrc apache24_enable=yes
mkdir /usr/local/www/apache24/data/temp


Now stop jail and create mountpoint as following:

Code:
Source
/mnt/pool-name/dataset-name/temperature-monitoring
Destination
/mnt/pooll-name/iocage/jails/Apache/root/usr/local/www/apache24/data/temp


Start jail and open web browser:

Code:
http://jail-ip-address/temp/


So you can see directory listing of files in the temperature-monitoring folder:

apache-ok.png

Just click on one of png files to see temp stats, CPU or drives:

drives.png


If you need to make any change to apache default conf:

Code:
ee /usr/local/etc/apache24/httpd.conf


And that's it, you can see your hdds and CPU temps from any web browser, hassle free.
 
Top