Guest User

Untitled

a guest
Dec 1st, 2018
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. #!/usr/bin/env perl
  2.  
  3. use strict;
  4. use warnings;
  5. use DBI;
  6.  
  7. my $data_source = "DBI:mysql:zabbix";
  8. my $username = "";
  9. my $password = "";
  10.  
  11. my $graph_name = "DiskUsage";
  12. my @recs = ();
  13.  
  14. eval {
  15. my $dbh = DBI->connect($data_source, $username, $password,
  16. {RaiseError => 1, PrintError => 0});
  17.  
  18. my $sql = "SELECT graphid FROM graphs WHERE name = ?";
  19. my $sth = $dbh->prepare($sql);
  20. $sth->execute($graph_name);
  21.  
  22. while (my $rec = $sth->fetchrow_arrayref) {
  23. push(@recs, $rec->[0]);
  24. }
  25.  
  26. $sth->finish;
  27. $dbh->disconnect;
  28. };
  29.  
  30. die "Error : $@\n" if ($@);
  31. print join(", ", @recs), "\n";
Add Comment
Please, Sign In to add comment