<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	
	>
<channel>
	<title>
	Comments on: 8 Useful Commands to Monitor Swap Space Usage in Linux	</title>
	<atom:link href="https://www.tecmint.com/commands-to-monitor-swap-space-usage-in-linux/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.tecmint.com/commands-to-monitor-swap-space-usage-in-linux/</link>
	<description>Tecmint - Linux Howtos, Tutorials, Guides, News, Tips and Tricks.</description>
	<lastBuildDate>Fri, 14 Jul 2023 02:45:48 +0000</lastBuildDate>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	
	<item>
		<title>
		By: Stanislav Genov		</title>
		<link>https://www.tecmint.com/commands-to-monitor-swap-space-usage-in-linux/comment-page-1/#comment-1992561</link>

		<dc:creator><![CDATA[Stanislav Genov]]></dc:creator>
		<pubDate>Wed, 05 Apr 2023 09:28:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.tecmint.com/?p=16051#comment-1992561</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.tecmint.com/commands-to-monitor-swap-space-usage-in-linux/comment-page-1/#comment-1992558&quot;&gt;Ravi Saive&lt;/a&gt;.

I have no experience with &lt;strong&gt;Mint&lt;/strong&gt; but in Redhat Linux with ordinary users is working as well. 
&lt;pre&gt;
stani@server:~$ sudo ./swap.sh
top swap using processes that are still running:
15816 kb                /usr/bin/perl -w /opt/lpar2rrd/lpar2rrd/bin/lpar2rrd-daemon.pl
10248 kb                [splunkd pid=3066545] splunkd -p 8089 restart [process-runner]
5864 kb         splunkd -p 8089 restart
5424 kb         /usr/lib/polkit-1/polkitd --no-debug
4912 kb         /usr/sbin/rngd -f --fill-watermark=0 -x pkcs11 -x nist -D daemon:daemon
4152 kb         /usr/libexec/platform-python -Es /usr/sbin/tuned -l -P
3064 kb         /usr/lib/systemd/systemd-journald
2027 kb         (sd-pam)
1464 kb         /usr/sbin/sshd -D
920 kb          /usr/libexec/postfix/master -w
&lt;/pre&gt;]]></description>
			<content:encoded><![CDATA[<p>In reply to <a target="_blank" href="https://www.tecmint.com/commands-to-monitor-swap-space-usage-in-linux/comment-page-1/#comment-1992558">Ravi Saive</a>.</p>
<p>I have no experience with <strong>Mint</strong> but in Redhat Linux with ordinary users is working as well. </p>
<pre>
stani@server:~$ sudo ./swap.sh
top swap using processes that are still running:
15816 kb                /usr/bin/perl -w /opt/lpar2rrd/lpar2rrd/bin/lpar2rrd-daemon.pl
10248 kb                [splunkd pid=3066545] splunkd -p 8089 restart [process-runner]
5864 kb         splunkd -p 8089 restart
5424 kb         /usr/lib/polkit-1/polkitd --no-debug
4912 kb         /usr/sbin/rngd -f --fill-watermark=0 -x pkcs11 -x nist -D daemon:daemon
4152 kb         /usr/libexec/platform-python -Es /usr/sbin/tuned -l -P
3064 kb         /usr/lib/systemd/systemd-journald
2027 kb         (sd-pam)
1464 kb         /usr/sbin/sshd -D
920 kb          /usr/libexec/postfix/master -w
</pre>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Ravi Saive		</title>
		<link>https://www.tecmint.com/commands-to-monitor-swap-space-usage-in-linux/comment-page-1/#comment-1992558</link>

		<dc:creator><![CDATA[Ravi Saive]]></dc:creator>
		<pubDate>Wed, 05 Apr 2023 09:09:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.tecmint.com/?p=16051#comment-1992558</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.tecmint.com/commands-to-monitor-swap-space-usage-in-linux/comment-page-1/#comment-1992514&quot;&gt;Stanislav Genov&lt;/a&gt;.

@Stanislav,

Thanks, yes it seems permission issue, as I am running the script as a &lt;strong&gt;sudo&lt;/strong&gt; user. Could you make the script workable with sudo privileges?]]></description>
			<content:encoded><![CDATA[<p>In reply to <a target="_blank" href="https://www.tecmint.com/commands-to-monitor-swap-space-usage-in-linux/comment-page-1/#comment-1992514">Stanislav Genov</a>.</p>
<p>@Stanislav,</p>
<p>Thanks, yes it seems permission issue, as I am running the script as a <strong>sudo</strong> user. Could you make the script workable with sudo privileges?</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Stanislav Genov		</title>
		<link>https://www.tecmint.com/commands-to-monitor-swap-space-usage-in-linux/comment-page-1/#comment-1992514</link>

		<dc:creator><![CDATA[Stanislav Genov]]></dc:creator>
		<pubDate>Wed, 05 Apr 2023 07:13:32 +0000</pubDate>
		<guid isPermaLink="false">http://www.tecmint.com/?p=16051#comment-1992514</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.tecmint.com/commands-to-monitor-swap-space-usage-in-linux/comment-page-1/#comment-1992460&quot;&gt;Ravi Saive&lt;/a&gt;.

Hi Ravi, seems you have no rights in &lt;strong&gt;/tmp&lt;/strong&gt;, check the permissions:

Here is the output from RedHat 8.7
&lt;pre&gt;
root@vxltsap001:~# ./swap.sh
top swap using processes which are still running:
251000 kb               /usr/libexec/packagekitd
126384 kb               /opt/commvault/commvault/Base/cvd
68564 kb                splunkd -p 8089 restart
48632 kb                /usr/sbin/rsyslogd -n
43776 kb                /app/code-server/lib/node /app/code-server --bind-addr 0.0.0.0:8443 --user-data-dir /config/data --extensions-dir 
                        /config/extensions --disable-telemetry --auth none  /config/workspace
30584 kb                /opt/commvault/commvault/Base/ClMgrS
24860 kb                [splunkd pid=1278354] splunkd -p 8089 restart [process-runner]
17424 kb                /usr/bin/docker-proxy -proto tcp -host-ip :: -host-port 8443 -container-ip 172.18.0.2 -container-port 8443
17376 kb                /usr/bin/docker-proxy -proto tcp -host-ip :: -host-port 80 -container-ip 172.18.0.3 -container-port 80
17352 kb                /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 80 -container-ip 172.18.0.3 -container-port 80
&lt;/pre&gt;]]></description>
			<content:encoded><![CDATA[<p>In reply to <a target="_blank" href="https://www.tecmint.com/commands-to-monitor-swap-space-usage-in-linux/comment-page-1/#comment-1992460">Ravi Saive</a>.</p>
<p>Hi Ravi, seems you have no rights in <strong>/tmp</strong>, check the permissions:</p>
<p>Here is the output from RedHat 8.7</p>
<pre>
root@vxltsap001:~# ./swap.sh
top swap using processes which are still running:
251000 kb               /usr/libexec/packagekitd
126384 kb               /opt/commvault/commvault/Base/cvd
68564 kb                splunkd -p 8089 restart
48632 kb                /usr/sbin/rsyslogd -n
43776 kb                /app/code-server/lib/node /app/code-server --bind-addr 0.0.0.0:8443 --user-data-dir /config/data --extensions-dir 
                        /config/extensions --disable-telemetry --auth none  /config/workspace
30584 kb                /opt/commvault/commvault/Base/ClMgrS
24860 kb                [splunkd pid=1278354] splunkd -p 8089 restart [process-runner]
17424 kb                /usr/bin/docker-proxy -proto tcp -host-ip :: -host-port 8443 -container-ip 172.18.0.2 -container-port 8443
17376 kb                /usr/bin/docker-proxy -proto tcp -host-ip :: -host-port 80 -container-ip 172.18.0.3 -container-port 80
17352 kb                /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 80 -container-ip 172.18.0.3 -container-port 80
</pre>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Ravi Saive		</title>
		<link>https://www.tecmint.com/commands-to-monitor-swap-space-usage-in-linux/comment-page-1/#comment-1992460</link>

		<dc:creator><![CDATA[Ravi Saive]]></dc:creator>
		<pubDate>Wed, 05 Apr 2023 04:22:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.tecmint.com/?p=16051#comment-1992460</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.tecmint.com/commands-to-monitor-swap-space-usage-in-linux/comment-page-1/#comment-1992226&quot;&gt;Stanislav Genov&lt;/a&gt;.

@Stanislav,

I tried running the script on my Linux Mint, but getting the following error.
&lt;pre&gt;
./swa.sh: 1: cannot create /tmp/ps_ax.output: Permission denied
./swa.sh: 2: cannot create /tmp/results: Permission denied
top swap using processes that are still running:
&lt;/pre&gt;]]></description>
			<content:encoded><![CDATA[<p>In reply to <a target="_blank" href="https://www.tecmint.com/commands-to-monitor-swap-space-usage-in-linux/comment-page-1/#comment-1992226">Stanislav Genov</a>.</p>
<p>@Stanislav,</p>
<p>I tried running the script on my Linux Mint, but getting the following error.</p>
<pre>
./swa.sh: 1: cannot create /tmp/ps_ax.output: Permission denied
./swa.sh: 2: cannot create /tmp/results: Permission denied
top swap using processes that are still running:
</pre>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Stanislav Genov		</title>
		<link>https://www.tecmint.com/commands-to-monitor-swap-space-usage-in-linux/comment-page-1/#comment-1992226</link>

		<dc:creator><![CDATA[Stanislav Genov]]></dc:creator>
		<pubDate>Tue, 04 Apr 2023 14:47:36 +0000</pubDate>
		<guid isPermaLink="false">http://www.tecmint.com/?p=16051#comment-1992226</guid>

					<description><![CDATA[I prefer to create a simple bash script with the content below:
&lt;pre&gt;
ps ax -o pid,args &#124; grep -v &#039;^  PID&#039;&#124;sed -e &#039;s,^ *,,&#039; &#062; /tmp/ps_ax.output
echo -n &#062;/tmp/results

for swappid in $(grep -l Swap /proc/[1-9]*/smaps ); do
        swapusage=0
        for x in $( grep Swap $swappid 2&#062;/dev/null &#124;grep -v &#039;\W0 kB&#039;&#124;awk &#039;{print $2}&#039; ); do
                let swapusage+=$x
        done
        pid=$(echo $swappid&#124; cut -d&#039; &#039; -f3&#124;cut -d&#039;/&#039; -f3)
        if ( [ $swapusage -ne 0 ] ); then
                echo -ne &quot;$swapusage kb\t\t&quot; &#062;&#062;/tmp/results
                egrep &quot;^$pid &quot; /tmp/ps_ax.output &#124;sed -e &#039;s,^[0-9]* ,,&#039; &#062;&#062;/tmp/results
        fi
done

echo &quot;top swap using processes which are still running:&quot;
sort -nr /tmp/results &#124; head -n 10
&lt;/pre&gt;
Result will be the top 10 processes using swap.]]></description>
			<content:encoded><![CDATA[<p>I prefer to create a simple bash script with the content below:</p>
<pre>
ps ax -o pid,args | grep -v '^  PID'|sed -e 's,^ *,,' &gt; /tmp/ps_ax.output
echo -n &gt;/tmp/results

for swappid in $(grep -l Swap /proc/[1-9]*/smaps ); do
        swapusage=0
        for x in $( grep Swap $swappid 2&gt;/dev/null |grep -v '\W0 kB'|awk '{print $2}' ); do
                let swapusage+=$x
        done
        pid=$(echo $swappid| cut -d' ' -f3|cut -d'/' -f3)
        if ( [ $swapusage -ne 0 ] ); then
                echo -ne "$swapusage kb\t\t" &gt;&gt;/tmp/results
                egrep "^$pid " /tmp/ps_ax.output |sed -e 's,^[0-9]* ,,' &gt;&gt;/tmp/results
        fi
done

echo "top swap using processes which are still running:"
sort -nr /tmp/results | head -n 10
</pre>
<p>Result will be the top 10 processes using swap.</p>
]]></content:encoded>
		
			</item>
	</channel>
</rss>
