print_cacti_create.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. ##### unknown mac clean ############
  19. my $db_sql = "Select device_name,ip,description,snmp_version,community from devices";
  20. $dbh->do("set character set utf8");
  21. $dbh->do("set names utf8");
  22. my $db = $dbh->prepare($db_sql);
  23. $db->execute;
  24. my $db_list=$db->fetchall_arrayref();
  25. $db->finish;
  26. foreach my $row (@$db_list) {
  27. my ($device_name,$ip,$description,$snmp_version,$community)=@$row;
  28. next if (!$ip);
  29. my $notes='';
  30. if ($description) { $notes="--notes='".$description."'"; }
  31. print "php add_device.php --description='".$device_name."' $notes --ip='".$ip."' --template=2 --site=1 --version=$snmp_version --community='".$community."'\n";
  32. }
  33. #add_graphs.php --graph-type=ds --graph-template-id=2 --host-id=[ID]
  34. exit 0;