print_cacti_hosts.pl 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #!/usr/bin/perl
  2. #
  3. # Copyright (C) Roman Dmitiriev, rnd@rajven.ru
  4. #
  5. use utf8;
  6. use warnings;
  7. use Encode;
  8. use open qw(:std :encoding(UTF-8));
  9. no warnings 'utf8';
  10. use FindBin '$Bin';
  11. use lib "/opt/Eye/scripts";
  12. use strict;
  13. use DBI;
  14. use Date::Parse;
  15. use eyelib::config;
  16. use eyelib::database;
  17. use eyelib::common;
  18. use eyelib::logconfig;
  19. ##### unknown mac clean ############
  20. my $db_sql = "Select device_name,ip,description,snmp_version,community from devices";
  21. $dbh->do("set character set utf8");
  22. $dbh->do("set names utf8");
  23. my $db = $dbh->prepare($db_sql);
  24. $db->execute;
  25. my $db_list=$db->fetchall_arrayref();
  26. $db->finish;
  27. foreach my $row (@$db_list) {
  28. my ($device_name,$ip,$description,$snmp_version,$community)=@$row;
  29. next if (!$ip);
  30. my $notes='';
  31. if ($description) { $notes="--notes='".$description."'"; }
  32. print "php add_device.php --description='".$device_name."' $notes --ip='".$ip."' --template=2 --site=1 --version=$snmp_version --community='".$community."'\n";
  33. }
  34. #add_graphs.php --graph-type=ds --graph-template-id=2 --host-id=[ID]
  35. exit 0;