Ad Widget

Collapse

Monitoring BackupPC

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • casshan
    Junior Member
    • Mar 2009
    • 13

    #1

    Monitoring BackupPC

    I use have a custom script that runs on the host using the system.run that pushes data the zabbix server using zabbix_sender. Attached is the perl script and xml file. Someone asked about it on the BackupPC mailing list, so I thought I would post it here. Save the perl script to /etc/zabbix/scripts/ or else change the system.run command in the template to where ever you save the file to. You might also need to change this line inside the perl script to point to the location of BackupPC lib directory:

    use lib "/usr/local/BackupPC/lib";

    You need to have sudo configured so this script can be run has backuppc, I have this inside my /etc/sudoers file:

    zabbix ALL = (ALL) NOPASSWD: /etc/zabbix/scripts/*

    You want to make sure all scripts and the folder are owned by root and permissions are configured for 755 or it could be a security issue. If you don't want to do that, you could also run the job with cron every 5/10 minutes.
    Attached Files
    Last edited by casshan; 10-06-2010, 01:13.
  • GooFy03
    Junior Member
    • Dec 2009
    • 7

    #2
    ! cant get it to work

    zabbix@supervision:~$ /usr/local/sbin/zabbix_agentd -c /etc/zabbix/zabbix_agentd.conf -t system.run["sudo -u backuppc /etc/zabbix/scripts/backuppc_info.pl"]
    system.run[localhost:sudo -u backuppc /etc/zabbix/scripts/backuppc_info.pl] [m|ZBX_NOTSUPPORTED]
    zabbix@supervision:~$ sudo -u backuppc /etc/zabbix/scripts/backuppc_info.pl

    We trust you have received the usual lecture from the local System
    Administrator. It usually boils down to these three things:

    #1) Respect the privacy of others.
    #2) Think before you type.
    #3) With great power comes great responsibility.

    [sudo] password for zabbix:
    Sorry, user zabbix is not allowed to execute '/etc/zabbix/scripts/backuppc_info.pl' as backuppc on supervision.(hide).

    Any idea please ?

    Comment

    • casshan
      Junior Member
      • Mar 2009
      • 13

      #3
      Did you add
      Code:
      zabbix ALL = (ALL) NOPASSWD: /etc/zabbix/scripts/*
      to /etc/sudoers?

      Comment

      • GooFy03
        Junior Member
        • Dec 2009
        • 7

        #4
        yes i'm not completly blind

        Comment

        • casshan
          Junior Member
          • Mar 2009
          • 13

          #5
          Try sudoing to the backuppc user and see if you can run the command. Check the permissions on the /etc/zabbix and /etc/zabbix/scripts folder, the backuppc user might not have permissions to read the script file

          Comment

          • GooFy03
            Junior Member
            • Dec 2009
            • 7

            #6
            Seems to be ok when i "su backuppc"

            Comment

            • casshan
              Junior Member
              • Mar 2009
              • 13

              #7
              Here is the contents of my sudoers file:
              Code:
              backup ~ # cat /etc/sudoers | grep -v '^#' | grep -v '^$'
              root    ALL=(ALL) ALL
              zabbix ALL = (ALL) NOPASSWD: /etc/zabbix/scripts/*
              And my sudo info:
              Code:
              backup ~ # sudo -V
              Sudo version 1.7.2p4
              
              Sudoers path: /etc/sudoers
              Authentication methods: 'pam'
              Syslog facility if syslog is being used for logging: local2
              Syslog priority to use when user authenticates successfully: notice
              Syslog priority to use when user authenticates unsuccessfully: alert
              Send mail if the user is not in sudoers
              Lecture user the first time they run sudo
              Require users to authenticate by default
              Root may run sudo
              Allow some information gathering to give useful error messages
              Visudo will honor the EDITOR environment variable
              Set the LOGNAME and USER environment variables
              Length at which to wrap log file lines (0 for no wrap): 80
              Authentication timestamp timeout: 5 minutes
              Password prompt timeout: 5 minutes
              Number of tries to enter a password: 3
              Umask to use or 0777 to use user's: 022
              Path to mail program: /usr/sbin/sendmail
              Flags for mail program: -t
              Address to send mail to: root
              Subject line for mail messages: *** SECURITY information for %h ***
              Incorrect password message: Sorry, try again.
              Path to authentication timestamp dir: /var/run/sudo
              Default password prompt: Password:
              Default user to run commands as: root
              Value to override user's $PATH with: /bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/opt/bin
              Path to the editor for use by visudo: /usr/libexec/gentoo-editor
              When to require a password for 'list' pseudocommand: any
              When to require a password for 'verify' pseudocommand: all
              File containing dummy exec functions: /usr/libexec/sudo_noexec.so
              File descriptors >= 3 will be closed before executing a command
              Reset the environment to a default set of variables
              Environment variables to check for sanity:
                      TERM
                      LINGUAS
                      LC_*
                      LANGUAGE
                      LANG
                      COLORTERM
              Environment variables to remove:
                      RUBYOPT
                      RUBYLIB
                      PYTHONINSPECT
                      PYTHONPATH
                      PYTHONHOME
                      TMPPREFIX
                      ZDOTDIR
                      READNULLCMD
                      NULLCMD
                      FPATH
                      PERL5DB
                      PERL5OPT
                      PERL5LIB
                      PERLLIB
                      PERLIO_DEBUG
                      JAVA_TOOL_OPTIONS
                      SHELLOPTS
                      GLOBIGNORE
                      PS4
                      BASH_ENV
                      ENV
                      TERMCAP
                      TERMPATH
                      TERMINFO_DIRS
                      TERMINFO
                      _RLD*
                      LD_*
                      PATH_LOCALE
                      NLSPATH
                      HOSTALIASES
                      RES_OPTIONS
                      LOCALDOMAIN
                      CDPATH
                      IFS
                      PERLIO_DEBUG
                      FPATH
                      NULLCMD
                      READNULLCMD
                      GLOBIGNORE
                      PYTHONHOME
                      PYTHONPATH
                      PYTHONINSPECT
                      RUBYLIB
                      RUBYOPT
                      ZDOTDIR
              Environment variables to preserve:
                      XAUTHORIZATION
                      XAUTHORITY
                      TZ
                      PS2
                      PS1
                      PATH
                      MAIL
                      LS_COLORS
                      KRB5CCNAME
                      HOSTNAME
                      HOME
                      DISPLAY
                      COLORS
              Locale to use while parsing sudoers: C
              File level permissions:
              Code:
              backup ~ # ls -l /etc/ | grep zabbix
              drwxr-xr-x 3 zabbix   zabbix     103 Apr 11 23:44 zabbix
              backup ~ # ls -l /etc/zabbix/
              total 8
              drwxr-xr-x 2 root root   72 May  4 01:01 scripts
              -rw-r----- 1 zabbix zabbix 1121 Apr 11 23:44 zabbix_agent.conf
              -rwxr-xr-x 1 zabbix zabbix 2419 Feb 22 00:57 zabbix_agentd.conf
              backup ~ # ls -l /etc/zabbix/scripts/
              total 16
              -rwxr-xr-x 1 root   root   9554 May  4 20:18 backuppc_info.pl
              -rwxr-xr-x 1 root   root   1444 May  4 01:01 find_deleted_process.pl
              lrwxrwxrwx 1 zabbix zabbix   21 Feb 22 00:57 tw_cli -> /usr/local/bin/tw_cli
              backup ~ #
              Last edited by casshan; 01-06-2010, 02:56.

              Comment

              • casshan
                Junior Member
                • Mar 2009
                • 13

                #8
                I'm currently running Gentoo if that matters as well

                Comment

                • GooFy03
                  Junior Member
                  • Dec 2009
                  • 7

                  #9
                  I have completly reinstall debian and zabbix and same problem

                  Comment

                  • MrKen
                    Senior Member
                    • Oct 2008
                    • 652

                    #10
                    @GooFy03,

                    Try with a % before zabbix

                    %zabbix ALL = (ALL) NOPASSWD: /etc/zabbix/scripts/*
                    Disclaimer: All of the above is pure speculation.

                    Comment

                    • GooFy03
                      Junior Member
                      • Dec 2009
                      • 7

                      #11
                      Thanks MrKEN it work now …

                      And Thanks casshan for your time and for your wonderfull script …

                      Comment

                      • GooFy03
                        Junior Member
                        • Dec 2009
                        • 7

                        #12
                        Doh i speak too quickly :

                        Illegal division by zero at /etc/zabbix/scripts/backuppc_info.pl line 129.

                        but :
                        /opt/zabbix/bin/zabbix_get -s 127.0.0.1 -k "system.run[sudo -u backuppc /etc/zabbix/scripts/backuppc_info.pl]"

                        work i gone hang myself

                        Comment

                        • casshan
                          Junior Member
                          • Mar 2009
                          • 13

                          #13
                          The problem is $fullCnt2 is 0 which means you don't have any full backups which is kinda weird. I can update it check for a 0 value.


                          Change:
                          Code:
                          $Val{hostsAvgFullSpeed} = ($total_speed_full / $fullCnt2);
                          $Val{hostsAvgIncrSpeed} = ($total_speed_incr / $incrCnt2);
                          to:
                          Code:
                                  if ($fullCnt2 > 0 )
                                  { $Val{hostsAvgFullSpeed} = ($total_speed_full / $fullCnt2); }
                                  if ($incrCnt2 > 0 )
                                  { $Val{hostsAvgIncrSpeed} = ($total_speed_incr / $incrCnt2); }
                          I also updated the script at the start of the post with this change
                          Last edited by casshan; 10-06-2010, 01:13.

                          Comment

                          • NiklasG
                            Junior Member
                            • Apr 2011
                            • 2

                            #14
                            Full Age Days

                            I have modified the script and template. If full backup is older than seven days Zabbix sends message.
                            Perhaps not the best solution. If you find it useful feel free to use it
                            Attached Files

                            Comment

                            • casshan
                              Junior Member
                              • Mar 2009
                              • 13

                              #15
                              I have also made some updates since the last time I posted. I had a client who only wanted backups of a server weekly. I changed the script so that it checks the FullPeriod and IncrPeriod and lets you know if there has not been a backup outside of that period.
                              Attached Files

                              Comment

                              Working...