feat linux script...

This commit is contained in:
2024-08-18 08:15:38 +08:00
parent 26b63d45ab
commit 8e22c02d6f
28 changed files with 366 additions and 137 deletions

View File

@@ -1,32 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<search>
<entry>
<title>page</title>
<url>/posts/1441.html</url>
<content><![CDATA[<ul>
<li><a href="./deploy">deploy</a></li>
<li></li>
</ul>
]]></content>
</entry>
<entry>
<title>网络相关</title>
<url>/posts/41168.html</url>
<content><![CDATA[]]></content>
</entry>
<entry>
<title>郑伯克段于鄢</title>
<url>/posts/58638.html</url>
<content><![CDATA[<p>原文如下:</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;初,郑武公娶于申【申国】,曰武姜【武为武公谥号,姜为其宗族之性】。生庄公及共叔段【共表示其曾出逃到共,叔为老三,段为名】。庄公寤生【出生时头先出,难产】,惊姜氏,故名曰“寤生”, 遂恶之爱【喜爱】共叔段欲立【立为储君】之【多次】请于武公及庄公即位为之【共叔段】请制【一个叫制的封地虎牢关所在】。公曰“制岩邑【险要的城邑】也虢叔死焉佗【通“他”其他】邑唯命是听。”请京使居之谓之“京城大叔”。</p>
]]></content>
<categories>
<category>古文观止</category>
</categories>
<tags>
<tag>古文观止</tag>
</tags>
</entry>
<entry>
<title>Hello World</title>
<url>/posts/16107.html</url>
@@ -43,6 +16,71 @@
<h3 id="Deploy-to-remote-sites"><a href="#Deploy-to-remote-sites" class="headerlink" title="Deploy to remote sites"></a>Deploy to remote sites</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo deploy</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/one-command-deployment.html">Deployment</a></p>
]]></content>
</entry>
<entry>
<title>page</title>
<url>/posts/1441.html</url>
<content><![CDATA[<ul>
<li><a href="./deploy">deploy</a></li>
<li></li>
</ul>
]]></content>
</entry>
<entry>
<title>网络相关</title>
<url>/posts/41168.html</url>
<content><![CDATA[]]></content>
</entry>
<entry>
<title>script</title>
<url>/posts/34849.html</url>
<content><![CDATA[<h3 id="查看CPU、内存使用率"><a href="#查看CPU、内存使用率" class="headerlink" title="查看CPU、内存使用率"></a>查看CPU、内存使用率</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line"><span class="meta">#!/bin/bash</span></span><br><span class="line"></span><br><span class="line"><span class="comment"># 定义颜色</span></span><br><span class="line">RED=<span class="string">&#x27;\033[0;31m&#x27;</span></span><br><span class="line">GREEN=<span class="string">&#x27;\033[0;32m&#x27;</span></span><br><span class="line">YELLOW=<span class="string">&#x27;\033[0;33m&#x27;</span></span><br><span class="line">BLUE=<span class="string">&#x27;\033[0;34m&#x27;</span></span><br><span class="line">NC=<span class="string">&#x27;\033[0m&#x27;</span> <span class="comment"># 无颜色</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">while</span> <span class="literal">true</span>; <span class="keyword">do</span></span><br><span class="line"> <span class="comment"># 获取所有进程的CPU使用率和内存使用率</span></span><br><span class="line"> cpu_usage=$(ps aux | awk <span class="string">&#x27;&#123;sum_cpu += $3&#125; END &#123;print sum_cpu&#125;&#x27;</span>)</span><br><span class="line"> mem_usage=$(ps aux | awk <span class="string">&#x27;&#123;sum_mem += $4&#125; END &#123;print sum_mem&#125;&#x27;</span>)</span><br><span class="line"> </span><br><span class="line"> <span class="comment"># 打印结果,带有时间戳、分隔线和颜色高亮</span></span><br><span class="line"> <span class="built_in">echo</span> -e <span class="string">&quot;<span class="variable">$&#123;BLUE&#125;</span>==============================<span class="variable">$&#123;NC&#125;</span>&quot;</span></span><br><span class="line"> <span class="built_in">echo</span> -e <span class="string">&quot;<span class="variable">$&#123;YELLOW&#125;</span>Timestamp: <span class="subst">$(date)</span><span class="variable">$&#123;NC&#125;</span>&quot;</span></span><br><span class="line"> <span class="built_in">echo</span> -e <span class="string">&quot;<span class="variable">$&#123;BLUE&#125;</span>==============================<span class="variable">$&#123;NC&#125;</span>&quot;</span></span><br><span class="line"> <span class="built_in">echo</span> -e <span class="string">&quot;<span class="variable">$&#123;GREEN&#125;</span>Total CPU usage: <span class="variable">$&#123;RED&#125;</span><span class="variable">$cpu_usage</span>%<span class="variable">$&#123;NC&#125;</span>&quot;</span></span><br><span class="line"> <span class="built_in">echo</span> -e <span class="string">&quot;<span class="variable">$&#123;GREEN&#125;</span>Total Memory usage: <span class="variable">$&#123;RED&#125;</span><span class="variable">$mem_usage</span>%<span class="variable">$&#123;NC&#125;</span>&quot;</span></span><br><span class="line"> <span class="built_in">echo</span> -e <span class="string">&quot;<span class="variable">$&#123;BLUE&#125;</span>==============================<span class="variable">$&#123;NC&#125;</span>&quot;</span></span><br><span class="line"> </span><br><span class="line"> <span class="comment"># 等待5秒后再次执行</span></span><br><span class="line"> <span class="built_in">sleep</span> 5</span><br><span class="line"><span class="keyword">done</span></span><br><span class="line"></span><br></pre></td></tr></table></figure>
<p><strong>保存脚本到&#x2F;usr&#x2F;local&#x2F;bin目录下</strong></p>
<figure class="highlight bash"><table><tr><td class="code"><pre><span class="line"><span class="built_in">mv</span> usage.sh /usr/local/bin/usage</span><br></pre></td></tr></table></figure>]]></content>
</entry>
<entry>
<title>Docker被墙如何继续使用</title>
<url>/posts/47807.html</url>
<content><![CDATA[<h2 id="Docker-Download"><a href="#Docker-Download" class="headerlink" title="Docker Download"></a>Docker Download</h2><blockquote>
<p>自从docker官方仓库在中国大陆被墙后docker的部署方式也发生了改变。<br>解决docker安装问题<a href="https://github.com/shenjianZ/docker_installer">https://github.com/shenjianZ/docker_installer</a></p>
</blockquote>
<ol>
<li><p>安装docker </p>
<figure class="highlight shell"><table><tr><td class="code"><pre><span class="line">sudo curl -fsSL https://gitee.com/tech-shrimp/docker_installer/releases/download/latest/linux.sh| bash -s docker --mirror Aliyun</span><br></pre></td></tr></table></figure>
</li>
<li><p>启动docker</p>
<figure class="highlight shell"><table><tr><td class="code"><pre><span class="line">sudo systemctl start docker</span><br></pre></td></tr></table></figure>
</li>
<li><p>设置开机自启</p>
<figure class="highlight shell"><table><tr><td class="code"><pre><span class="line">sudo systemctl enable docker</span><br></pre></td></tr></table></figure>
</li>
<li><p>Docker pull images</p>
<blockquote>
<p>将image下载到阿里云镜像仓库中<br>解决docker pull 镜像问题:<a href="https://github.com/shenjianZ/docker_image_pusher">https://github.com/shenjianZ/docker_image_pusher</a></p>
</blockquote>
<ol>
<li><p><strong>登录阿里云镜像服务</strong> <a href="https://cr.console.aliyun.com/">https://cr.console.aliyun.com/</a>,</p>
<p>启用个人实例,创建一个命名空间(<code>ALIYUN_NAME_SPACE</code></p>
</li>
<li><p>在<strong>访问凭证</strong> 可以看到账号 用户名(<code>ALIYUN_REGISTRY_USER</code>)</p>
<p>密码(<code>ALIYUN_REGISTRY_PASSWORD</code>)</p>
<p>仓库地址(<code>ALIYUN_REGISTRY</code></p>
</li>
<li><p><strong>启动Action</strong><br>进入您自己的项目,点击<code>Action</code>,启用<code>Github Action</code>功能</p>
</li>
<li><p><strong>配置环境变量</strong><br>进入Settings-&gt;Secret and variables-&gt;Actions-&gt;New Repository secret<br> 将上一步的四个值<br> <code>ALIYUN_NAME_SPACE</code>,</p>
<p> <code> ALIYUN_REGISTRY_USER</code></p>
<p> <code>ALIYUN_REGISTRY_PASSWORD</code></p>
<p> <code>ALIYUN_REGISTRY</code><br> 配置成环境变量</p>
</li>
<li><p><strong>添加镜像</strong><br> 打开<code>images.txt</code>文件,添加你想要的镜像 可以加tag</p>
</li>
<li><p>使用镜像<br>回到阿里云,镜像仓库,点击任意镜像,可查看镜像状态。(可以改成公开,拉取镜像免登录)</p>
</li>
</ol>
</li>
</ol>
]]></content>
</entry>
<entry>
@@ -95,17 +133,6 @@
<tag>网络代理</tag>
</tags>
</entry>
<entry>
<title>uniapp 开发</title>
<url>/posts/58817.html</url>
<content><![CDATA[<ul>
<li><a href="../component1">uniapp component</a></li>
</ul>
]]></content>
<tags>
<tag>uniapp</tag>
</tags>
</entry>
<entry>
<title>组件使用</title>
<url>/posts/33957.html</url>
@@ -126,47 +153,27 @@
</tags>
</entry>
<entry>
<title>Docker被墙如何继续使用</title>
<url>/posts/47807.html</url>
<content><![CDATA[<h2 id="Docker-Download"><a href="#Docker-Download" class="headerlink" title="Docker Download"></a>Docker Download</h2><blockquote>
<p>自从docker官方仓库在中国大陆被墙后docker的部署方式也发生了改变。<br>解决docker安装问题<a href="https://github.com/shenjianZ/docker_installer">https://github.com/shenjianZ/docker_installer</a></p>
</blockquote>
<ol>
<li><p>安装docker </p>
<figure class="highlight shell"><table><tr><td class="code"><pre><span class="line">sudo curl -fsSL https://gitee.com/tech-shrimp/docker_installer/releases/download/latest/linux.sh| bash -s docker --mirror Aliyun</span><br></pre></td></tr></table></figure>
</li>
<li><p>启动docker</p>
<figure class="highlight shell"><table><tr><td class="code"><pre><span class="line">sudo systemctl start docker</span><br></pre></td></tr></table></figure>
</li>
<li><p>设置开机自启</p>
<figure class="highlight shell"><table><tr><td class="code"><pre><span class="line">sudo systemctl enable docker</span><br></pre></td></tr></table></figure>
</li>
<li><p>Docker pull images</p>
<blockquote>
<p>将image下载到阿里云镜像仓库中<br>解决docker pull 镜像问题:<a href="https://github.com/shenjianZ/docker_image_pusher">https://github.com/shenjianZ/docker_image_pusher</a></p>
</blockquote>
<ol>
<li><p><strong>登录阿里云镜像服务</strong> <a href="https://cr.console.aliyun.com/">https://cr.console.aliyun.com/</a>,</p>
<p>启用个人实例,创建一个命名空间(<code>ALIYUN_NAME_SPACE</code></p>
</li>
<li><p>在<strong>访问凭证</strong> 可以看到账号 用户名(<code>ALIYUN_REGISTRY_USER</code>)</p>
<p>密码(<code>ALIYUN_REGISTRY_PASSWORD</code>)</p>
<p>仓库地址(<code>ALIYUN_REGISTRY</code></p>
</li>
<li><p><strong>启动Action</strong><br>进入您自己的项目,点击<code>Action</code>,启用<code>Github Action</code>功能</p>
</li>
<li><p><strong>配置环境变量</strong><br>进入Settings-&gt;Secret and variables-&gt;Actions-&gt;New Repository secret<br> 将上一步的四个值<br> <code>ALIYUN_NAME_SPACE</code>,</p>
<p> <code> ALIYUN_REGISTRY_USER</code></p>
<p> <code>ALIYUN_REGISTRY_PASSWORD</code></p>
<p> <code>ALIYUN_REGISTRY</code><br> 配置成环境变量</p>
</li>
<li><p><strong>添加镜像</strong><br> 打开<code>images.txt</code>文件,添加你想要的镜像 可以加tag</p>
</li>
<li><p>使用镜像<br>回到阿里云,镜像仓库,点击任意镜像,可查看镜像状态。(可以改成公开,拉取镜像免登录)</p>
</li>
</ol>
</li>
</ol>
<title>郑伯克段于鄢</title>
<url>/posts/58638.html</url>
<content><![CDATA[<p>原文如下:</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;初,郑武公娶于申【申国】,曰武姜【武为武公谥号,姜为其宗族之性】。生庄公及共叔段【共表示其曾出逃到共,叔为老三,段为名】。庄公寤生【出生时头先出,难产】,惊姜氏,故名曰“寤生”, 遂恶之爱【喜爱】共叔段欲立【立为储君】之【多次】请于武公及庄公即位为之【共叔段】请制【一个叫制的封地虎牢关所在】。公曰“制岩邑【险要的城邑】也虢叔死焉佗【通“他”其他】邑唯命是听。”请京使居之谓之“京城大叔”。</p>
]]></content>
<categories>
<category>古文观止</category>
</categories>
<tags>
<tag>古文观止</tag>
</tags>
</entry>
<entry>
<title>uniapp 开发</title>
<url>/posts/58817.html</url>
<content><![CDATA[<ul>
<li><a href="../component1">uniapp component</a></li>
</ul>
]]></content>
<tags>
<tag>uniapp</tag>
</tags>
</entry>
</search>