4 $hostname = 'localhost'; # Host that serves the mSQL Database
5 $dbname = 'snmp'; # mySQL Database name
9 print "$0 [-H host] [-u user] [-p password] [-v] [-h] [-n] [-g groupname] [-m machinename] TOKEN VALUE\n";
13 while ($#ARGV > -1 && $ARGV[0] =~ /^-/) {
16 $hostname = shift if (/-H/);
17 $user = shift if (/-u/);
18 $pass = shift if (/-p/);
19 $group = shift if (/-g/);
20 $machine = shift if (/-m/);
21 $verbose = 1 if (/-v/);
25 ( $dbh = DBI->connect("DBI:mysql:database=$dbname;host=$hostname", $user, $pass))
26 or die "\tConnect not ok: $DBI::errstr\n";
28 if (defined($machine)) {
33 $group = "default" if (!defined($group));
38 while(defined($value)) {
39 if (DO("select * from $table where lookup = '$group' and varcol = '$token'") eq "0E0") {
40 DO("insert into $table(lookup, varcol, valcol) values('$group', '$token', '$value')");
42 DO("update $table set valcol = '$value' where lookup = '$group' and varcol = '$token'");
52 print $cmd,"\n" if ($verbose);
53 my $ret = $dbh->do($cmd) if ($doit);
54 print " returned: $ret\n" if ($verbose);
56 print "db error ($ret): $DBI::errstr\n";