-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathcpu_and_memory_usage.sh
30 lines (23 loc) · 1.12 KB
/
cpu_and_memory_usage.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/bin/bash
##################################################################
# Author : Sinesio Bittencourt
# Email : [email protected]
# Info : Script to check cPanel CPU and Memory usage for a specific user
# Project : http://git.sinesio.com.br or https://github.com/sinesiobittencourt/
##################################################################
VERSAO="0.1b"
#tput cup
#clear
echo "# Version : v$VERSAO ( beta )"
echo -e "\n[!] - Bem vindo.\n"
read -p "Por favor informe o dominio a ser analisado: " DOMAIN
#domain="xxx.xx.xx";
#/usr/local/cpanel/bin/dcpumonview
for i in `seq 1 7`;
do
let i=$i+1 ;
let k=$i-1 ;
let s="$(date +%s) - (k-1)*86400";
let t="$(date +%s) - (k-2)*86400";
echo `date -Idate -d @$s`; /usr/local/cpanel/bin/dcpumonview `date -d @$s +%s` `date -d @$t +%s` | sed -r -e 's@^<tr bgcolor=#[[:xdigit:]]+><td>(.*)</td><td>(.*)</td><td>(.*)</td><td>(.*)</td><td>(.*)</td></tr>$@Account: \1\tDomain: \2\tCPU: \3\tMem: \4\tMySQL: \5@' -e 's@^<tr><td>Top Process</td><td>(.*)</td><td colspan=3>(.*)</td></tr>$@\1 - \2@' | grep $DOMAIN -A3 ;
done