-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathHOW_TO_ADD_YOUR_DATA.txt
executable file
·58 lines (41 loc) · 2.27 KB
/
HOW_TO_ADD_YOUR_DATA.txt
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
47
48
49
50
51
52
53
54
55
56
57
HOW TO ADD ANOTHER DATA SOURCE FOR VERSION > 0.4:
-------------------------------------------------
Now you must edit few php files. I marked places for your code:
MARK 1) setup.php - add your DS like others
MARK 2) topx.php - final operation. It is not necessary. It depands on your data
MARK 3) topx.php - your queries to data source stats
MARK 4) topx.php - It is not necessary. It depands on your data
HOW TO ADD ANOTHER DATA SOURCE FOR VERSION < 0.4:
-------------------------------------------------
All available datasources:
SELECT DISTINCT data_template.id, data_template.name,hash
FROM data_template INNER JOIN data_template_data
ON data_template.id=data_template_data.data_template_id
ORDER BY data_template.name
I choose (id and hash are important):
| 41 | Interface - Traffic | 6632e1e0b58a565c135d7ff90440c335 |
Go to (change id at the and to correct id)
http(s)://your.cacti.installation/data_templates.php?action=template_edit&id=41
Second way is via sql client:
select * from data_template_rrd where local_data_id=0 and data_template_id=16 order by data_source_name
There you find data source item (one or more, but my plugin works with one or two only):
For Interface traffic you found two data source items named "traffic_in" and "traffic_out"
Now you have all informations.
Now you must edit setup.php. I marked 4 places for your code:
MARK 1)
INSERT INTO plugin_topx_source (sorting,dt_name,hash,operation,unit,final_operation,final_unit)
values ('desc','Interface traffic','6632e1e0b58a565c135d7ff90440c335','traffic_in+traffic_out','bits','/1024','kbit')");
sorting - asc or desc
dt_name - your name of this data source
hash - you found out it earlier
operation with values - if you have only one, insert itemvalue=itemvalue (proc=proc). For two operation, try to understand prepared rows
unit - number of process or similiar
final_operation - for displaying in topx table
final_units - dtto
MARK2)
For one value (proc=proc) only add row at the beginning of case (like cpu=cpu, ...)
For two values, you can do what you want (add,substract,...). Result must be in $avg_value
MARK3)
Similar to MARK2. Be careful with two values. You have to insert one to value1 and second to value2
MARK4)
Similar to MARK3, instead of update it is for first insert of values