Bulk Clone from Command line

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Bulk Clone from Command line

Post by lmiltchev »

Thanks! Will let you know how it goes!
Please, do. I will keep this topic open for the time being.
Be sure to check out our Knowledgebase for helpful articles and solutions!
peter.zanetti
Posts: 90
Joined: Wed Oct 01, 2014 8:34 am

Re: Bulk Clone from Command line

Post by peter.zanetti »

So we got all the files in the /usr/local/nagiosxi/scripts folder, made the script executable, and tried to execute the command. The error that came back was "/bin/bash^M: bad interpreter: No such file or directory". Any help as to what this means?
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: Bulk Clone from Command line

Post by tgriep »

It looks like the first line of the script is corrupt. Can you delete the first line and modify it to the following?

Code: Select all

#!/bin/bash
Be sure to check out our Knowledgebase for helpful articles and solutions!
peter.zanetti
Posts: 90
Joined: Wed Oct 01, 2014 8:34 am

Re: Bulk Clone from Command line

Post by peter.zanetti »

shell script.PNG
It looks like that is what is already there.
You do not have the required permissions to view the files attached to this post.
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: Bulk Clone from Command line

Post by tgriep »

I think there is a non-printable character there. Try deleting it and re-typing it in.
Be sure to check out our Knowledgebase for helpful articles and solutions!
peter.zanetti
Posts: 90
Joined: Wed Oct 01, 2014 8:34 am

Re: Bulk Clone from Command line

Post by peter.zanetti »

I tried deleting that first line and retyping it. went to run the script again and it came back with the same error: "[root@esu2v236 scripts]# /usr/local/nagiosxi/scripts/cfg-generator.sh
-bash: /usr/local/nagiosxi/scripts/cfg-generator.sh: /bin/bash^M: bad interpreter: No such file or directory"
peter.zanetti
Posts: 90
Joined: Wed Oct 01, 2014 8:34 am

Re: Bulk Clone from Command line

Post by peter.zanetti »

Got the script to run as shown in the code below. However nothing happened in Nagios and the new host was not added. I only had one device on the CSV for testing purposes just to see if we could get it to work.

Code: Select all

[root@esu2v236 scripts]# /usr/local/nagiosxi/scripts/cfg-                                                                                                                     generator.sh
URL: http://localhost/nagiosxi/includes/components/ccm/
CMDLINE
/usr/bin/wget --save-cookies nagiosql.cookies --keep-session-cookies http://loca                                                                                                                     lhost/nagiosxi/includes/components/ccm/ --no-check-certificate --post-data 'subm                                                                                                                     it=Login&hidelog=true&loginSubmitted=true&username=nagiosxi&password=n@gweb' -O                                                                                                                      nagiosql.login--2015-06-10 08:59:44--  http://localhost/nagiosxi/includes/compon                                                                                                                     ents/ccm/
Resolving localhost... ::1, 127.0.0.1
Connecting to localhost|::1|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: “nagiosql.login”

    [ <=>                                   ] 10,379      --.-K/s   in 0.008s

2015-06-10 08:59:44 (1.21 MB/s) - “nagiosql.login” saved [10379]

LOGIN SUCCESSFUL!
IMPORTING CONFIG FILES...URL: http://localhost/nagiosxi/includes/components/ccm/
Array
(
)
SETUID ROOT OK
RESETTING PERMS
URL: http://localhost/nagiosxi/includes/components/ccm/
CMDLINE
/usr/bin/wget --save-cookies nagiosql.cookies --keep-session-cookies http://loca                                                                                                                     lhost/nagiosxi/includes/components/ccm/ --no-check-certificate --post-data 'subm                                                                                                                     it=Login&hidelog=true&loginSubmitted=true&username=nagiosxi&password=n@gweb' -O                                                                                                                      nagiosql.login--2015-06-10 08:59:45--  http://localhost/nagiosxi/includes/compon                                                                                                                     ents/ccm/
Resolving localhost... ::1, 127.0.0.1
Connecting to localhost|::1|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: “nagiosql.login”

    [ <=>                                   ] 10,379      --.-K/s   in 0.008s

2015-06-10 08:59:45 (1.21 MB/s) - “nagiosql.login” saved [10379]

LOGIN SUCCESSFUL!
URL: http://localhost/nagiosxi/includes/components/ccm/
CMDLINE:
/usr/bin/wget --load-cookies=nagiosql.cookies http://localhost/nagiosxi/includes                                                                                                                     /components/ccm/ --no-check-certificate --post-data 'cmd=apply&type=writeConfig'                                                                                                                      -O nagiosql.export.monitoring
--2015-06-10 08:59:45--  http://localhost/nagiosxi/includes/components/ccm/
Resolving localhost... ::1, 127.0.0.1
Connecting to localhost|::1|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: “nagiosql.export.monitoring”

    [  <=>                                  ] 13,233      45.1K/s   in 0.3s

2015-06-10 08:59:45 (45.1 KB/s) - “nagiosql.export.monitoring” saved [13233]

WRITE CONFIGS SUCCESSFUL!
OUTPUT:
Nagios Core 4.0.8
Copyright (c) 2009-present Nagios Core Development Team and Community Contributo                                                                                                                     rs
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 08-12-2014
License: GPL

Website: http://www.nagios.org
Reading configuration data...
   Read main config file okay...
   Read object config files okay...

Running pre-flight check on configuration data...

Checking objects...
Warning: Service 'DisplayAuditWCF.svc' on host 'BL001ASRET01' has no default con                                                                                                                     tacts or contactgroups defined!
        Checked 19 services.
Warning: Host 'BL001ASRET01' has no default contacts or contactgroups defined!
        Checked 4 hosts.
        Checked 4 host groups.
        Checked 0 service groups.
        Checked 10 contacts.
        Checked 2 contact groups.
        Checked 119 commands.
        Checked 16 time periods.
        Checked 0 host escalations.
        Checked 0 service escalations.
Checking for circular paths...
        Checked 4 hosts
        Checked 0 service dependencies
        Checked 0 host dependencies
        Checked 16 timeperiods
Checking global event handlers...
Checking obsessive compulsive processor commands...
Checking misc settings...

Total Warnings: 2
Total Errors:   0

Things look okay - No serious problems were detected during the pre-flight check
RET: 0
Running configuration check...
Stopping nagios: done.
Starting nagios: done.
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Bulk Clone from Command line

Post by lmiltchev »

Can you upload the csv file, base-template.cfg and cfg-generator.sh that you placed in the "/usr/local/nagiosxi/scripts/" directory?
We will try to recreate the issue in-house. Please, remove sensitive info. Thanks!
Be sure to check out our Knowledgebase for helpful articles and solutions!
peter.zanetti
Posts: 90
Joined: Wed Oct 01, 2014 8:34 am

Re: Bulk Clone from Command line

Post by peter.zanetti »

Here are the files you requested. I look forward to hearing back from you.
automation files.zip
You do not have the required permissions to view the files attached to this post.
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Bulk Clone from Command line

Post by lmiltchev »

Hm-m-m, for some reason you have spaces in the "new-hosts.csv" file.

Code: Select all

K4283696, K4283696, Test, LabDISDevices
Remove the spaces:

Code: Select all

K4283696,K4283696,Test,LabDISDevices
then rerun the script:

Code: Select all

./cfg-generator.sh
Edit: When I tested it - it worked for me after removing the spaces. If this, however doesn't work for you, run the script in a debug mode and show us the output:

Code: Select all

bash -x cfg-generator.sh
Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked