Skip to content

Commit f3b7a11

Browse files
authored
New howto - convert 5min poller to 1min (#181)
* add howto for change poller 5min->1min * formatting * formatting again * format3
1 parent d397c23 commit f3b7a11

5 files changed

+145
-2
lines changed

How-To-Poller-5-to-1-min.md

+141
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
# Change poller interval from 5 minutes to 1 minute
2+
3+
This howto describes all necessary steps for convert your cacti to 1 minute poller interval. This cause one gap in graphs during the convert. Gap size depends on count of your rrd files.
4+
5+
## Prerequisites and default values used in this howto
6+
- Cacti installation directory is **/usr/local/share/cacti/**
7+
- PHP binary is **/usr/local/bin/php**
8+
- RRD files are in **/usr/local/share/cacti/rra**
9+
- Poller is running by user **cacti**
10+
- **Not structured RRDfile paths** (`Configuration->Settings-> Data` -> Structured RRDfile Paths). With structured path you will have more works with splice rrd files. You need change splice script.
11+
- Crontab row looks like
12+
```shell
13+
*/5 * * * * cacti /usr/local/bin/php /usr/local/share/cacti/poller.php 2>&1
14+
```
15+
16+
17+
18+
## Backup your Cacti
19+
Before this operation, backup Cacti database and all data in rra folder
20+
21+
22+
## RRDCleaner (optional step)
23+
You can run rrdcleaner and delete unused RRD files. It can decrease converting time.
24+
[System Utilities](System-Utilities.md)
25+
26+
27+
## Stop poller
28+
Disable your poller in Crontab or via GUI `Console -> Configuration -> Settings -> Poller tab -> Data Collection Enabled`
29+
30+
31+
## Prepare directory structure for RRD file convert
32+
```shell
33+
mkdir -p /tmp/cacti/rrd_old
34+
mkdir -p /tmp/cacti/rrd_new
35+
mkdir -p /tmp/cacti/rrd_fin
36+
```
37+
Make sure that you have enought space on temporary disk. You need more than twice of rra directory size.
38+
39+
40+
## Move rrd files
41+
```shell
42+
mv /usr/local/share/cacti/rra/* /tmp/cacti/rrd_old/
43+
```
44+
45+
## Check or create Presets -> Data profiles
46+
Go to `Console -> Presets -> Data Profiles`. Here should be at least 5 Minute Collection profile (because you are using it until now) and 1 Minute Collection profile.
47+
If the second is missing, create it.
48+
![Presets](images/poller-5-1-preset-1min.png)
49+
50+
Remember Data profile ID - Edit your 1 minute collection again and in URL will be .../data_source_profiles.php?action=edit&**id=3**
51+
52+
53+
## Switch to 1 min
54+
`Console -> Configuration -> Settings -> Poller tab`
55+
- Poller interval = Every minute
56+
- Cron/Daemon interval = Every minute
57+
58+
59+
## Update database records
60+
Run these SQL queries:
61+
```shell
62+
UPDATE data_template_data SET rrd_step=60 WHERE rrd_step=300;
63+
UPDATE data_template_rrd SET rrd_heartbeat=600;
64+
```
65+
Here replace X with ID from Step "Check or create Presets -> Data profiles":
66+
```shell
67+
UPDATE data_template_data SET data_source_profile_id=X;
68+
```
69+
70+
## Rebuild poller cache
71+
`Console -> Utilities -> System utilities -> Rebuild Poller Cache`
72+
73+
## Set 1 min Data Profile as default
74+
`Console -> Presets -> Data Profiles`
75+
76+
Edit profile **1 min Collection**, checkbox default.
77+
78+
![Presets](images/poller-5-1-preset-default.png)
79+
80+
## Change profile for all Data templates
81+
`Console -> Templates -> Data Source`
82+
83+
Select all -> Change Profile
84+
85+
![Presets](images/poller-5-1-change-profile.png)
86+
87+
## Run the poller once
88+
New rrd files with correct 1 min profile will be created in **/usr/local/share/cacti/rra** directory.
89+
Cacti log shouldn't contain errors.
90+
91+
## Move new rrd files to temporary folder
92+
```shell
93+
mv /usr/local/share/cacti/rra/* /tmp/cacti/rrd_new/
94+
```
95+
96+
## Run splice
97+
You need run splice command for each rrd file. This could be time consuming, depends on number of files. You can use some tool for parallel tasks.
98+
The splice_rrd.php file is designed to allow two RRDfiles to be merged. This utility can effectively change the resolution/step of an RRDfile so long as the new RRDfile already has the correct step.
99+
100+
Basic script:
101+
```shell
102+
#!/bin/sh
103+
104+
cd /tmp/cacti/rrd_old/
105+
for f in *.rrd
106+
do
107+
echo $f
108+
/usr/local/bin/php /usr/local/share/cacti/cli/splice_rrd.php --oldrrd=/tmp/cacti/rrd_old/$f --newrrd=/tmp/cacti/rrd_new/$f --finrrd=/tmp/cacti/rrd_fin/$f
109+
done
110+
```
111+
112+
Run script and wait. My experience - 5200 files took 100 minutes without paralelisation. Script will be output sometning like:
113+
```console
114+
fortigate_1_-_fg200e4q17911506_traffic_in_7317.rrd
115+
NOTE: Using Native Arrays due to lack of SQLite.
116+
NOTE: Using RRDtool Version 1.8.0
117+
NOTE: RRDfile will be written to '/tmp/cacti/rrd_fin/fortigate_1_-_fg200e4q17911506_traffic_in_7317.rrd'
118+
NOTE: Re-Importing '/tmp/fortigate_1_-_fg200e4q17911506_traffic_in_7317.dump.27482713' to '/tmp/cacti/rrd_fin/fortigate_1_-_fg200e4q17911506_traffic_in_7317.rrd'
119+
NOTE: Time:0.88, RUsage:18 MB
120+
```
121+
122+
123+
## Move spliced files back to cacti
124+
```shell
125+
mv /tmp/cacti/rrd_fin/* /usr/local/share/cacti/rra/
126+
```
127+
File owner should be cacti
128+
```shell
129+
chown cacti /usr/local/share/cacti/rra/*
130+
```
131+
132+
## Enable poller in Cron again
133+
Change your cron settings from 5 minutes to 1 minute and enable (uncomment). Old row:
134+
```shell
135+
#*/5 * * * * cacti /usr/local/bin/php /usr/local/share/cacti/poller.php 2>&1
136+
```
137+
New row
138+
```shell
139+
* * * * * cacti /usr/local/bin/php /usr/local/share/cacti/poller.php 2>&1
140+
```
141+

README.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -313,9 +313,11 @@ PARTICULAR PURPOSE. See the GNU General Public License for more details.
313313

314314
9. [How To Setup SSH Tunnels](How-To-SSH-Tunnels.md)
315315

316-
10.[Enable SSL for Cacti](Cacti-SSL-Configuration.md)
316+
10.[Enable SSL for Cacti](Cacti-SSL-Configuration.md)
317317

318-
11.[Graph a Single SNMP OID](Graph-a-Single-SNMP-OID.md)
318+
11.[Graph a Single SNMP OID](Graph-a-Single-SNMP-OID.md)
319+
320+
12.[Change poller interval from 5 minutes to 1 minute ](How-To-Poller-5-to-1-min.md)
319321

320322
### Video Tutorials
321323

images/poller-5-1-change-profile.png

93.4 KB
Loading

images/poller-5-1-preset-1min.png

100 KB
Loading

images/poller-5-1-preset-default.png

36.2 KB
Loading

0 commit comments

Comments
 (0)