vCenter

 View Only
Expand all | Collapse all

Alarm script fail on vCenter 8

  • 1.  Alarm script fail on vCenter 8

    Posted Jan 22, 2024 12:03 PM

    Hi,

    I'm trying to send alarms to our application through the vCenter alarm definition with the script method. This works on vCenter v7 but fails on v8.

    VMware described the issue and solution here:
    https://kb.vmware.com/s/article/87918

    I followed the exact steps of the solution, but it is not working yet.

    What I did:

    Made two .sh script and uploaded to /root/:
    /root/alarm.sh

    sudo /root/root_alarm.sh

    /root/root_alarm.sh

    #!/bin/sh
    
    token='FSDQFf5423XVxd%$@#vdvxcDV' 
    
    curl -s \
        --form-string "token=$token" \
        --form-string "name=$VMWARE_ALARM_NAME" \
        --form-string "target=$VMWARE_ALARM_TARGET_NAME" \
        --form-string "value=$VMWARE_ALARM_ALARMVALUE" \
        --form-string "description=$VMWARE_ALARM_EVENTDESCRIPTION" \
        --form-string "status=$VMWARE_ALARM_NEWSTATUS" \
    https[:]//app.test.com/api/v4/alarm

     

    Those were created with the root owner by default, [I tried as it was, but it did not work], so I changed the alarm.sh owner to vpxd as VMware said:

    root@vcenter [ ~ ]# ls -lah
    -rwxr-xr-x 1 vpxd root 25 Jan 20 16:49 alarm.sh
    -rwxr-xr-x 1 root root 448 Jan 20 16:41 root_alarm.sh

    Also:

    root@vcenter [ ~ ]# chmod +x alarm.sh
    root@vcenter [ ~ ]# chmod +x root_alarm.s

     

    and privilege on /etc/sudoers (I added all I could, so one of those may work) :

    ...
    vpxd ALL= NOPASSWD: /usr/sbin/sendmail -tf*
    vpxd ALL= NOPASSWD: /usr/lib/vmware-vmon/vmon-cli --stop vcha
    vpxd ALL= NOPASSWD: /usr/lib/vmware-vmon/vmon-cli --start vcha
    vpxd ALL= NOPASSWD: /bin/vc-support.sh*
    vpxd ALL= NOPASSWD: /usr/bin/bash /root/root_alarm.sh
    vpxd ALL= NOPASSWD: /usr/bin/bash /root/alarm.sh
    vpxd ALL= NOPASSWD: /root/root_alarm.sh
    vpxd ALL= NOPASSWD: /root/root_alarm.sh*

    setup:
    2024-01-22 15_20_12 — Mozilla Firefo.png

    And, when the condition is triggered, I get the same error on /var/log/vmware/vpxd/vpxd.log and vcenter events:

    Script failed to execute: Command must exist/be executable

    2024_01_22_15_18_43_Window.png

    Any clue or help please?



  • 2.  RE: Alarm script fail on vCenter 8

    Posted Feb 18, 2024 10:30 AM

    any solution?