Re: Simple way for web to execute root shell script.

Liste des GroupesRevenir à col misc 
Sujet : Re: Simple way for web to execute root shell script.
De : theom+news (at) *nospam* chiark.greenend.org.uk (Theo)
Groupes : comp.os.linux.misc comp.sys.raspberry-pi
Date : 24. May 2025, 08:27:12
Autres entêtes
Organisation : University of Cambridge, England
Message-ID : <8JE*00fdA@news.chiark.greenend.org.uk>
References : 1 2 3
User-Agent : tin/1.8.3-20070201 ("Scotasay") (UNIX) (Linux/5.10.0-28-amd64 (x86_64))
In comp.sys.raspberry-pi The Natural Philosopher <tnp@invalid.invalid> wrote:
Sadly the data is not available in /sys or /proc AFAIK.
I wanted information on the temperature and data volumes on the SSDs and
the temperature of the ARM core. Plus data on the amount of data being
transported over the ethernet interface.
The tools that came to hand were vgcencmd, smartctl, df and ip. Plus
some sedery grepery and  awkery
 
  The script is (if you are interested)
 
#!/bin/bash
smartctl -a /dev/sda | grep Celsius | awk '{print $10}'
smartctl -a /dev/sdb | grep Celsius | awk '{print $10}'
vcgencmd measure_temp | sed -e 's/temp=//' | sed -e "s/'C//"
ip -s link show dev eth0 | awk 'FNR == 4 {print $1}'
ip -s link show dev eth0 | awk 'FNR == 6 {print $1}'
df -h | grep /dev/sd
[snip]
 
The intention is to poll that using AJAX and parse it into the position
of needles on dials in a web page.

Another option is to split this into two parts.  The above is a script
that's run as root, which is set up by cron to run every minute (or
whatever).  That outputs a file such as /var/www/whatever/stats.txt

Then Apache serves that file like any other file, no privileged access
needed.

Obviously in that case it's not live data, it can be up to a minute old.
But maybe that's not a problem, especially if you include a timestamp in the
data so the frontend knows when it's last updated.  But for things like
temperatures maybe it's ok that you're lagging slightly behind as physical
constraints mean they don't change very fast.

Theo

Date Sujet#  Auteur
23 May13:26 * Simple way for web to execute root shell script.28The Natural Philosopher
23 May13:51 +* Re: Simple way for web to execute root shell script.4Pancho
23 May15:47 i+* Re: Simple way for web to execute root shell script.2Lew Pitcher
23 May16:06 ii`- Re: Simple way for web to execute root shell script.1The Natural Philosopher
23 May16:00 i`- Re: Simple way for web to execute root shell script.1The Natural Philosopher
23 May15:08 +* Re: Simple way for web to execute root shell script.7Lew Pitcher
23 May15:23 i+* Re: Simple way for web to execute root shell script.2Lew Pitcher
23 May16:03 ii`- Re: Simple way for web to execute root shell script.1The Natural Philosopher
23 May16:02 i`* Re: Simple way for web to execute root shell script.4The Natural Philosopher
23 May16:24 i `* Re: Simple way for web to execute root shell script.3Marc Haber
23 May17:53 i  +- Re: Simple way for web to execute root shell script.1The Natural Philosopher
24 May01:37 i  `- Re: Simple way for web to execute root shell script.1Lawrence D'Oliveiro
23 May15:14 +* Re: Simple way for web to execute root shell script.2John-Paul Stewart
23 May16:05 i`- Re: Simple way for web to execute root shell script.1The Natural Philosopher
23 May17:46 +- Re: Simple way for web to execute root shell script.1Eli the Bearded
23 May19:44 +* Re: Simple way for web to execute root shell script.6Rich
23 May21:44 i`* Re: Simple way for web to execute root shell script.5The Natural Philosopher
24 May03:13 i +* Re: Simple way for web to execute root shell script.2Rich
24 May09:18 i i`- Re: Simple way for web to execute root shell script.1The Natural Philosopher
24 May08:27 i +- Re: Simple way for web to execute root shell script.1Theo
24 May13:28 i `- Re: Simple way for web to execute root shell script.1Chris Elvidge
23 May22:17 +- Re: Simple way for web to execute root shell script.1druck
24 May00:11 +- Re: Simple way for web to execute root shell script.1Lawrence D'Oliveiro
24 May09:20 +* Re: Simple way for web to execute root shell script.4The Natural Philosopher
24 May10:58 i+* Re: Simple way for web to execute root shell script.2Richard Kettlewell
24 May11:27 ii`- Re: Simple way for web to execute root shell script.1The Natural Philosopher
24 May16:41 i`- Re: Simple way for web to execute root shell script.1Rich
24 May18:35 `- Re: Simple way for web to execute root shell script.1Andrew Smallshaw

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal