queue_stats
Monitor task queue performance and status to identify bottlenecks and optimize workflow efficiency in SFTP server management.
Instructions
Affiche les statistiques détaillées de la queue de tâches.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- server.js:637-646 (handler)The inline handler function for the queue_stats tool. It retrieves statistics and crashed jobs from the queue module and returns formatted JSON.async () => { const stats = queue.getStats(); const crashed = queue.getCrashedJobs(); const result = { stats, crashedJobs: crashed.length, canRetry: crashed.map(j => ({ id: j.id, type: j.type, crashedAt: j.crashedAt })) }; return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] }; }
- server.js:632-636 (schema)Input schema and metadata for the queue_stats tool (no input parameters required).{ title: "Statistiques de la queue", description: "Affiche les statistiques détaillées de la queue de tâches.", inputSchema: z.object({}) },
- server.js:630-647 (registration)Registration of the queue_stats tool using McpServer.registerTool, including schema and handler.server.registerTool( "queue_stats", { title: "Statistiques de la queue", description: "Affiche les statistiques détaillées de la queue de tâches.", inputSchema: z.object({}) }, async () => { const stats = queue.getStats(); const crashed = queue.getCrashedJobs(); const result = { stats, crashedJobs: crashed.length, canRetry: crashed.map(j => ({ id: j.id, type: j.type, crashedAt: j.crashedAt })) }; return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] }; } );
- queue.js:293-325 (helper)queue.getStats(): Computes comprehensive statistics on the job queue, including counts by status/type, average duration, and success rate.function getStats() { const stats = { total: Object.keys(jobQueue).length, byStatus: {}, byType: {}, avgDuration: 0, successRate: 0 }; let totalDuration = 0; let completedCount = 0; for (const job of Object.values(jobQueue)) { stats.byStatus[job.status] = (stats.byStatus[job.status] || 0) + 1; stats.byType[job.type] = (stats.byType[job.type] || 0) + 1; if (job.duration) { totalDuration += job.duration; completedCount++; } } if (completedCount > 0) { stats.avgDuration = Math.round(totalDuration / completedCount); } const totalFinished = (stats.byStatus.completed || 0) + (stats.byStatus.failed || 0); if (totalFinished > 0) { stats.successRate = Math.round((stats.byStatus.completed || 0) / totalFinished * 100); } return stats; }
- queue.js:285-291 (helper)queue.getCrashedJobs(): Filters and returns crashed jobs that are eligible for retry.function getCrashedJobs() { return Object.values(jobQueue).filter(job => job.status === 'crashed' && job.canRetry && job.retryCount < job.maxRetries ); }