| 1 | 85 | simandl | <?php |
| 2 | | | |
| 3 | | | $cacti_root = "/var/www/docs/cacti"; |
| 4 | | | |
| 5 | | | @include_once($cacti_root."/include/global.php"); |
| 6 | | | @include_once($cacti_root."/include/config.php"); |
| 7 | | | |
| 8 | | | $target_format = ""; |
| 9 | | | $infourl_format = ""; |
| 10 | | | $overlib_format = ""; |
| 11 | | | |
| 12 | | | # |
| 13 | | | # change these three and then run this. |
| 14 | | | # run the result through cacti-integrate to fill in the TARGETS etc. |
| 15 | | | # Change the |
| 16 | | | |
| 17 | | | $switchname = "sw1"; |
| 18 | | | $nports = 48; |
| 19 | | | $cacti_host_id = 17; |
| 20 | | | $interfacepattern = "Gi0/%d"; |
| 21 | | | |
| 22 | | | |
| 23 | | | printf("# generated by bristle.php - %d ports\n# First, the actual switch node. Give this an ICON\nNODE %s\n\tPOSITION 400 400\n\n",$nports, $switchname); |
| 24 | | | |
| 25 | | | for($n=1; $n<=$nports; $n++) |
| 26 | | | { |
| 27 | | | $nodename = sprintf("%s_p%d",$switchname,$n); |
| 28 | | | $linkname = sprintf("%s_%s",$switchname,$nodename); |
| 29 | | | |
| 30 | | | $halfway = $nports/2; // the midpoint of a side |
| 31 | | | $quarter = $halfway/2; // the midpoint of a side |
| 32 | | | $voffset = 40; // the length of the bristle |
| 33 | | | $voffset2 = 13; // the inside offset of the bristle |
| 34 | | | |
| 35 | | | if($n > $halfway) |
| 36 | | | { |
| 37 | | | $offset = ($n - 24 - 1 - $quarter)*8; |
| 38 | | | } |
| 39 | | | else |
| 40 | | | { |
| 41 | | | // The first 24 ports grow up instead of down |
| 42 | | | $offset = ($n - 1 - $quarter)*8; |
| 43 | | | $voffset = -$voffset; |
| 44 | | | $voffset2 = -$voffset2; |
| 45 | | | } |
| 46 | | | |
| 47 | | | |
| 48 | | | $target = "tgt?"; |
| 49 | | | $infourl = "info?"; |
| 50 | | | $overliburl = "over?"; |
| 51 | | | |
| 52 | | | printf("NODE %s\n\tPOSITION %s %d %d\n\tSET cacti_id %d\n\n", |
| 53 | | | $nodename,$switchname,$offset,$voffset, $cacti_host_id); |
| 54 | | | |
| 55 | | | printf("LINK %s\n\tNODES %s:%d:%d %s\n\tBWLABEL none\n\tWIDTH 2\n\tARROWSTYLE compact\n\tOUTLINECOLOR none\n", $linkname, $switchname, $offset, $voffset2, $nodename |
| 56 | | | ); |
| 57 | | | |
| 58 | | | $interfacename = sprintf($interfacepattern,$n); |
| 59 | | | |
| 60 | | | print "\tSET out_interface $interfacename"; |
| 61 | | | |
| 62 | | | # printf("\tINFOURL %s\n\tOVERLIBGRAPH %s\n\tTARGET %s\n", $infourl, $overliburl, $target ); |
| 63 | | | print "\n\n"; |
| 64 | | | |
| 65 | | | } |
| 66 | | | print "# Now run this output through cacti-integrate.php to add all the INFOURL and TARGET lines"; |
| 67 | | | |
| 68 | | | ?> |