# SQLServer # Introduction **This plugin is designed to monitor SQL Server** databases by executing queries that extract information crucial for assessing the performance and status of the databases. This information includes metrics such as the number of connections, query counts, and restart status. These data points will be reflected in PandoraFMS through modules that provide statistical value within an agent representing each database. It's important to note that this plugin is specifically developed for use with Pandora FMS Discovery. Unlike other plugins, it doesn't generate agents through XML; instead, all the discovered information is returned in the JSON output of the plugin. # Prerrequisites This plugin establishes remote connections to the databases it monitors, so it's essential to ensure connectivity between the Pandora FMS server and these databases. In turn the following permissions are required for the user that is used to connect. VIEW SERVER STATE: To execute the SELECT @@VERSION query. To query sys.dm\_os\_sys\_info (server uptime). To query sys.dm\_exec\_requests (active requests on the server). To query @@MAX\_CONNECTIONS (maximum connections allowed). To run sp\_who 'ACTIVE' (active sessions on the server). SELECT: To execute custom queries on specific database tables or views. # Parameters and configuration **Parameters**
--conf | Path to the configuration file. |
--target\_databases | Path to the configuration file containing database targets. |
--target\_agents | Path to the configuration file containing agent targets. |
--custom\_queries | Path to the configuration file containing custom queries. |
server_startup | Monitors the uptime (in days) of the database server |
locks_used | Monitors percentage of used lock and lock owner blocks |
workspace_memory | Monitors amount of memory that is used for executing processes such as hash, sort, bulk copy, and index creation operations |
average_waittime | SQL Server Average Lock Wait Time |
restart\_detection | It will be 0 if an unexpected restart is detected, and 1 if this is not the case. When a server restarts unexpectedly, there can be a disruption in database access, and potentially, transactions or data may not be saved correctly, leading to data integrity issues. |
queries | **The total number of queries**. Monitoring queries is essential for understanding the workload running on the server and assessing the overall system performance. By monitoring the total number of queries, you can identify activity spikes, optimize performance, and detect potential issues such as inefficient or excessive queries. |
update | **The number of UPDATE queries**. UPDATE queries are used to modify existing data in the database. Monitoring UPDATE queries is important to assess the frequency and efficiency of data updates. You can identify UPDATE queries that affect a large number of rows or have a significant impact on server performance. This allows you to optimize queries, review table structures, or take measures to reduce the load generated by updates. |
delete | **The number of DELETE queries**. DELETE queries are used to remove data from the database. Monitoring DELETE queries is useful to assess the frequency and efficiency of data deletions. You can identify DELETE queries that affect a large number of rows or have a significant impact on server performance. This allows you to optimize queries, review table structures, or take measures to reduce the load generated by deletions. |
insert | **The number of INSERT queries.** INSERT queries are used to add new data to the database. Monitoring INSERT queries allows you to assess the frequency and efficiency of data insertions. You can identify INSERT queries that are generating a high load on the server or may be causing performance issues. This enables you to optimize queries, review table structures, or consider strategies like deferred insertion to enhance performance in high-concurrency environments. |
session usage | **The number of current connections relative to the total maximum connections**. Monitoring session usage in SQL Server is important for optimizing performance, identifying locking issues, enhancing security and auditing, and efficiently planning server resources. |
lock_memory | Monitors amount of allocated lock memory in Bytes |
connection_memory | Monitors amount of connection memory in Bytes |
optimizer_memory | Monitors amount of optimizer memory in Bytes |
sqlcache_memory | Monitors amount of SQL cache memory in Bytes |
total_memory | Monitors total amount of dynamic server memory in Bytes |
retrieve_locks_statistics | Monitors the number of deadlocks per second |
lock_timeouts | Monitor the number of lock-timeouts per second |
lock_requests | Monitor the number of lock-requests per second |
lock_waits | Monitor the number of lock-waits per second |
buf_cachehit_ratio | Percentage of pages found in the buffer cache without having to read from the disk |
free_connections | Monitors % free connections to SQL Server instance |
page_reads | Monitors the number of database page reads per second |
page_writes | Monitors the number of database page writes per second |
latch_waits | Monitors the number of latch requests per second |
full_scans | Monitors the number of full scans (table or index) per second |
server_cpu | Monitors % of CPU usage by SQL Server instance |
io_busy | Monitors % of I/O busy for SQL Server instance |
server_io | Monitors % of I/O busy for SQL Server instance |
active_connection_ratio | Monitors ratio of active connections to total allowed connections |
locked_users | Monitors the number of users suspended by locks |
blocked_users | Monitors the number of users suspended by locks |
active_users | Monitors the number of users currently logged onto the server |
long_queries | Monitors long running queries (in seconds) |
long_queries_string | Complete output of long running queries |
aag_cluster_quorum_state | State: < desc >. Monitors AlwaysOn WSFC quorum State. |
aag_cluster_members_state | State: < desc >. Monitors AlwaysOn WSFC nodes state |
aag_synchronization_health | State: <desc >. Monitors the synchronization health of an availability group |
aag_replica_synchronization_health | State: < desc >. Role: < role > . Monitors the synchronization health of an availability replica |
aag_replica_connected_state | State: < desc >. Role: < rol > .Monitors connected state of an availability replica |
aag_replica_recovery_health | State: < desc >. Role: < rol> . Monitors the recovery health of an availability replica |
aag_replica_operational_state | State: < state >. Role: < rol >. Monitors the Current operational state of the availability replica |
aag_db_replica_synchronization_state | State: < desc >. Monitors the synchronization state of databases on availability replica |
aag_listener_state | State: < desc >. Role: < rol >. Monitor the AlwaysOn availability Group Listener state |
active users | Monitors the number of active user transactions per database |
transactions | Monitors the number of transactions per second |
active transactions | Active Transactions |
log\_flush\_waits | Monitors the number of log flush waits per second |
log\_file\_growths | Monitors the usage (growth) of the transaction logs |
log\_file\_shrinks | Monitors the usage (shrinking) of the transaction logs |
logfile\_size | Monitors logfile size |
logfile\_usage | Monitors free space in log files |
backup\_status\_minutes | Monitors number of minutes since last backup |
backup\_status\_last\_backup | Monitors when last backup was done |
fg\_free\_space | Monitors free space in filegroups |
Monitors reserved space in user tables | Monitors reserved space in user tables |
Monitors reserved space free data % in user tables | Monitors reserved space free data % in user tables |