Sometimes when I\'m trying to diagnose what process is hogging all of my laptop\'s resources, I notice that htop
will sort the CPU% column incorrectly.
Example below:
\n\n\n\nThe \xe2\x80\x9cCPU%\xe2\x80\x9d column is highlighted in the header row, so that means its sorting by that column (right?), yet it\xe2\x80\x99s all out of order. It\xe2\x80\x99s clearly not sorting it numerically, and neither is it sorting it lexicographically. I\'m not sure how else it could be trying to sort it.
\n\n …我正在编写一个脚本,该脚本将帮助我们团队的系统管理员监控其他登录用户在其他终端上发生的事情。
我现在遇到的一件事是如何查看已键入的命令。我意识到在用户退出或输入之前不会保存历史记录history -a
,但是必须有一种方法来查看当前历史记录中的内容,即使它存储在内存中的某处。
它可能保存在某个地方/proc/${pid_of_users_bash}
吗?我试着键入命令呼应的唯一字符串(EG: echo "foobarbaz"
,然后greping为foobarbaz 通过相关联的任何平面文件/proc/PID
的目录,但没有运气。
如果有人有不涉及设置PROMPT_COMMAND
或设置histappend
(像这些)的解决方案,那将不胜感激。
我正在编写一个脚本(它将在 OSX 上运行,可能没有别的),它基本上只是解析/var/log/accountpolicy.log*
日志以获取身份验证时间/计数。初始命令是通过zgrep
执行的sudo
,它通过管道传输到awk
,执行 awk 脚本。命令运行后,我${PIPESTATUS[@]}
用来确定是否有任何失败,如果失败,是哪个部分。
这是当前状态的 awk 脚本:
#! /usr/local/bin/awk -f
BEGIN {
return_code = 0
if ( length( username ) == 0 ){
return_code = 2
exit return_code
}
rows = 0
}
{
if ( $8 != sprintf("\"%s\",", username ) ) next
rows = rows+1
print $0
}
END {
if ( return_code > 0 ) exit return_code
if ( rows == 0 ) exit 3
}
Run Code Online (Sandbox Code Playgroud)
awk …