Export current perfdata to csv/excel

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
User avatar
BanditBBS
Posts: 2474
Joined: Tue May 31, 2011 12:57 pm
Location: Scio, OH
Contact:

Export current perfdata to csv/excel

Post by BanditBBS »

Any method to export current perf data into a spreadsheet?

For example, one of my disk checks is replyign with this:

Code: Select all

DISK WARNING - free space: /ut1002 98 GB (17% inode=17%); /un1001 18 GB (18% inode=18%); /un1002 17 GB (17% inode=17%);| /=1GB;0;0;0;1 /tmp=1GB;7;8;0;9 /usr=5GB;11;12;0;14 /var=8GB;11;12;0;14 /boot=0GB;0;0;0;0 /dev/shm=0GB;49;55;0;62 /interface=60GB;76;86;0;96 /ua1002=90GB;96;108;0;120 /ua1001=62GB;88;99;0;110 /backupnew=0GB;1167;1313;0;1459 /us1001=38GB;39;44;0;49 /ur1001=218GB;560;630;0;700 /ut1002=451GB;440;495;0;550 /un1001=81GB;79;89;0;99 /un1002=82GB;79;89;0;99 /uc1001=0GB;3;3;0;4 /uf1001=316GB;800;900;0;1000 /ud1007=672GB;720;810;0;900 /ud1008=590GB;720;810;0;900 /ud1010=325GB;720;810;0;900 /ud1011=610GB;720;810;0;900 /ud1012=515GB;720;810;0;900 /backup=0GB;629;708;0;787
We'd like to get all that data into a spreadsheet so we can play with the numbers, any method to do that?
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
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Export current perfdata to csv/excel

Post by abrist »

Echoing that string through a a series of seds would give you a csv:

Code: Select all

echo "<string>" | sed 's/.*|//g' | sed 's/ /\n/g' | sed 's/=/,/g' | sed 's/;/,/g'
Outputs:

Code: Select all

/,1GB,0,0,0,1
/tmp,1GB,7,8,0,9
/usr,5GB,11,12,0,14
/var,8GB,11,12,0,14
/boot,0GB,0,0,0,0
/dev/shm,0GB,49,55,0,62
/interface,60GB,76,86,0,96
/ua1002,90GB,96,108,0,120
/ua1001,62GB,88,99,0,110
/backupnew,0GB,1167,1313,0,1459
/us1001,38GB,39,44,0,49
/ur1001,218GB,560,630,0,700
/ut1002,451GB,440,495,0,550
/un1001,81GB,79,89,0,99
/un1002,82GB,79,89,0,99
/uc1001,0GB,3,3,0,4
/uf1001,316GB,800,900,0,1000
/ud1007,672GB,720,810,0,900
/ud1008,590GB,720,810,0,900
/ud1010,325GB,720,810,0,900
/ud1011,610GB,720,810,0,900
/ud1012,515GB,720,810,0,900
/backup,0GB,629,708,0,787
But I would presume you are looking for a solution in the ui. I wonder if the actions component could do this.
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
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

Re: Export current perfdata to csv/excel

Post by Box293 »

Have a look at my performance data tool, it displays the data from RRDs into a table.

http://exchange.nagios.org/directory/Ad ... ol/details
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
BanditBBS
Posts: 2474
Joined: Tue May 31, 2011 12:57 pm
Location: Scio, OH
Contact:

Re: Export current perfdata to csv/excel

Post by BanditBBS »

Andy,

Is there a variable I can use inthe actions component to use the most recent perfdata?

Box,
I like that, definitely keeping it installed, but won't work for this project.
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
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Export current perfdata to csv/excel

Post by abrist »

BanditBBS wrote:Is there a variable I can use in the actions component to use the most recent perfdata?
Yep. For hosts: %hostperfdata%
Services: %serviceperfdata%
So you could pass these to a script and then run the seds on the string and then do whatever you want with the string.
Check out the actions component documentation:
http://assets.nagios.com/downloads/nagi ... ponent.pdf
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: Export current perfdata to csv/excel

Post by BanditBBS »

Prepare for ugliness beyond comparison...
.
.
.
.
You have been warned...
.

Code: Select all

#! /bin/bash
cd /app01/perfdata
mkdir /tmp/disk
ls -ldm1 $1* >> /tmp/disk/folders.txt
while read line
do
        if [ -f /app01/perfdata/$line/Check_Disk.xml ]; then
                temp=$(cat /app01/perfdata/$line/Check_Disk.xml |grep NAGIOS_PERFDATA)
                temp2=",$line"
                echo "$temp" | sed 's/<NAGIOS_PERFDATA>//g' | sed 's/<\/NAGIOS_PERFDATA>//g' |sed "s/ /$temp2\n/g" | sed 's/=/,/g' | sed 's/GB;/,/g' | sed 's/MB;/,/g' | sed 's/;/,/g' >> /tmp/test.csv

        fi
done < /tmp/disk/folders.txt
rm -rf /tmp/disk
That does what I want, the reason for MB and GB removal is one XI box is charting as MB and the other is charting as GB, otherwise if it was mixed I'd keep it. Also, the 1 command line argument I supply is the 3-4 letter code for the customer I want to see the data for.

Close this up, I just posted in case anyone else wants something similar.
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
Locked