source: nscp/scripts/check_battery.vbs @ 1307e3f5

0.4.00.4.10.4.2
Last change on this file since 1307e3f5 was 1307e3f5, checked in by Michael Medin <michael@…>, 22 months ago

Fixed check_battery.vbs

  • Property mode set to 100644
File size: 1.8 KB
Line 
1' =========================================================
2' WMI script to return the charge remaining in a laptop battery, using the
3' EstimatedChargeRemaining property of the Win32_Battery class
4' =========================================================
5
6' Required Variables
7Const PROGNAME = "check_battery"
8Const VERSION = "0.0.1"
9
10' Default settings for your script.
11threshold_warning = "50:"
12threshold_critical = "20:"
13strComputer = "."
14
15' Create the NagiosPlugin object
16Set np = New NagiosPlugin
17
18' Define what args that should be used
19np.add_arg "computer", "Computer name", 0
20np.add_arg "warning", "warning threshold", 0
21np.add_arg "critical", "critical threshold", 0
22
23' If we have no args or arglist contains /help or not all of the required arguments are fulfilled show the usage output,.
24If Args.Exists("help") Then
25        np.Usage
26End If
27
28' If we define /warning /critical on commandline it should override the script default.
29If Args.Exists("warning") Then threshold_warning = Args("warning")
30If Args.Exists("critical") Then threshold_critical = Args("critical")
31If Args.Exists("computer") Then strComputer = Args("computer")
32np.set_thresholds threshold_warning, threshold_critical
33
34Set colInstances = np.simple_WMI_CIMV2(strComputer, "SELECT * FROM Win32_Battery")
35return_code = OK
36
37For Each objInstance In colInstances
38        if message <> "" then : message = message & ", "
39        if perf <> "" then : perf = perf & ", "
40        message = message & "Battery " & objInstance.Status & " - Charge Remaining = " & objInstance.EstimatedChargeRemaining & "%"
41        perf = perf & "charge=" & objInstance.EstimatedChargeRemaining
42        return_code = np.escalate_check_threshold(return_code, objInstance.EstimatedChargeRemaining)
43Next
44' Nice Exit with msg and exitcode
45np.nagios_exit message & "|" & perf, return_code
Note: See TracBrowser for help on using the repository browser.