Jail uptime and server load widget?

jgreco

Resident Grinch
Joined
May 29, 2011
Messages
18,680
A widget? No, but a CGI script that simply calls the UNIX uptime command might suffice.
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,700
You're going to run into two problems there, but if you use this: http://www.freebsddiary.org/uptime.php

You will be able to display the uptime of the host system (not the jail).

Since the jail is actually running the OS from the host with an overlay, it thinks it started when the host did.

iocage is aware of the jail started time (iocage get last_started <jailname>), but it's not in your jail where nginX will be running.

You would actually need to use a script (run periodically by a cron task) to output the uptime to a file that's in your jail's filesystem root somewhere and then use a variant of the uptime.pl inside the jail to pull the value from the file and calculate the uptime from the started time and display that.

Or maybe I'm overcomplicating and what you really wanted was the host uptime... so just read the first link.
 
Last edited:

Daisuke

Contributor
Joined
Jun 23, 2011
Messages
1,041
Basically, what I need is to display on an webpage the current jail server load and uptime. This is related to an automated setup of several media tools running all into same jail (which I plan to publish soon, hovering over icons moves the icon, like Apple dock icons, note Sabnzbplus icon being higher):

1616427309423.png


The IP you see is the actual jail where all above tools run. Ideally, I want to see the uptime and server load on that page. The index.html file is static and also mobile friendly, with images linked directly from applications and requires no edit:

1616427795280.png


Also, the Nginx configuration does not requires any changes, is universal for any setup, therefore it can be easily automated.
 
Last edited:

Patrick M. Hausen

Hall of Famer
Joined
Nov 25, 2013
Messages
7,776
Server load only for a jail does not make sense. The value will be identical for all jails.
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,700

Daisuke

Contributor
Joined
Jun 23, 2011
Messages
1,041
Are you trying to create something like Organizr or Heimdall?
I'm aware of these products, they are complex to install and require several extra packages. My setup has zero complexity and requires only Nginx with a static index.hml file and zero customizations. You don't even have to define the IP address, it will be automatically picked by Nginx configuration.

1616445808571.png


Server load only for a jail does not make sense. The value will be identical for all jails.
Radarr, Sonarr, Lidarr, Transmission, SABnzbd, Transmission and Jacket run on same 192.168.2.23 jail. If all jails have same load, is fine with me, I want to display this info embedded into index.html page:
Code:
# iocage exec media uptime
4:16PM  up 19 days, 23:17, 0 users, load averages: 0.10, 0.14, 0.17


@jgreco I looked into CGI scripting and I could use an iframe:
Code:
<iframe src="/cgi-bin/script.cgi" width="300" height="150"></iframe>


And the Perl script:
Code:
# cat script.cgi
#!/usr/bin/env perl
use strict;

print(`uptime`);


The thing is Nginx does not supports CGI, like Apache for example. How do you run your CGI scripts, as you use Nginx for web interface.
 
Last edited:

jgreco

Resident Grinch
Joined
May 29, 2011
Messages
18,680
Oh, I forgot, nginx is weird. You need to find whatever it is currently using for CGI.

From some years ago .. https://stackoverflow.com/questions/11667489/how-to-run-cgi-scripts-on-nginx

I don't use nginx for much of anything since it is just reinventing the wheel for a slightly different rim size, and I already have all my tires.

You've obviously got a lead on a reasonable Perl script, and I'm guessing you might find a PHP implementation on nginx to be slightly easier to get working, but I don't really know for sure.

You're on the right path.
 

Daisuke

Contributor
Joined
Jun 23, 2011
Messages
1,041
I'm guessing you might find a PHP implementation on nginx
Ya, that would require to add more packages to jail, I'm very familiar with Nginx FastCGI and PHP. If I don't find anything else, I will go this route. The goal is to have a very simple install, so anyone can do it.

BTW, where is the best place to post the tutorial? It includes the automated install for all components using pkg (no manual install), as well a script to update the software to latest versions, you run it from terminal into TrueNAS (not jail) to execute all iocage commands:

1616448378473.png


For example, Sonarr3 is out of beta but only the Lord knows when freshport packages will be updated.
 
Last edited:
Top