Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use tab between cols
- cat hosts.csv
- reporting-cucm 127.0.0.1 report-host dummy
- reporting-fax 127.0.0.1 report-host dummy
- vm-rz1-001 cust1-uk-lon-001 10.10.10.11 generic-host linux
- vm-rz1-002 cust1-de-ber-001 10.10.10.12 generic-host windows
- vm-rz2-001 cust1-uk-lon-001 10.10.10.21 generic-host linux
- vm-rz2-002 cust1-de-ber-001 10.10.10.22 generic-host windows
- cat make_host.pl
- #! /usr/bin/perl
- #by shafiz
- #use strict;
- #use warnings;
- #use Text::CSV;
- my($version) = "1.0";
- my($file) = "/etc/icinga2/scripts/hosts.csv";
- my @hosts = `cat $file`;
- foreach( @hosts )
- {
- chomp;
- my @array = split("\t", $_);
- printf "object Host \"$array[0]\"\{\n";
- printf " import \"$array[3]\"\n";
- printf " address = \"$array[2]\"\n";
- printf " vars.os = \"$array[4]\"\n";
- printf " vars.urix = \"$array[1]\"\n";
- printf " \}\n";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement