I have a little problem with my Script! In the first part i do a cat on a textdocument and set in VAR1-VAR3 the login data for the WMI-Request!
In the second part i do a WMI-Request to a Windows Server and ask him how many Warrnings and Errors are in his Application and System eventlog!
Code: Select all
#!/bin/bash
VAR1=`cat $VAR[0] | head -1 | tail -1 | awk -F '=' '{print $2}'`
VAR2=`cat $VAR[0] | head -2 | tail -1 | awk -F '=' '{print $2}'`
VAR3=`cat $VAR[0] | head -3 | tail -1 | awk -F '=' '{print $2}'`
let VAR4=`wmic -U $VAR1/$VAR2%$VAR3 //$VAR[1] 'SELECT * FROM Win32_NTLogEvent WHERE Logfile ="Application"' | grep "|Warnung|" | wc --lines`
let VAR5=`wmic -U $VAR1/$VAR2%$VAR3 //$VAR[1] 'SELECT * FROM Win32_NTLogEvent WHERE Logfile ="System"' | grep "|Warnung|" | wc --lines`
let VAR6=$VAR4+$VAR5
let VAR7=`wmic -U $VAR1/$VAR2%$VAR3 //$VAR[1] 'SELECT * FROM Win32_NTLogEvent WHERE Logfile ="Application"' | grep "|Fehler|" | wc --lines`
let VAR8=`wmic -U $VAR1/$VAR2%$VAR3 //$VAR[1] 'SELECT * FROM Win32_NTLogEvent WHERE Logfile ="System"' | grep "|Fehler|" | wc --lines`
let VAR9=$VAR7+$VAR8
echo Fehler:$VAR9 Warnungen:$VAR6
If i set $VAR[0] and $VAR[1] in the Script and run it on the ubuntu i get the right data back but if i get the Script into cacti i always get this in the logfile:
Why i get "Fehler: Warnungen:" but no data?!03/30/2011 10:50:23 AM - CMDPHP: Poller[0] Host[9] DS[372] CMD: sh /var/www/cacti/scripts/wmi/wmi_eventlog_warnung.sh /var/www/cacti/scripts/wmi/wmi_service_login.txt 172.27.27.199, output: Fehler: Warnungen: