Advertisement
Guest User

Untitled

a guest
Jan 26th, 2017
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. #!/usr/bin/perl
  2. use Data::Dumper;
  3. use Net::SSH::Perl;
  4.  
  5. $debug=0;
  6. $ip="IP OD ROUTERJA DAJ SEM";
  7. $username="USERNAME DAJ SEM CUJ!";
  8. $password="PASSWORD DAJ SEM";
  9. $hostname="HOSTNAME DAJ SEM";
  10.  
  11. #=======================================================
  12.  
  13. $ENV{HOME} = '/tmp/';
  14.  
  15.  
  16. if ($ARGV[0] && $ARGV[0] eq "config") {
  17. print "host_name $hostname\n";
  18. print "graph_args --base 1000 -l 0 -r --lower-limit 0\n";
  19. print "graph_title DHCP leases\n";
  20. print "graph_vlabel number\n";
  21. print "graph_category network\n";
  22. print "graph_info This graph shows the number of active DHCP leases\n";
  23. print "graph_scale no\n";
  24. print "dhcp.label DHCP Leases\n";
  25.  
  26. exit;
  27. }
  28.  
  29.  
  30.  
  31.  
  32.  
  33. $ssh = Net::SSH::Perl->new($ip) or die $!;
  34. $ssh->login($username, $password) or die $!;
  35. ($stdout,$stderr,$exitcode) = $ssh->cmd("ip dhcp-server lease print without-paging terse where status=\"bound\"");
  36.  
  37. print Dumper($stdout) if $debug;
  38.  
  39. $numberofclients = () = $stdout =~ /status=bound/gi;
  40.  
  41. print "num: $numberofclients\n" if $debug;
  42.  
  43. print "dhcp.value $numberofclients\n";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement