Ad Widget

Collapse

userparameter .bat to kick off powershell scripts

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jimzs
    Junior Member
    • Sep 2014
    • 7

    #1

    userparameter .bat to kick off powershell scripts

    I'm using a userparameter to kick off a .bat script. I don't care what the

    Code:
    UserParameter=outlook,"D:\EmailMonitor\zabbix_send.bat"
    I'm getting the following unsupported message when I run the command with \zabbix_agentd.exe -c C:\zabbix_agentd.conf -p
    outlook [m|ZBX_NOTSUPPORTED]
    I dont really care about that value that would be returned here, i'm just using the userparameter as a means to kick off the script. i just have an echo 1 to satisfy a value coming through at the start of the script for key value.

    In the .bat script, I have the following code.

    Code:
    d:
    cd \EmailMonitor
    echo 1
    @echo off
    @echo start of commands >> sender.log 
    @echo Wait 10 minutes >> sender.log
    date /T >> sender.log 
    time /T >> sender.log 
    @echo score_mailbox run >> sender.log
    Powershell.exe -executionpolicy remotesigned -File  D:\EmailMonitor\score_mailbox.ps1
    @echo score_cas run >> sender.log
    Powershell.exe -executionpolicy remotesigned -File  D:\EmailMonitor\score_cas.ps1
    @echo testmbxmx101_db01finaloutput >> sender.log 
    D:\zabbix_sender.exe -vv -z 10.106.21.99 -i D:\EmailMonitor\testmbxmx101_db01finaloutput.txt >> sender.log 
    @echo testmbxmx102_db01finaloutput >> sender.log
    D:\zabbix_sender.exe -vv -z 10.106.21.99 -i D:\EmailMonitor\testmbxmx102_db01finaloutput.txt >> sender.log 
    @echo testmbxmx103_db01finaloutput >> sender.log
    D:\zabbix_sender.exe -vv -z 10.106.21.99 -i D:\EmailMonitor\testmbxmx103_db01finaloutput.txt >> sender.log 
    @echo testmbxmx104_db01finaloutput >> sender.log
    When I run the script from the windows command prompt, I get the expected output as follows in the sender.log file in D:\EmailMonitor directory and zabbix has the correct latest data. The two powershell scripts also run correctly and have the correct data.

    Code:
    Start of commands  
    Wait 10 minutes 
    Wed 12/31/2014 
    12:30 PM
    score_mailbox run 
    score_cas run 
    testmbxmx101_db01finaloutput  
    info from server: "processed: 23; failed: 0; total: 23; seconds spent: 0.001880"
    sent: 23; skipped: 0; total: 23
    testmbxmx102_db01finaloutput 
    info from server: "processed: 16; failed: 0; total: 16; seconds spent: 0.000882"
    sent: 16; skipped: 0; total: 16
    testmbxmx103_db01finaloutput 
    info from server: "processed: 28; failed: 0; total: 28; seconds spent: 0.001080"
    sent: 28; skipped: 0; total: 28
    When I use the command to use the zabbix agent (\zabbix_agentd.exe -c C:\zabbix_agentd.conf -p) to run the .bat command, I get the following in the sender.log file and the latest data is not updated. It also looks like the powershell scripts are kicking off incorrectly as they are blank.

    Code:
     start of commands  
    Wait 10 minutes 
    Wed 12/31/2014 
    01:00 PM
    score_mailbox run 
    score_cas run
    Any help would be appreciated.
  • issak
    Junior Member
    • Jul 2014
    • 8

    #2
    Try
    zabbix_agentd.exe -t outlook

    or
    zabbix_agentd.exe -c c:\zabbix_agentd.conf -t outlook

    or from server:
    zabbix-get -s <hostname> -k outlook

    If nothing works, you probably have permission issues, because you're running the script as non administator user, try running zabbix-agentd service as a admin user (could be your username, as long as you have the rights)
    start > run > services.msc > zabbix agent > properties > Log On > This account, enter username and password
    Last edited by issak; 14-01-2015, 14:42.

    Comment

    • jimzs
      Junior Member
      • Sep 2014
      • 7

      #3
      I went ahead and just started using scheduled tasks to run this rather than the userparameter.

      When I have some time I will revisit and let you know if any of those suggestions work. Thanks for taking a look!

      Comment

      Working...