Grafana Monitoring Script and general scrips
Will push data to a Influx 2.0 DB so you can use it as grafana source.
- Influx DB
- Grafana
- NodeJS & PM2
If you have docker installed already, you can skip this
curl -sSL https://get.docker.com/ | CHANNEL=stable bash
systemctl enable --now docker
docker run -d -p 8086:8086 \
--name=InfluxDB \
-v influxdb2:/var/lib/influxdb2 \
influxdb:2.0
docker run -d --name=grafana \
-p 3000:3000 \
grafana/grafana
curl -sL https://deb.nodesource.com/setup_16.x | sudo -E bash -
sudo apt install nodejs -y
npm i pm2 -g
pm2 startup
- Go to
Server IP:8086
in your Browser and click "Get Started". - Setup a username & password.
- Setup your organisation and your first bukket. You´ll need that later!
- Click on "Setup later" on the next Step.
- Go to
Server IP:3000
in your Browser and log in with Username/Password: admin/admin - It will ask you to setup a new password.
- Click on configuration and then datacources then add data source.
- Select InfluxDB.
- Select Flux as your Query Language.
- Write your
http://serverip:port
into the URL field. - Fill out your Organization, Default Bucket and write for "Min time interval" 1s
- Go back to your InfluxDb webpanel, click on "Data" then "Tokens" then on your Token and copy that.
- Paste this token into the field "Token" in the grafana config.
- Click save&test. It should say "X Buckets found", if it shows an error check your config.
It is recommendet you run this software on the same server as you run the MySQL DB for your pterodactyl and controlpanel.gg installtion.
- Clone the repo to your server, you can change the path.
git clone https://github.com/EBG-PW/ControlPanel.gg-Stats-and-Scripts.git /etc/ControlPanelStats/ && cd /etc/ControlPanelStats/
- Rename the .env.example and edit it
mv ./.env.example ./.env && nanoe .env
- Write the DB Credentials & InfluxDB Data
DB_HOST=localhost
DB_USER=dashboarduser
DB_PASSWORD=mysecretpassword
DB_DATABASE=dashboard
CheckDelayInMS=10000
ExcludeAdminCoins=true // If true, the admin coins will not be shown in the stats.
Influx_Host=InfluxDB Ip
Influx_Protocol=http
Influx_Port=8086
Influx_Token=The token that you put into grafana data source
orga=YourOrga
bucket=YourDefaultBucket
host=Dashboard
PteroStatusURL= //Pterostatus URL (with protocol and port, like http://myserver.com:8080)
PteroStatusToken= //Barer Token for the Pterostatus API
- Install node modules and setup pm2
npm i
node PM2_Setup.js
pm2 save
- for the grafana dashboard, click on Dasboards->Manage->Import and paste the json found in
Dashboards/Example Dashboard
- You´ll need to make some ajustments in each panel because the names are dynamic and will differ from my names.
To see if the software is running, you can use the command pm2 monit
and look for 'ControlPanel.gg Stats'. There you can see CPU / RAM usage, the current log, the restarts and other performance metrics.
- Follow installation of Ptero-Status
- Write the url (localhost if installed localy) into the .env "PteroStatusURL"
- Optional: If you setup Token auth (recommended) you have to write the token after PteroStatusToken=
- Restart the software (pm2 restart "ControlPanel.gg Stats")
- Make sure you use the example dashboard with livestats OR edit your current dashbord.
If you don´t know Flux Query language used by InflixDB2 you can always go to your InfluxDB Webpanel and use the GUI under the "Explore" tab.
After you have the graph you wanted, click on "Script editor" and paste the code into the grafana query field.
Name | Function | MySQL Root | Usage |
---|---|---|---|
Transfer Users | Move users from pterodactyl to controlpanel | Recommended | npm run transfer |
This script will move all non admin users from your existing pterodactyl installation to controlpanel.
It will keep the same login information, users just have to verify e-mail (if you requiere). Those emails will not be send by this script!
Its recommented to use root MYSQL user, but you can also use a user with dump permissions and pterodactyl DB + Contropanel DB permission.
This script will ONLY work on instalation with DEFAULT database names:
Pterodactyl: panel
Controlpanel: controlpanel
If you want to use diffrent DB names, you have to modify the script.