How send value in collectd with perl script? -


i created script , use in collectd.

i used collectd-perl plugin don't know how use it.

the goal count how many mail sent server.

#!/usr/bin/perl  use strict; use warnings;  $pathvalue = 'value.txt'; ($value, $old_value) = (countmodule(), old_value());   ########## main #############  main();  ####### functions ############# sub old_value {     open(fic,$pathvalue) or die return 0;     @fic = <fic> ;         foreach $line (@fic)         {                 chomp($line) ;                 return $line;   #return old value         } }  sub countmodule {     $file = "mail.log";     open $fh, "<",$file or die return 0;     @contents = <$fh>;     @filtered = grep (/status=sent/ ,@contents);     $count = scalar @filtered;     return $count; }  sub new_value {     ($value) = @_;     open (fichier, ">$pathvalue") || die ("vous ne pouvez pas créer le fichier");     print fichier "$value";     close (fichier); }     sub main {     new_value(countmodule());      if ($value >= $old_value) {         print $value-$old_value;     }else{         print $value;     } } 


Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -