User permissions

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: User permissions

Post by abrist »

The script you are looking for is:

Code: Select all

/usr/local/nagiosxi/scripts/reconfigure_nagios.sh
This script fires off a whole bunch of stuff, and it is the one that is run when "apply configuration" is clicked.
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
User avatar
BanditBBS
Posts: 2474
Joined: Tue May 31, 2011 12:57 pm
Location: Scio, OH
Contact:

Re: User permissions

Post by BanditBBS »

Small update. Everything has been tested. I am still waiting on the applications team to put the export of the data on a server so we can schedule it to run, but I have my two scripts fully tested. Hopefully they get their end done soon so I can start using this in production. I added in slight error handling in the perl script. It will die if one of the input files are not found. If that happens, that means either the applications team script failed or my ftp script failed. We'll be using Control-M to schedule the jobs. The applications team's job will run at 8am daily and then my two jobs will run. I'll add one more update to this post after it is in production and has been used for a couple weeks with a full write-up.

FTP script to grab file: (ftpscript.sh)

Code: Select all

HOST=xxxxxxxx  #This is the FTP servers host or IP address.
USER=xxxxxx         #This is the FTP user that has access to the server.
PASS=xxxxxx         #This is the password for the FTP user.

ftp -inv $HOST << EOF

user $USER $PASS

cd /nagiosftp

get primaryOnCall.txt
get secondaryOnCall.txt

delete primaryOnCall.txt
delete secondaryOnCall.txt

bye
EOF
Perl script to create static config file:(oncall.pl)

Code: Select all

#!/usr/bin/perl

#Process primary on-call file
open (INFILE, 'primaryOnCall.txt') or die $1;
while (<INFILE>) {
        chomp;
        ($group, $alias, $id) = split(",");
        if ($alias ne '') {
        open (OUTFILE, '>/usr/local/nagios/etc/static/'  . $alias . '_oncall_pri.cfg');
                print OUTFILE "define contactgroup{\n";
                print OUTFILE "contactgroup_name $alias" . "_oncall_pri\n";
                print OUTFILE "alias $group\n";
                print OUTFILE "members $id\n";
                print OUTFILE "}";
        close (OUTFILE);
        }
        }
close (INFILE);

#Process secondary on-call file
open (INFILE, 'secondaryOnCall.txt') or die $1;
while (<INFILE>) {
        chomp;
        ($group, $alias, $id) = split(",");
        if ($alias ne '') {
        open (OUTFILE, '>/usr/local/nagios/etc/static/'  . $alias . '_oncall_sec.cfg');
                print OUTFILE "define contactgroup{\n";
                print OUTFILE "contactgroup_name $alias" . "_oncall_sec\n";
                print OUTFILE "alias $group\n";
                print OUTFILE "members $id\n";
                print OUTFILE "}";
        close (OUTFILE);
        }
        }
close (INFILE);

#Chane ownership and permissions of config files
system ("sudo /bin/chown apache:nagios /usr/local/nagios/etc/static/*.cfg");
system ("sudo /bin/chmod 775 /usr/local/nagios/etc/static/*.cfg");

#Delete data files
system ("rm primaryOnCall.txt");
system ("rm secondaryOnCall.txt");

#Restart Nagios
sudo su -l nagios -c 'cd /usr/local/nagiosxi/scripts/ && ./reconfigure_nagios.sh'

#Exit clean
exit 0;
2 of XI5.6.14 Prod/DR/DEV - Nagios LogServer 2 Nodes
See my projects on the Exchange at BanditBBS - Also check out my Nagios stuff on my personal page at Bandit's Home and at github
slansing
Posts: 7698
Joined: Mon Apr 23, 2012 4:28 pm
Location: Travelling through time and space...

Re: User permissions

Post by slansing »

Great, let us know :).
User avatar
BanditBBS
Posts: 2474
Joined: Tue May 31, 2011 12:57 pm
Location: Scio, OH
Contact:

Re: User permissions

Post by BanditBBS »

FYI - We are live with this in production and seems to be working great. Anyone else that needs on-call rotation handling and have any question of what I explained, feel free to message me and ask!

Next I need to build a XI Component to handle it :)
2 of XI5.6.14 Prod/DR/DEV - Nagios LogServer 2 Nodes
See my projects on the Exchange at BanditBBS - Also check out my Nagios stuff on my personal page at Bandit's Home and at github
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: User permissions

Post by scottwilkerson »

Awesome! Thanks for sharing!
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
Locked