I have searched the splunk board and find this thread.
change filename of pdf
As you can read they modify the sendemail.py code to change the filename of the pdf document.
I have made some changes but the filenames are only 30 characters long.
Have anyone changed the sendemail.py too and get more than 30 characters in the filename?
The pdf files look like this:
20120113_113008_st_search.pdf
20120113_113007_srv060.pdf
The first pdf is wrong. The filename should look like 20120113_113008_test_search.pdf .
The second one is fine.
Here are the changes I've made.
pdfviewfn = pdfview and pdfview.strip(' .:;|><\'"')
filepart = subject and subject.strip('Splunk Alert: ')
# logger.info('pdfview=%s pdfviewfn=%s subject=%s filepart=%s' % (pdfview, pdfviewfn, subject, filepart))
# logger.debug('pdfview=%s pdfviewfn=%s' % (pdfview, pdfviewfn))
datestamp = time.strftime('%Y-%m-%d')
datecomplete = time.strftime("%Y%m%d_%H%M%S")
if pdfviewfn:
filename = '%s_%s.pdf' % (datecomplete, filepart)
# filename = '%s-%s.pdf' % (pdfviewfn[:50], datestamp)
# strip control characters, forward & backslash
filename = re.sub(r'[\x00-\x1f\x7f/\\]+', '-', filename)
if isinstance(filename, unicode):
filename = ('utf-8', '', filename.encode('utf-8'))
else:
filename = '%s_%s.pdf' % (datecomplete, filepart)
# filename = 'splunk-report-%s.pdf' % datestamp
... View more