source: trunk/misc/operations_helpers/munin/tahoe_cpu_watcher

Last change on this file was b856238, checked in by Alexandre Detiste <alexandre.detiste@…>, at 2024-02-15T15:53:34Z

remove old Python2 future statements

  • Property mode set to 100644
File size: 719 bytes
Line 
1#!/usr/bin/env python
2
3
4import os, sys, re
5import urllib
6import json
7
8url = os.environ["url"]
9current = json.loads(urllib.urlopen(url).read())
10
11configinfo = """\
12graph_title Tahoe CPU Usage
13graph_vlabel CPU %
14graph_category tahoe
15graph_info This graph shows the 5min average of CPU usage for each process
16"""
17data = ""
18
19for (name, avg1, avg5, avg15) in current:
20    dataname = re.sub(r'[^\w]', '_', name)
21    configinfo += dataname + ".label " + name + "\n"
22    configinfo += dataname + ".draw LINE2\n"
23    if avg5 is not None:
24        data += dataname + ".value %.2f\n" % (100.0 * avg5)
25
26if len(sys.argv) > 1:
27    if sys.argv[1] == "config":
28        print(configinfo.rstrip())
29        sys.exit(0)
30print(data.rstrip())
Note: See TracBrowser for help on using the repository browser.