Archive for June, 2006

Adding a large number of devices to Cacti

Wednesday, June 28th, 2006

There is a very nice open source snmp graphing and monitoring package avaiable called cacti. I have used it for almost a year now and have been very pleased with its functionality and ease of use.

Recently at work I had the need to graph a large number (300) of network devices and a handful of Linux servers. Being the sort of guy that would rather write scripts than manually enter 300 devices via the cacti web interface, I cobbled together some perl and php code. I had a list of network devices in a CSV file.

The format of the file is:

ID,City,State,IP Address.

If you use the scripts below you will need to edit them to fit your own device data. They are provided for illustration purposes and will most likely not work for you “out of the box”.

Update See this thread for more advanced scripts.

Process to add hosts and create graphs for each

  1. Branches.CSV branches.csv
  2. Check branches.csv for empty IP address fields and remove
  3. branches.csv > branches.sql
  4. branches.sql ==> DB
  5. branches.csv > host_graph.sql
  6. host_graph.sql ==> DB
  7. branches.csv > host_snmp_query.sql
  8. host_snmp_query.sql ==> DB
  9. foreach host_id do php run_data_query.php $host_id
  10. foreach host_id do php run_host_new_graphs.php $host_id
  11. Clear Poller Cache (php rebuild_poller_cache.php)

Process to add each host to proper state in graph tree

  1. create alphabetical flat file of state abbreviations, states
  2. states > branches-states.sql
  3. branches-states.sql ==> DB
  4. branches.csv > graph_tree_items.sql

Autocreate thresholds

  • foreach host_id do php run_autocreate.php $host_id




Linux Quiz #002

Wednesday, June 28th, 2006

The Patch Command (submit answer)

Create a patch file called helloworld.patch suitable for use with the
patch command to fix a typo in helloworld.c. Also, give the command line necessary to apply the patch.

To test the syntax of the .c file use: gcc -o helloworld helloworld.c


$%#@&!! DOS

Tuesday, June 27th, 2006

If someday you should find yourself launching your head with much force against a masonry wall, wailing to all that will listen of the futility of expecting kickstart to work as designed…

Check your kickstart file for DOS line endings. Trust me. They break stuff.


Linux Quiz #001

Saturday, June 24th, 2006

This is the first in a series of Linux Quizzes. Some quizzes will be very basic while some will be quite tough even for the graybeards. I will post my version of the correct answer after a few days.

I/O Redirection (submit answer)

An imaginary bash shell script,, outputs data on standard output and diagnostic messages on standard error. What command line would you use to run and have the data output in file data.out and the diagnostic
output in file diag.out?

For extra credit, submit a bash script that creates output as described.