-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpainel2.sh
46 lines (31 loc) · 1.14 KB
/
painel2.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/bash
users=$(getent passwd | cut -f1 -d":")
echo "" > dashboard2.txt
for nome in $users
do
somacpu=0
somamem=0
existe=`ps -eo %mem,%cpu,user | grep $nome`
if [[ -n $existe ]]; then
processos=$(ps -eo %cpu,user | grep $nome |cut -f2 -d" ")
for num in $processos
do
somacpu=`echo $somacpu + $num | bc`
done
memoria=$(ps -eo %mem,user | grep $nome |cut -f2 -d" ")
for num in $memoria
do
somamem=`echo $somamem + $num | bc`
done
echo "cpu_$nome,host=hostname value=$somacpu" >> /home/ekarani/dashboard2.txt
echo "mem_$nome,host=hostname value=$somamem" >> /home/ekarani/dashboard2.txt
fi
done
########################### Tarefas #####################
tasks=$(ps -A --no-headers | wc -l)
threads=$(ps -AL --no-headers | wc -l)
sleeping=$(ps -A --no-headers -eo stat | grep S | wc -l)
echo "tasks,host=hostname value=$tasks" >> /home/ekarani/dashboard2.txt
echo "threads,host=hostname value=$threads" >> /home/ekarani/dashboard2.txt
echo "sleeping,host=hostname value=$sleeping" >> /home/ekarani/dashboard2.txt
curl -i -XPOST 'http://localhost:8086/write?db=teste' --data-binary @/home/ekarani/dashboard2.txt