Page 2 of 4

Re: Bulk Clone from Command line

Posted: Thu May 28, 2015 10:25 am
by lmiltchev
Thanks! Will let you know how it goes!
Please, do. I will keep this topic open for the time being.

Re: Bulk Clone from Command line

Posted: Tue Jun 09, 2015 2:09 pm
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?

Re: Bulk Clone from Command line

Posted: Tue Jun 09, 2015 2:14 pm
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

Re: Bulk Clone from Command line

Posted: Tue Jun 09, 2015 2:22 pm
by peter.zanetti
shell script.PNG
It looks like that is what is already there.

Re: Bulk Clone from Command line

Posted: Tue Jun 09, 2015 2:54 pm
by tgriep
I think there is a non-printable character there. Try deleting it and re-typing it in.

Re: Bulk Clone from Command line

Posted: Wed Jun 10, 2015 6:58 am
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"

Re: Bulk Clone from Command line

Posted: Wed Jun 10, 2015 8:16 am
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.

Re: Bulk Clone from Command line

Posted: Wed Jun 10, 2015 9:27 am
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!

Re: Bulk Clone from Command line

Posted: Wed Jun 10, 2015 10:03 am
by peter.zanetti
Here are the files you requested. I look forward to hearing back from you.
automation files.zip

Re: Bulk Clone from Command line

Posted: Wed Jun 10, 2015 10:49 am
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