Ad Widget

Collapse

Is possible set this trigger?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • DeXTeR-ITA
    Junior Member
    • Dec 2007
    • 22

    #1

    Is possible set this trigger?

    Hi all!
    Another question...

    I explain what I do, in crontab I put this line, run this script every 10 min.:

    Code:
    0,10,20,30,40,50 * * * * /share/archivio/datedvd.sh "Colunga V1" /share/archivio/cfc/ cfc
    The script is this, return 2 value for 2 zabbix item (date & time):

    Code:
    #!/bin/sh
    
    #########################################################################
    #
    # datedvd.sh
    # Versione 1.0
    # Autore: Lorenzo Giandomenico
    #
    # Date: 07/03/08
    # Ultima revisione: 14/03/08 Alessandro Bagalini
    #
    #########################################################################
    #
    # Script per il controllo data ed ora dell'ultimo dato dei DVD.
    # All'avvio dello script e' necessario specificare l'host, il percorso
    # di partenza e la banca dati che si vuole controllare
    #
    # Es: ./datedvd.sh /share/archivio/cfc/ cfc
    #
    # La banca dati deve corrispondere alla chiave settata su Zabbix
    # 
    #
    
    HOST_CF=$1
    DIR=$2
    BANCA_DATI=$3
    
    cd $DIR
    
    for i in $( ls -d yd*); do
        YDIR=$i
    done
    
    for i in $( ls -d $YDIR/md*); do
        MDIR=$i
    done
    
    for i in $( ls $MDIR/*.dvd); do
        FILE=$i
    done
    
    DATA=`head $FILE --lines=7 | tail --lines=1 | awk -F '=' {'print $2'} | awk {'print $1'}`
    ORA=`head $FILE --lines=8 | tail --lines=1 | awk -F '=' {'print $2'} | awk {'print $1'}`
    
    # echo $HOST_CF $DIR $DATA $ORA
    
    zabbix_sender -z 172.23.0.35 -p 10051 -s "$HOST_CF" -k datedvd.$BANCA_DATI -o $DATA
    zabbix_sender -z 172.23.0.35 -p 10051 -s "$HOST_CF" -k timedvd.$BANCA_DATI -o $ORA
    ~
    In zabbix I configure the items in this way:

    Description: DVD CFC Date
    Type: ZABBIX agent (active)
    key: datedvd.cfc
    Type information: Character
    Show value: As Is

    Description: DVD CFC Time
    Type: ZABBIX agent (active)
    key: timedvd.cfc
    Type information: Character
    Show value: As Is

    After a little work is fine, the result in zabbix is:

    YYYYMMDD
    HH:MM

    Es.:
    20080314
    15:30

    But now I miss only one thing, create a trigger for this two items.
    For the date, trigger ON if no change evary 24h, better if different from today's date. And for time if it is different from time is 15 minutes.

    If I explained evil ask please, thank you in advance.
  • bbrendon
    Senior Member
    • Sep 2005
    • 870

    #2
    For zabbix_sender I think they type is zabbix trapper, not active.
    I didn't understand the trigger question very well.
    Unofficial Zabbix Expert
    Blog, Corporate Site

    Comment

    • DeXTeR-ITA
      Junior Member
      • Dec 2007
      • 22

      #3
      Ok, I made some changes to the script, now collect the time in format UNIXTIME.

      Script:
      Code:
      #!/bin/sh
      
      #########################################################################
      #
      # datedvd.sh
      # Versione 1.0
      # Autore: Lorenzo Giandomenico
      #
      # Date: 07/03/08
      # Ultima revisione: 17/03/08 Alessandro Bagalini
      #
      #########################################################################
      #
      # Script per il controllo data ed ora dell'ultimo dato dei DVD,
      # convertendo la data in UNIXTIME (secondi a partire dal 1970/01/01 00:00)
      # All'avvio dello script e' necessario specificare il percorso
      # di partenza e la banca dati che si vuole controllare
      #
      # Es: ./datedvd.sh /share/archivio/cfc/ cfc
      #
      # La banca dati deve corrispondere alla chiave settata su Zabbix
      #
      #
      
      HOST_CF=$1
      DIR=$2
      BANCA_DATI=$3
      
      cd $DIR
      
      for i in $( ls -d yd*); do
          YDIR=$i
      done
      
      for i in $( ls -d $YDIR/md*); do
          MDIR=$i
      done
      
      for i in $( ls $MDIR/*.dvd); do
          FILE=$i
      done
      
      YYYY=`head $FILE --lines=7 | tail --lines=1 | awk -F '=' {'print $2'} | awk {'print $1'} | cut -c1-4`
      MM=`head $FILE --lines=7 | tail --lines=1 | awk -F '=' {'print $2'} | awk {'print $1'} | cut -c5-6`
      DD=`head $FILE --lines=7 | tail --lines=1 | awk -F '=' {'print $2'} | awk {'print $1'} | cut -c7-8`
      
      ORA=`head $FILE --lines=8 | tail --lines=1 | awk -F '=' {'print $2'} | awk {'print $1'}`
      
      UNIXTIME=`date -d "$MM/$DD/$YYYY $ORA" +%s`
      
      ## echo Host CF $HOST_CF - Directory  $DIR - Data $DD/$MM/$YYYY - Ora $ORA - Unixtime $UNIXTIME
      
      zabbix_sender -z 172.23.0.35 -p 10051 -s "$HOST_CF" -k datedvd.$BANCA_DATI -o $UNIXTIME
      The data collected is fine, but have an error at the end of page "Overview" (repeted 6 time):

      Code:
      date() expects parameter 2 to be long, string given[/usr/share/zabbix/include/config.inc.php:410]
      What about this error?

      I changed Type of Item in Zabbix Trapper, of course.

      Comment

      • DeXTeR-ITA
        Junior Member
        • Dec 2007
        • 22

        #4
        Resolved, the error was due to old incorrect data.

        And finaly I set the Items:

        Code:
         Description: DVD CFC Date
         Type: ZABBIX trapper
         key: datedvd.cfc
         Type information: Numeric (integer 64bit)
         Units: Unixtime
         Show value: As Is

        Trigger fire if the date is 30 min old:

        Code:
        {Template_CF-DVDControl:datedvd.cfc.fuzzytime(1800)}#1
        I am pleased!

        Comment

        Working...