ikzelf / zbxdb

Zabbix database monitoring, the easy and extendable way
GNU General Public License v3.0
94 stars 45 forks source link

Trouble using zbxdb_sender #2

Closed sliwa95 closed 6 years ago

sliwa95 commented 6 years ago

Hi,

I have trouble using zbxdb_sender. simply running zbxdb_sender gives me default info:

Usage zbxdb_sender ZBXDB_OUT
   to collect outputs from that directory to send to zabbix
   using $HOME/zbxdb_sender directory for work space
   using $HOME/log for log directory
   PLEASE do not run zbxdb processes as root

So, trying to use it with ZBXDB_OUT, like this: zbxdb_sender zbx_pss-ora_out gives me output below:

/home/zbxdb/zbxdb/bin/zbxdb_sender: line 47: /home/zbxdb/log/zbxdb_sender.Wed.log: No such file or directory
find: ‘/home/zbxdb/log/zbxdb_sender.*.log’: No such file or director

Output of ls -l zbx_pss-ora_out/ is:

-rw-rw-r-- 1 zbxdb zbxdb 27318 Sep  5 15:27 zbxdb.pss-ora.zbx

while the only log directory is empty:

ls -l zbxdb/log/
total 0

In the same time only log file is in zbxdb_sender directory:

ls -l zbxdb_sender/in/
total 160
-rw-rw-r-- 1 zbxdb zbxdb   6624 Sep  5 15:05 zbxdb.pss-ora.cfg.log
-rw-rw-r-- 1 zbxdb zbxdb 143928 Sep  5 15:22 zbxdb.pss-ora.zbx
-rw-rw-r-- 1 zbxdb zbxdb   2335 Sep  5 14:05 zbxdb_starter.log

Home directory for zbxdb user looks like this:

ls -l
total 16
drwxrwxr-x 3 zbxdb zbxdb 4096 Sep  5 11:11 oradiag_zbxdb
drwxrwxr-x 2 zbxdb zbxdb 4096 Sep  5 15:23 zbx_pss-ora_out
drwxrwxr-x 7 zbxdb zbxdb 4096 Sep  5 15:10 zbxdb
drwxrwxr-x 4 zbxdb zbxdb 4096 Sep  5 13:19 zbxdb_sender

I'm using zbxdb_starter in cron, set to fire up every minute (like in readme), and my config file looks like this:

db_url = //hostname/DBPROD
username = zbxmon
password =
db_type = oracle
db_driver = cx_Oracle
instance_type = rdbms
role = normal
out_dir = /home/zbxdb/zbx_pss-ora_out
hostname = pss-ora
checks_dir = /home/zbxdb/zbxdb/etc/zbxdb_checks
site_checks = sap,asm.11
password_enc = somethinghere

Tool looks very nice, connects to instance and writes data nicely to zbxdb.pss-ora.zbx file, but I might be bit too rusty for current documentation. Makes me think I'll have to make some blog post about it (or submit some detailed documentation for newbies, if You wish).

ikzelf commented 6 years ago

Hi, yes, contribution for improvements is always welcome on any item, including documentation and howto's.

What I have in crontab is:

My zbxdb.{XXX}.cfg all write to the same $HOME/zbxora_out directory what zbxdb_sender does is 1) create $HOME/zbxdb_sender directory if nonexistent 2) create $HOME/zbxdb_sender/in directory if nonexistent 3) create $HOME/zbxdb_sender/archive directory if nonexixtent 4) move the contents from -in this case- $HOME/zbxora_out to $HOME/zbxdb_sender/in/ 5) send the files concatenated to zabbix_sender (where zabbix_sender uses -z 127.0.0.1) 6) zip the files from $HOME/zbxdb_sender/in and place archive in $HOME/zbxdb_sender/archive 7) remove the files from $HOME/zbxdb_sender/in/ 8) removes older files from $HOME/zbxdb_sender/archive/

It certainly is not the cleanest of all scripts but it works. In my setups, I run the zbxdb.py scripts on the same machines where the zabbix_server or the zabbix_proxy processes are running. This explains the hardcoded -z 127.0.0.1 for the zabbix server.

sliwa95 commented 6 years ago

Yeah, I was missing that second parameter - log directory for zbxdb_sender, after creating it and adding parameter it started working.

Now I have to figure out why I'm getting info from server: "processed: 0; failed: 250; total: 250; seconds spent: 0.001821" in sender's logfile, but that's not connected to Your tool.

Thank You again for help and fast response. I'll try wrap up some detailed documentation and/or howto, but I'll have to wait for next week.

sliwa95 commented 6 years ago

Just adding about why zabbixsender had issues: Zabbix couldn't recognize hostname, so had to add temporairy -s hostname_ parameter to zbxdb_sender script, so I can trick Zabbix server that data comes from my Oracle instance (not machine that ZbxDB is running on).

Will have to think about easy way to automate this. And maybe add another (optional) parameter to zbxdb sender, with Zabbix server address (with localhost as default value).

ikzelf commented 6 years ago

the hostname has to correspond with hostname parameter in your configuration file. In your case "pss-ora" If you check the datafile that is generated for your configuration file in your out directory, you will see it as one of the columns in there. The idea is that you can run many zbxdb.py processes from the same machine, all monitoring their own database/cluster. All data is concatenated and sent to zabbix in one go.