Hi all,
I figured this belongs in a different topic. I am trying to query the event log, and am instead getting a Databaase Failure error of the following:
Traceback (most recent call last):
File "nxshell_eventcounter.py", line 8, in <module>
eventLog.query(logFilter)
at org.netxms.client.NXCSession.waitForRCC(NXCSession.java:1536)
at org.netxms.client.log.Log.query(Log.java:121)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
org.netxms.client.NXCException: org.netxms.client.NXCException: Database failure
Any thoughts? I'm worried the Columfilter is being set incorrectly. My eventual goal is to use a column filter to query events only of a certain severity, but I figured I would start easy. My code is reproduced below:
eventLog = session.openServerLog("EventLog")
columnFilter = ColumnFilter(ColumnFilter.EQUALS,8153)
logFilter = LogFilter()
logFilter.setColumnFilter("Source",columnFilter)
eventLog.query(logFilter)
table = eventLog.retrieveData(0,2)
Thanks,
Zach
Check your server log on debug level 4. There should be something like: "LOG QUERY: %s"
I looked at it once but I can't seem to remember where the log file should be located on Linux. Any suggestions as to where I could look?
Thanks,
Zach
Check "LogFile" parameter in server config(NETXMSHOME/etc/netxmsd.conf or /etc/netxmsd.conf). If it is not defined try to check something like /var/log/netxmsd.
Optimal log level for debugging problems is 6.
Good to know. We're currently running really hard on Debug levels, I think. The only relevant line I could find in any of the five (netxmsd.0/1/2/3/4) logfiles was this:
[20-Jun-2016 12:31:54.204] [DEBUG] [CLSN-4] User
[email protected] authenticated (language=en clientInfo="nxjclient/2.0.3 (Linux 3.19.0-58-generic; libnxcl 2.0.3)")
Our debug level is currently at 6. We have a million of these messages:
[20-Jun-2016 12:31:54.245] [DEBUG] [CLSN-4] Sending message CMD_OBJECT
which is making it a bit hard to read through the logs. Searching for "database" "nxc" or similar terms got me nothing. Any guesses? Should I try to dig into the postgresql logs?
Thanks,
Zach
That was it! I looked in the postgresql log:
2016-06-20 12:37:31 EDT ERROR: column "source" does not exist at character 159
2016-06-20 12:37:31 EDT STATEMENT: SELECT event_id,event_timestamp,event_source,dci_id,event_code,event_severity,event_message,user_tag,root_event_id FROM event_log WHERE event_id<=934558 AND (Source BETWEEN 0 AND 8153) LIMIT 1000
I guess the column isn't named Source? I'll have to look in the postgresql database to see what's there, unless you have a better idea of the column name.
Thanks,
Zach
The name is "event_source". UI is hiding column real names. You should use names that are defined in database.
One last question, I hope! It appears to not be filtering anything. Running the following code, I get five events, 10, 11, 12, 13, 109. The filter should have spat out 27628, right? If I pull the columnfilter from the logfilter, I get that the filter is still in place, but I don't seem to get any filtering. Any guesses?
eventLog = session.openServerLog("EventLog")
columnFilter = ColumnFilter(ColumnFilter.EQUALS,27628)
columnFilter.setNumericValue(27628)
logFilter = LogFilter()
logFilter.setColumnFilter("event_id",columnFilter)
#print(columnFilter.getNumericValue())
#print(columnFilter.getOperation())
fill = logFilter.getColumnFilter("event_id")
print(fill.getNumericValue())
eventLog.query(logFilter)
table = eventLog.retrieveData(0,5)
for j in range(table.getRowCount()):
#for i in range(table.getColumnCount()):
print(table.getColumnDisplayName(0))
print(table.getCellValue(j,0))
output is:
27628 [output of fill.getNumericValue()]
event_id
10
event_id
11
event_id
12
event_id
13
event_id
109
For some quick information, I chose this event because it was not filtering on event_severity, so I gave ID a try, and it seems to similarly not work. I have pasted the event below, so that you can see it exists.
27628 19.05.2016 11:56:32 Karmaloop-R1 0 SYS_NODE_CRITICAL Critical Node status changed to CRITICAL 0
I found problem. It's bad class declaration. You want function "public ColumnFilter(int type, long value)" to be used, but both values are counted like long and class is created like: "public ColumnFilter(long rangeFrom, long rangeTo)". So your values were counted like a range. Type should be change to Enum type. I have created bug on it: https://dev.raden.solutions/issues/1245.
Temporary solution:
import java.lang.Integer
eventLog = session.openServerLog("EventLog")
columnFilter = ColumnFilter(java.lang.Integer(ColumnFilter.EQUALS),363)
logFilter = LogFilter()
logFilter.setColumnFilter("event_id",columnFilter)
...
Hey, thanks! That works perfectly. Thanks again for all your work + help!
Have a good one,
Zach