/metrics.d/LinuxCPU.py (9babdb001901ead9621e9d45af7522c48ee65fa0) (1225 bytes) (mode 100755) (type blob)
#!/usr/bin/python3
import time
import socket
import sys
import os
def cpu():
file = open("/proc/stat","r")
lines = file.readlines()
now = int(time.time())
met = ""
for cpu in lines:
values=cpu.split()
if ('cpu' in values[0]):
met=met+"%s.%s.system.%s.user.ticks %s %s\n" % (sys.platform,os.uname()[1],values[0],values[1],now)
met=met+"%s.%s.system.%s.nice.ticks %s %s\n" % (sys.platform,os.uname()[1],values[0],values[2],now)
met=met+"%s.%s.system.%s.system.ticks %s %s\n" % (sys.platform,os.uname()[1],values[0],values[3],now)
met=met+"%s.%s.system.%s.idle.ticks %s %s\n" % (sys.platform,os.uname()[1],values[0],values[4],now)
met=met+"%s.%s.system.%s.iowait.ticks %s %s\n" % (sys.platform,os.uname()[1],values[0],values[5],now)
met=met+"%s.%s.system.%s.irq.ticks %s %s\n" % (sys.platform,os.uname()[1],values[0],values[6],now)
if (values[0] in 'ctxt'):
met=met+"%s.%s.system.%s.contextswitches %s %s\n" % (sys.platform,os.uname()[1],values[0],values[1],now)
if (values[0] in 'processes'):
met=met+"%s.%s.system.%s.processes %s %s\n" % (sys.platform,os.uname()[1],values[0],values[1],now)
return met
Mode |
Type |
Size |
Ref |
File |
040000 |
tree |
- |
bdfaa25bd7c44e6091d31189c9d10c7019ebef91 |
conf |
040000 |
tree |
- |
211ff1b3b194e0ed0810abcf99eaf6d7f2535fc9 |
graphana_examples |
100755 |
blob |
1187 |
0033fae7b80040519f94dee23c3a4d93d95f6aa9 |
metrics-nosend.py |
040000 |
tree |
- |
620b68dd84166f2b7d8045753feeacbd8ef282d3 |
metrics.d |
100755 |
blob |
1439 |
735b3280bf3c1f9913316c9dca0e5fef2c48aa13 |
metrics.py |
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"
Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/mihai.leontescu/metrics
Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/mihai.leontescu/metrics
Clone this repository using git:
git clone git://git.rocketgit.com/user/mihai.leontescu/metrics
You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a
merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main