TECHZEN Zenoss User Community ARCHIVE  

windows shell custom command, someone has this working ?

Subject: windows shell custom command, someone has this working ?
Author: Charles Bueche
Posted: 2015-03-02 09:46

Hi,

Using Zenoss 4.x Core and the WIndows Zenpack, I'm trying to get the size of a directory on a remote WIndows server. The server is otherwise correctly configured, and I can issue this command successfully from the zenoss user on my linux server :

winrs single -r https://winserver:5986 -u 'user' -a basic --command 'powershell -noprofile -command "[int]((Get-ChildItem C:\temp | Measure-Object -property length -sum -ea SilentlyContinue).Sum)"'

I cannot figure how to do the same in a local template. The goal is to detect when a directory goes over a certain size. I would like to use a custom command to get a data-point, graph it, and apply a threshold to it.

Does someone have a cookbook

TIA,
Charles



Subject: Windows custom shell
Author: Dave Bouchillon
Posted: 2015-03-05 10:24

Hi Charles,

Yes, you can use the custom command datasource to accomplish this.

- Create a monitoring template or choose an existing one for the Windows device class
- Create a datasource and choose Windows Shell as the type
- Edit the datasource, and choose Custom Command for the strategy
- Choose Auto for the parser
- Enter your command, [int]((Get-ChildItem C:\temp | Measure-Object -property length -sum -ea SilentlyContinue).Sum), into the script field, and make sure the Use Powershell box is ticked.
- Add your datapoint, and graph it.

You can then apply a threshold to it.

Hope this helps,

Dave



Subject: Hi Dave,
Author: Charles Bueche
Posted: 2015-03-23 11:57

Hi Dave,

sorry, I did not see your answer, I forgot to subscribe to my own thread.

It is sort of working, but only once. I can do all what you specify, the rrd file get created, the first value is collected, but then never collected anymore. It's like it would be ignored. The data-source is enabled.

If I start the collection using

zenpython run -v 10 -d devicename

I see the data-collection in output:

...
2015-03-23 16:39:13,655 DEBUG zen.collector.scheduler: Task devicename 300 Custom Command fscheck devicename changing state from STATE_SEND_EVENTS to STORE_PERF_DATA
2015-03-23 16:39:13,656 DEBUG zen.RRDUtil: /opt/zenoss/perf/Devices/devicename/fscheck_usage.rrd: 57318545.0, @ N
2015-03-23 16:39:13,656 DEBUG zen.collector.scheduler: Task devicename 300 Custom Command fscheck devicename finished, result: None
2015-03-23 16:39:13,656 DEBUG zen.collector.scheduler: Task devicename 300 Custom Command fscheck devicename changing state from STORE_PERF_DATA to IDLE
...

and apparently, the rrd file is updated:

rrdtool dump /opt/zenoss/perf/Devices/devicename/fscheck_usage.rrd | grep 5731854
57318545.0

but the collection never happen automatically. Do you have an idea why it only runs with manual / debug launch and not automatically

TIA,
Charles



Subject: I tested this out today and
Author: [Not Specified]
Posted: 2015-05-08 13:55

I tested this out today and am getting the same results as Charles. It appears to run fine manually, but never runs automatically I am running Zenoss 4.2.5 and the 2.4.1 Windows ZenPack. I am using the most basic PowerShell script I could think of for testing.

I am using the following for the data source definition:

Enabled: True (checked)
Cycle Time: 60
Strategy: Custom Command
Parser: Auto
Use Powershell: True (checked)
Script: Write-Output 5;

I also added a data point with the exact name as the data source. Unfortunately it never graphs output with this command. I've let it run for hours, and no luck.

If I manually run the "zenpython run -v 10 -d devicename" command, I do see the following in the output:

2015-05-08 14:33:29,046 DEBUG zen.RRDUtil: /opt/zenoss/perf/Devices/devicename/datasource_datasource.rrd: 5.0, @ N

I have looked through the logs in the /opt/zenoss/logs folder but could not find anything helpful for this issue.

We originally were running 4.2.4 and upgraded to 4.2.5. All other monitoring features of the Microsoft ZenPack are working fine.



< Previous
Getting attribute error while trying to test component class .
  Next
WinRM issue with Win32_ComputerSystem
>