<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<atom:link href="https://dev1galaxy.org/extern.php?action=feed&amp;tid=5032&amp;type=rss" rel="self" type="application/rss+xml" />
		<title><![CDATA[Dev1 Galaxy Forum / [SOLVED] Script printout format assistance]]></title>
		<link>https://dev1galaxy.org/viewtopic.php?id=5032</link>
		<description><![CDATA[The most recent posts in [SOLVED] Script printout format assistance.]]></description>
		<lastBuildDate>Sun, 15 May 2022 10:38:46 +0000</lastBuildDate>
		<generator>FluxBB</generator>
		<item>
			<title><![CDATA[Re: [SOLVED] Script printout format assistance]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=35957#p35957</link>
			<description><![CDATA[<p>Hello:</p><div class="quotebox"><cite>ralph.ronnquist wrote:</cite><blockquote><div><p>... possibly the MemAvailable measure has lost ...</p></div></blockquote></div><p>I had the exact same thought when I first saw the printout.<br />But no, it is correct.</p><p>The thing is that the <span class="bbc">/proc/meminfo</span> list prints like this ...</p><div class="codebox"><pre><code>root@OpenWrt:~# cat /proc/meminfo
MemTotal:         251868 kB
MemFree:          222268 kB
MemAvailable:     208408 kB
--- snip ---</code></pre></div><p>... which makes sense as they are usually progressively declining values.<br />ie: as I understand it (?) <span class="bbc">total</span> will always be higher than <span class="bbc">free</span> which will be equal to or higher than <span class="bbc">available</span> due to buffers, cached, etc. This when <span class="bbc">swap</span> is not part of the equation as it adds to the <span class="bbc">available</span> memory.</p><p>I think the confusion arises because I put them the wrong way around.<br />ie: instead of how they are originally listed.</p><p>Now it looks like it makes sense:</p><div class="codebox"><pre><code>~$ ssh user@192.168.1.3
--- snip ---
uptime:		32 min
ui:		inactive
daemon:		running
mem free:	222312 kB
mem available:	208392 kB
sda1 free/used:	  3.6M  53%
sda3 free/used:	362.6G  58%
hd temp:	36°C
~# </code></pre></div><p>Thank you for pointing that out.</p><p>Best,</p><p>A.</p>]]></description>
			<author><![CDATA[dummy@example.com (Altoid)]]></author>
			<pubDate>Sun, 15 May 2022 10:38:46 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=35957#p35957</guid>
		</item>
		<item>
			<title><![CDATA[Re: [SOLVED] Script printout format assistance]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=35956#p35956</link>
			<description><![CDATA[<p>Hello:</p><div class="quotebox"><cite>Head_on_a_Stick wrote:</cite><blockquote><div><div class="codebox"><pre><code>printf &#039;%s\t%s\n&#039; &quot;hd temp:&quot; &quot;${_drive_temp}°C&quot;</code></pre></div></div></blockquote></div><p>Done.</p><div class="codebox"><pre><code>~$ ssh user@192.168.1.3
--- snip ---
uptime:		9 min
ui:		inactive
daemon:		running
mem available:	208392 kB
mem free:	222252 kB
sda1 free/used:	  3.6M  53%
sda3 free/used:	362.6G  58%
hd temp:	26°C
~$ </code></pre></div><div class="quotebox"><cite>Head_on_a_Stick wrote:</cite><blockquote><div><p>I prefer Kelvin.</p></div></blockquote></div><p>Cool!&#160; 8^D</p><p>Thank you for your input.</p><p>Best,</p><p>A.</p>]]></description>
			<author><![CDATA[dummy@example.com (Altoid)]]></author>
			<pubDate>Sun, 15 May 2022 10:12:57 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=35956#p35956</guid>
		</item>
		<item>
			<title><![CDATA[Re: [SOLVED] Script printout format assistance]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=35955#p35955</link>
			<description><![CDATA[<p>@Altoid, quite possibly the MemAvailable measure has lost its most significant digit (it&#039;s rather unusual to have more free than available memory), and maybe you should consider replacing</p><div class="quotebox"><blockquote><div><div class="codebox"><pre><code>_memavail=$(grep -i memavailable /proc/meminfo | cut -c 19-27)    # OK no cats harmed
_memfree=$(grep -i memfree /proc/meminfo | cut -c 19-27)          # OK no cats harmed</code></pre></div></div></blockquote></div><p>with something else, like e.g.</p><div class="codebox"><pre><code>_memavail=$(sed &#039;/memavailable/I!d;s/[^0-9]*//;q&#039; /proc/meminfo)    # OK no cats or cuts
_memfree=$(sed &#039;/memfree/I!d;s/[^0-9]*//;q&#039; /proc/meminfo)          # OK no cats or cuts</code></pre></div><p>EDIT: (though maybe I&#039;m wrong about what memfree and memavailable means?)</p>]]></description>
			<author><![CDATA[dummy@example.com (ralph.ronnquist)]]></author>
			<pubDate>Sun, 15 May 2022 08:22:26 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=35955#p35955</guid>
		</item>
		<item>
			<title><![CDATA[Re: [SOLVED] Script printout format assistance]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=35954#p35954</link>
			<description><![CDATA[<div class="quotebox"><cite>Altoid wrote:</cite><blockquote><div><p>Could not figure out how to get the <span class="bbc">°C</span> after the temperature [number] print</p></div></blockquote></div><div class="codebox"><pre><code>printf &#039;%s\t%s\n&#039; &quot;hd temp:&quot; &quot;${_drive_temp}°C&quot;</code></pre></div><div class="quotebox"><cite>Altoid wrote:</cite><blockquote><div><p>I&#039;ve been a Celsius man all my life</p></div></blockquote></div><p>I prefer Kelvin.</p>]]></description>
			<author><![CDATA[dummy@example.com (Head_on_a_Stick)]]></author>
			<pubDate>Sun, 15 May 2022 07:44:34 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=35954#p35954</guid>
		</item>
		<item>
			<title><![CDATA[Re: [SOLVED] Script printout format assistance]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=35950#p35950</link>
			<description><![CDATA[<p>Hello:</p><div class="quotebox"><cite>Altoid wrote:</cite><blockquote><div><p>... check it out ...<br />... report back as soon as I figure out ...</p></div></blockquote></div><p>It took me a while, eventually got a decent result.<br />Trimmed it a bit so that what I get is just the essential information.</p><p>This:</p><div class="codebox"><pre><code>#!/bin/sh
PATH=&quot;/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/bin&quot;

# \t adds tab characters
# \n adds new lines
# %s defines strings which are listed afterwards
# awk can search so no need for grep

_uptime=$(uptime| sed &#039;s/.*up \([^,]*\), .*/\1/&#039;)
_rsync_status=$(sudo /etc/init.d/rsyncd status)                   # OK needs root x ash
_memavail=$(grep -i memavailable /proc/meminfo | cut -c 19-27)    # OK no cats harmed
_memfree=$(grep -i memfree /proc/meminfo | cut -c 19-27)          # OK no cats harmed
_fs_status1=$(df -h | grep -vE &#039;^Filesystem|/dev/root|tmpfs&#039; | cut -c 6-70 | grep -i sda1 | cut -c 40-50)
_fs_status2=$(df -h | grep -vE &#039;^Filesystem|/dev/root|tmpfs&#039; | cut -c 6-70 | grep -i sda3 | cut -c 40-50)
_drive_temp=$(sudo smartctl -a -d ata /dev/sda | awk &#039;/Temperature/ {print $10}&#039;)

printf &#039;%s\t\t%s\n&#039; &quot;uptime:&quot; &quot;$_uptime&quot;           # OK
printf &#039;%s\t\t%s\n&#039; &quot;daemon:&quot; &quot;$_rsync_status&quot;     # OK
printf &#039;%s\t%s\n&#039; &quot;mem available:&quot; &quot;$_memavail&quot;    # OK
printf &#039;%s\t%s\n&#039; &quot;mem free:&quot; &quot;$_memfree&quot;          # OK
printf &#039;%s\t%s\n&#039; &quot;sda1 free/used:&quot; &quot;$_fs_status1&quot; # OK
printf &#039;%s\t%s\n&#039; &quot;sda3 free/used:&quot; &quot;$_fs_status2&quot; # OK
printf &#039;%s\t&#039; &quot;hd temp:&quot; &quot;$_drive_temp&quot;            # OK</code></pre></div><p>Gets me this when I <span class="bbc">ssh</span> to the NAS:</p><div class="codebox"><pre><code>~$ ssh user@192.168.1.3
--- snip ---
uptime:		 2:34
daemon:		running
mem available:	210064 kB
mem free:	226420 kB
sda1 free/used:	  3.6M  53%
sda3 free/used:	362.6G  58%
hd temp:	48	
~$ </code></pre></div><p>Seems good enough and the info is there.<br />Could not figure out how to get the <span class="bbc">°C</span> after the temperature [number] print but it is just for me.<br />And I&#039;ve been a Celsius man all my life. =^ )</p><p>Your pointers on lines, characters and strings were a big help.</p><p>Best,</p><p>A.</p><p>Edit: spelling/format.</p>]]></description>
			<author><![CDATA[dummy@example.com (Altoid)]]></author>
			<pubDate>Sat, 14 May 2022 21:17:08 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=35950#p35950</guid>
		</item>
		<item>
			<title><![CDATA[Re: [SOLVED] Script printout format assistance]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=35927#p35927</link>
			<description><![CDATA[<p>Hello:</p><div class="quotebox"><cite>Head_on_a_Stick wrote:</cite><blockquote><div><div class="codebox"><pre><code>#!/bin/sh
_uptime=$(uptime|cut -c 2-19)
_rsync_status=$(/etc/init.d/rsyncd status) # does not need root!
_memavail=$(grep -i memavailable /proc/meminfo) # save those poor cats!
_memfree=$(grep -i memfree /proc/meminfo) # ditto
_fs_status=$(df -h|awk &#039;/^Filesystem/||/\/dev\/root/||/tmpfs/{ print $5 &quot; &quot; $1}&#039;) # awk can search so no need for grep
_drive_temp=$(sudo smartctl -d ata -A /dev/sda | grep Temperature | cut -c 5-8,87-89) 

printf &#039;%s\t\t%s\n\n&#039; &quot;uptime:&quot; &quot;$_uptime&quot; # \t adds tab characters, \n adds new lines, %s defines strings which are listed afterwards

printf &#039;%s\t%s\n\n&#039; &quot;rsync daemon status:&quot; &quot;$_rsync_status&quot;

printf &#039;%s\n%s\n%s\n\n&#039; &quot;memory status:&quot; &quot;$_mem_avail&quot; &quot;$_mem_free&quot;

printf &#039;%s\t%s\n\n&#039; &quot;filesystem status:&quot; &quot;$_fs_status&quot; # might not work :/

printf &#039;%s\t%s\n&#039; &quot;drive temperature&quot; &quot;$_drive_temp&quot;</code></pre></div></div></blockquote></div><p>Right ...</p><p>I&#039;ll check it out tonight and report back as soon as I figure out how it works.</p><div class="quotebox"><cite>Head_on_a_Stick wrote:</cite><blockquote><div><p>... trapped in Windows atm ...</p></div></blockquote></div><p>You&#039;ll manage.&#160; ;^ )</p><div class="quotebox"><cite>Head_on_a_Stick wrote:</cite><blockquote><div><p>... post back later when I&#039;m in a proper OS...</p></div></blockquote></div><p>Thank you for your input.</p><p>Best,</p><p>A.</p>]]></description>
			<author><![CDATA[dummy@example.com (Altoid)]]></author>
			<pubDate>Thu, 12 May 2022 20:17:22 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=35927#p35927</guid>
		</item>
		<item>
			<title><![CDATA[Re: [SOLVED] Script printout format assistance]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=35920#p35920</link>
			<description><![CDATA[<div class="codebox"><pre><code>#!/bin/sh

_uptime=$(uptime|cut -c 2-19)
_rsync_status=$(/etc/init.d/rsyncd status) # does not need root!
_memavail=$(grep -i memavailable /proc/meminfo) # save those poor cats!
_memfree=$(grep -i memfree /proc/meminfo) # ditto
_fs_status=$(df -h|awk &#039;!/^Filesystem/&amp;&amp;!/\/dev\/root/&amp;&amp;!/tmpfs/{ print $5 &quot; &quot; $1}&#039;) # awk can search so no need for grep
_drive_temp=$(sudo smartctl -d ata -A /dev/sda | grep Temperature | cut -c 5-8,87-89) 

printf &#039;%s\t\t%s\n\n&#039; &quot;uptime:&quot; &quot;$_uptime&quot; # \t adds tab characters, \n adds new lines, %s defines strings which are listed afterwards

printf &#039;%s\t%s\n\n&#039; &quot;rsync daemon status:&quot; &quot;$_rsync_status&quot;

printf &#039;%s\n%s\n%s\n\n&#039; &quot;memory status:&quot; &quot;$_memavail&quot; &quot;$_memfree&quot;

printf &#039;%s\t%s\n\n&#039; &quot;filesystem status:&quot; &quot;$_fs_status&quot; # might not work :/

printf &#039;%s\t%s\n&#039; &quot;drive temperature&quot; &quot;$_drive_temp&quot;</code></pre></div><p>I&#039;m trapped in Windows atm so this is untested, I&#039;ll post back later when I&#039;m in a proper OS...</p><p>EDIT: fixes...</p>]]></description>
			<author><![CDATA[dummy@example.com (Head_on_a_Stick)]]></author>
			<pubDate>Thu, 12 May 2022 14:28:17 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=35920#p35920</guid>
		</item>
		<item>
			<title><![CDATA[[SOLVED] Script printout format assistance]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=35918#p35918</link>
			<description><![CDATA[<p>Hello:</p><p>I have this script running on <span class="bbc">ssh</span> login:</p><div class="codebox"><pre><code>#!/bin/sh
PATH=&quot;/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/bin&quot;
echo uptime:
# run uptime - no load stats
uptime | cut -c 2-19
echo
echo rsync daemon status:
# run alias daemon
sudo /etc/init.d/rsyncd status
echo
echo memory status:
cat /proc/meminfo | grep -i memavailable &amp;&amp; cat /proc/meminfo | grep -i memfree
echo
echo filesystem status:
# run alias fschk
df -h | grep -vE &#039;^Filesystem|/dev/root|tmpfs&#039;| awk &#039;{ print $5 &quot; &quot; $1}&#039;
echo
echo drive temperature:
# run alias tempchk
sudo smartctl -d ata -A /dev/sda | grep Temperature | cut -c 5-8,87-89
echo
echo filesystem health:
# run alias drivechk
sudo dmesg | grep -i ext4-fs | grep -i sda</code></pre></div><p>This is the terminal printout:</p><div class="codebox"><pre><code>uptime:
10:46:23 up 0 min,

rsync daemon status:
running

memory status:
MemAvailable:      211716 kB
MemFree:           228924 kB

filesystem status:
53% /dev/sda1
58% /dev/sda3

drive temperature:
Temp 22</code></pre></div><p>How can I get it to print out in this format?</p><div class="codebox"><pre><code>uptime:              10:46:23 up 0 min,

rsync daemon status: running

memory status:
MemAvailable:        211716 kB
MemFree:             228924 kB

filesystem status:   53% /dev/sda1
                     58% /dev/sda3

drive temperature:   Temp 22</code></pre></div><p>Thanks in advance.</p><p>Best,</p><p>A.</p><p>Edit: spelling</p>]]></description>
			<author><![CDATA[dummy@example.com (Altoid)]]></author>
			<pubDate>Thu, 12 May 2022 14:06:30 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=35918#p35918</guid>
		</item>
	</channel>
</rss>
