Code Monkey home page Code Monkey logo

Comments (9)

RogerTheUnicornHive avatar RogerTheUnicornHive commented on August 25, 2024

Hello,
You can try searching the directory listing located in readme.md to find all supported templates by models.

from community-templates.

jesulo avatar jesulo commented on August 25, 2024

I have not found any template to check the status of the notebook battery, is there a guide to create templates? Regards

from community-templates.

hlovdal avatar hlovdal commented on August 25, 2024

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.

from community-templates.

jesulo avatar jesulo commented on August 25, 2024

I think this is the way but, I need make for windows

from community-templates.

Sunspreader avatar Sunspreader commented on August 25, 2024

You can achieve this by using Windows agent and Powershell commands.
In your case:
(Get-WmiObject win32_battery).estimatedChargeRemaining

from community-templates.

jesulo avatar jesulo commented on August 25, 2024

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

from community-templates.

Sunspreader avatar Sunspreader commented on August 25, 2024

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"

from community-templates.

jesulo avatar jesulo commented on August 25, 2024

powercfg/batteryreport this command generate a complete report but output in html, can

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 and need be administrator, how can send by agent?

from community-templates.

jesulo avatar jesulo commented on August 25, 2024

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 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 /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

from community-templates.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.