-
-
Notifications
You must be signed in to change notification settings - Fork 438
271 lines (231 loc) · 10.4 KB
/
syntax.yml
File metadata and controls
271 lines (231 loc) · 10.4 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
# +-------------------------------------------------------------------------+
# | Copyright (C) 2004-2024 The Cacti Group |
# | |
# | This program is free software; you can redistribute it and/or |
# | modify it under the terms of the GNU General Public License |
# | as published by the Free Software Foundation; either version 2 |
# | of the License, or (at your option) any later version. |
# | |
# | This program is distributed in the hope that it will be useful, |
# | but WITHOUT ANY WARRANTY; without even the implied warranty of |
# | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
# | GNU General Public License for more details. |
# +-------------------------------------------------------------------------+
# | Cacti: The Complete RRDtool-based Graphing Solution |
# +-------------------------------------------------------------------------+
# | This code is designed, written, and maintained by the Cacti Group. See |
# | about.php and/or the AUTHORS file for specific developer information. |
# +-------------------------------------------------------------------------+
# | http://www.cacti.net/ |
# +-------------------------------------------------------------------------+
name: Cacti Commit Audit
on:
push:
branches: [ 1.2.x ]
pull_request:
branches: [ 1.2.x ]
permissions:
contents: read
concurrency:
group: build-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
check:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
php: ['8.1', '8.2', '8.3', '8.4']
experimental: [false]
services:
mysql:
image: mariadb:10.6
env:
MYSQL_DATABASE: cacti
MYSQL_HOST: 127.0.0.1
MYSQL_USER: cactiuser
MYSQL_PASSWORD: cactiuser
MYSQL_ROOT_PASSWORD: cactiroot
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
name: PHP ${{ matrix.php }} Test on ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install PHP ${{ matrix.php }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: intl, mysql, gd, ldap, gmp, xml, curl, json, mbstring #optional
ini-values: "post_max_size=256M, max_execution_time=60, date.timezone=America/New_York" #optional
- name: Check PHP version
run: php -v
- name: Checkout Thold Plugin
uses: GuillaumeFalourd/clone-github-repo-action@v2
with:
owner: 'Cacti'
repository: 'plugin_thold'
- name: Checkout Monitor Plugin
uses: GuillaumeFalourd/clone-github-repo-action@v2
with:
owner: 'Cacti'
repository: 'plugin_monitor'
- name: Checkout MacTrack Plugin
uses: GuillaumeFalourd/clone-github-repo-action@v2
with:
owner: 'Cacti'
repository: 'plugin_mactrack'
- name: Checkout Intropage Plugin
uses: GuillaumeFalourd/clone-github-repo-action@v2
with:
owner: 'Cacti'
repository: 'plugin_intropage'
- name: Checkout FlowView Plugin
uses: GuillaumeFalourd/clone-github-repo-action@v2
with:
owner: 'Cacti'
repository: 'plugin_flowview'
- name: Checkout Audit Plugin
uses: GuillaumeFalourd/clone-github-repo-action@v2
with:
owner: 'Cacti'
repository: 'plugin_audit'
- name: Checkout Syslog Plugin
uses: GuillaumeFalourd/clone-github-repo-action@v2
with:
owner: 'Cacti'
repository: 'plugin_syslog'
- name: Move Plugins to Plugin Directory
run: |
mv plugin_thold ${{ github.workspace }}/plugins/thold
mv plugin_monitor ${{ github.workspace }}/plugins/monitor
mv plugin_mactrack ${{ github.workspace }}/plugins/mactrack
mv plugin_audit ${{ github.workspace }}/plugins/audit
mv plugin_flowview ${{ github.workspace }}/plugins/flowview
mv plugin_intropage ${{ github.workspace }}/plugins/intropage
mv plugin_syslog ${{ github.workspace }}/plugins/syslog
# With syslog we have to enable batch installs using the lines below
cd ${{ github.workspace }}/plugins/syslog
cp -p config.php.dist config.php
sed -i 's/\/\/\$syslog_install_options/\$syslog_install_options/g' config.php
- name: Move plugin config files
run: |
cp -p ${{ github.workspace }}/plugins/flowview/config.php.dist ${{ github.workspace }}/plugins/flowview/config.php
cp -p ${{ github.workspace }}/plugins/syslog/config.php.dist ${{ github.workspace }}/plugins/syslog/config.php
sed -i 's/\/\/\$/\$/g' ${{ github.workspace }}/plugins/syslog/config.php
- name: Check PHP syntax
run: if find ${{ github.workspace }} -name '*.php' -exec php -l {} 2>&1 \; | grep -iv 'no syntax errors detected'; then exit 1; fi
- name: Run and apt-get update
run: sudo apt-get update
- name: Install Apache and Tools
run: sudo apt-get install apache2 snmp snmpd rrdtool libapache2-mod-php${{ matrix.php }}
- name: Start SNMPD Agent and Test Agent
run: |
sudo systemctl start snmpd
sudo snmpwalk -c public -v2c -On localhost .1.3.6.1.2.1.1
- name: Link Web Root and Fix Permissions and Disable Apparmor
run: |
sudo ln -s /home/runner/work/cacti/cacti /var/www/html
sudo find /home/runner/work/cacti -type d -exec chmod 777 {} \;
sudo find /home/runner/work/cacti -type f -exec chmod 777 {} \;
sudo systemctl stop apparmor
sudo systemctl disable apparmor
sudo chown -R www-data:runner /home/runner/work/cacti
sudo chmod o+x /home
sudo chmod o+x /home/runner
sudo chmod o+x /home/runner/work
sudo chmod o+x /home/runner/work/cacti
sudo chmod o+x /home/runner/work/cacti/cacti
- name: Configure Apache Site
run: |
cat ${{ github.workspace }}/tests/tools/cacti.conf | sed -r 's#GITHUB_WORKSPACE#${{ github.workspace }}#g' > /tmp/cacti.conf
sudo cp /tmp/cacti.conf /etc/apache2/sites-available/000-default.conf
- name: Restart Apache2
run: sudo systemctl restart apache2
- name: Create and Initialize Database
env:
MYSQL_AUTH_USR: '--defaults-file=~/.my.cnf'
run: |
echo -e "[client]\nuser = root\npassword = cactiroot\nhost = 127.0.0.1\n" >> ~/.my.cnf
cat ~/.my.cnf
mysql $MYSQL_AUTH_USR -e 'CREATE DATABASE IF NOT EXISTS cacti;'
mysql $MYSQL_AUTH_USR -e "CREATE USER 'cactiuser'@'localhost' IDENTIFIED BY 'cactiuser';"
mysql $MYSQL_AUTH_USR -e "GRANT ALL PRIVILEGES ON cacti.* TO 'cactiuser'@'localhost';"
mysql $MYSQL_AUTH_USR -e "FLUSH PRIVILEGES;"
mysql $MYSQL_AUTH_USR cacti < ${{ github.workspace }}/cacti.sql
mysql $MYSQL_AUTH_USR -e "INSERT INTO settings (name, value) VALUES ('path_php_binary', '/bin/php')" cacti
- name: Prime Cacti config.php File
run: |
cat ${{ github.workspace }}/include/config.php.dist | sed -r "s/localhost/127.0.0.1/g" > ${{ github.workspace }}/include/config.php
sudo chmod 777 ${{ github.workspace }}/include/config.php
cat ${{ github.workspace}}/include/config.php
- name: Setup Cacti Daemon
run: |
sudo cp ${{ github.workspace }}/tests/tools/cactid.service /etc/systemd/system/cactid.service
sudo systemctl enable cactid
sudo systemctl start cactid
sudo systemctl status cactid
if ! systemctl is-active --quiet cactid; then
echo "Cacti daemon failed to start"
exit 1
fi
- name: Check install code for validity
run: |
cd ${{ github.workspace }}
sudo php -q tests/tools/check_install_code.php
- name: Check that all CLI scripts have a valid --version flag
run: |
cd ${{ github.workspace }}
sudo bash tests/tools/check_cli_version.sh
- name: Install Cacti through the CLI
run: |
cd ${{ github.workspace }}
sudo php cli/install_cacti.php --accept-eula --install --force
- name: Audit the Installation Schema
run: |
cd ${{ github.workspace }}
sudo php cli/audit_database.php --report
- name: Install and Enable Plugins
run: |
cd ${{ github.workspace }}
sudo php cli/plugin_manage.php --plugin=thold --plugin=intropage --plugin=monitor --plugin=mactrack --plugin=audit --plugin=flowview --plugin=syslog --install --enable --allperms
- name: Add Device for Moc Test, Check CLI scripts for Errors
run: |
cd ${{ github.workspace }}
sudo php cli/add_device.php --description=test_device --ip=127.0.0.1 --template=24
sudo php cli/rebuild_poller_cache.php --debug
sudo php cli/poller_reindex_hosts.php --id=all --debug
- name: Run Cacti poller
run: |
sudo php ${{ github.workspace }}/poller.php --poller=1 --force --debug
if ! grep -q "SYSTEM STATS" ${{ github.workspace }}/log/cacti.log; then
echo "Cacti poller did not finish successfully"
exit 1
fi
- name: Check All Pages Using Recursive wget
run: |
cd ${{ github.workspace }}
echo -e "[client]\nuser = root\npassword = cactiroot\nhost = 127.0.0.1\n" > ${{ github.workspace }}/.my.cnf
sudo tests/tools/check_all_pages.sh -vmstat 10
- name: View Contents of Logs
run: sudo cat ${{ github.workspace }}/log/cacti.log
# - name: Validate composer.json and composer.lock
# run: composer validate --strict
# - name: Cache Composer packages
# id: composer-cache
# uses: actions/cache@v3
# with:
# path: vendor
# key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
# restore-keys: |
# ${{ runner.os }}-php-
#
# - name: Install dependencies
# run: composer install --prefer-dist --no-progress
# Add a test script to composer.json, for instance: "test": "vendor/bin/phpunit"
# Docs: https://getcomposer.org/doc/articles/scripts.md
#
# - name: Run test suite
# run: composer run-script test