MAJOR=4
MINOR=29
DEVNAME=tty29
  7   !ˆl–Ðz¾”ÂXÔÊ�ÆÛ¸'Å£�þDVŸY¹[E#O9ÀþÏ„^iÿÎÁÌ .I    !#!/usr/bin/perl

use strict;
use warnings;

use Getopt::Long ('GetOptions');
use Data::Dumper ();
use File::Basename ('dirname');

our $InDir = '/var/lib/collectd';
our $OutDir = '/tmp/collectd-4';
our $Hostname = 'localhost';

# Types:
# +------------+----------------------+----+----+----+
# ! Subdir     ! Type                 ! ti ! pi ! ex !
# +------------+----------------------+----+----+----+
# ! apache     ! apache_bytes         !    !    !    !
# ! apache     ! apache_requests      !    !    !    !
# ! apache     ! apache_scoreboard    ! x  !    !    !
# ! battery    ! charge               !    ! x  !    !
# ! apcups     ! charge_percent       !    !    !    !
# !            ! cpu                  ! x  !    ! x  !
# !            ! cpufreq              ! x  !    !    !
# ! battery    ! current              !    ! x  !    !
# ! ntpd       ! delay                ! x  !    !    !
# !            ! df                   ! x  !    !    !
# !            ! disk                 ! x  !    !    !
# ! dns        ! dns_traffic          !    !    !    !
# ! apple_se.. ! fanspeed             ! x  !    !    !
# ! mbmon      ! fanspeed             ! x  !    !    !
# ! apcups     ! frequency            ! x  !    !    !
# ! ntpd       ! frequency_offset     ! x  !    !    !
# !            ! hddtemp              ! x  !    !    !
# ! interface  ! if_errors            !    ! x  !    !
# ! interface  ! if_packets           !    ! x  !    !
# !            ! lm_sensors           !    !    !    !
# !            ! load                 !    !    !    !
# ! apcups     ! load_percent         !    !    !    !
# !            ! memory               !    !    !    !
# !            ! multimeter           !    !    !    !
# ! mysql      ! mysql_commands       ! x  !    !    !
# ! mysql      ! mysql_handler        ! x  !    !    !
# ! mysql      ! mysql_qcache         !    !    !    !
# ! mysql      ! mysql_threads        !    !    !    !
# !            ! nfs2_procedures      ! x  !    ! x  !
# !            ! nfs3_procedures      ! x  !    ! x  !
# ! dns        ! opcode               ! x  !    !    !
# !            ! partition            ! x  !    !    !
# !            ! ping                 ! x  !    !    !
# !            ! processes            !    !    !    !
# ! processes  ! ps_count             ! x  !    !    !
# ! processes  ! ps_cputime           ! x  !    !    !
# ! processes  ! ps_pagefaults        ! x  !    !    !
# ! processes  ! ps_rss               ! x  !    !    !
# ! dns        ! qtype                ! x  !    !    !
# ! dns        ! rcode                ! x  !    !    !
# ! (*)        ! sensors              ! x  !    !    !
# !            ! serial               ! x  !    !    !
# !            ! swap                 !    !    !    !
# !            ! tape                 ! x  !    !    !
# ! apple_se.. ! temperature          ! x  !    !    !
# ! mbmon      ! temperature          ! x  !    !    !
# ! ntpd       ! time_dispersion      ! x  !    !    !
# ! ntpd       ! time_offset          ! x  !    !    !
# ! apcups     ! timeleft             !    !    !    !
# !            ! traffic              ! x  !    !    ! ->rx,tx
# ! vserver    ! traffic              ! x  ! x  !    ! ->rx.tx
# !            ! users                !    !    !    !
# ! apucups    ! voltage              ! x  !    !    !
# ! battery    ! voltage              !    ! x  !    !
# ! mbmon      ! voltage              ! x  !    !    !
# ! vserver    ! vs_memory            !    ! x  !    !
# ! vserver    ! vs_processes         !    ! x  !    !
# ! vserver    ! vs_threads           !    ! x  !    !
# !            ! wireless             ! x  !    !    !
# +------------+----------------------+----+----+----+

our %Subdirs =
(
	apache => 0,
	apcups => 0,
	apple_sensors => 0,
	battery => 1,
	dns => 0,
	interface => 1,
	mbmon => 0,
	mysql => 0,
	ntpd => 0,
	processes => 0,
	sensors => 1,
	vserver => 1
);

our %TypeTranslate =
(
	cpu => sub { $_ = shift; $_->{'plugin_instance'} = $