Closed jesulo closed 3 months ago
Hello, You can try searching the directory listing located in readme.md to find all supported templates by models.
I have not found any template to check the status of the notebook battery, is there a guide to create templates? Regards
There are several ways to query the battery status. For instance using acpi, upower or just cat /sys/class/power_supply/BAT0/capacity
.
Some of the tools provide additional information, but start with only capturing one thing - the battery level - and get that working. You can always extend the template later.
The battery query operation needs to run on the agent, and there are two ways to extend the agent configuration to run a custom battery level query command, either via user parameter, e.g. create a file /etc/zabbix/zabbix_agentd.d/user-parameter.conf
and add
UserParameter=notebook.battery.level,cat /sys/class/power_supply/BAT0/capacity
(I am completely blank on naming policies regarding UserParameter keys, but I guess avoiding collisions with keys already defined in upstream Zabbix is the safest choice. Alternatively system.hw.bat.level
would be in line with the existing keys (although you then run a risk of collision if Zabbix should add that key in the future).)
The other alternative is to use system.run
to execute the command. Then you need to add the following to zabbix_agentd.conf
:
...
AllowKey=system.run[cat /sys/class/power_supply/BAT0/capacity]
...
DenyKey=system.run[*]
DenyKey=system.run
Of these two I would strongly suggest UserParameter
since it hides the implementation detail from the Zabbix template and easily allows for different agents to run different commands to query the battery level.
As for guide on creating a template I do not know, but for this case I would make a copy of Applications/template_zabbix-apt since that is one of the smallest templates in this repository with just one item, i.e. ideal as a starting point and I think you just need to replace the text and check.
Notice that for the yaml file you need to change most of the uuids. I wrote a script to make these changes automatically, see this pull request.
I would be interested in using this battery, so I'll be happy to help testing.
I think this is the way but, I need make for windows
You can achieve this by using Windows agent and Powershell commands.
In your case:
(Get-WmiObject win32_battery).estimatedChargeRemaining
You can achieve this by using Windows agent and Powershell commands. In your case:
(Get-WmiObject win32_battery).estimatedChargeRemaining
Thanks but how can agent take data and send to server? Regards
You sould save srcipt as script_name.ps1 somewhere on hard drive.
For example: c:\script\script_name.ps1
Then you should edit Zabbix agent config file, for example:
LogFile=c:\zabbix_agentd.log
LogFileSize=10
DebugLevel=2
Server=10.10.10.10
ListenPort=10050
Hostname=W7X86
EnableRemoteCommands=1
LogRemoteCommands=1
Timeout=30
*UserParameter=somename[],PowerShell.exe -nologo "C:\script\script_name.ps1" "somename"**
powercfg/batteryreport this command generate a complete report but output in html, can
You sould save srcipt as _scriptname.ps1 somewhere on hard drive.
For example: c:\script\script_name.ps1
Then you should edit Zabbix agent config file, for example:
LogFile=c:\zabbix_agentd.log
LogFileSize=10
DebugLevel=2
Server=10.10.10.10
ListenPort=10050
Hostname=W7X86
EnableRemoteCommands=1
LogRemoteCommands=1
Timeout=30
*UserParameter=somename[],PowerShell.exe -nologo "C:\script\script_name.ps1" "somename"**
powercfg/batteryreport this command generate a complete report but output in html and need be administrator, how can send by agent?
powercfg /batteryreport /xml /output batteryreport.xml $battery = [xml](Get-Content batteryreport.xml) $health = [pscustomobject]@{ time = $battery.BatteryReport.ReportInformation.ScanTime; maxpower = $battery.BatteryReport.Batteries.Battery.FullChargeCapacity; design = $battery.BatteryReport.Batteries.Battery.DesignCapacity } $health | Format-Table Write-Host "Max battery capacity is only $($health.maxpower / $health.design * 100)% of designed capacity"
I found this script very useful, now how can I get this data on the server? using a template
You sould save srcipt as _scriptname.ps1 somewhere on hard drive.
For example: c:\script\script_name.ps1
Then you should edit Zabbix agent config file, for example:
LogFile=c:\zabbix_agentd.log
LogFileSize=10
DebugLevel=2
Server=10.10.10.10
ListenPort=10050
Hostname=W7X86
EnableRemoteCommands=1
LogRemoteCommands=1
Timeout=30
*UserParameter=somename[],PowerShell.exe -nologo "C:\script\script_name.ps1" "somename"**
powercfg /batteryreport /xml /output batteryreport.xml $battery = [xml](Get-Content batteryreport.xml) $health = [pscustomobject]@{ time = $battery.BatteryReport.ReportInformation.ScanTime; maxpower = $battery.BatteryReport.Batteries.Battery.FullChargeCapacity; design = $battery.BatteryReport.Batteries.Battery.DesignCapacity } $health | Format-Table Write-Host "Max battery capacity is only $($health.maxpower / $health.design * 100)% of designed capacity"
I found this script very useful, now how can I get this data on the server? using a template. Regards
Hi, there is a Template for check status battery notebook? Regards