Mysql-baserad plugin för att läsa från tinyrss
This commit is contained in:
54
tinyrss_unread
Executable file
54
tinyrss_unread
Executable file
@@ -0,0 +1,54 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import MySQLdb as mysql
|
||||
import sys
|
||||
|
||||
def autoconf():
|
||||
print "yes"
|
||||
|
||||
def count():
|
||||
query = "select sum(value) from ttrss_counters_cache where owner_uid=1;"
|
||||
mysql_user = "tinyrss"
|
||||
mysql_pass = "EttLitetToken"
|
||||
mysql_db = "tinyrss"
|
||||
mysql_server = "localhost"
|
||||
|
||||
try:
|
||||
connection = mysql.connect(mysql_server, mysql_user, mysql_pass, mysql_db);
|
||||
cursor = connection.cursor()
|
||||
cursor.execute(query)
|
||||
result = cursor.fetchone()
|
||||
print "ttrss.value %s" % result
|
||||
except mysql.Error, e:
|
||||
print "Error %d: %s" % (e.args[0], e.args[1])
|
||||
sys.exit(1)
|
||||
finally:
|
||||
if connection:
|
||||
connection.close()
|
||||
|
||||
|
||||
def config():
|
||||
print """
|
||||
graph_title Tiny Tiny RSS Unread count
|
||||
graph_args -l 0 --base 1000
|
||||
graph_args --base 1000
|
||||
graph_vlabel Unread
|
||||
graph_category Apps
|
||||
graph_period second
|
||||
graph_info This graph shows the current number of unread RSS articles for Fredrik
|
||||
ttrss.label Unread
|
||||
ttrss.colour 663399
|
||||
ttrss.max 10000
|
||||
ttrss.min 0
|
||||
ttrss.info The number of unread articles.
|
||||
"""
|
||||
|
||||
if len(sys.argv) > 1:
|
||||
if sys.argv[1] == "autoconf":
|
||||
autoconf()
|
||||
elif sys.argv[1] == "config":
|
||||
config()
|
||||
else:
|
||||
count()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user