Register for the iXsystems Community to get an ad-free experience and exclusive discounts in our eBay Store.

Temperature monitoring

Rand

FreeNAS Experienced
Joined
Dec 30, 2013
Messages
787
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

Newbie
Joined
Jun 1, 2019
Messages
17
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

FreeNAS Experienced
Joined
Dec 30, 2013
Messages
787
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

Newbie
Joined
Jun 1, 2019
Messages
17
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.
 

Jacopx

FreeNAS Experienced
Joined
Feb 19, 2016
Messages
350
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

Newbie
Joined
Jun 1, 2019
Messages
17
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

FreeNAS Wizard
Joined
Aug 16, 2011
Messages
10,801

Rand0mUser

Newbie
Joined
Jun 1, 2019
Messages
17
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

FreeNAS Wizard
Joined
Aug 16, 2011
Messages
10,801
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

Newbie
Joined
Jun 1, 2019
Messages
17
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

Newbie
Joined
Jun 1, 2019
Messages
17

Chris Moore

Super Moderator
Moderator
Joined
May 2, 2015
Messages
9,665
Is your command in a file that is executed as a script?
 

Rand0mUser

Newbie
Joined
Jun 1, 2019
Messages
17
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.
 
Top