iT邦幫忙

第 12 屆 iThome 鐵人賽

DAY 8
0
自我挑戰組

30天菜鳥學 Linux 系列 第 8

8天-解決 ubuntu sar 問題 ( 非常水的一天XD )

今天閱讀 鳥哥的 Linux 私房菜 -- 程序與資源管理
image-20200910090822444

發現想按照文中使用 sar 查詢 ubuntu 的系統資源情況,發現以下錯誤

test@test:~$ sar
Cannot open /var/log/sysstat/sa10: No such file or directory
Please check if data collecting is enabled

搜尋 google 找到文章 14.04 - Cannot open /var/log/sysstat/sa20: No such file or directory - Ask Ubuntu

Open /etc/default/sysstat using your favorite file editor and change ENABLED="false" to ENABLED="true"

vi /etc/default/sysstat
----
# Should sadc collect system activity informations? Valid values
# are "true" and "false". Please do not put other values, they
# will be overwritten by debconf!
ENABLED="true"
----

Restart sysstat: sudo service sysstat restart

and now here you are!

叫我去修改 /etc/default/sysstat 文件,將ENABLED改成true

但是我輸入 vi /etc/default/sysstat 去修改時,會跳出以下警告跟阻擋

test$ vi /etc/default/sysstat
W10: Warning: Changing a readonly file 
--我按enter確認

E325: ATTENTION
Found a swap file by the name "/var/tmp/sysstat.swp"
          owned by: test   dated: Wed Sep 09 08:37:26 2020
         file name: /etc/default/sysstat
          modified: YES
         user name: test   host name: test
        process ID: 4681
While opening file "/etc/default/sysstat"
             dated: Wed Sep 09 08:35:41 2020

(1) Another program may be editing the same file.  If this is the case,
    be careful not to end up with two different instances of the same
    file when making changes.  Quit, or continue with caution.
(2) An edit session for this file crashed.
    If this is the case, use ":recover" or "vim -r /etc/default/sysstat"
    to recover the changes (see ":help recovery").
    If you did this already, delete the swap file "/var/tmp/sysstat.swp"
    to avoid this message.

Press ENTER or type command to continue
--我按enter確認
--修改ENABLED改成true
$ :wq!
"/etc/default/sysstat" E212: Can't open file for writing

image-20200910081759397

接著爬文 : [SOLVED] E212 cant open file for writing. I have root access

這篇文章說建議不要修改

Note: Just because you're root, doesn't mean you can do things that can't be done. For instance, if you have a file's permissions set for read only, you can't normally edit it without changing permissions to read/write. Also, lock-files may block access to a service, etc. Think of root as "super-user," with pervasive authority to change things in the system,... not a "God mode," omnipotent and able to change the rules of the system.

請問 sar 命令是否現在不建議使用? 那要使用什麼命令監控系統資源呢? 像是 windows 工作管理員


使用以下方式解決 :

$ sudo vi /etc/default/sysstat
--改為
#
# Default settings for /etc/init.d/sysstat, /etc/cron.d/sysstat
# and /etc/cron.daily/sysstat files
#

# Should sadc collect system activity informations? Valid values
# are "true" and "false". Please do not put other values, they
# will be overwritten by debconf!
ENABLED="true"
$ sudo /etc/init.d/sysstat restart
$ sudo sar
Linux 4.19.104-microsoft-standard (DESKTOP)         09/11/20        _x86_64_        (8 CPU)

今天真是水水的一天 XD
哈~哈~哈~哈


上一篇
7天-搞懂多人多工
下一篇
9天-ubuntu desktop vi 命令出現無法上下左右移動,會出現ABDC,順便學習 vi
系列文
30天菜鳥學 Linux 59
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言