Skip to content

Instantly share code, notes, and snippets.

@riywo
Created June 18, 2013 20:42
Show Gist options
  • Save riywo/5809166 to your computer and use it in GitHub Desktop.
Save riywo/5809166 to your computer and use it in GitHub Desktop.
sub check_sudo {
my @commands = (
'/bin/netstat',
);
my @unexecutable = grep {
system("sudo -l -U user $_ > /dev/null 2>&1") != 0;
} @commands;
message_for_sudo(@unexecutable);
}
sub message_for_sudo {
my @commands = @_;
return if scalar(@commands) == 0;
print "Please add lines below to /etc/sudoers or /etc/sudoers.d\n\n";
print "======================================================\n";
print "zabbix ALL=(root) NOPASSWD: $_\n" for (@commands);
print "======================================================\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment