Skip to content

Instantly share code, notes, and snippets.

@ysaotome
Created May 6, 2012 10:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ysaotome/2621567 to your computer and use it in GitHub Desktop.
Save ysaotome/2621567 to your computer and use it in GitHub Desktop.
generate graphviz dot file for NiftyCloud Firewall map
#!/usr/bin/awk -f
BEGIN {
FS="##";
print "digraph G {";
print "\t\"0.0.0.0/0\" [label = \"インターネット\"];";
}
$7 ~ /CIDR|IP|GRPNAME/ {
src = $8;
}
/^PERMISSION/ {
dst = $2;
pair = sprintf("\"%s\" -> \"%s\"", src, dst);
label = $3":"$4":"$5;
if (grants[pair]) {
grants[pair] = grants[pair]" "label;
} else {
grants[pair] = label;
}
}
END{
for (pair in grants) {
label = grants[pair];
printf("\t%s [label = \"%s\"]\n", pair, label);
}
print "}"
}
@ysaotome
Copy link
Author

ysaotome commented May 6, 2012

example)

% nifty-describe-security-groups --show-empty-fields --delimiter "##" | \
% ./niftycloud-fw-visualization.awk | \
% dot -Tpng > fw.png

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment