Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new sensors listing feature #2038

Closed
wants to merge 1 commit into from
Closed

Conversation

DL6ER
Copy link
Member

@DL6ER DL6ER commented Aug 23, 2024

What does this implement/fix?

Adds a new CLI feature useful for debugging sensor issues. We should add it to pihole -d as well.

Example output:

$ pihole-FTL --sensors
{
        "list": [{
                        "name": "nct6793",                                                                                                                                                    
                        "path": "hwmon2",                                                                                                                                                     
                        "source":       "devices/platform/nct6775.656",                                                                                                                       
                        "temps":        [{                                                                                                                                                    
                                        "name": "AUXTIN3",                                                                                                                                    
                                        "value":        104,                                                                                                                                  
                                        "max":  null,                                                                                                                                         
                                        "crit": null,                                                                                                                                         
                                        "sensor":       "temp6"                                                                                                                               
                                }, {                                                                                                                                                          
                                        "name": "AUXTIN0",                                                                                                                                    
                                        "value":        45,                                                                                                                                   
                                        "max":  0,                                                                                                                                            
                                        "crit": null,                                                                                                                                         
                                        "sensor":       "temp3"                                                                                                                               
                                }, {                                                                                                                                                          
                                        "name": "SMBUSMASTER 0",                                                                                                                              
                                        "value":        46.5,                                                                                                                                 
                                        "max":  null,                                                                                                                                         
                                        "crit": null,                                                                                                                                         
                                        "sensor":       "temp7"                                                                                                                               
                                }, {                                                                                                                                                          
                                        "name": "AUXTIN1",                                                                                                                                    
                                        "value":        109,                                                                                                                                  
                                        "max":  null,                                                                                                                                         
                                        "crit": null,                                                                                                                                         
                                        "sensor":       "temp4"                                                                                                                               
                                }, {
                                        "name": "SYSTIN",
                                        "value":        114.5,                                                                                                                                
                                        "max":  null,                                                                                                                                         
                                        "crit": null,                                                                                                                                         
                                        "sensor":       "temp1"
                                }, {                                                           
                                        "name": "AUXTIN2",
                                        "value":        107,
                                        "max":  null,         
                                        "crit": null,
                                        "sensor":       "temp5"
                                }, {                                                           
                                        "name": "CPUTIN",
                                        "value":        46,
                                        "max":  80,
                                        "crit": null,
                                        "sensor":       "temp2"                        
                                }]        
                }, {                                                                           
                        "name": "nvme",                                                        
                        "path": "hwmon0",                                                      
                        "source":       "devices/pci0000:00/0000:00:02.4/0000:04:00.0/nvme/nvme0",
                        "temps":        [{                                                     
                                        "name": "Composite",
                                        "value":        41.85,
                                        "max":  117.85,
                                        "crit": 149.85,
                                        "sensor":       "temp1"
                                }]
                }, {
                        "name": "k10temp",
                        "path": "hwmon3",
                        "source":       "devices/pci0000:00/0000:00:18.3",
                        "temps":        [{
                                        "name": "Tctl",
                                        "value":        46.25,
                                        "max":  null,
                                        "crit": null,
                                        "sensor":       "temp1"
                                }]
                }, {
                        "name": "amdgpu",
                        "path": "hwmon1",
                        "source":       "devices/pci0000:00/0000:00:08.1/0000:05:00.0",
                        "temps":        [{
                                        "name": "edge",
                                        "value":        43,
                                        "max":  null,
                                        "crit": null,
                                        "sensor":       "temp1"
                                }]
                }],
        "cpu_temp":     46.25,
        "hot_limit":    0,
        "unit": "C"
}

Related issue or feature (if applicable): N/A

Pull request in docs with documentation (if applicable): N/A


By submitting this pull request, I confirm the following:

  1. I have read and understood the contributors guide, as well as this entire template. I understand which branch to base my commits and Pull Requests against.
  2. I have commented my proposed changes within the code.
  3. I am willing to help maintain this change if there are issues with it later.
  4. It is compatible with the EUPL 1.2 license
  5. I have squashed any insignificant commits. (git rebase)

Checklist:

  • The code change is tested and works locally.
  • I based my code and PRs against the repositories developmental branch.
  • I signed off all commits. Pi-hole enforces the DCO for all contributions
  • I signed all my commits. Pi-hole requires signatures to verify authorship
  • I have read the above and my PR is ready for review.

Copy link
Member

@yubiuser yubiuser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was wondering, instead of having a fixed new cli option for a specific endpoint, could we bake a http client into FTL only allowing to query itself. This would offer all GET endpoints to be easily accessible from cli.

E.g.
pihole-FTL --api '/info/sensors'
pihole-FTL --api '/stats/summary'

@rdwebdesign
Copy link
Member

We should add it to pihole -d as well.

Follow-up PR: pi-hole/pi-hole#5735

@DL6ER
Copy link
Member Author

DL6ER commented Aug 24, 2024

could we bake a http client into FTL

In theory yes, but I'm afraid it is some deep rabbit hole. CIvetweb has some very basic HTTP client but...

  1. It is still an HTTP connection via a socket, the server cannot reliably determine that this is an internal connection -> we need to authenticate. Even when CLI password is enabled, the normal user does probably have access to the CLI password unless they manually tweaked permissions/group ownership.
  2. HTTPS is not possible with CivetWeb so the implementation would only work when there is at least one HTTP port.

It's probably easier to implement something like this in the pihole CLI command which can then utilize curl which is able to handle HTTPS and all the other things as well. We also already have the authentication code readily available in core.

@DL6ER
Copy link
Member Author

DL6ER commented Aug 24, 2024

See pi-hole/pi-hole#5736

I'm still not sure if this supersedes this particular PR. The reason being that the pihole api feature may require the users to log in (as said above) which is probably not working very well when used in pihole -d.

@yubiuser
Copy link
Member

I think pi-hole/pi-hole#5736 supersedes this PR. It's way more generic and can be very helpful during supporting on discourse.

We should add it to pihole -d as well.

I don't think this is the case. Having issues with the senor data is very rar and we tried to keep pihole -d lean to handle the output (and to reduce the data we collect by default). With pi-hole/pi-hole#5736 the information is available very easily and can be asked by supporting staff if needed.

@DL6ER DL6ER closed this Aug 26, 2024
@DL6ER DL6ER deleted the new/list_sensors branch August 26, 2024 16:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants