https://github.com/lifailon/psinfluxdb
Integrating PowerShell Core with Indlux Database.
https://github.com/lifailon/psinfluxdb
api chart database influx influxdata influxdb-client powershell powershell-module rest rest-api windows winforms winforms-chart
Last synced: 6 months ago
JSON representation
Integrating PowerShell Core with Indlux Database.
- Host: GitHub
- URL: https://github.com/lifailon/psinfluxdb
- Owner: Lifailon
- License: apache-2.0
- Created: 2023-07-04T12:27:59.000Z (over 2 years ago)
- Default Branch: rsa
- Last Pushed: 2024-02-10T20:00:29.000Z (over 1 year ago)
- Last Synced: 2025-03-28T03:30:09.719Z (7 months ago)
- Topics: api, chart, database, influx, influxdata, influxdb-client, powershell, powershell-module, rest, rest-api, windows, winforms, winforms-chart
- Language: PowerShell
- Homepage: https://www.nuget.org/packages/psinfluxdb
- Size: 735 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# psinfluxdb
[](https://github.com/Lifailon/psinfluxdb)
[](https://www.nuget.org/packages/psinfluxdb)
[](https://github.com/PowerShell/PowerShell)
[](https://github.com/Lifailon/psinfluxdb/blob/rsa/LICENSE)**PowerShell module for interaction to InfluxDB 1.x via API**. \
By default GET requests give line-by output. This module is used to automate the query form and output in **object format**. \
Only GET requests.## 🚀 Install
Install module from [NuGet repository](https://www.nuget.org/packages/psinfluxdb):
```PowerShell
Install-Module psinfluxdb -Repository NuGet
```Import module:
```PowerShell
PS C:\Users\Lifailon> Import-Module psinfluxdb
PS C:\Users\lifailon> Get-Command -Module psinfluxdbCommandType Name Version Source
----------- ---- ------- ------
Function Get-InfluxChart 0.3 psinfluxdb
Function Get-InfluxData 0.3 psinfluxdb
Function Get-InfluxDatabases 0.3 psinfluxdb
Function Get-InfluxPolicy 0.3 psinfluxdb
Function Get-InfluxTables 0.3 psinfluxdb
Function Get-InfluxUsers 0.3 psinfluxdb
```## 📚 Examples
Get user list:
```PowerShell
PS C:\Users\Lifailon> Get-InfluxUsers -server 192.168.3.102user admin
---- -----
admin True
root True
read False
```Get database list:
```PowerShell
PS C:\Users\Lifailon> Get-InfluxDatabases -server 192.168.3.102_internal
PowerShell
```Creat and delete database:
```PowerShell
PS C:\Users\lifailon> Get-InfluxDatabases -server 192.168.3.102 -creat -database test_internal
PowerShell
testPS C:\Users\lifailon> Get-InfluxDatabases -server 192.168.3.102 -delete -database test
_internal
PowerShell
```Database storage policies (creat and set default):
```PowerShell
PS C:\Users\lifailon> Get-InfluxPolicy -server 192.168.3.102 -database PowerShellname : autogen
duration : 0s
shardGroupDuration : 168h0m0s
replicaN : 1
default : TruePS C:\Users\lifailon> Get-InfluxPolicy -server 192.168.3.102 -database PowerShell -creat -policyName del2d -hours 48
name : autogen
duration : 0s
shardGroupDuration : 168h0m0s
replicaN : 1
default : Truename : del2d
duration : 48h0m0s
shardGroupDuration : 24h0m0s
replicaN : 1
default : FalsePS C:\Users\lifailon> Get-InfluxPolicy -server 192.168.3.102 -database PowerShell -policyName del2d -default
name : autogen
duration : 0s
shardGroupDuration : 168h0m0s
replicaN : 1
default : Falsename : del2d
duration : 48h0m0s
shardGroupDuration : 24h0m0s
replicaN : 1
default : True
```Get table (measurement) list:
```PowerShell
PS C:\Users\Lifailon> Get-InfluxTables -server 192.168.3.102 -database PowerShellperformance
ping
speedtest
HardwareMonitor
```Get data from table (measurement) selected:
```PowerShell
PS C:\Users\Lifailon> Get-InfluxData -server 192.168.3.102 -database PowerShell -table ping | fttime host rtime status
---- ---- ----- ------
07/08/2023-15:16:24 HUAWEI-MB-X-Pro 22 True
07/08/2023-15:16:29 HUAWEI-MB-X-Pro 20 True
07/08/2023-15:16:35 HUAWEI-MB-X-Pro 20 True
07/08/2023-15:16:41 HUAWEI-MB-X-Pro 20 True
07/08/2023-15:16:51 HUAWEI-MB-X-Pro 0 False
07/08/2023-15:17:06 HUAWEI-MB-X-Pro 32 True
07/08/2023-15:17:16 HUAWEI-MB-X-Pro 22 True
07/08/2023-15:17:27 HUAWEI-MB-X-Pro 20 True
07/08/2023-15:17:37 HUAWEI-MB-X-Pro 20 True
07/08/2023-15:17:47 HUAWEI-MB-X-Pro 21 True
...
```
Get data for the last 30 minutes from [HardwareMonitor](https://github.com/Lifailon/PowerShellHardwareMonitor):
```PowerShell
PS C:\Users\lifailon> Get-InfluxData -server 192.168.3.102 -database PowerShell -table HardwareMonitor -minutes 30 | Format-Tabletime HardwareName Host SensorName SensorType Value
---- ------------ ---- ---------- ---------- -----
02/03/2024-22:27:45 Intel_Core_i5-10400 PLEX-01 CPU_Core_#1 Temperature_0 24
02/03/2024-22:27:45 Intel_Core_i5-10400 PLEX-01 CPU_Core_#1_Distance_to_TjMax Temperature_7 76
02/03/2024-22:27:45 Intel_Core_i5-10400 PLEX-01 CPU_Core_#2 Temperature_1 24
02/03/2024-22:27:45 Intel_Core_i5-10400 PLEX-01 CPU_Core_#2_Distance_to_TjMax Temperature_8 76
02/03/2024-22:27:45 Intel_Core_i5-10400 PLEX-01 CPU_Core_#3 Temperature_2 23
02/03/2024-22:27:45 Intel_Core_i5-10400 PLEX-01 CPU_Core_#3_Distance_to_TjMax Temperature_9 77
02/03/2024-22:27:45 Intel_Core_i5-10400 PLEX-01 CPU_Core_#4 Temperature_3 22
02/03/2024-22:27:45 Intel_Core_i5-10400 PLEX-01 CPU_Core_#4_Distance_to_TjMax Temperature_10 78
02/03/2024-22:27:45 Intel_Core_i5-10400 PLEX-01 CPU_Core_#5 Temperature_4 23
02/03/2024-22:27:45 Intel_Core_i5-10400 PLEX-01 CPU_Core_#5_Distance_to_TjMax Temperature_11 77
02/03/2024-22:27:45 Intel_Core_i5-10400 PLEX-01 CPU_Core_#6 Temperature_5 22
02/03/2024-22:27:45 Intel_Core_i5-10400 PLEX-01 CPU_Core_#6_Distance_to_TjMax Temperature_12 78
02/03/2024-22:27:45 Intel_Core_i5-10400 PLEX-01 CPU_Package Temperature_6 24
02/03/2024-22:27:45 Intel_Core_i5-10400 PLEX-01 Core_Average Temperature_14 23
02/03/2024-22:27:45 Intel_Core_i5-10400 PLEX-01 Core_Max Temperature_13 24
02/03/2024-22:27:45 MSI_M390_250GB PLEX-01 Temperature Temperature_0 34
02/03/2024-22:27:45 Nuvoton_NCT6687D PLEX-01 CPU Temperature_0 28
02/03/2024-22:27:45 Nuvoton_NCT6687D PLEX-01 CPU_Socket Temperature_4 27
02/03/2024-22:27:45 Nuvoton_NCT6687D PLEX-01 M2_1 Temperature_6 23
02/03/2024-22:27:45 Nuvoton_NCT6687D PLEX-01 PCH Temperature_3 36
02/03/2024-22:27:45 Nuvoton_NCT6687D PLEX-01 PCIe_x1 Temperature_5 29
02/03/2024-22:27:45 Nuvoton_NCT6687D PLEX-01 System Temperature_1 30
02/03/2024-22:27:45 Nuvoton_NCT6687D PLEX-01 VRM_MOS Temperature_2 36
02/03/2024-22:27:45 Radeon_RX_570_Series PLEX-01 GPU_Core Temperature_0 34
02/03/2024-22:27:45 ST1000DM003-1CH162 PLEX-01 Temperature Temperature_0 31
02/03/2024-22:27:45 WDC_WD2005FBYZ-01YCBB2 PLEX-01 Temperature Temperature_0 33
02/03/2024-22:27:50 12th_Gen_Intel_Core_i7-1260P HUAWEI-BOOK CPU_Core_#1 Temperature_0 47
02/03/2024-22:27:50 12th_Gen_Intel_Core_i7-1260P HUAWEI-BOOK CPU_Core_#10 Temperature_9 45
02/03/2024-22:27:50 12th_Gen_Intel_Core_i7-1260P HUAWEI-BOOK CPU_Core_#10_Distance_to_TjMax Temperature_22 55
02/03/2024-22:27:50 12th_Gen_Intel_Core_i7-1260P HUAWEI-BOOK CPU_Core_#11 Temperature_10 45
02/03/2024-22:27:50 12th_Gen_Intel_Core_i7-1260P HUAWEI-BOOK CPU_Core_#11_Distance_to_TjMax Temperature_23 55
02/03/2024-22:27:50 12th_Gen_Intel_Core_i7-1260P HUAWEI-BOOK CPU_Core_#12 Temperature_11 45
02/03/2024-22:27:50 12th_Gen_Intel_Core_i7-1260P HUAWEI-BOOK CPU_Core_#12_Distance_to_TjMax Temperature_24 55
02/03/2024-22:27:50 12th_Gen_Intel_Core_i7-1260P HUAWEI-BOOK CPU_Core_#1_Distance_to_TjMax Temperature_13 53
02/03/2024-22:27:50 12th_Gen_Intel_Core_i7-1260P HUAWEI-BOOK CPU_Core_#2 Temperature_1 48
02/03/2024-22:27:50 12th_Gen_Intel_Core_i7-1260P HUAWEI-BOOK CPU_Core_#2_Distance_to_TjMax Temperature_14 52
02/03/2024-22:27:50 12th_Gen_Intel_Core_i7-1260P HUAWEI-BOOK CPU_Core_#3 Temperature_2 47
02/03/2024-22:27:50 12th_Gen_Intel_Core_i7-1260P HUAWEI-BOOK CPU_Core_#3_Distance_to_TjMax Temperature_15 53
02/03/2024-22:27:50 12th_Gen_Intel_Core_i7-1260P HUAWEI-BOOK CPU_Core_#4 Temperature_3 45
02/03/2024-22:27:50 12th_Gen_Intel_Core_i7-1260P HUAWEI-BOOK CPU_Core_#4_Distance_to_TjMax Temperature_16 55
02/03/2024-22:27:50 12th_Gen_Intel_Core_i7-1260P HUAWEI-BOOK CPU_Core_#5 Temperature_4 50
02/03/2024-22:27:50 12th_Gen_Intel_Core_i7-1260P HUAWEI-BOOK CPU_Core_#5_Distance_to_TjMax Temperature_17 50
02/03/2024-22:27:50 12th_Gen_Intel_Core_i7-1260P HUAWEI-BOOK CPU_Core_#6 Temperature_5 50
02/03/2024-22:27:50 12th_Gen_Intel_Core_i7-1260P HUAWEI-BOOK CPU_Core_#6_Distance_to_TjMax Temperature_18 50
02/03/2024-22:27:50 12th_Gen_Intel_Core_i7-1260P HUAWEI-BOOK CPU_Core_#7 Temperature_6 50
02/03/2024-22:27:50 12th_Gen_Intel_Core_i7-1260P HUAWEI-BOOK CPU_Core_#7_Distance_to_TjMax Temperature_19 50
02/03/2024-22:27:50 12th_Gen_Intel_Core_i7-1260P HUAWEI-BOOK CPU_Core_#8 Temperature_7 50
02/03/2024-22:27:50 12th_Gen_Intel_Core_i7-1260P HUAWEI-BOOK CPU_Core_#8_Distance_to_TjMax Temperature_20 50
02/03/2024-22:27:50 12th_Gen_Intel_Core_i7-1260P HUAWEI-BOOK CPU_Core_#9 Temperature_8 45
02/03/2024-22:27:50 12th_Gen_Intel_Core_i7-1260P HUAWEI-BOOK CPU_Core_#9_Distance_to_TjMax Temperature_21 55
02/03/2024-22:27:50 12th_Gen_Intel_Core_i7-1260P HUAWEI-BOOK CPU_Package Temperature_12 50
02/03/2024-22:27:50 12th_Gen_Intel_Core_i7-1260P HUAWEI-BOOK Core_Average Temperature_26 47
02/03/2024-22:27:50 12th_Gen_Intel_Core_i7-1260P HUAWEI-BOOK Core_Max Temperature_25 50
...
```💡 Now we can filter the received data in the usual way (without resorting to SQL queries):
```PowerShell
$Data | Where-Object {$_.SensorName -match "Package" -and $_.Value -gt 90} | Format-Tabletime HardwareName Host SensorName SensorType Value
---- ------------ ---- ---------- ---------- -----
02/10/2024-19:05:24 12th_Gen_Intel_Core_i7-1260P HUAWEI-BOOK CPU_Package Temperature_12 95
02/10/2024-19:20:01 12th_Gen_Intel_Core_i7-1260P HUAWEI-BOOK CPU_Package Temperature_12 92
02/10/2024-19:20:24 12th_Gen_Intel_Core_i7-1260P HUAWEI-BOOK CPU_Package Temperature_12 94
02/10/2024-19:29:04 12th_Gen_Intel_Core_i7-1260P HUAWEI-BOOK CPU_Package Temperature_12 99
02/10/2024-19:30:20 12th_Gen_Intel_Core_i7-1260P HUAWEI-BOOK CPU_Package Temperature_12 98
02/10/2024-19:30:32 12th_Gen_Intel_Core_i7-1260P HUAWEI-BOOK CPU_Package Temperature_12 92
```## 📈 Charts
The Grafana alternative (used **WinForms**) to create graphs from data obtained with the [Ookla-SpeedTest](https://github.com/Lifailon/Ookla-SpeedTest-API) module.
`$influx = Get-InfluxData -server 192.168.3.104 -database PowerShell -table speedtest` \
`Get-InfluxChart -time ($influx.time) -data ($influx.download) -title "SpeedTest Download" -path "C:\Users\Lifailon\Desktop"`
`Get-InfluxChart -time ($influx.time) -data ($influx.upload) -title "SpeedTest Upload" -path "C:\Users\Lifailon\Desktop"`
